示例#1
0
static int semanage_user_add (semanage_handle_t *handle,
                             semanage_seuser_key_t *key,
                             const char *login_name,
                             const char *seuser_name)
{
	int ret;
	semanage_seuser_t *seuser = NULL;

	ret = semanage_seuser_create (handle, &seuser);
	if (ret != 0) {
		fprintf (stderr,
		         _("Cannot create SELinux login mapping for %s\n"),
		         login_name);
		ret = 1;
		goto done;
	}

	ret = semanage_seuser_set_name (handle, seuser, login_name);
	if (ret != 0) {
		fprintf (stderr, _("Could not set name for %s\n"), login_name);
		ret = 1;
		goto done;
	}

	ret = semanage_seuser_set_mlsrange (handle, seuser, DEFAULT_SERANGE);
	if (ret != 0) {
		fprintf (stderr,
		         _("Could not set serange for %s\n"),
		         login_name);
		ret = 1;
		goto done;
	}

	ret = semanage_seuser_set_sename (handle, seuser, seuser_name);
	if (ret != 0) {
		fprintf (stderr,
		         _("Could not set SELinux user for %s\n"),
		         login_name);
		ret = 1;
		goto done;
	}

	ret = semanage_seuser_modify_local (handle, key, seuser);
	if (ret != 0) {
		fprintf (stderr,
		         _("Could not add login mapping for %s\n"),
		         login_name);
		ret = 1;
		goto done;
	}

	ret = 0;
done:
	semanage_seuser_free (seuser);
	return ret;
}
示例#2
0
static int sss_semanage_user_add(semanage_handle_t *handle,
                                 semanage_seuser_key_t *key,
                                 const char *login_name,
                                 const char *seuser_name,
                                 const char *mls)
{
    int ret;
    semanage_seuser_t *seuser = NULL;

    ret = semanage_seuser_create(handle, &seuser);
    if (ret != 0) {
        DEBUG(SSSDBG_CRIT_FAILURE,
              "Cannot create SELinux login mapping for %s\n", login_name);
        ret = EIO;
        goto done;
    }

    ret = semanage_seuser_set_name(handle, seuser, login_name);
    if (ret != 0) {
        DEBUG(SSSDBG_CRIT_FAILURE, "Could not set name for %s\n", login_name);
        ret = EIO;
        goto done;
    }

    ret = semanage_seuser_set_mlsrange(handle, seuser,
                                       mls ? mls : DEFAULT_SERANGE);
    if (ret != 0) {
        DEBUG(SSSDBG_CRIT_FAILURE,
              "Could not set serange for %s\n", login_name);
        ret = EIO;
        goto done;
    }

    ret = semanage_seuser_set_sename(handle, seuser, seuser_name);
    if (ret != 0) {
        DEBUG(SSSDBG_CRIT_FAILURE,
              "Could not set SELinux user for %s\n", login_name);
        ret = EIO;
        goto done;
    }

    ret = semanage_seuser_modify_local(handle, key, seuser);
    if (ret != 0) {
        DEBUG(SSSDBG_CRIT_FAILURE,
              "Could not add login mapping for %s\n", login_name);
        ret = EIO;
        goto done;
    }

    ret = EOK;
done:
    semanage_seuser_free(seuser);
    return ret;
}
示例#3
0
static int semanage_user_mod (semanage_handle_t *handle,
                              semanage_seuser_key_t *key,
                              const char *login_name,
                              const char *seuser_name)
{
	int ret;
	semanage_seuser_t *seuser = NULL;

	semanage_seuser_query (handle, key, &seuser);
	if (NULL == seuser) {
		fprintf (stderr,
		         _("Could not query seuser for %s\n"), login_name);
		ret = 1;
		goto done;
	}

	ret = semanage_seuser_set_mlsrange (handle, seuser, DEFAULT_SERANGE);
	if (ret != 0) {
		fprintf (stderr,
		         _("Could not set serange for %s\n"), login_name);
		ret = 1;
		goto done;
	}

	ret = semanage_seuser_set_sename (handle, seuser, seuser_name);
	if (ret != 0) {
		fprintf (stderr,
		         _("Could not set sename for %s\n"),
		         login_name);
		ret = 1;
		goto done;
	}

	ret = semanage_seuser_modify_local (handle, key, seuser);
	if (ret != 0) {
		fprintf (stderr,
		         _("Could not modify login mapping for %s\n"),
		         login_name);
		ret = 1;
		goto done;
	}

	ret = 0;
done:
	semanage_seuser_free (seuser);
	return ret;
}
示例#4
0
文件: selinux.c 项目: mmsrubar/thesis
static int sss_semanage_user_mod(semanage_handle_t *handle,
                                 semanage_seuser_key_t *key,
                                 const char *login_name,
                                 const char *seuser_name)
{
    int ret;
    semanage_seuser_t *seuser = NULL;

    semanage_seuser_query(handle, key, &seuser);
    if (seuser == NULL) {
        DEBUG(SSSDBG_CRIT_FAILURE,
              "Could not query seuser for %s\n", login_name);
        ret = EIO;
        goto done;
    }

    ret = semanage_seuser_set_mlsrange(handle, seuser, DEFAULT_SERANGE);
    if (ret != 0) {
        DEBUG(SSSDBG_CRIT_FAILURE,
              "Could not set serange for %s\n", login_name);
        ret = EIO;
        goto done;
    }

    ret = semanage_seuser_set_sename(handle, seuser, seuser_name);
    if (ret != 0) {
        DEBUG(SSSDBG_CRIT_FAILURE, "Could not set sename for %s\n", login_name);
        ret = EIO;
        goto done;
    }

    ret = semanage_seuser_modify_local(handle, key, seuser);
    if (ret != 0) {
        DEBUG(SSSDBG_CRIT_FAILURE,
              ("Could not modify login mapping for %s\n"), login_name);
        ret = EIO;
        goto done;
    }

    ret = EOK;
done:
    semanage_seuser_free(seuser);
    return ret;
}