From a90cf00bb52e078f8055422f5d97e66a7629cb1a Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 24 Oct 2007 19:10:19 +0200 Subject: Add UserConfig module. It will get/set configuration for a single user, this should be hidden by the dispatcher in the form of SelfConfig, as the backend modules can't know the uid of the requester. --- Users/Users.pm | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'Users') diff --git a/Users/Users.pm b/Users/Users.pm index 6bc5100..d63092e 100644 --- a/Users/Users.pm +++ b/Users/Users.pm @@ -527,6 +527,32 @@ sub modify_shadow_password &Utils::File::save_buffer ($buffer, @shadow_names); } +sub set_passwd +{ + my ($login, $password) = @_; + my ($pwdpipe, $command); + + if ($Utils::Backend::tool{"system"} eq "FreeBSD") + { + + $command = "$cmd_pw usermod -H 0"; + $pwdpipe = &Utils::File::run_pipe_write ($command); + print $pwdpipe $password; + &Utils::File::close_file ($pwdpipe); + } + elsif ($Utils::Backend::tool{"system"} eq "SunOS") + { + &modify_shadow_password ($login, $password); + } + else + { + $command = "$cmd_usermod " . + " -p '" . $password . "' " . $login; + + &Utils::File::run ($command); + } +} + sub add_user { my ($user) = @_; @@ -752,4 +778,34 @@ sub set } } +sub get_user +{ + my ($uid) = @_; + my ($users) = &get (); + + foreach $user (@$users) + { + next if ($uid != $$user[$UID]); + return ($$user[$UID], $$user[$PASSWD], $$user[$COMMENT]); + } + + return ($uid, "", []); +} + +sub set_user +{ + my ($uid, $passwd, @comment) = @_; + my ($users) = &get (); + + foreach $user (@$users) + { + if ($uid == $$user[$UID]) + { + &set_passwd ($$user[$LOGIN], $passwd); + &change_user_chfn ($$user[$LOGIN], undef, @comment); + return; + } + } +} + 1; -- cgit v1.2.3