7035
|
1 |
--- /usr/tmp/clean/system-tools-backends-1.4.2/users-conf.in Mon Jan 2 15:48:06 2006
|
|
2 |
+++ system-tools-backends-1.4.2/users-conf.in Mon Apr 10 15:21:15 2006
|
|
3 |
@@ -47,6 +47,8 @@
|
|
4 |
# pw: modifying users/groups and user/group data on FreeBSD.
|
|
5 |
|
|
6 |
|
|
7 |
+use Authen::PAM;
|
|
8 |
+
|
|
9 |
BEGIN {
|
|
10 |
$SCRIPTSDIR = "@scriptsdir@";
|
|
11 |
if ($SCRIPTSDIR =~ /^@scriptsdir[@]/)
|
|
12 |
@@ -74,6 +76,7 @@
|
6955
|
13 |
"mandrake-7.1", "mandrake-7.2", "mandrake-9.0", "mandrake-9.1", "mandrake-9.2",
|
|
14 |
"mandrake-10.0", "mandrake-10.1",
|
|
15 |
"debian-2.2", "debian-3.0", "debian-sarge",
|
|
16 |
+ "nexenta-1.0", "solaris-2.11",
|
|
17 |
"suse-7.0", "suse-9.0", "suse-9.1", "turbolinux-7.0",
|
|
18 |
"slackware-8.0.0", "slackware-8.1", "slackware-9.0.0", "slackware-9.1.0", "slackware-10.0.0", "slackware-10.1.0", "slackware-10.2.0",
|
|
19 |
"freebsd-4", "freebsd-5", "freebsd-6",
|
7035
|
20 |
@@ -115,9 +118,12 @@
|
6975
|
21 |
# --- Mapping constants --- #
|
|
22 |
|
6955
|
23 |
%users_prop_map = ();
|
6975
|
24 |
+
|
|
25 |
+sub get_users_prop_array
|
|
26 |
+{
|
6955
|
27 |
@users_prop_array = ();
|
|
28 |
|
|
29 |
-if ($$tool{"platform"} eq "Linux")
|
6975
|
30 |
+if ($$tool{"system"} eq "Linux" || $$tool{"system"} eq "SunOS")
|
6955
|
31 |
{
|
|
32 |
@users_prop_array = (
|
|
33 |
"key", 0,
|
7035
|
34 |
@@ -157,6 +163,7 @@
|
6975
|
35 |
$users_prop_map {$users_prop_array[$i]} = $users_prop_array[$i + 1];
|
|
36 |
$users_prop_map {$users_prop_array[$i + 1]} = $users_prop_array[$i];
|
|
37 |
}
|
|
38 |
+}
|
|
39 |
|
|
40 |
%groups_prop_map = ();
|
|
41 |
@groups_prop_array = (
|
7035
|
42 |
@@ -315,6 +322,20 @@
|
6955
|
43 |
}
|
|
44 |
}
|
|
45 |
|
|
46 |
+my $nexenta_logindefs_defaults = {
|
|
47 |
+ 'shell' => '/bin/bash',
|
|
48 |
+ 'group' => 'users',
|
|
49 |
+ 'skel_dir' => '/etc/skel/',
|
|
50 |
+ 'home_prefix' => '/export/home/$user',
|
|
51 |
+};
|
|
52 |
+
|
|
53 |
+my $solaris_logindefs_defaults = {
|
|
54 |
+ 'shell' => '/bin/bash',
|
|
55 |
+ 'group' => 'users',
|
|
56 |
+ 'skel_dir' => '/etc/skel/',
|
|
57 |
+ 'home_prefix' => '/home/$user',
|
|
58 |
+};
|
|
59 |
+
|
|
60 |
my $rh_logindefs_defaults = {
|
|
61 |
'shell' => '/bin/bash',
|
|
62 |
'group' => '$user',
|
7035
|
63 |
@@ -362,6 +383,8 @@
|
6955
|
64 |
'debian-2.2' => $rh_logindefs_defaults,
|
|
65 |
'debian-3.0' => $rh_logindefs_defaults,
|
|
66 |
'debian-sarge' => $rh_logindefs_defaults,
|
|
67 |
+ 'nexenta-1.0' => $nexenta_logindefs_defaults,
|
|
68 |
+ 'solaris-2.11' => $solaris_logindefs_defaults,
|
|
69 |
'vine-3.0' => $rh_logindefs_defaults,
|
|
70 |
'vine-3.1' => $rh_logindefs_defaults,
|
|
71 |
'gentoo' => $gentoo_logindefs_defaults,
|
7035
|
72 |
@@ -740,7 +763,40 @@
|
6975
|
73 |
push (@shells, "/bin/false") if (stat ("/bin/false"));
|
|
74 |
|
|
75 |
$ifh = &gst_file_open_read_from_names(@shell_names);
|
|
76 |
- return unless $ifh;
|
|
77 |
+ unless ($ifh)
|
|
78 |
+ {
|
|
79 |
+ if ($gst_dist =~ /solaris/)
|
|
80 |
+ {
|
|
81 |
+ push (@shells, "/bin/bash");
|
|
82 |
+ push (@shells, "/bin/csh");
|
|
83 |
+ push (@shells, "/bin/jsh");
|
|
84 |
+ push (@shells, "/bin/ksh");
|
|
85 |
+ push (@shells, "/bin/pfcsh");
|
|
86 |
+ push (@shells, "/bin/pfksh");
|
|
87 |
+ push (@shells, "/bin/pfsh");
|
|
88 |
+ push (@shells, "/bin/sh");
|
|
89 |
+ push (@shells, "/bin/tcsh");
|
|
90 |
+ push (@shells, "/bin/zsh");
|
|
91 |
+ push (@shells, "/sbin/jsh");
|
|
92 |
+ push (@shells, "/sbin/jsh");
|
|
93 |
+ push (@shells, "/sbin/pfsh");
|
|
94 |
+ push (@shells, "/sbin/sh");
|
|
95 |
+ push (@shells, "/usr/bin/bash");
|
|
96 |
+ push (@shells, "/usr/bin/csh");
|
|
97 |
+ push (@shells, "/usr/bin/jsh");
|
|
98 |
+ push (@shells, "/usr/bin/ksh");
|
|
99 |
+ push (@shells, "/usr/bin/pfcsh");
|
|
100 |
+ push (@shells, "/usr/bin/pfksh");
|
|
101 |
+ push (@shells, "/usr/bin/pfsh");
|
|
102 |
+ push (@shells, "/usr/bin/sh");
|
|
103 |
+ push (@shells, "/usr/bin/tcsh");
|
|
104 |
+ push (@shells, "/usr/bin/zsh");
|
|
105 |
+ push (@shells, "/usr/xpg4/bin/sh");
|
|
106 |
+ $$hash{"shelldb"} = \@shells;
|
|
107 |
+ }
|
|
108 |
+ return;
|
|
109 |
+ }
|
|
110 |
+
|
|
111 |
|
|
112 |
while (<$ifh>)
|
|
113 |
{
|
7035
|
114 |
@@ -879,6 +935,11 @@
|
6983
|
115 |
{
|
|
116 |
$command = "$cmd_pw usermod -n " . $username . " -c \'" . $comment . "\'";
|
|
117 |
}
|
|
118 |
+ elsif ($gst_dist =~ /^solaris/)
|
|
119 |
+ {
|
|
120 |
+ ($fname, $office, $office_phone, $home_phone) = @line;
|
|
121 |
+ $command = "$cmd_usermod" . " -c \'" . $fname . "\' " . $username;
|
|
122 |
+ }
|
|
123 |
else
|
|
124 |
{
|
|
125 |
($fname, $office, $office_phone, $home_phone) = @line;
|
7035
|
126 |
@@ -886,7 +947,7 @@
|
6955
|
127 |
$fname = "-f \'" . $fname . "\'";
|
|
128 |
$home_phone = "-h \'" . $home_phone . "\'";
|
|
129 |
|
|
130 |
- if ($gst_dist =~ /^debian/ || $gst_dist =~ /^archlinux/)
|
|
131 |
+ if ($gst_dist =~ /^debian/ || $gst_dist =~ /^archlinux/ || $gst_dist =~ /^nexenta/)
|
|
132 |
{
|
|
133 |
$office = "-r \'" . $office . "\'";
|
|
134 |
$office_phone = "-w \'" . $office_phone . "\'";
|
7035
|
135 |
@@ -903,6 +964,30 @@
|
|
136 |
&gst_file_run ($command);
|
|
137 |
}
|
|
138 |
|
|
139 |
+$service = "passwd";
|
|
140 |
+$username = "";
|
|
141 |
+$newpassword = "";
|
|
142 |
+
|
|
143 |
+sub my_conv_func {
|
|
144 |
+ my @res;
|
|
145 |
+ while ( @_ ) {
|
|
146 |
+ my $code = shift;
|
|
147 |
+ my $msg = shift;
|
|
148 |
+ my $ans = "";
|
|
149 |
+
|
|
150 |
+ $ans = $username if ($code == PAM_PROMPT_ECHO_ON() );
|
|
151 |
+ if ($code == PAM_PROMPT_ECHO_OFF() ) {
|
|
152 |
+ $ans = $newpassword;
|
|
153 |
+ $ans = $newpassword;
|
|
154 |
+
|
|
155 |
+ }
|
|
156 |
+
|
|
157 |
+ push @res, (PAM_SUCCESS(),$ans);
|
|
158 |
+ }
|
|
159 |
+ push @res, PAM_SUCCESS();
|
|
160 |
+ return @res;
|
|
161 |
+}
|
|
162 |
+
|
|
163 |
sub add_user
|
|
164 |
{
|
|
165 |
my ($data) = @_;
|
|
166 |
@@ -932,6 +1017,38 @@
|
6955
|
167 |
print $pwdpipe $$data[$users_prop_map{"password"}];
|
|
168 |
&gst_file_close ($pwdpipe);
|
|
169 |
}
|
|
170 |
+ elsif ($gst_dist =~ /^nexenta/)
|
|
171 |
+ {
|
|
172 |
+ my $pwdpipe;
|
|
173 |
+ $home_parents = $$data[$users_prop_map{"home"}];
|
|
174 |
+ $home_parents =~ s/\/+[^\/]+\/*$//;
|
|
175 |
+ &gst_file_run ("$tool_mkdir -p $home_parents");
|
|
176 |
+
|
|
177 |
+ $command = "$cmd_useradd" . " -d \'" . $$data[$users_prop_map{"home"}] .
|
|
178 |
+ "\' -g \'" . $$data[$users_prop_map{"gid"}] .
|
|
179 |
+ "\' -s \'" . $$data[$users_prop_map{"shell"}] .
|
|
180 |
+ "\' -u \'" . $$data[$users_prop_map{"uid"}] .
|
|
181 |
+ "\' \'" . $$data[$users_prop_map{"login"}] . "\'";
|
|
182 |
+ &gst_file_run ($command);
|
|
183 |
+ &gst_file_run("echo " . $$data[$users_prop_map{"login"}] . ":" . $$data[$users_prop_map{"password"}] . " | chpasswd -e");
|
|
184 |
+ }
|
6983
|
185 |
+ elsif ($gst_dist =~ /^solaris/)
|
|
186 |
+ {
|
|
187 |
+ $home_parents = $$data[$users_prop_map{"home"}];
|
|
188 |
+ $home_parents =~ s/\/+[^\/]+\/*$//;
|
|
189 |
+ &gst_file_run ("$tool_mkdir -p $home_parents");
|
|
190 |
+
|
|
191 |
+ $command = "$cmd_useradd" . " -d \'" . $$data[$users_prop_map{"home"}] .
|
|
192 |
+ "\' -g \'" . $$data[$users_prop_map{"gid"}] .
|
|
193 |
+ "\' -m -s \'" . $$data[$users_prop_map{"shell"}] .
|
|
194 |
+ "\' -u \'" . $$data[$users_prop_map{"uid"}] .
|
|
195 |
+ "\' \'" . $$data[$users_prop_map{"login"}] . "\'";
|
|
196 |
+ &gst_file_run ($command);
|
7035
|
197 |
+ $username = $$data[$users_prop_map{"login"}];
|
|
198 |
+ $newpassword = $$data[$users_prop_map{"password"}];
|
|
199 |
+ ref($pamh = new Authen::PAM($service, $username, \&my_conv_func));
|
|
200 |
+ $pamh->pam_chauthtok(PAM_NO_AUTHTOK_CHECK());
|
6983
|
201 |
+ }
|
6955
|
202 |
else
|
|
203 |
{
|
|
204 |
$home_parents = $$data[$users_prop_map{"home"}];
|
7035
|
205 |
@@ -967,9 +1084,33 @@
|
|
206 |
" -H 0"; # pw(8) reads password from STDIN
|
|
207 |
|
|
208 |
$pwdpipe = &gst_file_run_pipe($command, $GST_FILE_WRITE);
|
|
209 |
- print $pwdpipe $$data[$users_prop_map{"password"}];
|
|
210 |
+ print $pwdpipe $$new_data[$users_prop_map{"password"}];
|
6955
|
211 |
&gst_file_close ($pwdpipe);
|
|
212 |
}
|
|
213 |
+ elsif ($gst_dist =~ /^nexenta/)
|
|
214 |
+ {
|
|
215 |
+ $command = "$cmd_usermod" . " -d \'" . $$new_data[$users_prop_map{"home"}] .
|
|
216 |
+ "\' -g \'" . $$new_data[$users_prop_map{"gid"}] .
|
|
217 |
+ "\' -l \'" . $$new_data[$users_prop_map{"login"}] .
|
|
218 |
+ "\' -s \'" . $$new_data[$users_prop_map{"shell"}] .
|
|
219 |
+ "\' -u \'" . $$new_data[$users_prop_map{"uid"}] .
|
|
220 |
+ "\' \'" . $$old_data[$users_prop_map{"login"}] . "\'";
|
|
221 |
+ &gst_file_run ($command);
|
7035
|
222 |
+ &gst_file_run("echo " . $$new_data[$users_prop_map{"login"}] . ":" . $$new_data[$users_prop_map{"password"}] . " | chpasswd -e");
|
6955
|
223 |
+ }
|
6975
|
224 |
+ elsif ($gst_dist =~ /^solaris/)
|
|
225 |
+ {
|
|
226 |
+ $command = "$cmd_usermod" . " -d \'" . $$new_data[$users_prop_map{"home"}] .
|
|
227 |
+ "\' -g \'" . $$new_data[$users_prop_map{"gid"}] .
|
|
228 |
+ "\' -s \'" . $$new_data[$users_prop_map{"shell"}] .
|
|
229 |
+ "\' -u \'" . $$new_data[$users_prop_map{"uid"}] .
|
|
230 |
+ "\' \'" . $$old_data[$users_prop_map{"login"}] . "\'";
|
|
231 |
+ &gst_file_run ($command);
|
7035
|
232 |
+ $username = $$old_data[$users_prop_map{"login"}];
|
|
233 |
+ $newpassword = $$new_data[$users_prop_map{"password"}];
|
|
234 |
+ ref($pamh = new Authen::PAM($service, $username, \&my_conv_func));
|
|
235 |
+ $pamh->pam_chauthtok(PAM_NO_AUTHTOK_CHECK());
|
6975
|
236 |
+ }
|
6955
|
237 |
else
|
|
238 |
{
|
|
239 |
$command = "$cmd_usermod" . " -d \'" . $$new_data[$users_prop_map{"home"}] .
|
7035
|
240 |
@@ -1026,8 +1167,24 @@
|
6983
|
241 |
|
|
242 |
foreach $user (@$u)
|
|
243 |
{
|
|
244 |
- $command = "$cmd_gpasswd -a \'" . $user .
|
|
245 |
- "\' " . $$data[$groups_prop_map{"name"}];
|
|
246 |
+ if ($gst_dist =~ /^solaris/)
|
|
247 |
+ {
|
|
248 |
+ my ($groups, @a);
|
|
249 |
+ $command = "groups \'" . $user . "\'";
|
|
250 |
+ $groups = &gst_file_run_backtick ($command);
|
|
251 |
+ chomp ($groups);
|
|
252 |
+ @a = split (/ /, $groups);
|
|
253 |
+ $groups = join (',', @a);
|
|
254 |
+
|
|
255 |
+ $command = "$cmd_usermod -G " . $groups . "," .
|
|
256 |
+ $$data[$groups_prop_map{"name"}] . " " .
|
|
257 |
+ $user . " ";
|
|
258 |
+ }
|
|
259 |
+ else
|
|
260 |
+ {
|
|
261 |
+ $command = "$cmd_gpasswd -a \'" . $user .
|
|
262 |
+ "\' " . $$data[$groups_prop_map{"name"}];
|
|
263 |
+ }
|
|
264 |
&gst_file_run ($command);
|
|
265 |
}
|
|
266 |
}
|
7035
|
267 |
@@ -1069,25 +1226,62 @@
|
6981
|
268 |
$max_o = $#$o;
|
|
269 |
for ($i = 0, $j = 0; $i <= &max ($max_n, $max_o); ) {
|
|
270 |
$r = $$n[$i] cmp $$o[$j];
|
|
271 |
- $r *= -1 if (($$o[$j] eq "") || ($$n[$i] eq ""));
|
|
272 |
|
|
273 |
- if ($r < 0) { # add this user to the group.
|
|
274 |
- $command = "$cmd_gpasswd -a \'" . $$n[$i] . "\' \'" .
|
|
275 |
- $$new_data[$groups_prop_map{"name"}] . "\'";
|
|
276 |
+ if ($r > 0) { # add this user to the group.
|
|
277 |
+ if ($gst_dist =~ /^solaris/)
|
|
278 |
+ {
|
|
279 |
+ my ($groups, @a);
|
|
280 |
+ $command = "groups \'" . $$n[$i] . "\'";
|
|
281 |
+ $groups = &gst_file_run_backtick ($command);
|
|
282 |
+ chomp ($groups);
|
|
283 |
+ @a = split (/ /, $groups);
|
|
284 |
+ $groups = join (',', @a);
|
|
285 |
+
|
|
286 |
+ $command = "$cmd_usermod -G " . $groups . "," .
|
|
287 |
+ $$new_data[$groups_prop_map{"name"}] . " " .
|
|
288 |
+ $$n[$i] . " ";
|
|
289 |
+ }
|
|
290 |
+ else
|
|
291 |
+ {
|
|
292 |
+ $command = "$cmd_gpasswd -a " . $$n[$i] . " " . $$new_data[$groups_prop_map{"name"}] . " ";
|
|
293 |
+ }
|
|
294 |
$i ++;
|
|
295 |
-
|
|
296 |
+
|
|
297 |
&gst_file_run ($command);
|
|
298 |
- } elsif ($r > 0) { # delete the user from the group.
|
|
299 |
- $command = "$cmd_gpasswd -d \'" . $$o[$j] . "\' \'" .
|
|
300 |
- $$new_data[$groups_prop_map{"name"}] . "\'";
|
|
301 |
+ } elsif ($r < 0) { # delete the user from the group.
|
|
302 |
+ if ($gst_dist =~ /^solaris/)
|
|
303 |
+ {
|
|
304 |
+ my ($groups, @a, $k);
|
|
305 |
+ $command = "groups \'" . $$o[$j] . "\'";
|
|
306 |
+ $groups = &gst_file_run_backtick ($command);
|
|
307 |
+ chomp ($groups);
|
|
308 |
+ @a = split (/ /, $groups);
|
|
309 |
+ for ($k = 0; $k < $#a + 1; $k++)
|
|
310 |
+ {
|
|
311 |
+ if ($a[$k] eq $$new_data[$groups_prop_map{"name"}])
|
|
312 |
+ {
|
|
313 |
+ splice (@a, $k, 1);
|
|
314 |
+ last;
|
|
315 |
+ }
|
|
316 |
+ }
|
|
317 |
+ $groups = join (',', @a);
|
|
318 |
+
|
|
319 |
+ $command = "$cmd_usermod -G " . $groups . " " .
|
|
320 |
+ $$o[$j] . " ";
|
|
321 |
+ }
|
|
322 |
+ else
|
|
323 |
+ {
|
|
324 |
+ $command = "$cmd_gpasswd -d \'" . $$o[$j] . "\' \'" .
|
|
325 |
+ $$new_data[$groups_prop_map{"name"}] . "\'";
|
|
326 |
+ }
|
|
327 |
$j ++;
|
|
328 |
-
|
|
329 |
+
|
|
330 |
&gst_file_run ($command);
|
|
331 |
- } else { # The information is the same. Go to next tuple.
|
|
332 |
+ } else { # The information is the same. Go to next tuple.
|
|
333 |
$i ++; $j ++;
|
|
334 |
- }
|
|
335 |
- }
|
|
336 |
- }
|
|
337 |
+ }
|
|
338 |
+ }
|
|
339 |
+ }
|
|
340 |
}
|
|
341 |
}
|
|
342 |
|
7035
|
343 |
@@ -1204,6 +1398,7 @@
|
6975
|
344 |
elsif ($$tree[0] eq "group_last_modified") { &xml_parse_group_last_modified ($$tree[1], $hash); }
|
|
345 |
elsif ($$tree[0] eq "userdb") { &xml_parse_userdb ($$tree[1], $hash); }
|
|
346 |
elsif ($$tree[0] eq "groupdb") { &xml_parse_groupdb ($$tree[1], $hash); }
|
|
347 |
+ elsif ($$tree[0] eq "use_md5") { }
|
|
348 |
elsif ($$tree[0] eq "shelldb") { }
|
|
349 |
elsif ($$tree[0] eq "profiledb") { &xml_parse_profiledb ($$tree[1], $hash); }
|
|
350 |
else
|
7035
|
351 |
@@ -1323,6 +1518,7 @@
|
6976
|
352 |
if ($$tree[0] eq "users") { $line[$groups_prop_map{$$tree[0]}] = $$tree[1]; }
|
|
353 |
else { $line[$groups_prop_map{$$tree[0]}] = $$tree[1][2]; }
|
|
354 |
}
|
|
355 |
+ elsif ($$tree[0] eq "allows_to") { }
|
|
356 |
else
|
|
357 |
{
|
|
358 |
&gst_report ("xml_unexp_tag", $$tree[0]);
|
7035
|
359 |
@@ -1627,6 +1823,7 @@
|
6975
|
360 |
$tool = &gst_init ($name, $version, $description, $directives, @ARGV);
|
|
361 |
&gst_platform_ensure_supported ($tool, @platforms);
|
|
362 |
|
|
363 |
+&get_users_prop_array ();
|
|
364 |
&get_login_defs_prop_array ();
|
|
365 |
&get_profiles_prop_array ();
|
|
366 |
|