3 # Display a form for creating a new user
5 require './cluster-useradmin-lib.pl';
6 require 'timelocal.pl';
8 &foreign_require("useradmin", "user-lib.pl");
10 &ui_print_header(undef, $text{'uedit_title2'}, "");
11 @hosts = &list_useradmin_hosts();
12 @servers = &list_servers();
14 # build list of used shells and uids
16 foreach $u (@{$h->{'users'}}) {
17 push(@shlist, $u->{'shell'}) if ($u->{'shell'});
20 foreach $g (@{$h->{'groups'}}) {
21 push(@glist, $g) if (!$donegroup{$g->{'group'}}++);
24 open(SHELLS, "/etc/shells");
28 push(@shlist, $_) if (/\S/);
32 print "<form action=create_user.cgi method=post>\n";
33 print "<table border width=100%>\n";
34 print "<tr $tb> <td><b>$text{'uedit_details'}</b></td> </tr>\n";
35 print "<tr $cb> <td><table width=100%>\n";
37 print "<tr> <td><b>$text{'user'}</b></td>\n";
38 print "<td><input name=user size=10></td>\n";
40 # Find the first free UID above the base
41 print "<td><b>$text{'uid'}</b></td>\n";
42 $newuid = int($uconfig{'base_uid'});
43 while($used{$newuid}) {
46 print "<td><input name=uid size=10 value='$newuid'></td> </tr>\n";
48 if ($uconfig{'extra_real'}) {
49 print "<tr> <td><b>$text{'real'}</b></td>\n";
50 print "<td><input name=real size=20></td>\n";
52 print "<td><b>$text{'office'}</b></td>\n";
53 print "<td><input name=office size=20 value=\"$real[1]\"></td> </tr>\n";
55 print "<tr> <td><b>$text{'workph'}</b></td>\n";
56 print "<td><input name=workph size=20></td>\n";
58 print "<td><b>$text{'homeph'}</b></td>\n";
59 print "<td><input name=homeph size=20></td> </tr>\n";
61 print "<tr> <td><b>$text{'extra'}</b></td>\n";
62 print "<td><input name=extra size=20></td>\n";
65 print "<tr> <td><b>$text{'real'}</b></td>\n";
66 print "<td><input name=real size=20></td>\n";
69 print "<td><b>$text{'home'}</b></td>\n";
71 if ($uconfig{'home_base'}) {
72 printf "<input type=radio name=home_base value=1 checked> %s\n",
74 printf "<input type=radio name=home_base value=0>\n";
75 printf "<input name=home size=25> %s\n",
76 &file_chooser_button("home", 1);
79 print "<input name=home size=25>\n",
80 &file_chooser_button("home", 1);
82 print "</td> </tr>\n";
84 print "<tr> <td valign=top><b>$text{'shell'}</b></td>\n";
85 print "<td valign=top><select name=shell>\n";
86 @shlist = &unique(@shlist);
87 foreach $s (@shlist) {
88 printf "<option value='%s'>%s\n", $s,
89 $s eq "" ? "<None>" : $s;
91 print "<option value=*>$text{'uedit_other'}\n";
92 print "</select></td>\n";
96 $random_password .= $random_password_chars[
97 rand(scalar(@random_password_chars))];
99 print "<td valign=top rowspan=4><b>$text{'pass'}</b>",
100 "</td> <td rowspan=4 valign=top>\n";
101 printf "<input type=radio name=passmode value=0> %s<br>\n",
102 $uconfig{'empty_mode'} ? $text{'none1'} : $text{'none2'};
103 printf "<input type=radio name=passmode value=1 checked> %s<br>\n",
105 printf "<input type=radio name=passmode value=3> %s\n",
107 printf "<input %s name=pass size=15 value='%s'><br>\n",
108 $uconfig{'passwd_stars'} ? "type=password" : "",
109 $uconfig{'random_password'} ? $random_password : "";
110 printf "<input type=radio name=passmode value=2> $text{'encrypted'}\n";
111 printf "<input name=encpass size=13>\n";
112 print "</td> </tr>\n";
114 print "<tr> <td valign=top>$text{'uedit_other'}</td>\n";
115 print "<td valign=top><input size=25 name=othersh>\n";
116 print &file_chooser_button("othersh", 0),"</td> </tr>\n";
117 print "<tr> <td colspan=2><br></td> </tr>\n";
118 print "</table></td></tr></table><p>\n";
120 $pft = &foreign_call("useradmin", "passfiles_type");
121 if ($pft == 1 || $pft == 6) {
122 # This is a BSD system.. a few extra password options are supported
123 print "<table border width=100%>\n";
124 print "<tr $tb> <td><b>$text{'uedit_passopts'}</b></td> </tr>\n";
125 print "<tr $cb> <td><table width=100%>\n";
126 print "<tr> <td><b>$text{'change2'}</b></td>\n";
128 &date_input("", "", "", 'change');
129 print " <input name=changeh size=3>";
130 print ":<input name=changemi size=3></td>\n";
132 print "<td><b>$text{'expire2'}</b></td>\n";
134 &date_input("", "", "", 'expire');
135 print " <input name=expireh size=3>";
136 print ":<input name=expiremi size=3></td> </tr>\n";
138 print "<tr> <td><b>$text{'class'}</b></td>\n";
139 print "<td><input name=class size=10></td>\n";
141 print "</table></td></tr></table><p>\n";
144 # System has a shadow password file as well.. which means it supports
145 # password expiry and so on
146 print "<table border width=100%>\n";
147 print "<tr $tb> <td><b>$text{'uedit_passopts'}</b></td> </tr>\n";
148 print "<tr $cb> <td><table width=100%>\n";
150 print "<td><b>$text{'expire'}</b></td>\n";
152 &date_input($eday, $emon, $eyear, 'expire');
153 print "</td> </tr>\n";
155 print "<tr> <td><b>$text{'min'}</b></td>\n";
156 print "<td><input size=5 name=min></td>\n";
158 print "<td><b>$text{'max'}</b></td>\n";
159 print "<td><input size=5 name=max></td></tr>\n";
161 print "<tr> <td><b>$text{'warn'}</b></td>\n";
162 print "<td><input size=5 name=warn></td>\n";
164 print "<td><b>$text{'inactive'}</b></td>\n";
165 print "<td><input size=5 name=inactive></td></tr>\n";
167 print "</table></td></tr></table><p>\n";
170 # This is an AIX system
171 print "<table border width=100%>\n";
172 print "<tr $tb> <td><b>$text{'uedit_passopts'}</b></td> </tr>\n";
173 print "<tr $cb> <td><table width=100%>\n";
175 print "<tr> <td><b>$text{'expire'}</b></td>\n";
177 &date_input("", "", "", 'expire');
178 print " <input name=expireh size=3>";
179 print "<b>:</b><input name=expiremi size=3></td> </tr>\n";
181 print "<tr> <td><b>$text{'min_weeks'}</b></td>\n";
182 print "<td><input size=5 name=min></td>\n";
184 print "<td><b>$text{'max_weeks'}</b></td>\n";
185 print "<td><input size=5 name=max></td></tr>\n";
187 print "<tr> <td valign=top><b>$text{'warn'}</b></td>\n";
188 print "<td valign=top><input size=5 name=warn></td>\n";
190 print "<td valign=top><b>$text{'flags'}</b></td> <td>\n";
191 printf "<input type=checkbox name=flags value=admin> %s<br>\n",
192 $text{'uedit_admin'};
193 printf "<input type=checkbox name=flags value=admchg> %s<br>\n",
194 $text{'uedit_admchg'};
195 printf "<input type=checkbox name=flags value=nocheck> %s\n",
196 $text{'uedit_nocheck'};
197 print "</td> </tr>\n";
199 print "</table></td></tr></table><p>\n";
202 # Output group memberships
203 print "<table border width=100%>\n";
204 print "<tr $tb> <td><b>$text{'uedit_gmem'}</b></td> </tr>\n";
205 print "<tr $cb> <td><table width=100%>\n";
206 print "<tr> <td valign=top><b>$text{'group'}</b></td> <td valign=top>\n";
207 printf "<input name=gid size=8 value=\"%s\">\n",
208 $uconfig{'default_group'};
209 print "<input type=button onClick='ifield = document.forms[0].gid; chooser = window.open(\"/useradmin/my_group_chooser.cgi?multi=0&group=\"+escape(ifield.value), \"chooser\", \"toolbar=no,menubar=no,scrollbars=yes,width=300,height=200\"); chooser.ifield = ifield' value=\"...\"></td>\n";
211 print "<td valign=top><b>$text{'uedit_2nd'}</b></td>\n";
212 print "<td><select name=sgid multiple size=5>\n";
213 @glist = sort { $a->{'group'} cmp $b->{'group'} } @glist
214 if ($uconfig{'sort_mode'});
215 foreach $g (@glist) {
216 @mems = split(/,/ , $g->{'members'});
217 print "<option value=\"$g->{'gid'}\">$g->{'group'} ($g->{'gid'})\n";
219 print "</select></td> </tr>\n";
220 print "</table></td></tr></table><p>\n";
222 print "<table border width=100%>\n";
223 print "<tr $tb> <td><b>$text{'uedit_oncreate'}</b></td> </tr>\n";
224 print "<tr $cb> <td><table>\n";
226 print "<tr> <td><b>$text{'uedit_makehome'}</b></td>\n";
227 print "<td><input type=radio name=makehome value=1 checked> $text{'yes'}</td>\n";
228 print "<td><input type=radio name=makehome value=0> $text{'no'}</td> </tr>\n";
230 if ($uconfig{'user_files'} =~ /\S/) {
231 print "<tr> <td><b>$text{'uedit_copy'}<b></td>\n";
232 print "<td><input type=radio name=copy_files ",
233 "value=1 checked> $text{'yes'}</td>\n";
234 print "<td><input type=radio name=copy_files ",
235 "value=0> $text{'no'}</td> </tr>\n";
238 # Show make home on all servers option
239 print "<tr> <td><b>$text{'uedit_servs'}</b></td>\n";
240 print "<td><input type=radio name=servs value=1> $text{'uedit_mall'}</td>\n";
241 print "<td><input type=radio name=servs value=0 checked> $text{'uedit_mthis'}</td> </tr>\n";
243 # Show other modules option
244 print "<tr> <td><b>$text{'uedit_others'}</b></td>\n";
245 print "<td><input type=radio name=others value=1 checked> $text{'yes'}</td>\n";
246 print "<td><input type=radio name=others value=0> $text{'no'}</td> </tr>\n";
248 # Show selector for hosts to create on
249 &create_on_input($text{'uedit_servers'});
251 print "</table></td> </tr></table><p>\n";
253 print "<input type=submit value=\"$text{'create'}\"></form><p>\n";
255 &ui_print_footer("", $text{'index_return'});
257 # date_input(day, month, year, prefix)
260 print "<input name=$_[3]d size=3 value='$_[0]'>";
261 print "/<select name=$_[3]m>\n";
264 printf "<option value=%d %s>%s\n",
265 $m, $_[1] eq $m ? 'selected' : '', $text{"smonth_$m"};
268 print "/<input name=$_[3]y size=5 value='$_[2]'>";
269 print &date_chooser_button("$_[3]d", "$_[3]m", "$_[3]y");