/[smeserver]/rpms/e-smith-base/sme9/e-smith-base-5.4.0-optimize_user_modify_unix.patch
ViewVC logotype

Contents of /rpms/e-smith-base/sme9/e-smith-base-5.4.0-optimize_user_modify_unix.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download)
Mon Mar 24 03:05:36 2014 UTC (10 years, 2 months ago) by wellsi
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
FILE REMOVED
* Sun Mar 23 2014 Ian Wells <esmith@wellsi.com> 5.6.0-1.sme
- Roll new stream to remove obsolete images [SME: 7962]

1 diff -Nur e-smith-base-5.2.0/root/etc/e-smith/events/actions/user-modify-unix e-smith-base-5.2.0-optimize_user_modify_unix/root/etc/e-smith/events/actions/user-modify-unix
2 --- e-smith-base-5.2.0/root/etc/e-smith/events/actions/user-modify-unix 2013-01-30 21:29:34.003293926 +0100
3 +++ e-smith-base-5.2.0-optimize_user_modify_unix/root/etc/e-smith/events/actions/user-modify-unix 2013-01-30 21:31:10.221693946 +0100
4 @@ -22,7 +22,8 @@
5 use Errno;
6 use esmith::AccountsDB;
7 use esmith::ConfigDB;
8 -use File::Temp;
9 +use Net::LDAP;
10 +use esmith::util;
11
12 my $conf = esmith::ConfigDB->open or die "Could not open configuration db";
13
14 @@ -33,6 +34,18 @@
15 || die("Couldn't determine domain name");
16 $domain = $domain->value;
17
18 +# prepare LDAP bind
19 +my $pw = esmith::util::LdapPassword();
20 +my $base = esmith::util::ldapBase ($domain);
21 +
22 +my $ldap = Net::LDAP->new('localhost')
23 + or die "$@";
24 +
25 +$ldap->bind(
26 + dn => "cn=root,$base",
27 + password => $pw
28 +);
29 +
30 my $event = $ARGV [0];
31 my $userName = $ARGV [1];
32
33 @@ -63,13 +76,14 @@
34 unless ( ($userName eq 'admin') or ($type eq 'user') );
35
36 setpwent;
37 - my ($comment, $shell) = (getpwnam($userName))[5,8];
38 + my ($comment, $shell) = (getpwnam($userName))[6,8];
39 endpwent;
40 my $new_shell = $u->prop('Shell')
41 || (($shell eq "/bin/sshell") ? "/usr/bin/rssh" : $shell);
42
43 $u->set_prop('Shell', $new_shell);
44
45 + my $result;
46 #------------------------------------------------------------
47 # Modify user's shell, if required, in /etc/passwd using "usermod"
48 #------------------------------------------------------------
49 @@ -81,8 +95,13 @@
50 or ( $x = 255, warn "Failed to modify shell of (unix) account $userName.\n" );
51 }
52
53 - system("/usr/sbin/cpu", "usermod", '-s', "$new_shell", $userName) == 0
54 - or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to modify shell of (ldap) account $userName.\n" );
55 + my @new_shell = ($new_shell);
56 + $result = $ldap->modify("uid=$userName,ou=Users,$base",
57 + replace => {
58 + loginShell => \@new_shell
59 + }
60 + );
61 + $result->code && ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to modify shell of (ldap) account $userName.\n" );
62 }
63
64 #------------------------------------------------------------
65 @@ -101,26 +120,37 @@
66 or ( $x = 255, warn "Failed to modify comment of (unix) account $userName.\n" );
67 }
68
69 - system("/usr/sbin/cpu", "usermod", "-f", "$first", "-E", "$last", $userName) == 0
70 - or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to modify comment/name of (ldap) account $userName.\n" );
71 + my @new_comment = ($new_comment);
72 + my @first = ($first);
73 + my @last = ($last);
74 + $result = $ldap->modify("uid=$userName,ou=Users,$base",
75 + replace => {
76 + givenName => \@first,
77 + sn => \@last,
78 + cn => \@new_comment,
79 + displayName => \@new_comment
80 + }
81 + );
82 + $result->code && ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to modify comment/name of (ldap) account $userName.\n" );
83 }
84
85 - my $new_phone = $u->prop('Phone') || '';
86 - my $new_company = $u->prop('Company') || '';
87 - my $new_dept = $u->prop('Dept') || '';
88 - my $new_city = $u->prop('City') || '';
89 - my $new_street = $u->prop('Street') || '';
90 -
91 - my $tmpattr = File::Temp->new();
92 - print $tmpattr "telephoneNumber: $new_phone\n";
93 - print $tmpattr "o: $new_company\n";
94 - print $tmpattr "ou: $new_dept\n";
95 - print $tmpattr "l: $new_city\n";
96 - print $tmpattr "street: $new_street\n";
97 - $tmpattr->flush();
98 - system("/usr/sbin/cpu", "usermod", "-a", "$tmpattr", "-e", "$userName\@$domain", $userName) == 0
99 - or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to modify email of (ldap) account $userName.\n" );
100 - undef $tmpattr;
101 + my @new_phone = ($u->prop('Phone')) || ();
102 + my @new_company = ($u->prop('Company')) || ();
103 + my @new_dept = ($u->prop('Dept')) || ();
104 + my @new_city = ($u->prop('City')) || ();
105 + my @new_street = ($u->prop('Street')) || ();
106 + $result = $ldap->modify("uid=$userName,ou=Users,$base",
107 + replace => {
108 + telephoneNumber => \@new_phone,
109 + o => \@new_company,
110 + ou => \@new_dept,
111 + l => \@new_city,
112 + street => \@new_street
113 + }
114 + );
115 + $result->code && ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to modify email of (ldap) account $userName.\n" );
116 +
117 }
118
119 +$ldap->unbind;
120 exit ($x);

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed