From: Yunmi Ha Date: Wed, 24 Aug 2016 07:49:39 +0000 (+0900) Subject: Update: add checking home directory logic X-Git-Tag: accepted/tizen/common/20160829.140225^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bed3b500b9b7b109cff8f3674f1fcf30ada2f0b6;p=platform%2Fupstream%2Fgumd.git Update: add checking home directory logic When update user data, check home directory. If home directory is not exists, create home directory and run user add post scripts. (This is for tizen 3.0 migration) Change-Id: If609186d8a0c154eac05b38a01903ad08e78dce6 Signed-off-by: Yunmi Ha --- diff --git a/src/daemon/core/gumd-daemon-user.c b/src/daemon/core/gumd-daemon-user.c old mode 100644 new mode 100755 index 6258fcb..f4c602e --- a/src/daemon/core/gumd-daemon-user.c +++ b/src/daemon/core/gumd-daemon-user.c @@ -1947,6 +1947,7 @@ gumd_daemon_user_update ( struct _userinfo info = {0,}; gchar *old_name = NULL; gint change = 0; + gint update_homedir = 0; DBG (""); @@ -2042,7 +2043,16 @@ gumd_daemon_user_update ( change++; } - if (change == 0) { + if (!g_file_test(self->priv->pw->pw_dir, G_FILE_TEST_EXISTS)) { + DBG("home directory is not exists : %s ", self->priv->pw->pw_dir); + if (!_create_home_dir(self, error)) { + gum_lock_pwdf_unlock(); + return FALSE; + } + update_homedir++; + } + + if ((change == 0) && (update_homedir == 0)) { gum_lock_pwdf_unlock (); GUM_RETURN_WITH_ERROR (GUM_ERROR_USER_NO_CHANGES, "No changes registered", error, FALSE); @@ -2063,6 +2073,16 @@ gumd_daemon_user_update ( } g_free (old_name); + if (update_homedir != 0) { + const gchar *scrip_dir = USERADD_SCRIPT_DIR; + gchar *ut = gum_string_utils_get_string(self->priv->pw->pw_gecos, ",", + GECOS_FIELD_USERTYPE); + gum_utils_run_user_scripts(scrip_dir, self->priv->pw->pw_name, + self->priv->pw->pw_uid, self->priv->pw->pw_gid, + self->priv->pw->pw_dir, ut); + g_free(ut); + } + gum_lock_pwdf_unlock (); return TRUE; }