[SOLVED] chmod +w /var/log/messages fails for root user? Why?
Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
chmod +w /var/log/messages fails for root user? Why?
Does anybody know why the root user can add the read right for everybody to the /var/log/messages giving the commands:
$ ls -l /var/log/messages
-rw------- 1 root root 161613 Aug 8 14:12 /var/log/messages
$ chmod +r /var/log/messages
$ ls -l /var/log/messages
-rw-r--r-- 1 root root 161613 Aug 8 14:20 /var/log/messages
but with the same command can not add the write right
$ chmod +w /var/log/messages
$ ls -l /var/log/messages
-rw-r--r-- 1 root root 161613 Aug 8 14:20 /var/log/messages
Thank-you
-----------------
I've solved the problem with a 2 step procedure:
1) editing the /etc/syslog-ng/syslog-ng.conf file and adding into the option {….} block the line perm(0666);
2) rebooting the computer
Last edited by PaxToYou; 10-17-2016 at 04:51 PM.
Reason: SOLUTION FOUND
A combination of the letters ugoa controls which users' access to the file will be changed: the user who owns it (u), other users in the file's group (g), other users not in the file's group (o), or all users (a). If none of these are given, the effect is as if (a) were given, but bits that are set in the umask are not affected.
The (default) umask for file creation is 0022, meaning that the write bit (w) is set for group and others so chmod will ignore it according to the above.
If you are sure you want to change the file, use either one of the following:
I don't believe it is AT ALL WISE to allow ordinary users write permissions on a system log file. It can then be altered at will, possibly maliciously, and even benign changes to it by a user might totally break new valid system entries.
That said, logrotate will likely change its permissions back to the default each time it runs.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.