Fix the bug that create abnormal user 22/38622/1 accepted/tizen/common/20150424.100315 accepted/tizen/mobile/20150424.064002 accepted/tizen/tv/20150424.063125 accepted/tizen/wearable/20150424.063714 submit/tizen/20150424.050028
authorHurnjoo Lee <hurnjoo.lee@samsung.com>
Thu, 23 Apr 2015 04:28:06 +0000 (13:28 +0900)
committerHurnjoo Lee <hurnjoo.lee@samsung.com>
Thu, 23 Apr 2015 06:46:37 +0000 (15:46 +0900)
In case there was wrong group in DEFAULT_USR_GROUP, user home directory was not created.
This patch will prevent abnormal termination of creating user by wrong default groups.

Change-Id: I74176fbce066ec160d518b228a2f7bd019de4d52
Signed-off-by: Hurnjoo Lee <hurnjoo.lee@samsung.com>
src/daemon/core/gumd-daemon-user.c

index f0b0ea1..b22b912 100644 (file)
@@ -1218,7 +1218,6 @@ _set_default_groups (
                 GUM_CONFIG_GENERAL_DEF_USR_GROUPS), ",", -1);
 
     if (def_groupsv) {
                 GUM_CONFIG_GENERAL_DEF_USR_GROUPS), ",", -1);
 
     if (def_groupsv) {
-
         gint ind = 0;
         while (def_groupsv[ind]) {
             GumdDaemonGroup *agroup = gumd_daemon_group_new (self->priv->config);
         gint ind = 0;
         while (def_groupsv[ind]) {
             GumdDaemonGroup *agroup = gumd_daemon_group_new (self->priv->config);
@@ -1228,7 +1227,9 @@ _set_default_groups (
                 added = gumd_daemon_group_add_member (agroup,
                         self->priv->pw->pw_uid, FALSE, error);
                 g_object_unref (agroup);
                 added = gumd_daemon_group_add_member (agroup,
                         self->priv->pw->pw_uid, FALSE, error);
                 g_object_unref (agroup);
-                if (!added) break;
+                if (!added) {
+                    WARN ("Failed to set group : %s", def_groupsv[ind]);
+                }
             } else {
                 GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_GROUP_ADD_FAILURE,
                                 "Unable to add default groups", error, FALSE);
             } else {
                 GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_GROUP_ADD_FAILURE,
                                 "Unable to add default groups", error, FALSE);
@@ -1740,8 +1741,9 @@ gumd_daemon_user_add (
 
     _add_userinfo(self);
 
 
     _add_userinfo(self);
 
-    if (!_set_default_groups (self, error) ||
-        !_create_home_dir (self, error)) {
+    _set_default_groups (self, error);
+
+    if (!_create_home_dir (self, error)) {
         gum_lock_pwdf_unlock ();
         return FALSE;
     }
         gum_lock_pwdf_unlock ();
         return FALSE;
     }