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'}, "");
9 $mode = ($0 =~ /passwd_shadow_full.cgi$/ ? 2 :
10 $0 =~ /passwd_shadow.cgi$/ ? 1 : 0);
12 # Build list of available shells
13 @shlist = ("/bin/sh", "/bin/csh", "/bin/false");
14 open(SHELLS, "/etc/shells");
18 push(@shlist, $_) if (/\S/);
22 ($t, $lnums, $passwd, $shadow) =
23 &table_edit_setup($in{'table'}, $in{'line'}, ':');
24 print "<form action=save_passwd_shadow.cgi method=post>\n";
25 print "<input type=hidden name=table value='$in{'table'}'>\n";
26 print "<input type=hidden name=line value='$in{'line'}'>\n";
27 print "<input type=hidden name=mode value='$mode'>\n";
29 print "<table border width=100%>\n";
30 print "<tr $tb> <td><b>$text{'passwd_header1'}</b></td> </tr>\n";
31 print "<tr $cb> <td><table width=100%>\n";
33 print "<tr> <td><b>$text{'passwd_name'}</b></td>\n";
34 print "<td><input name=name size=10 value=\"$passwd->[0]\"></td>\n";
36 print "<td><b>$text{'passwd_uid'}</b></td>\n";
37 print "<td><input name=uid size=10 value=\"$passwd->[2]\"></td> </tr>\n";
39 print "<tr> <td><b>$text{'passwd_real'}</b></td>\n";
40 print "<td><input name=real size=20 value=\"$passwd->[4]\"></td>\n";
42 print "<td><b>$text{'passwd_home'}</b></td>\n";
43 print "<td><input name=home size=25 value=\"$passwd->[5]\"> ",
44 &file_chooser_button("home", 1),"</td> </tr>\n";
46 print "<tr> <td valign=top><b>$text{'passwd_shell'}</b></td>\n";
47 print "<td valign=top><select name=shell>\n";
48 foreach $s (&unique(@shlist)) {
49 printf "<option %s>%s\n",
50 $passwd->[6] eq $s ? 'selected' : '', $s;
51 $found++ if ($passwd->[6] eq $s);
53 printf "<option value='' %s>%s\n",
54 $found ? '' : 'selected', $text{'passwd_other'};
55 print "</select><br>\n";
56 printf "<input name=other size=20 value='%s'> %s</td>\n",
57 $found ? '' : $passwd->[6], &file_chooser_button("other");
59 $pass = $mode ? $shadow->[1] : $passwd->[1];
60 %uconfig = &foreign_config("useradmin");
61 print "<td valign=top rowspan=2><b>$text{'passwd_pass'}</b></td> <td rowspan=2>\n";
62 printf"<input type=radio name=passmode value=0 %s> %s<br>\n",
63 $pass eq "" ? "checked" : "",
64 $uconfig{'empty_mode'} ? $text{'passwd_none1'} : $text{'passwd_none2'};
65 printf"<input type=radio name=passmode value=1 %s> $text{'passwd_nologin'}<br>\n",
66 $pass eq $uconfig{'lock_string'} ? "checked" : "";
67 print "<input type=radio name=passmode value=3> $text{'passwd_clear'}\n";
68 printf "<input %s name=pass size=15><br>\n",
69 $uconfig{'passwd_stars'} ? "type=password" : "";
70 printf "<input type=radio name=passmode value=2 %s> $text{'passwd_encrypted'}\n",
71 $pass && $pass ne $uconfig{'lock_string'} ? "checked" :"";
72 printf "<input name=encpass size=13 value=\"%s\">\n",
73 $pass && $pass ne $uconfig{'lock_string'} ? $pass : "";
74 print "</td> </tr>\n";
76 print "<tr> <td><b>$text{'passwd_gid'}</b></td>\n";
77 print "<td><input name=gid size=10 value='$passwd->[3]'></td> </tr>\n";
80 print "</table></td></tr></table><br>\n";
81 print "<table border width=100%>\n";
82 print "<tr $tb> <td><b>$text{'passwd_header2'}</b></td> </tr>\n";
83 print "<tr $cb> <td><table width=100%>\n";
85 print "<tr> <td><b>$text{'passwd_change'}</b></td>\n";
86 if ($shadow->[2] && $shadow->[2] >= 0) {
87 @tm = localtime(timelocal(gmtime($shadow->[2] * 60*60*24)));
88 printf "<td>%s/%s/%s</td>\n",
89 $tm[3], $text{"smonth_".($tm[4]+1)}, $tm[5]+1900;
91 elsif ($in{'line'} eq "") { print "<td>$text{'passwd_never'}</td>\n"; }
92 else { print "<td>$text{'passwd_unknown'}</td>\n"; }
94 print "<td><b>$text{'passwd_expire'}</b></td>\n";
95 if ($shadow->[7] && $shadow->[7] >= 0) {
96 @tm = localtime($shadow->[7] * 60*60*24);
102 &date_input($eday, $emon, $eyear, 'expire');
105 print "<tr> <td><b>$text{'passwd_min'}</b></td>\n";
106 printf "<td><input size=5 name=min value=\"%s\"></td>\n",
107 $shadow->[3] < 0 ? "" : $shadow->[3];
109 print "<td><b>$text{'passwd_max'}</b></td>\n";
110 printf "<td><input size=5 name=max value=\"%s\"></td></tr>\n",
111 $shadow->[4] < 0 ? "" : $shadow->[4];
113 print "<tr> <td><b>$text{'passwd_warn'}</b></td>\n";
114 printf "<td><input size=5 name=warn value=\"%s\"></td>\n",
115 $shadow->[5] < 0 ? "" : $shadow->[5];
117 print "<td><b>$text{'passwd_inactive'}</b></td>\n";
118 printf "<td><input size=5 name=inactive value=\"%s\"></td></tr>\n",
119 $shadow->[6] < 0 ? "" : $shadow->[6];
121 print "</table></td></tr></table>\n";
123 if (defined($in{'line'})) {
124 print "<input type=submit value='$text{'save'}'>\n";
125 print "<input type=submit name=delete value='$text{'delete'}'>\n";
128 print "<input type=submit value='$text{'create'}'>\n";
131 &ui_print_footer("edit_tables.cgi?table=$in{'table'}", $text{'tables_return'},
132 "", $text{'index_return'});