Changeset View
Changeset View
Standalone View
Standalone View
sysutils/accountsservice/files/patch-src_user.c
| --- src/user.c.orig 2018-04-20 20:52:07 UTC | --- src/user.c.orig 2022-01-28 20:47:34 UTC | ||||
| +++ src/user.c | +++ src/user.c | ||||
| @@ -138,9 +138,14 @@ user_reset_icon_file (User *user) | @@ -396,9 +396,14 @@ user_update_from_template (User *user) | ||||
| } | } | ||||
| void | void | ||||
| Context not available. | |||||
| { | { | ||||
| g_autofree gchar *real_name = NULL; | g_autofree gchar *real_name = NULL; | ||||
| gboolean is_system_account; | gboolean is_system_account; | ||||
| @@ -199,8 +204,10 @@ user_update_from_pwent (User *user, | @@ -460,8 +465,10 @@ user_update_from_pwent (User *user, | ||||
| accounts_user_set_shell (ACCOUNTS_USER (user), pwent->pw_shell); | accounts_user_set_shell (ACCOUNTS_USER (user), pwent->pw_shell); | ||||
| passwd = NULL; | passwd = NULL; | ||||
| Context not available. | |||||
| if (passwd && passwd[0] == '!') { | if (passwd && passwd[0] == '!') { | ||||
| locked = TRUE; | locked = TRUE; | ||||
| @@ -218,6 +225,7 @@ user_update_from_pwent (User *user, | @@ -479,6 +486,7 @@ user_update_from_pwent (User *user, | ||||
| mode = PASSWORD_MODE_NONE; | mode = PASSWORD_MODE_NONE; | ||||
| } | } | ||||
| Context not available. | |||||
| if (spent) { | if (spent) { | ||||
| if (spent->sp_lstchg == 0) { | if (spent->sp_lstchg == 0) { | ||||
| mode = PASSWORD_MODE_SET_AT_LOGIN; | mode = PASSWORD_MODE_SET_AT_LOGIN; | ||||
| @@ -231,6 +239,9 @@ user_update_from_pwent (User *user, | @@ -495,6 +503,9 @@ user_update_from_pwent (User *user, | ||||
| user->days_after_expiration_until_lock = spent->sp_inact; | user->days_after_expiration_until_lock = spent->sp_inact; | ||||
| user->account_expiration_policy_known = TRUE; | user->account_expiration_policy_known = TRUE; | ||||
| } | } | ||||
| +#else | +#else | ||||
| + user->expiration_time = pwent->pw_expire; | + user->user_expiration_time = g_date_time_new_from_unix_utc(pwent->pw_expire); | ||||
| +#endif | +#endif | ||||
| accounts_user_set_password_mode (ACCOUNTS_USER (user), mode); | accounts_user_set_password_mode (ACCOUNTS_USER (user), mode); | ||||
| is_system_account = !user_classify_is_human (accounts_user_get_uid (ACCOUNTS_USER (user)), | is_system_account = !user_classify_is_human (accounts_user_get_uid (ACCOUNTS_USER (user)), | ||||
| @@ -813,11 +824,11 @@ user_change_real_name_authorized_cb (Daemon | @@ -1141,11 +1152,11 @@ user_change_real_name_authorized_cb (Daemon | ||||
| accounts_user_get_uid (ACCOUNTS_USER (user)), | new_gecos = g_strdup (name); | ||||
| name); | } | ||||
| - argv[0] = "/usr/sbin/usermod"; | - argv[0] = "/usr/sbin/usermod"; | ||||
| - argv[1] = "-c"; | - argv[1] = "-c"; | ||||
| - argv[2] = name; | - argv[2] = new_gecos; | ||||
| - argv[3] = "--"; | - argv[3] = "--"; | ||||
| - argv[4] = accounts_user_get_user_name (ACCOUNTS_USER (user)); | - argv[4] = accounts_user_get_user_name (ACCOUNTS_USER (user)); | ||||
| + argv[0] = "/usr/sbin/pw"; | + argv[0] = "/usr/sbin/pw"; | ||||
| + argv[1] = "usermod"; | + argv[1] = "usermod"; | ||||
| + argv[2] = accounts_user_get_user_name (ACCOUNTS_USER (user)); | + argv[2] = accounts_user_get_user_name (ACCOUNTS_USER (user)); | ||||
| + argv[3] = "-c"; | + argv[3] = "-c"; | ||||
| + argv[4] = name; | + argv[4] = new_gecos; | ||||
| argv[5] = NULL; | argv[5] = NULL; | ||||
| if (!spawn_with_login_uid (context, argv, &error)) { | if (!spawn_with_login_uid (context, argv, &error)) { | ||||
| @@ -882,11 +893,11 @@ user_change_user_name_authorized_cb (Daemon | @@ -1214,11 +1225,11 @@ user_change_user_name_authorized_cb (Daemon | ||||
| accounts_user_get_uid (ACCOUNTS_USER (user)), | accounts_user_get_uid (ACCOUNTS_USER (user)), | ||||
| name); | name); | ||||
| Context not available. | |||||
| argv[5] = NULL; | argv[5] = NULL; | ||||
| if (!spawn_with_login_uid (context, argv, &error)) { | if (!spawn_with_login_uid (context, argv, &error)) { | ||||
| @@ -1183,7 +1194,7 @@ user_change_home_dir_authorized_cb (Daemon | @@ -1610,7 +1621,7 @@ user_change_home_dir_authorized_cb (Daemon | ||||
| { | { | ||||
| gchar *home_dir = data; | gchar *home_dir = data; | ||||
| g_autoptr(GError) error = NULL; | g_autoptr(GError) error = NULL; | ||||
| - const gchar *argv[7]; | - const gchar *argv[7]; | ||||
| + const gchar *argv[6]; | + const gchar *argv[8]; | ||||
| if (g_strcmp0 (accounts_user_get_home_directory (ACCOUNTS_USER (user)), home_dir) != 0) { | if (g_strcmp0 (accounts_user_get_home_directory (ACCOUNTS_USER (user)), home_dir) != 0) { | ||||
| sys_log (context, | sys_log (context, | ||||
| @@ -1192,13 +1203,12 @@ user_change_home_dir_authorized_cb (Daemon | @@ -1619,13 +1630,14 @@ user_change_home_dir_authorized_cb (Daemon | ||||
| accounts_user_get_uid (ACCOUNTS_USER (user)), | accounts_user_get_uid (ACCOUNTS_USER (user)), | ||||
| home_dir); | home_dir); | ||||
| Context not available. | |||||
| - argv[5] = accounts_user_get_user_name (ACCOUNTS_USER (user)); | - argv[5] = accounts_user_get_user_name (ACCOUNTS_USER (user)); | ||||
| - argv[6] = NULL; | - argv[6] = NULL; | ||||
| + argv[0] = "/usr/sbin/pw"; | + argv[0] = "/usr/sbin/pw"; | ||||
| + argv[1] = "-d"; | + argv[1] = "usermod"; | ||||
| + argv[2] = home_dir; | + argv[2] = "-n"; | ||||
| + argv[3] = "-n"; | + argv[3] = accounts_user_get_user_name (ACCOUNTS_USER (user)); | ||||
| + argv[4] = accounts_user_get_user_name (ACCOUNTS_USER (user)); | + argv[4] = "-d"; | ||||
| + argv[5] = NULL; | + argv[5] = home_dir; | ||||
| + argv[6] = "-m"; | |||||
| + argv[7] = NULL; | |||||
| if (!spawn_with_login_uid (context, argv, &error)) { | if (!spawn_with_login_uid (context, argv, &error)) { | ||||
| throw_error (context, ERROR_FAILED, "running '%s' failed: %s", argv[0], error->message); | throw_error (context, ERROR_FAILED, "running '%s' failed: %s", argv[0], error->message); | ||||
| @@ -1249,11 +1259,11 @@ user_change_shell_authorized_cb (Daemon | @@ -1675,11 +1687,11 @@ user_change_shell_authorized_cb (Daemon | ||||
| accounts_user_get_uid (ACCOUNTS_USER (user)), | accounts_user_get_uid (ACCOUNTS_USER (user)), | ||||
| shell); | shell); | ||||
| Context not available. | |||||
| argv[5] = NULL; | argv[5] = NULL; | ||||
| if (!spawn_with_login_uid (context, argv, &error)) { | if (!spawn_with_login_uid (context, argv, &error)) { | ||||
| @@ -1456,7 +1466,7 @@ user_change_locked_authorized_cb (Daemon | @@ -1888,7 +1900,7 @@ user_change_locked_authorized_cb (Daemon | ||||
| { | { | ||||
| gboolean locked = GPOINTER_TO_INT (data); | gboolean locked = GPOINTER_TO_INT (data); | ||||
| g_autoptr(GError) error = NULL; | g_autoptr(GError) error = NULL; | ||||
| Context not available. | |||||
| if (accounts_user_get_locked (ACCOUNTS_USER (user)) != locked) { | if (accounts_user_get_locked (ACCOUNTS_USER (user)) != locked) { | ||||
| sys_log (context, | sys_log (context, | ||||
| @@ -1464,11 +1474,10 @@ user_change_locked_authorized_cb (Daemon | @@ -1896,11 +1908,10 @@ user_change_locked_authorized_cb (Daemon | ||||
| locked ? "locking" : "unlocking", | locked ? "locking" : "unlocking", | ||||
| accounts_user_get_user_name (ACCOUNTS_USER (user)), | accounts_user_get_user_name (ACCOUNTS_USER (user)), | ||||
| accounts_user_get_uid (ACCOUNTS_USER (user))); | accounts_user_get_uid (ACCOUNTS_USER (user))); | ||||
| - argv[0] = "/usr/sbin/usermod"; | - argv[0] = "/usr/sbin/usermod"; | ||||
| - argv[1] = locked ? "-L" : "-U"; | + argv[0] = "/usr/sbin/pw"; | ||||
| argv[1] = locked ? "-L" : "-U"; | |||||
| - argv[2] = "--"; | - argv[2] = "--"; | ||||
| - argv[3] = accounts_user_get_user_name (ACCOUNTS_USER (user)); | - argv[3] = accounts_user_get_user_name (ACCOUNTS_USER (user)); | ||||
| - argv[4] = NULL; | - argv[4] = NULL; | ||||
| + argv[0] = "/usr/sbin/pw"; | |||||
| + argv[1] = locked ? "lock" : "unlock"; | |||||
| + argv[2] = accounts_user_get_user_name (ACCOUNTS_USER (user)); | + argv[2] = accounts_user_get_user_name (ACCOUNTS_USER (user)); | ||||
| + argv[3] = NULL; | + argv[3] = NULL; | ||||
| if (!spawn_with_login_uid (context, argv, &error)) { | if (!spawn_with_login_uid (context, argv, &error)) { | ||||
| throw_error (context, ERROR_FAILED, "running '%s' failed: %s", argv[0], error->message); | throw_error (context, ERROR_FAILED, "running '%s' failed: %s", argv[0], error->message); | ||||
| @@ -1589,11 +1598,11 @@ user_change_account_type_authorized_cb (Daemon | @@ -1973,7 +1984,7 @@ user_change_account_type_authorized_cb (Daemon | ||||
| gsize n_extra_admin_groups_gids = 0; | |||||
| gid_t admin_gid; | |||||
| gint i; | |||||
| - const gchar *argv[6]; | |||||
| + const gchar *argv[7]; | |||||
| if (((AccountType) accounts_user_get_account_type (ACCOUNTS_USER (user))) != account_type) { | |||||
| sys_log (context, | |||||
| @@ -2018,11 +2029,11 @@ user_change_account_type_authorized_cb (Daemon | |||||
| g_free (groups); | g_free (groups); | ||||
| Context not available. | |||||
| argv[5] = NULL; | argv[5] = NULL; | ||||
| if (!spawn_with_login_uid (context, argv, &error)) { | if (!spawn_with_login_uid (context, argv, &error)) { | ||||
| @@ -1643,7 +1652,7 @@ user_change_password_mode_authorized_cb (Daemon | @@ -2071,7 +2082,7 @@ user_change_password_mode_authorized_cb (Daemon | ||||
| { | { | ||||
| PasswordMode mode = GPOINTER_TO_INT (data); | PasswordMode mode = GPOINTER_TO_INT (data); | ||||
| g_autoptr(GError) error = NULL; | g_autoptr(GError) error = NULL; | ||||
| Context not available. | |||||
| if (((PasswordMode) accounts_user_get_password_mode (ACCOUNTS_USER (user))) != mode) { | if (((PasswordMode) accounts_user_get_password_mode (ACCOUNTS_USER (user))) != mode) { | ||||
| sys_log (context, | sys_log (context, | ||||
| @@ -1658,10 +1667,8 @@ user_change_password_mode_authorized_cb (Daemon | @@ -2086,10 +2097,8 @@ user_change_password_mode_authorized_cb (Daemon | ||||
| mode == PASSWORD_MODE_NONE) { | mode == PASSWORD_MODE_NONE) { | ||||
| argv[0] = "/usr/bin/passwd"; | argv[0] = "/usr/bin/passwd"; | ||||
| Context not available. | |||||
| if (!spawn_with_login_uid (context, argv, &error)) { | if (!spawn_with_login_uid (context, argv, &error)) { | ||||
| throw_error (context, ERROR_FAILED, "running '%s' failed: %s", argv[0], error->message); | throw_error (context, ERROR_FAILED, "running '%s' failed: %s", argv[0], error->message); | ||||
| @@ -1669,12 +1676,11 @@ user_change_password_mode_authorized_cb (Daemon | @@ -2097,12 +2106,11 @@ user_change_password_mode_authorized_cb (Daemon | ||||
| } | } | ||||
| if (mode == PASSWORD_MODE_SET_AT_LOGIN) { | if (mode == PASSWORD_MODE_SET_AT_LOGIN) { | ||||
| Context not available. | |||||
| if (!spawn_with_login_uid (context, argv, &error)) { | if (!spawn_with_login_uid (context, argv, &error)) { | ||||
| throw_error (context, ERROR_FAILED, "running '%s' failed: %s", argv[0], error->message); | throw_error (context, ERROR_FAILED, "running '%s' failed: %s", argv[0], error->message); | ||||
| @@ -1690,11 +1696,10 @@ user_change_password_mode_authorized_cb (Daemon | @@ -2186,7 +2194,7 @@ user_change_password_authorized_cb (Daemon | ||||
| accounts_user_set_locked (ACCOUNTS_USER (user), FALSE); | |||||
| } | |||||
| else if (accounts_user_get_locked (ACCOUNTS_USER (user))) { | |||||
| - argv[0] = "/usr/sbin/usermod"; | |||||
| - argv[1] = "-U"; | |||||
| - argv[2] = "--"; | |||||
| - argv[3] = accounts_user_get_user_name (ACCOUNTS_USER (user)); | |||||
| - argv[4] = NULL; | |||||
| + argv[0] = "/usr/sbin/pw"; | |||||
| + argv[1] = "unlock"; | |||||
| + argv[2] = accounts_user_get_user_name (ACCOUNTS_USER (user)); | |||||
| + argv[3] = NULL; | |||||
| if (!spawn_with_login_uid (context, argv, &error)) { | |||||
| throw_error (context, ERROR_FAILED, "running '%s' failed: %s", argv[0], error->message); | |||||
| @@ -1759,7 +1764,7 @@ user_change_password_authorized_cb (Daemon | |||||
| { | { | ||||
| gchar **strings = data; | gchar **strings = data; | ||||
| g_autoptr(GError) error = NULL; | g_autoptr(GError) error = NULL; | ||||
| - const gchar *argv[6]; | - const gchar *argv[6]; | ||||
| + const gchar *argv[5]; | + const gchar *argv[4]; | ||||
| sys_log (context, | sys_log (context, | ||||
| "set password and hint of user '%s' (%d)", | "set password and hint of user '%s' (%d)", | ||||
| @@ -1768,12 +1773,11 @@ user_change_password_authorized_cb (Daemon | @@ -2195,12 +2203,10 @@ user_change_password_authorized_cb (Daemon | ||||
| g_object_freeze_notify (G_OBJECT (user)); | g_object_freeze_notify (G_OBJECT (user)); | ||||
| - argv[0] = "/usr/sbin/usermod"; | - argv[0] = "/usr/sbin/usermod"; | ||||
| + argv[0] = "/usr/sbin/chpass"; | - argv[1] = "-p"; | ||||
| argv[1] = "-p"; | - argv[2] = strings[0]; | ||||
| argv[2] = strings[0]; | |||||
| - argv[3] = "--"; | - argv[3] = "--"; | ||||
| - argv[4] = accounts_user_get_user_name (ACCOUNTS_USER (user)); | - argv[4] = accounts_user_get_user_name (ACCOUNTS_USER (user)); | ||||
| - argv[5] = NULL; | - argv[5] = NULL; | ||||
| + argv[3] = accounts_user_get_user_name (ACCOUNTS_USER (user)); | + argv[0] = "/usr/bin/passwd"; | ||||
| + argv[4] = NULL; | + argv[1] = strings[0]; | ||||
| + argv[2] = accounts_user_get_user_name (ACCOUNTS_USER (user)); | |||||
| + argv[3] = NULL; | |||||
| if (!spawn_with_login_uid (context, argv, &error)) { | if (!spawn_with_login_uid (context, argv, &error)) { | ||||
| throw_error (context, ERROR_FAILED, "running '%s' failed: %s", argv[0], error->message); | throw_error (context, ERROR_FAILED, "running '%s' failed: %s", argv[0], error->message); | ||||
| Context not available. | |||||