diff options
author | Milan Bouchet-Valat <nalimilan@club.fr> | 2009-12-21 13:33:38 +0100 |
---|---|---|
committer | Milan Bouchet-Valat <nalimilan@club.fr> | 2010-01-11 17:37:43 +0100 |
commit | cf7148081bfc2d5dff7fd742ce1cd1dda4fdf1f4 (patch) | |
tree | 7b1d31feb20d9741040fc1648b6f18f45f3bf8e2 /Users | |
parent | 252d6781055c88ef911f4f966368753e752273dc (diff) |
New SelfConfig protocol
SelfConfig is now a real object, and a dispatcher redirects messages with the UID of the caller. Rename a few calls that were naming it user_config, to avoid any confusion with the general UserConfig.
Add SelfConfig.pm, only accepting GECOS fields, locale and location, since other parameters can't be changed without admin authentication. Old and new passwords are required, since we'll use PAM to change it. Add Users.pm::[sg]et_self() to handle the DBus methods. Update DBus config file as needed.
Diffstat (limited to 'Users')
-rw-r--r-- | Users/Users.pm | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Users/Users.pm b/Users/Users.pm index 80f982d..8034ce8 100644 --- a/Users/Users.pm +++ b/Users/Users.pm @@ -779,6 +779,20 @@ sub set_logindefs } } +sub get_self +{ + my ($uid) = @_; + my ($users) = &get (); + + foreach $user (@$users) + { + next if ($uid != $$user[$UID]); + return ($$user[$COMMENT], $$user[$LOCALE]); + } + + return ([""], ""); +} + sub get_user { my ($login) = @_; @@ -812,6 +826,27 @@ sub set_user } } +sub set_self +{ + my ($uid, $old_passwd, $new_passwd, @comments) = @_; + my ($users) = &get (); + + # Make backups manually, otherwise they don't get backed up. + &Utils::File::do_backup ($_) foreach (@passwd_names); + &Utils::File::do_backup ($_) foreach (@shadow_names); + + foreach $user (@$users) + { + if ($uid == $$user[$UID]) + { + &change_user_chfn ($$user[$LOGIN], $$user[$COMMENT], @comments); + return; + } + } + # TODO: change password +} + + sub get_files { my ($arr); |