forked from webmin/webmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit_group.cgi
executable file
·159 lines (134 loc) · 4.18 KB
/
edit_group.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/usr/local/bin/perl
# edit_group.cgi
# Display a form for editing or creating a group
require './ldap-useradmin-lib.pl';
&ReadParse();
$ldap = &ldap_connect();
if ($in{'new'}) {
$access{'gcreate'} || &error($text{'gedit_ecreate'});
&ui_print_header(undef, $text{'gedit_title2'}, "");
}
else {
$rv = $ldap->search(base => $in{'dn'},
scope => 'base',
filter => &group_filter());
($ginfo) = $rv->all_entries;
$group = $ginfo->get_value('cn');
$gid = $ginfo->get_value('gidNumber');
$pass = $ginfo->get_value('userPassword');
$desc = $ginfo->get_value('description');
@members = $ginfo->get_value('memberUid');
foreach $oc ($ginfo->get_value('objectClass')) {
$oclass{$oc} = 1;
}
%ginfo = &dn_to_hash($ginfo);
&can_edit_group(\%ginfo) || &error($text{'gedit_eedit'});
&ui_print_header(undef, $text{'gedit_title'}, "");
}
# Build list of all possible users
@ulist = &useradmin::list_users();
%ulistdone = map { $_->{'user'}, 1 } @ulist;
push(@ulist, grep { !$ulistdone{$_->{'user'}} } &list_users());
# Start of form
print &ui_form_start("save_group.cgi", "post");
print &ui_hidden("new", $in{'new'});
print &ui_hidden("dn", $in{'dn'});
print &ui_table_start($text{'gedit_details'}, "width=100%", 2, [ "width=30%" ]);
# Current DN and classes
if (!$in{'new'}) {
print &ui_table_row($text{'gedit_dn'},
"<tt>$in{'dn'}</tt>");
print &ui_table_row($text{'uedit_classes'},
join(" , ", map { "<tt>$_</tt>" }
$ginfo->get_value('objectClass')));
}
# Group name
print &ui_table_row($text{'gedit_group'},
&ui_textbox("group", $group, 20));
# Group ID
if ($in{'new'}) {
# Next GID comes from LDAP only
$newgid = $mconfig{'base_gid'};
while(&check_gid_used($ldap, $newgid)) {
$newgid++;
}
$gidfield = &ui_textbox("gid", $newgid, 10);
}
else {
$gidfield = &ui_textbox("gid", $gid, 10);
}
print &ui_table_row($text{'gedit_gid'},
$gidfield);
# Description
print &ui_table_row($text{'gedit_desc'},
&ui_textbox("desc", $desc, 40));
# Group password (rarely used, but..)
print &ui_table_row($text{'pass'},
&ui_radio_table("passmode", $pass eq "" ? 0 : 1,
[ [ 0, $text{'none2'} ],
[ 1, $text{'encrypted'},
&ui_textbox("encpass", $pass, 20) ],
[ 2, $text{'clear'},
&ui_textbox("pass", undef, 15) ] ]));
# Member chooser
if ($config{'membox'} == 0) {
# Nicer left/right chooser
print &ui_table_row($text{'gedit_members'},
&ui_multi_select("members",
[ map { [ $_, $_ ] } @members ],
[ map { [ $_->{'user'}, $_->{'user'} ] } @ulist ],
10, 1, 0,
$text{'gedit_allu'}, $text{'gedit_selu'}, 150));
}
else {
# Text box
print &ui_table_row($text{'gedit_members'},
&ui_textarea("members", join("\n", @members), 5, 30));
}
print &ui_table_end();
# Show extra fields (if any)
&extra_fields_input($config{'group_fields'}, $ginfo, \@tds);
# Show capabilties section
print &ui_table_start($text{'gedit_cap'}, "width=100%", 4, [ "width=30%" ]);
# Samba group?
print &ui_table_row($text{'gedit_samba'},
&ui_yesno_radio("samba", $oclass{$samba_group_class}));
print &ui_table_end();
# Show section for on-save or on-creation options
if (!$in{'new'}) {
print &ui_table_start($text{'onsave'}, "width=100%", 2,
[ "width=30%" ]);
# Change GID on save
print &ui_table_row($text{'chgid'},
&ui_radio("chgid", 0,
[ [ 0, $text{'no'} ],
[ 1, $text{'gedit_homedirs'} ],
[ 2, $text{'gedit_allfiles'} ] ]));
# Update in other modules?
print &ui_table_row($text{'gedit_mothers'},
&ui_radio("others", $mconfig{'default_other'},
[ [ 1, $text{'yes'} ],
[ 0, $text{'no'} ] ]));
print &ui_table_end();
}
else {
print &ui_table_start($text{'uedit_oncreate'}, "width=100%", 2,
[ "width=30%" ]);
# Create in other modules?
print &ui_table_row($text{'gedit_cothers'},
&ui_radio("others", $mconfig{'default_other'},
[ [ 1, $text{'yes'} ],
[ 0, $text{'no'} ] ]));
print &ui_table_end();
}
# Save/delete/create buttons
if (!$in{'new'}) {
print &ui_form_end([ [ undef, $text{'save'} ],
[ 'raw', $text{'uedit_raw'} ],
[ 'delete', $text{'delete'} ],
]);
}
else {
print &ui_form_end([ [ undef, $text{'create'} ] ]);
}
&ui_print_footer("index.cgi?mode=groups", $text{'index_greturn'});