GNOME Bugzilla – Bug 523180
Changing anything about the root account sets and invalid home directory
Last modified: 2009-07-26 20:17:03 UTC
This bug has been filed here: https://bugs.edge.launchpad.net/ubuntu/+source/gnome-system-tools/+bug/198172 "When the user uses users-admin to edit anythin to do with the root account the root home directory is set to /home/root/. This makes tools like synaptic unable to open. The problem is that the preferences window uses a profile from /etc/gnome-system-tools/users/profiles to set certain default values. For the root account it is the "Administrator" type, which says that the home folder should live under /home/ This means that /home/root is then filled in as the default value of the Advanced tab for the root user. Therefore if the user makes any change and presses "OK" (or perhaps on no change) the home directory for the root account is set to the wrong value. I think that this is fine behaviour for new accounts, but for existing accounts these fields shouldn't be set to the default value, but to the current existing value, which would mean that clicking OK would only set the value to the same as it was before. " Thanks,
Hi, Here's the diff and explanation I provided in the Ubuntu bug report. By way of explanation, as it's not completely obvious I include the main part here. +--- gnome-system-tools-2.22.0~/src/users/user-settings.c 2008-03-31 16:32:35.000000000 +0100 ++++ gnome-system-tools-2.22.0/src/users/user-settings.c 2008-03-31 16:32:36.000000000 +0100 +@@ -347,9 +347,6 @@ + widget = gst_dialog_get_widget (tool->main_dialog, "user_settings_shell"); + set_entry_text (GTK_BIN (widget)->child, oobs_user_get_shell (user)); + +- widget = gst_dialog_get_widget (tool->main_dialog, "user_settings_home"); +- set_entry_text (widget, oobs_user_get_home_directory (user)); +- + widget = gst_dialog_get_widget (tool->main_dialog, "user_settings_uid"); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), oobs_user_get_uid (user)); + gtk_widget_set_sensitive (GTK_SPIN_BUTTON (widget), FALSE); Here's where the code used to set the home dir for existing users. +@@ -394,6 +391,11 @@ + if (!login) + table_set_default_profile (GST_USERS_TOOL (tool)); + However this eventually sets the default home dir prefix for the user's profile, and then calls the callback to update that based on the user's name. This then overwrote the value we set above. It is exactly the right thing to do if the user didn't exist on the system yet, i.e. user == NULL. ++ if (user) { ++ widget = gst_dialog_get_widget (tool->main_dialog, "user_settings_home"); ++ set_entry_text (widget, oobs_user_get_home_directory (user)); ++ } So, we just add this right after, which is taking the code above and moving it below this, with the same guard. This means that we still set the user's home directory if they already exist, we just do it later so that it is not overwritten. I have tested this and found * It shows both mine and the root account's home dir correctly, where only mine was shown before. * It uses the default prefix from the user's profile when creating a user, and updates the homedir as you type in the username, which is the same behaviour as before. Thanks, James
Created attachment 108349 [details] [review] Patch to set the user's homedir correctly
Thanks again for that patch. Pushed as b89c075d44b415a34a43ecc1d22457091c69dc60.