#include <gshadow.h>
#include <gio/gio.h>
-#include <common/gum-config.h>
-
G_BEGIN_DECLS
typedef enum {
struct passwd *
gum_file_getpwnam (
- const gchar *usrname,
- GumConfig *config);
+ const gchar *username,
+ const gchar *filename);
struct passwd *
gum_file_getpwuid (
uid_t uid,
- GumConfig *config);
+ const gchar *filename);
struct passwd *
gum_file_find_user_by_gid (
- gid_t gid,
- GumConfig *config);
+ gid_t primary_gid,
+ const gchar *filename);
struct spwd *
gum_file_getspnam (
- const gchar *usrname,
- GumConfig *config);
+ const gchar *username,
+ const gchar *filename);
struct group *
gum_file_getgrnam (
const gchar *grname,
- GumConfig *config);
+ const gchar *filename);
struct group *
gum_file_getgrgid (
gid_t gid,
- GumConfig *config);
+ const gchar *filename);
struct sgrp *
gum_file_getsgnam (
- const gchar *grpname,
- GumConfig *config);
+ const gchar *grname,
+ const gchar *filename);
GFile *
gum_file_new_path (
const gchar *dir,
- const gchar *fname);
+ const gchar *filename);
gboolean
gum_file_create_home_dir (
- GumConfig *config,
- const gchar *usr_home_dir,
+ const gchar *home_dir,
uid_t uid,
gid_t gid,
+ guint umask,
GError **error);
gboolean
return retval;
}
+/**
+ * gum_file_getpwnam:
+ * @username: (transfer none): name of the user
+ * @filename: (transfer none): path to the file
+ *
+ * Gets the passwd structure from the file based on username.
+ *
+ * Returns: (transfer full): passwd structure if successful, NULL otherwise.
+ */
struct passwd *
gum_file_getpwnam (
- const gchar *usrname,
- GumConfig *config)
+ const gchar *username,
+ const gchar *filename)
{
struct passwd *pent = NULL;
FILE *fp = NULL;
- if (!usrname || !config) {
+ if (!username || !filename) {
return NULL;
}
- if (!(fp = _open_file (gum_config_get_string (config,
- GUM_CONFIG_GENERAL_PASSWD_FILE), "r"))) {
+ if (!(fp = _open_file (filename, "r"))) {
return NULL;
}
while ((pent = fgetpwent (fp)) != NULL) {
- if(g_strcmp0 (usrname, pent->pw_name) == 0)
+ if(g_strcmp0 (username, pent->pw_name) == 0)
break;
pent = NULL;
}
return pent;
}
+/**
+ * gum_file_getpwuid:
+ * @uid: user id
+ * @filename: (transfer none): path to the file
+ *
+ * Gets the passwd structure from the file based on uid.
+ *
+ * Returns: (transfer full): passwd structure if successful, NULL otherwise.
+ */
struct passwd *
gum_file_getpwuid (
uid_t uid,
- GumConfig *config)
+ const gchar *filename)
{
struct passwd *pent = NULL;
FILE *fp = NULL;
- if (!config) {
+ if (!filename) {
return NULL;
}
- if (!(fp = _open_file (gum_config_get_string (config,
- GUM_CONFIG_GENERAL_PASSWD_FILE), "r"))) {
+ if (!(fp = _open_file (filename, "r"))) {
return NULL;
}
return pent;
}
+/**
+ * gum_file_find_user_by_gid:
+ * @primary_gid: primary gid of the user
+ * @filename: (transfer none): path to the file
+ *
+ * Gets the passwd structure from the file based on the primary group id.
+ *
+ * Returns: (transfer full): passwd structure if successful, NULL otherwise.
+ */
struct passwd *
gum_file_find_user_by_gid (
- gid_t gid,
- GumConfig *config)
+ gid_t primary_gid,
+ const gchar *filename)
{
struct passwd *pent = NULL;
FILE *fp = NULL;
- if (!config || gid == GUM_GROUP_INVALID_GID) {
+ if (!filename || primary_gid == GUM_GROUP_INVALID_GID) {
return NULL;
}
- if (!(fp = _open_file (gum_config_get_string (config,
- GUM_CONFIG_GENERAL_PASSWD_FILE), "r"))) {
+ if (!(fp = _open_file (filename, "r"))) {
return NULL;
}
while ((pent = fgetpwent (fp)) != NULL) {
- if(gid == pent->pw_gid)
+ if(primary_gid == pent->pw_gid)
break;
pent = NULL;
}
return pent;
}
+/**
+ * gum_file_getspnam:
+ * @username: (transfer none): name of the user
+ * @filename: (transfer none): path to the file
+ *
+ * Gets the spwd structure from the file based on the username.
+ *
+ * Returns: (transfer full): spwd structure if successful, NULL otherwise.
+ */
struct spwd *
gum_file_getspnam (
- const gchar *usrname,
- GumConfig *config)
+ const gchar *username,
+ const gchar *filename)
{
struct spwd *spent = NULL;
FILE *fp = NULL;
- if (!usrname || !config) {
+ if (!username || !filename) {
return NULL;
}
- if (!(fp = _open_file (gum_config_get_string (config,
- GUM_CONFIG_GENERAL_SHADOW_FILE), "r"))) {
+ if (!(fp = _open_file (filename, "r"))) {
return NULL;
}
while ((spent = fgetspent (fp)) != NULL) {
- if(g_strcmp0 (usrname, spent->sp_namp) == 0)
+ if(g_strcmp0 (username, spent->sp_namp) == 0)
break;
spent = NULL;
}
return spent;
}
+/**
+ * gum_file_getgrnam:
+ * @grname: (transfer none): name of the group
+ * @filename: (transfer none): path to the file
+ *
+ * Gets the group structure from the file based on the groupname @grname.
+ *
+ * Returns: (transfer full): group structure if successful, NULL otherwise.
+ */
struct group *
gum_file_getgrnam (
const gchar *grname,
- GumConfig *config)
+ const gchar *filename)
{
struct group *gent = NULL;
FILE *fp = NULL;
- if (!grname || !config) {
+ if (!grname || !filename) {
return NULL;
}
- if (!(fp = _open_file (gum_config_get_string (config,
- GUM_CONFIG_GENERAL_GROUP_FILE), "r"))) {
+ if (!(fp = _open_file (filename, "r"))) {
return NULL;
}
while ((gent = fgetgrent (fp)) != NULL) {
return gent;
}
+/**
+ * gum_file_getgrgid:
+ * @gid: id of the group
+ * @filename: (transfer none): path to the file
+ *
+ * Gets the group structure from the file based on the gid.
+ *
+ * Returns: (transfer full): group structure if successful, NULL otherwise.
+ */
struct group *
gum_file_getgrgid (
gid_t gid,
- GumConfig *config)
+ const gchar *filename)
{
struct group *gent = NULL;
FILE *fp = NULL;
- if (!config) {
+ if (!filename) {
return NULL;
}
- if (!(fp = _open_file (gum_config_get_string (config,
- GUM_CONFIG_GENERAL_GROUP_FILE), "r"))) {
+ if (!(fp = _open_file (filename, "r"))) {
return NULL;
}
while ((gent = fgetgrent (fp)) != NULL) {
return gent;
}
+/**
+ * gum_file_getsgnam:
+ * @grname: (transfer none): name of the group
+ * @filename: (transfer none): path to the file
+ *
+ * Gets the sgrp structure from the file based on the groupname @grname.
+ *
+ * Returns: (transfer full): sgrp structure if successful, NULL otherwise.
+ */
struct sgrp *
gum_file_getsgnam (
- const gchar *grpname,
- GumConfig *config)
+ const gchar *grname,
+ const gchar *filename)
{
struct sgrp *sgent = NULL;
FILE *fp = NULL;
- const gchar *shadow_file = NULL;
- if (!grpname || !config) {
+ if (!grname || !filename) {
return NULL;
}
- shadow_file = gum_config_get_string (config,
- GUM_CONFIG_GENERAL_GSHADOW_FILE);
- if (!g_file_test (shadow_file, G_FILE_TEST_EXISTS) ||
- !(fp = _open_file (shadow_file, "r"))) {
+ if (!g_file_test (filename, G_FILE_TEST_EXISTS) ||
+ !(fp = _open_file (filename, "r"))) {
return NULL;
}
while ((sgent = fgetsgent (fp)) != NULL) {
- if(g_strcmp0 (grpname, sgent->sg_namp) == 0)
+ if(g_strcmp0 (grname, sgent->sg_namp) == 0)
break;
sgent = NULL;
}
return sgent;
}
+/**
+ * gum_file_new_path:
+ * @dir: (transfer none): directory path
+ * @filename: (transfer none): name of the file
+ *
+ * Builds complete file path based on the @filename and @dir.
+ *
+ * Returns: (transfer full): the #GFile if successful, NULL otherwise.
+ */
GFile *
gum_file_new_path (
const gchar *dir,
- const gchar *fname)
+ const gchar *filename)
{
GFile *file = NULL;
gchar *fn = NULL;
- if (!dir || !fname) {
+ if (!dir || !filename) {
return NULL;
}
- fn = g_build_filename (dir, fname, NULL);
+ fn = g_build_filename (dir, filename, NULL);
if (fn) {
file = g_file_new_for_path (fn);
g_free (fn);
static gboolean
_copy_dir_recursively (
- GumConfig *config,
const gchar *src,
const gchar *dest,
uid_t uid,
gid_t gid,
+ guint umask,
GError **error)
{
gboolean retval = TRUE;
if (S_ISDIR (stat_entry.st_mode)) {
DBG ("copy directory %s", src_filepath);
- gint mode = GUM_PERM & ~gum_config_get_uint (config,
- GUM_CONFIG_GENERAL_UMASK, GUM_UMASK);
+ gint mode = GUM_PERM & ~umask;
g_mkdir_with_parents (dest_filepath, mode);
- stop = !_copy_dir_recursively (config, src_filepath, dest_filepath,
- uid, gid, NULL);
+ stop = !_copy_dir_recursively (src_filepath, dest_filepath, uid,
+ gid, umask, NULL);
} else {
DBG ("copy file %s", src_filepath);
if (!g_file_copy (src_file, dest_file,
goto _free_data;
}
}
- /* when run in test mode, user may not exist */
-#ifndef ENABLE_TESTS
if (!stop) stop = (chown (dest_filepath, uid, gid) < 0);
-#endif
_free_data:
g_free (src_filepath);
return retval;
}
+/**
+ * gum_file_create_home_dir:
+ * @home_dir: path to the user home directory
+ * @uid: id of the user
+ * @gid: group id of the user
+ * @umask: the umask to be used for setting the mode of the files/directories
+ * @error: (transfer none): the #GError which is set in case of an error
+ *
+ * Creates the home directory of the user. All the files from the
+ * #GUM_CONFIG_GENERAL_SKEL_DIR are copied (recursively) to the user home
+ * directory.
+ *
+ * Returns: TRUE if successful, FALSE otherwise and @error is set.
+ */
gboolean
gum_file_create_home_dir (
- GumConfig *config,
- const gchar *usr_home_dir,
+ const gchar *home_dir,
uid_t uid,
gid_t gid,
+ guint umask,
GError **error)
{
gboolean retval = TRUE;
- gint mode = GUM_PERM & ~gum_config_get_uint (config,
- GUM_CONFIG_GENERAL_UMASK, GUM_UMASK);
+ gint mode = GUM_PERM & ~umask;
+ const gchar *skel_dir = NULL;
+ /* TODO: fix skel directory path */
- if (!usr_home_dir) {
+ if (!home_dir) {
GUM_RETURN_WITH_ERROR (GUM_ERROR_HOME_DIR_CREATE_FAILURE,
"Invalid home directory path", error, FALSE);
}
- if (g_access (usr_home_dir, F_OK) != 0) {
+ if (g_access (home_dir, F_OK) != 0) {
- if (!g_file_test (usr_home_dir, G_FILE_TEST_EXISTS)) {
- g_mkdir_with_parents (usr_home_dir, mode);
+ if (!g_file_test (home_dir, G_FILE_TEST_EXISTS)) {
+ g_mkdir_with_parents (home_dir, mode);
}
- if (!g_file_test (usr_home_dir, G_FILE_TEST_IS_DIR)) {
+ if (!g_file_test (home_dir, G_FILE_TEST_IS_DIR)) {
GUM_RETURN_WITH_ERROR (GUM_ERROR_HOME_DIR_CREATE_FAILURE,
"Home directory creation failure", error, FALSE);
}
/* when run in test mode, user may not exist */
-#ifndef ENABLE_TESTS
- if (chown (usr_home_dir, uid, gid) < 0) {
- GUM_RETURN_WITH_ERROR (GUM_ERROR_HOME_DIR_CREATE_FAILURE,
- "Home directory chown failure", error, FALSE);
- }
+#ifdef ENABLE_TESTS
+ uid = getuid ();
+ gid = getgid ();
#endif
+ if (chown (home_dir, uid, gid) < 0) {
+ GUM_RETURN_WITH_ERROR (GUM_ERROR_HOME_DIR_CREATE_FAILURE,
+ "Home directory chown failure", error, FALSE);
+ }
- retval = _copy_dir_recursively (config, gum_config_get_string (config,
- GUM_CONFIG_GENERAL_SKEL_DIR), usr_home_dir, uid, gid,
- error);
+ if (skel_dir) {
+ retval = _copy_dir_recursively (skel_dir, home_dir, uid, gid, umask,
+ error);
+ }
}
return retval;
}
+/**
+ * gum_file_delete_home_dir:
+ * @dir: (transfer none): the path to the directory
+ * @error: (transfer none): the #GError which is set in case of an error
+ *
+ * Deletes the directory and its sub-directories recursively.
+ *
+ * Returns: TRUE if successful, FALSE otherwise and @error is set.
+ */
gboolean
gum_file_delete_home_dir (
const gchar *dir,
gid_t tmp_gid, gid_min, gid_max;
if (preferred_gid != GUM_GROUP_INVALID_GID &&
- gum_file_getgrgid (preferred_gid, self->priv->config) == NULL) {
+ gum_file_getgrgid (preferred_gid, gum_config_get_string (
+ self->priv->config, GUM_CONFIG_GENERAL_GROUP_FILE)) == NULL) {
*gid = preferred_gid;
return TRUE;
}
/* Select the first available gid */
tmp_gid = gid_min;
while (tmp_gid <= gid_max) {
- if (gum_file_getgrgid (tmp_gid, self->priv->config) == NULL) {
+ if (gum_file_getgrgid (tmp_gid, gum_config_get_string (
+ self->priv->config, GUM_CONFIG_GENERAL_GROUP_FILE)) == NULL) {
*gid = tmp_gid;
return TRUE;
}
return FALSE;
}
- if (gum_file_getgrnam (self->priv->group->gr_name, self->priv->config)
+ if (gum_file_getgrnam (self->priv->group->gr_name, gum_config_get_string (
+ self->priv->config, GUM_CONFIG_GENERAL_GROUP_FILE))
!= NULL) {
GUM_RETURN_WITH_ERROR (GUM_ERROR_GROUP_ALREADY_EXISTS,
"Group already exists", error, FALSE);
if (self->priv->group->gr_gid != G_MAXUINT) {
s_gid = self->priv->group->gr_gid;
- grp = gum_file_getgrgid (s_gid, self->priv->config);
+ grp = gum_file_getgrgid (s_gid, gum_config_get_string (
+ self->priv->config, GUM_CONFIG_GENERAL_GROUP_FILE));
}
if (self->priv->group->gr_name) {
s_name = self->priv->group->gr_name;
if (!grp) {
- grp = gum_file_getgrnam (s_name, self->priv->config);
+ grp = gum_file_getgrnam (s_name, gum_config_get_string (
+ self->priv->config, GUM_CONFIG_GENERAL_GROUP_FILE));
}
}
}
if (!sgent) {
- sgent = gum_file_getsgnam (gent->gr_name, self->priv->config);
+ sgent = gum_file_getsgnam (gent->gr_name, gum_config_get_string (
+ self->priv->config, GUM_CONFIG_GENERAL_GSHADOW_FILE));
}
/*group entry*/
* being used as primary group by any user.
*/
if (gum_file_find_user_by_gid (self->priv->group->gr_gid,
- self->priv->config) != NULL) {
+ gum_config_get_string (self->priv->config,
+ GUM_CONFIG_GENERAL_PASSWD_FILE)) != NULL) {
gum_lock_pwdf_unlock ();
GUM_RETURN_WITH_ERROR (GUM_ERROR_GROUP_HAS_USER,
"Group is a primary group of an existing user", error, FALSE);
return FALSE;
}
- gshadow = gum_file_getsgnam (grp->gr_name, self->priv->config);
+ gshadow = gum_file_getsgnam (grp->gr_name, gum_config_get_string (
+ self->priv->config, GUM_CONFIG_GENERAL_GSHADOW_FILE));
if (!self->priv->group->gr_passwd ||
g_strcmp0 (self->priv->group->gr_passwd, "x") == 0 ||
"Database already locked", error, FALSE);
}
- if ((pent = gum_file_getpwuid (uid, self->priv->config)) == NULL) {
+ if ((pent = gum_file_getpwuid (uid, gum_config_get_string (
+ self->priv->config, GUM_CONFIG_GENERAL_PASSWD_FILE))) == NULL) {
gum_lock_pwdf_unlock ();
GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_NOT_FOUND, "User not found", error,
FALSE);
"User already a member of the group", error, FALSE);
}
- gshadow = gum_file_getsgnam (grp->gr_name, self->priv->config);
+ gshadow = gum_file_getsgnam (grp->gr_name, gum_config_get_string (
+ self->priv->config, GUM_CONFIG_GENERAL_GSHADOW_FILE));
if (!_copy_group_data (self, grp, gshadow, error)) {
gum_lock_pwdf_unlock ();
"Database already locked", error, FALSE);
}
- if ((pent = gum_file_getpwuid (uid, self->priv->config)) == NULL) {
+ if ((pent = gum_file_getpwuid (uid, gum_config_get_string (
+ self->priv->config, GUM_CONFIG_GENERAL_PASSWD_FILE))) == NULL) {
gum_lock_pwdf_unlock ();
GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_NOT_FOUND, "User not found", error,
FALSE);
"User not a member of the group", error, FALSE);
}
- gshadow = gum_file_getsgnam (grp->gr_name, self->priv->config);
+ gshadow = gum_file_getsgnam (grp->gr_name, gum_config_get_string (
+ self->priv->config, GUM_CONFIG_GENERAL_GSHADOW_FILE));
if (!_copy_group_data (self, grp, gshadow, error)) {
gum_lock_pwdf_unlock ();
if (!gum_lock_pwdf_lock ()) {
return gid;
}
- struct group *grp = gum_file_getgrnam (groupname, config);
+ struct group *grp = gum_file_getgrnam (groupname,
+ gum_config_get_string (config, GUM_CONFIG_GENERAL_GROUP_FILE));
gum_lock_pwdf_unlock ();
if (grp) {
return grp->gr_gid;
/* Select the first available uid */
tmp_uid = uid_min;
while (tmp_uid <= uid_max) {
- if (gum_file_getpwuid (tmp_uid, self->priv->config) == NULL) {
+ if (gum_file_getpwuid (tmp_uid, gum_config_get_string (
+ self->priv->config, GUM_CONFIG_GENERAL_PASSWD_FILE)) == NULL) {
*uid = tmp_uid;
return TRUE;
}
return FALSE;
}
- if (gum_file_getpwnam (self->priv->pw->pw_name, self->priv->config)
+ if (gum_file_getpwnam (self->priv->pw->pw_name, gum_config_get_string (
+ self->priv->config, GUM_CONFIG_GENERAL_PASSWD_FILE))
!= NULL) {
GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_ALREADY_EXISTS,
"User already exists", error, FALSE);
return TRUE;
}
- return gum_file_create_home_dir (self->priv->config,
- self->priv->pw->pw_dir, self->priv->pw->pw_uid,
- self->priv->pw->pw_gid, error);
+ return gum_file_create_home_dir (self->priv->pw->pw_dir,
+ self->priv->pw->pw_uid, self->priv->pw->pw_gid,
+ gum_config_get_uint (self->priv->config,
+ GUM_CONFIG_GENERAL_UMASK, GUM_UMASK), error);
}
gboolean
if (self->priv->pw->pw_uid != GUM_USER_INVALID_UID) {
s_uid = self->priv->pw->pw_uid;
- pwd = gum_file_getpwuid (s_uid, self->priv->config);
+ pwd = gum_file_getpwuid (s_uid, gum_config_get_string (
+ self->priv->config, GUM_CONFIG_GENERAL_PASSWD_FILE));
}
if (self->priv->pw->pw_name) {
s_name = self->priv->pw->pw_name;
if (!pwd) {
- pwd = gum_file_getpwnam (s_name, self->priv->config);
+ pwd = gum_file_getpwnam (s_name, gum_config_get_string (
+ self->priv->config, GUM_CONFIG_GENERAL_PASSWD_FILE));
}
}
if ((pent = _get_passwd (self, error)) == NULL) {
return FALSE;
}
- spent = gum_file_getspnam (pent->pw_name, self->priv->config);
+ spent = gum_file_getspnam (pent->pw_name, gum_config_get_string (
+ self->priv->config, GUM_CONFIG_GENERAL_SHADOW_FILE));
if (!spent) {
GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_NOT_FOUND, "User not found",
error, FALSE);
return FALSE;
}
- if ((shadow = gum_file_getspnam (pw->pw_name,
- self->priv->config)) == NULL) {
+ if ((shadow = gum_file_getspnam (pw->pw_name, gum_config_get_string (
+ self->priv->config, GUM_CONFIG_GENERAL_SHADOW_FILE))) == NULL) {
gum_lock_pwdf_unlock ();
GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_NOT_FOUND,
"User not found in Shadow", error, FALSE);
if (!gum_lock_pwdf_lock ()) {
return uid;
}
- struct passwd *pwd = gum_file_getpwnam (username, config);
+ struct passwd *pwd = gum_file_getpwnam (username,
+ gum_config_get_string (config, GUM_CONFIG_GENERAL_PASSWD_FILE));
gum_lock_pwdf_unlock ();
if (pwd) {
return pwd->pw_uid;
fail_unless (gum_file_getpwnam (NULL, NULL) == NULL);
fail_unless (gum_file_getpwnam ("", NULL) == NULL);
- fail_unless (gum_file_getpwnam ("", config) == NULL);
- fail_unless (gum_file_getpwnam ("test121", config) == NULL);
- fail_unless (gum_file_getpwnam ("root", config) != NULL);
+ fail_unless (gum_file_getpwnam ("", gum_config_get_string (config,
+ GUM_CONFIG_GENERAL_PASSWD_FILE)) == NULL);
+ fail_unless (gum_file_getpwnam ("test121", gum_config_get_string (config,
+ GUM_CONFIG_GENERAL_PASSWD_FILE)) == NULL);
+ fail_unless (gum_file_getpwnam ("root", gum_config_get_string (config,
+ GUM_CONFIG_GENERAL_PASSWD_FILE)) != NULL);
fail_unless (gum_file_getpwuid (1, NULL) == NULL);
- fail_unless (gum_file_getpwuid (0, config) != NULL);
+ fail_unless (gum_file_getpwuid (0, gum_config_get_string (config,
+ GUM_CONFIG_GENERAL_PASSWD_FILE)) != NULL);
fail_unless (gum_file_find_user_by_gid (GUM_GROUP_INVALID_GID, NULL)
== NULL);
- fail_unless (gum_file_find_user_by_gid (0, config) != NULL);
+ fail_unless (gum_file_find_user_by_gid (0, gum_config_get_string (config,
+ GUM_CONFIG_GENERAL_PASSWD_FILE)) != NULL);
fail_unless (gum_file_getspnam (NULL,NULL) == NULL);
fail_unless (gum_file_getspnam ("", NULL) == NULL);
- fail_unless (gum_file_getspnam ("", config) == NULL);
- fail_unless (gum_file_getspnam ("test121", config) == NULL);
- fail_unless (gum_file_getspnam ("root", config) != NULL);
+ fail_unless (gum_file_getspnam ("", gum_config_get_string (config,
+ GUM_CONFIG_GENERAL_SHADOW_FILE)) == NULL);
+ fail_unless (gum_file_getspnam ("test121", gum_config_get_string (config,
+ GUM_CONFIG_GENERAL_SHADOW_FILE)) == NULL);
+ fail_unless (gum_file_getspnam ("root", gum_config_get_string (config,
+ GUM_CONFIG_GENERAL_SHADOW_FILE)) != NULL);
fail_unless (gum_file_getgrnam (NULL,NULL) == NULL);
fail_unless (gum_file_getgrnam ("", NULL) == NULL);
- fail_unless (gum_file_getgrnam ("", config) == NULL);
- fail_unless (gum_file_getgrnam ("test121", config) == NULL);
- fail_unless (gum_file_getgrnam ("root", config) != NULL);
+ fail_unless (gum_file_getgrnam ("", gum_config_get_string (config,
+ GUM_CONFIG_GENERAL_GROUP_FILE)) == NULL);
+ fail_unless (gum_file_getgrnam ("test121", gum_config_get_string (config,
+ GUM_CONFIG_GENERAL_GROUP_FILE)) == NULL);
+ fail_unless (gum_file_getgrnam ("root", gum_config_get_string (config,
+ GUM_CONFIG_GENERAL_GROUP_FILE)) != NULL);
fail_unless (gum_file_getgrgid (1, NULL) == NULL);
- fail_unless (gum_file_getgrgid (0, config) != NULL);
+ fail_unless (gum_file_getgrgid (0, gum_config_get_string (config,
+ GUM_CONFIG_GENERAL_GROUP_FILE)) != NULL);
if (g_file_test (gum_config_get_string (config,
GUM_CONFIG_GENERAL_GSHADOW_FILE), G_FILE_TEST_EXISTS)) {
fail_unless (gum_file_getsgnam (NULL,NULL) == NULL);
fail_unless (gum_file_getsgnam ("", NULL) == NULL);
- fail_unless (gum_file_getsgnam ("", config) == NULL);
- fail_unless (gum_file_getsgnam ("test121", config) == NULL);
- fail_unless (gum_file_getsgnam ("root", config) != NULL);
+ fail_unless (gum_file_getsgnam ("", gum_config_get_string (config,
+ GUM_CONFIG_GENERAL_GSHADOW_FILE)) == NULL);
+ fail_unless (gum_file_getsgnam ("test121", gum_config_get_string (
+ config, GUM_CONFIG_GENERAL_GSHADOW_FILE)) == NULL);
+ fail_unless (gum_file_getsgnam ("root", gum_config_get_string (config,
+ GUM_CONFIG_GENERAL_GSHADOW_FILE)) != NULL);
}
fail_unless (gum_file_new_path (NULL, NULL) == NULL);
gid = getgid ();
hdir = g_build_filename (gum_config_get_string (config,
GUM_CONFIG_GENERAL_HOME_DIR_PREF), "test_daemon_user_file", NULL);
- fail_unless (gum_file_create_home_dir (config, hdir, uid, gid,
+ fail_unless (gum_file_create_home_dir (hdir, uid, gid,
+ gum_config_get_uint (config, GUM_CONFIG_GENERAL_UMASK, GUM_UMASK),
&error) == TRUE);
fail_unless (error == NULL);
fail_unless (stat (hdir, &sb) == 0);
fail_unless (error->code == GUM_ERROR_HOME_DIR_DELETE_FAILURE);
g_error_free (error);
- fail_unless (gum_file_create_home_dir (config, NULL, uid, gid,
+ fail_unless (gum_file_create_home_dir (NULL, uid, gid,
+ gum_config_get_uint (config, GUM_CONFIG_GENERAL_UMASK, GUM_UMASK),
&error) == FALSE);
fail_unless (error != NULL);
fail_unless (error->code == GUM_ERROR_HOME_DIR_CREATE_FAILURE);
fail_unless (str != NULL);
fail_unless (stat (str, &sb) != 0);
fail_unless (error == NULL);
- fail_unless (gum_file_getpwnam ("guest_daemon_user1", config) == NULL);
- fail_unless (gum_file_getgrnam ("guest_daemon_user1", config) == NULL);
+
+ fail_unless (gum_file_getpwnam ("guest_daemon_user1",
+ gum_config_get_string (config,
+ GUM_CONFIG_GENERAL_PASSWD_FILE)) == NULL);
+ fail_unless (gum_file_getgrnam ("guest_daemon_user1",
+ gum_config_get_string (config,
+ GUM_CONFIG_GENERAL_GROUP_FILE)) == NULL);
g_free (str);
/* case 16: user exist and delete (dont remove home dir) */
fail_unless (str != NULL);
fail_unless (stat (str, &sb) == 0);
fail_unless (error == NULL);
- fail_unless (gum_file_getpwnam ("admin_daemon_user1", config) == NULL);
- fail_unless (gum_file_getgrnam ("admin_daemon_user1", config) == NULL);
+ fail_unless (gum_file_getpwnam ("admin_daemon_user1",
+ gum_config_get_string (config,
+ GUM_CONFIG_GENERAL_PASSWD_FILE)) == NULL);
+ fail_unless (gum_file_getgrnam ("admin_daemon_user1",
+ gum_config_get_string (config,
+ GUM_CONFIG_GENERAL_GROUP_FILE)) == NULL);
g_free (str);
/* case 17: user does exist and update fails */
"groupname", "user_daemon_group1", "gid", gid, NULL);
fail_unless (gumd_daemon_group_delete (group, &error) == TRUE);
fail_unless (error == NULL);
- fail_unless (gum_file_getgrnam ("user_daemon_group1", config) == NULL);
+ fail_unless (gum_file_getgrnam ("user_daemon_group1",
+ gum_config_get_string (config,
+ GUM_CONFIG_GENERAL_GROUP_FILE)) == NULL);
/* case 11: group exist and delete*/
g_object_unref (group);
g_object_set (G_OBJECT (group), "grouptype", GUM_GROUPTYPE_SYSTEM,
"groupname", "system_daemon_group1", "gid", sys_gid, NULL);
- fail_unless (gum_file_getgrnam ("system_daemon_group1", config) != NULL);
+ fail_unless (gum_file_getgrnam ("system_daemon_group1",
+ gum_config_get_string (config,
+ GUM_CONFIG_GENERAL_GROUP_FILE)) != NULL);
fail_unless (gumd_daemon_group_delete (group, &error) == TRUE);
fail_unless (error == NULL);
- fail_unless (gum_file_getgrnam ("system_daemon_group1", config) == NULL);
+ fail_unless (gum_file_getgrnam ("system_daemon_group1",
+ gum_config_get_string (config,
+ GUM_CONFIG_GENERAL_GROUP_FILE)) == NULL);
/* case 12: add user to group and user does not exist*/
g_object_unref (group);