forked from webmin/webmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit_user.cgi
executable file
·51 lines (43 loc) · 1.28 KB
/
edit_user.cgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/local/bin/perl
# Show a form to edit or create a user
use strict;
use warnings;
require './iscsi-server-lib.pl';
our (%text, %in);
&ReadParse();
# Get the user, or create a new one
my $user;
if ($in{'new'}) {
&ui_print_header(undef, $text{'user_create'}, "");
$user = { 'mode' => 'chap' };
}
else {
&ui_print_header(undef, $text{'user_edit'}, "");
($user) = grep { $_->{'user'} eq $in{'user'} } &list_iscsi_users();
$user || &error($text{'user_egone'});
}
# Show editing form
print &ui_form_start("save_user.cgi", "post");
print &ui_hidden("new", $in{'new'});
print &ui_hidden("old", $in{'user'});
print &ui_table_start($text{'user_header'}, undef, 2);
# Username
print &ui_table_row($text{'user_user'},
&ui_textbox("iuser", $user->{'user'}, 40));
# Authentication method
print &ui_table_row($text{'user_mode'},
&ui_select("imode", lc($user->{'mode'}),
[ [ "none", $text{'user_modenone'} ],
[ "chap", "CHAP" ] ], 1, 0, 1));
# Password
print &ui_table_row($text{'user_pass'},
&ui_textbox("ipass", $user->{'pass'}, 20));
print &ui_table_end();
if ($in{'new'}) {
print &ui_form_end([ [ undef, $text{'create'} ] ]);
}
else {
print &ui_form_end([ [ undef, $text{'save'} ],
[ 'delete', $text{'delete'} ] ]);
}
&ui_print_footer("list_users.cgi", $text{'users_return'});