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

Annotation 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.1 - (hide annotations) (download)
Thu Feb 21 19:32:24 2013 UTC (11 years, 8 months ago) by vip-ire
Branch: MAIN
CVS Tags: e-smith-base-5_4_0-33_el6_sme, e-smith-base-5_4_0-40_el6_sme, e-smith-base-5_4_0-44_el6_sme, e-smith-base-5_4_0-49_el6_sme, e-smith-base-5_4_0-23_el6_sme, e-smith-base-5_4_0-37_el6_sme, e-smith-base-5_4_0-15_el6_sme, e-smith-base-5_4_0-17_el6_sme, e-smith-base-5_4_0-42_el6_sme, e-smith-base-5_4_0-27_el6_sme, e-smith-base-5_4_0-22_el6_sme, e-smith-base-5_4_0-21_el6_sme, e-smith-base-5_4_0-24_el6_sme, e-smith-base-5_4_0-43_el6_sme, e-smith-base-5_4_0-11_el6_sme, e-smith-base-5_4_0-34_el6_sme, e-smith-base-5_4_0-35_el6_sme, e-smith-base-5_4_0-36_el6_sme, e-smith-base-5_4_0-41_el6_sme, e-smith-base-5_4_0-30_el6_sme, e-smith-base-5_4_0-50_el6_sme, e-smith-base-5_4_0-29_el6_sme, e-smith-base-5_4_0-26_el6_sme, e-smith-base-5_4_0-58_el6_sme, e-smith-base-5_4_0-19_el6_sme, e-smith-base-5_4_0-45_el6_sme, e-smith-base-5_4_0-57_el6_sme, e-smith-base-5_4_0-46_el6_sme, e-smith-base-5_4_0-12_el6_sme, e-smith-base-5_4_0-62_el6_sme, e-smith-base-5_4_0-32_el6_sme, e-smith-base-5_4_0-39_el6_sme, e-smith-base-5_4_0-56_el6_sme, e-smith-base-5_4_0-14_el6_sme, e-smith-base-5_4_0-16_el6_sme, e-smith-base-5_4_0-52_el6_sme, e-smith-base-5_4_0-13_el6_sme, e-smith-base-5_4_0-54_el6_sme, e-smith-base-5_4_0-51_el6_sme, e-smith-base-5_4_0-47_el6_sme, e-smith-base-5_4_0-18_el6_sme, e-smith-base-5_4_0-55_el6_sme, e-smith-base-5_4_0-31_el6_sme, e-smith-base-5_4_0-38_el6_sme, e-smith-base-5_4_0-25_el6_sme, e-smith-base-5_4_0-28_el6_sme, e-smith-base-5_4_0-53_el6_sme, e-smith-base-5_4_0-61_el6_sme, e-smith-base-5_4_0-60_el6_sme, e-smith-base-5_4_0-48_el6_sme, e-smith-base-5_4_0-59_el6_sme
* Thu Feb 21 2013 Daniel Berteaud <daniel@firewall-services.com> 5.4.0-11.sme
- Optimize user-modify-unix script and link it in bootstrap-ldap-save [SME: 7387]

1 vip-ire 1.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