[projects/rc-scripts] use /proc/sys/kernel/dmesg_restrict to set file mode for /var/log/dmesg

glen glen at pld-linux.org
Thu Jan 22 17:01:36 CET 2015


commit 907c31bf68d293d42e2350aa763d4f001b5f0c28
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Thu Oct 16 10:56:53 2014 +0300

    use /proc/sys/kernel/dmesg_restrict to set file mode for /var/log/dmesg

 rc.d/rc.sysinit | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/rc.d/rc.sysinit b/rc.d/rc.sysinit
index e14ad74..6da0575 100755
--- a/rc.d/rc.sysinit
+++ b/rc.d/rc.sysinit
@@ -1062,17 +1062,20 @@ if ! is_yes "$VSERVER"; then
 
 	# Now that we have all of our basic modules loaded and the kernel going,
 	# let's dump the syslog ring somewhere so we can find it later
+	mode=0600
+	if [ "$(cat /proc/sys/kernel/dmesg_restrict)" = 0 ]; then
+		mode=0644
+	fi
 	dmesg --raw > /var/log/dmesg
+	chmod $mode /var/log/dmesg
 	i=5
 	while [ $i -ge 0 ]; do
 		if [ -f /var/log/dmesg.$i ]; then
-			chmod 0600 /var/log/dmesg.$i
 			mv -f /var/log/dmesg.$i /var/log/dmesg.$(($i+1))
 		fi
 		i=$(($i-1))
 	done
-	cp -f /var/log/dmesg /var/log/dmesg.0
-	chmod 0600 /var/log/dmesg /var/log/dmesg.0
+	cp -pf /var/log/dmesg /var/log/dmesg.0
 else
 	emit --no-wait all-swaps
 fi
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/rc-scripts.git/commitdiff/907c31bf68d293d42e2350aa763d4f001b5f0c28



More information about the pld-cvs-commit mailing list