2 # edit_passwd_shadow.cgi
3 # Edit a NIS password/shadow files entry
5 require './nis-lib.pl';
6 require 'timelocal.pl';
8 &ui_print_header(undef, $text{'passwd_title'}, "");
10 # Build list of available shells
11 @shlist = ("/bin/sh", "/bin/csh", "/bin/false");
12 open(SHELLS, "/etc/shells");
16 push(@shlist, $_) if (/\S/);
20 ($t, $lnums, $passwd, $shadow) =
21 &table_edit_setup($in{'table'}, $in{'line'}, ':');
22 print "<form action=save_passwd_shadow.cgi>\n";
23 print "<input type=hidden name=table value='$in{'table'}'>\n";
24 print "<input type=hidden name=line value='$in{'line'}'>\n";
26 print "<table border width=100%>\n";
27 print "<tr $tb> <td><b>$text{'passwd_header1'}</b></td> </tr>\n";
28 print "<tr $cb> <td><table width=100%>\n";
30 print "<tr> <td><b>$text{'passwd_name'}</b></td>\n";
31 print "<td><input name=name size=10 value=\"$passwd->[0]\"></td>\n";
33 print "<td><b>$text{'passwd_uid'}</b></td>\n";
34 print "<td><input name=uid size=10 value=\"$passwd->[2]\"></td> </tr>\n";
36 print "<tr> <td><b>$text{'passwd_real'}</b></td>\n";
37 print "<td><input name=real size=20 value=\"$passwd->[4]\"></td>\n";
39 print "<td><b>$text{'passwd_home'}</b></td>\n";
40 print "<td><input name=home size=25 value=\"$passwd->[5]\"> ",
41 &file_chooser_button("home", 1),"</td> </tr>\n";
43 print "<tr> <td valign=top><b>$text{'passwd_shell'}</b></td>\n";
44 print "<td valign=top><select name=shell>\n";
45 foreach $s (&unique(@shlist)) {
46 printf "<option %s>%s\n",
47 $passwd->[6] eq $s ? 'selected' : '', $s;
48 $found++ if ($passwd->[6] eq $s);
50 printf "<option %s>%s\n", $found ? '' : 'selected', $text{'passwd_other'};
51 print "</select><br>\n";
52 printf "<input name=other size=20 value='%s'> %s</td>\n",
53 $found ? '' : $passwd->[6], &file_chooser_button("other");
55 %uconfig = &foreign_config("useradmin");
56 print "<td valign=top rowspan=2><b>$text{'passwd_pass'}</b></td> <td rowspan=2>\n";
57 printf"<input type=radio name=passmode value=0 %s> %s<br>\n",
58 $passwd->[0] eq "" ? "checked" : "",
59 $uconfig{'empty_mode'} ? $text{'passwd_none1'} : $text{'passwd_none2'};
60 printf"<input type=radio name=passmode value=1 %s> $text{'passwd_nologin'}<br>\n",
61 $passwd->[0] eq $uconfig{'lock_string'} ? "checked" : "";
62 print "<input type=radio name=passmode value=3> $text{'passwd_clear'}\n";
63 printf "<input %s name=pass size=15><br>\n",
64 $uconfig{'passwd_stars'} ? "type=password" : "";
65 printf "<input type=radio name=passmode value=2 %s> $text{'passwd_encrypted'}\n",
66 $passwd->[0] && $passwd->[0] ne $uconfig{'lock_string'} ? "checked" :"";
67 printf "<input name=encpass size=13 value=\"%s\">\n",
68 $passwd->[0] && $passwd->[0] ne $uconfig{'lock_string'} ? $pass : "";
69 print "</td> </tr>\n";
71 print "<tr> <td><b>$text{'passwd_gid'}</b></td>\n";
72 print "<td><input name=gid size=10 value='$passwd->[3]'></td> </tr>\n";
74 print "</table></td></tr></table><p>\n";
75 print "<table border width=100%>\n";
76 print "<tr $tb> <td><b>$text{'passwd_header2'}</b></td> </tr>\n";
77 print "<tr $cb> <td><table width=100%>\n";
79 print "<tr> <td><b>$text{'passwd_change'}</b></td>\n";
80 if ($shadow->[2] && $shadow->[2] >= 0) {
81 @tm = localtime(timelocal(gmtime($shadow->[2] * 60*60*24)));
82 printf "<td>%s/%s/%s</td>\n",
83 $tm[3], $text{"smonth_".($tm[4]+1)}, $tm[5]+1900;
85 elsif ($in{'line'} eq "") { print "<td>$text{'passwd_never'}</td>\n"; }
86 else { print "<td>$text{'passwd_unknown'}</td>\n"; }
88 print "<td><b>$text{'passwd_expire'}</b></td>\n";
89 if ($shadow->[7] && $shadow->[7] >= 0) {
90 @tm = localtime($shadow->[7] * 60*60*24);
96 &date_input($eday, $emon, $eyear, 'expire');
99 print "<tr> <td><b>$text{'passwd_min'}</b></td>\n";
100 printf "<td><input size=5 name=min value=\"%s\"></td>\n",
101 $shadow->[3] < 0 ? "" : $shadow->[3];
103 print "<td><b>$text{'passwd_max'}</b></td>\n";
104 printf "<td><input size=5 name=max value=\"%s\"></td></tr>\n",
105 $shadow->[4] < 0 ? "" : $shadow->[4];
107 print "<tr> <td><b>$text{'passwd_warn'}</b></td>\n";
108 printf "<td><input size=5 name=warn value=\"%s\"></td>\n",
109 $shadow->[5] < 0 ? "" : $shadow->[5];
111 print "<td><b>$text{'passwd_inactive'}</b></td>\n";
112 printf "<td><input size=5 name=inactive value=\"%s\"></td></tr>\n",
113 $shadow->[6] < 0 ? "" : $shadow->[6];
115 print "<input type=hidden name=flags value='$shadow->[8]'>\n";
116 print "</table></td></tr></table>\n";
118 if (defined($in{'line'})) {
119 print "<input type=submit value='$text{'save'}'>\n";
120 print "<input type=submit name=delete value='$text{'delete'}'>\n";
123 print "<input type=submit value='$text{'create'}'>\n";
126 &ui_print_footer("edit_tables.cgi?table=$in{'table'}", $text{'tables_return'});