Hi,
I am experiencing quite strange problem with Webmin > Others > Custom Commands > Custom Editor creating duplicated files instead of overriding the existing one.
I have Advanced Policy Firewall (APF) installed on my CentOS 6.4 server. To make it easier for my users I have created File Editor for /etc/apf/deny_hosts.rules with the detailes shown in the attached screenshot. So every time I edit this file, the /etc/apf directory shows duplicate 'deny_hosts.rules' file like:
root@ns1:/etc/apf#
l
total 116
-rw-r----- 1 root root 1010 Jan 24 22:02 allow_hosts.rules
-rwxr-x--- 1 root root 6364 Dec 13 15:11 apf
-rw-r----- 1 root root 19192 Dec 13 15:11 bt.rules
-rw-r----- 1 root root 23159 Dec 16 14:37 conf.apf
-rw------- 1 root root 7 May 30 00:23 deny_hosts.rules
-rw-r--r-- 1 root root 13 May 30 00:23 deny_hosts.rules
drw-r----- 2 root root 4096 Dec 13 15:11 doc
-rw------- 1 root root 0 May 30 00:23 ds_hosts.rules
-rw-r----- 1 root root 0 Dec 13 15:11 ecnshame_hosts.rules
drw-r----- 3 root root 4096 Dec 13 15:11 extras
-rwxr-x--- 1 root root 10723 Dec 13 15:11 firewall
-rw------- 1 root root 0 May 30 00:23 glob_allow.rules
-rw------- 1 root root 0 May 30 00:23 glob_deny.rules
drw-r----- 2 root root 4096 May 30 00:20 internals
-rw-r----- 1 root root 495 Dec 13 15:11 log.rules
-rw-r----- 1 root root 164 Dec 13 15:11 main.rules
-rw------- 1 root root 0 May 30 00:23 php_hosts.rules
-rw-r----- 1 root root 172 Dec 13 15:11 postroute.rules
-rw-r----- 1 root root 168 Dec 13 15:11 preroute.rules
-rw------- 1 root root 0 May 30 00:23 sdrop_hosts.rules
-rw-r----- 1 root root 3245 Dec 13 15:11 sysctl.rules
-rw-r----- 1 root root 15 Dec 13 15:11 VERSION
drw-r----- 2 root root 4096 Dec 13 15:11 vnet
root@ns1:/etc/apf#
I wonder is this a problem of Webmin creating duplicate file instead of using the existing one or APF?
Anyway, if I try to delete the file it still shows one of the files:
root@ns1:/etc/apf# rm -rf deny_hosts.rules root@ns1:/etc/apf# ls -l total 112 -rw-r----- 1 root root 1010 Jan 24 22:02 allow_hosts.rules -rwxr-x--- 1 root root 6364 Dec 13 15:11 apf -rw-r----- 1 root root 19192 Dec 13 15:11 bt.rules -rw-r----- 1 root root 23159 Dec 16 14:37 conf.apf -rw-r--r-- 1 root root 13 May 30 00:23 deny_hosts.rules drw-r----- 2 root root 4096 Dec 13 15:11 doc -rw------- 1 root root 0 May 30 00:23 ds_hosts.rules -rw-r----- 1 root root 0 Dec 13 15:11 ecnshame_hosts.rules drw-r----- 3 root root 4096 Dec 13 15:11 extras -rwxr-x--- 1 root root 10723 Dec 13 15:11 firewall -rw------- 1 root root 0 May 30 00:30 glob_allow.rules -rw------- 1 root root 0 May 30 00:30 glob_deny.rules drw-r----- 2 root root 4096 May 30 00:30 internals -rw-r----- 1 root root 495 Dec 13 15:11 log.rules -rw-r----- 1 root root 164 Dec 13 15:11 main.rules -rw------- 1 root root 0 May 30 00:23 php_hosts.rules -rw-r----- 1 root root 172 Dec 13 15:11 postroute.rules -rw-r----- 1 root root 168 Dec 13 15:11 preroute.rules -rw------- 1 root root 0 May 30 00:23 sdrop_hosts.rules -rw-r----- 1 root root 3245 Dec 13 15:11 sysctl.rules -rw-r----- 1 root root 15 Dec 13 15:11 VERSION drw-r----- 2 root root 4096 Dec 13 15:11 vnet root@ns1:/etc/apf#
If I try to remove the file again, it simply doesn't delete, it is shown still there:
root@ns1:/etc/apf#
rm -rf deny_hosts.rules
root@ns1:/etc/apf#
ls -l
total 112
-rw-r----- 1 root root 1010 Jan 24 22:02 allow_hosts.rules
-rwxr-x--- 1 root root 6364 Dec 13 15:11 apf
-rw-r----- 1 root root 19192 Dec 13 15:11 bt.rules
-rw-r----- 1 root root 23159 Dec 16 14:37 conf.apf
-rw-r--r-- 1 root root 13 May 30 00:23 deny_hosts.rules
drw-r----- 2 root root 4096 Dec 13 15:11 doc
-rw------- 1 root root 0 May 30 00:23 ds_hosts.rules
-rw-r----- 1 root root 0 Dec 13 15:11 ecnshame_hosts.rules
drw-r----- 3 root root 4096 Dec 13 15:11 extras
-rwxr-x--- 1 root root 10723 Dec 13 15:11 firewall
-rw------- 1 root root 0 May 30 00:30 glob_allow.rules
-rw------- 1 root root 0 May 30 00:30 glob_deny.rules
drw-r----- 2 root root 4096 May 30 00:30 internals
-rw-r----- 1 root root 495 Dec 13 15:11 log.rules
-rw-r----- 1 root root 164 Dec 13 15:11 main.rules
-rw------- 1 root root 0 May 30 00:23 php_hosts.rules
-rw-r----- 1 root root 172 Dec 13 15:11 postroute.rules
-rw-r----- 1 root root 168 Dec 13 15:11 preroute.rules
-rw------- 1 root root 0 May 30 00:23 sdrop_hosts.rules
-rw-r----- 1 root root 3245 Dec 13 15:11 sysctl.rules
-rw-r----- 1 root root 15 Dec 13 15:11 VERSION
drw-r----- 2 root root 4096 Dec 13 15:11 vnet
Strangely enough, 'cat' command shows there is no such file:
root@ns1:/etc/apf#
cat deny_hosts.rules
cat: deny_hosts.rules: No such file or directory
However, 'ls -l' command still shows it is there. And only if I use wildcard when deleting then the file doesn't show with 'ls -l':
rm -rf deny*
root@ns1:/etc/apf#
ls -l
total 108
-rw-r----- 1 root root 1010 Jan 24 22:02 allow_hosts.rules
-rwxr-x--- 1 root root 6364 Dec 13 15:11 apf
-rw-r----- 1 root root 19192 Dec 13 15:11 bt.rules
-rw-r----- 1 root root 23159 Dec 16 14:37 conf.apf
drw-r----- 2 root root 4096 Dec 13 15:11 doc
-rw------- 1 root root 0 May 30 00:23 ds_hosts.rules
-rw-r----- 1 root root 0 Dec 13 15:11 ecnshame_hosts.rules
drw-r----- 3 root root 4096 Dec 13 15:11 extras
-rwxr-x--- 1 root root 10723 Dec 13 15:11 firewall
-rw------- 1 root root 0 May 30 00:30 glob_allow.rules
-rw------- 1 root root 0 May 30 00:30 glob_deny.rules
drw-r----- 2 root root 4096 May 30 00:30 internals
-rw-r----- 1 root root 495 Dec 13 15:11 log.rules
-rw-r----- 1 root root 164 Dec 13 15:11 main.rules
-rw------- 1 root root 0 May 30 00:23 php_hosts.rules
-rw-r----- 1 root root 172 Dec 13 15:11 postroute.rules
-rw-r----- 1 root root 168 Dec 13 15:11 preroute.rules
-rw------- 1 root root 0 May 30 00:23 sdrop_hosts.rules
-rw-r----- 1 root root 3245 Dec 13 15:11 sysctl.rules
-rw-r----- 1 root root 15 Dec 13 15:11 VERSION
drw-r----- 2 root root 4096 Dec 13 15:11 vnet
root@ns1:/etc/apf#
I really lost any edge in understanding this issue and would appreciate any elaboration on this. Thanks!
By the way, I have similar custom file editor for 'allow_hosts.rules' in the same directory /etc/apf, editing of which never creates a duplicate file.
Howdy,
When you're creating the file editor in the Custom Command screen, is it possible that there's a space at the end of the filename?
A space in the filename is the only way I can think of that would cause the behavior you're seeing -- the filesystem wouldn't allow you to have two of the same file... but with a space at the end of the filename, they're not actually the same name.
-Eric
Eric,
You made my day! That was it, thank you very much!