summaryrefslogtreecommitdiff
path: root/Users
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2007-10-24 19:10:19 +0200
committerCarlos Garnacho <carlosg@gnome.org>2007-11-06 01:27:19 +0100
commita90cf00bb52e078f8055422f5d97e66a7629cb1a (patch)
tree417ebd21b255d6ab34b766daf17580a1e642d1c4 /Users
parent98b009fac0cce753cf238f9080d964e5deaf8ff2 (diff)
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.
Diffstat (limited to 'Users')
-rw-r--r--Users/Users.pm56
1 files changed, 56 insertions, 0 deletions
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;