diff options
author | Xin Ouyang <Xin.Ouyang@windriver.com> | 2012-09-11 15:41:55 +0800 |
---|---|---|
committer | Xin Ouyang <Xin.Ouyang@windriver.com> | 2012-10-18 11:07:44 +0800 |
commit | 4c59f03c8311540fc84b6a543fa93633a183fb62 (patch) | |
tree | 0dcdb614c42c0f62a852c0b1f682fecd77e2bb5e | |
parent | 0674df16fbee26d269af0552eb11a5110f43b40f (diff) | |
download | meta-selinux-4c59f03c8311540fc84b6a543fa93633a183fb62.tar.gz |
sysklogd: initscripts restorecon for log devices
sysklogd would create /dev/log and create log files in /var/log
with the default security contexts while starting.
So we should restore the correct security contexts.
The initscript file is from oe-core, and add these lines after
the start action.
test ! -x /sbin/restorecon || \
/sbin/restorecon -R /dev/log /var/log/
Signed-off-by: Xin Ouyang <Xin.Ouyang@windriver.com>
-rwxr-xr-x | recipes-extended/sysklogd/files/sysklogd | 141 | ||||
-rw-r--r-- | recipes-extended/sysklogd/sysklogd_1.5.bbappend | 3 |
2 files changed, 144 insertions, 0 deletions
diff --git a/recipes-extended/sysklogd/files/sysklogd b/recipes-extended/sysklogd/files/sysklogd new file mode 100755 index 0000000..18a6154 --- /dev/null +++ b/recipes-extended/sysklogd/files/sysklogd | |||
@@ -0,0 +1,141 @@ | |||
1 | #! /bin/sh | ||
2 | # /etc/init.d/sysklogd: start the system log daemon. | ||
3 | |||
4 | ### BEGIN INIT INFO | ||
5 | # Provides: sysklogd | ||
6 | # Required-Start: $remote_fs $time | ||
7 | # Required-Stop: $remote_fs $time | ||
8 | # Should-Start: $network | ||
9 | # Should-Stop: $network | ||
10 | # Default-Start: 2 3 4 5 | ||
11 | # Default-Stop: 0 1 6 | ||
12 | # Short-Description: System logger | ||
13 | ### END INIT INFO | ||
14 | |||
15 | PATH=/bin:/usr/bin:/sbin:/usr/sbin | ||
16 | |||
17 | pidfile_syslogd=/var/run/syslogd.pid | ||
18 | pidfile_klogd=/var/run/klogd.pid | ||
19 | binpath_syslogd=/sbin/syslogd | ||
20 | binpath_klogd=/sbin/klogd | ||
21 | |||
22 | test -x $binpath || exit 0 | ||
23 | |||
24 | test ! -r /etc/default/syslogd || . /etc/default/syslogd | ||
25 | |||
26 | create_xconsole() | ||
27 | { | ||
28 | # Only proceed if /dev/xconsole is used at all | ||
29 | if ! grep -q '^[^#].*/dev/xconsole' /etc/syslog.conf | ||
30 | then | ||
31 | return | ||
32 | fi | ||
33 | |||
34 | if [ ! -e /dev/xconsole ]; then | ||
35 | mknod -m 640 /dev/xconsole p | ||
36 | else | ||
37 | chmod 0640 /dev/xconsole | ||
38 | fi | ||
39 | chown root:adm /dev/xconsole | ||
40 | test ! -x /sbin/restorecon || /sbin/restorecon /dev/xconsole | ||
41 | } | ||
42 | |||
43 | log_begin_msg () { | ||
44 | echo -n $1 | ||
45 | } | ||
46 | |||
47 | log_end_msg () { | ||
48 | echo $1 | ||
49 | } | ||
50 | |||
51 | log_success_msg () { | ||
52 | echo $1 | ||
53 | } | ||
54 | |||
55 | running() | ||
56 | { | ||
57 | # No pidfile, probably no daemon present | ||
58 | # | ||
59 | if [ ! -f $pidfile ] | ||
60 | then | ||
61 | return 1 | ||
62 | fi | ||
63 | |||
64 | pid=`cat $pidfile_syslogd` | ||
65 | |||
66 | # No pid, probably no daemon present | ||
67 | # | ||
68 | if [ -z "$pid" ] | ||
69 | then | ||
70 | return 1 | ||
71 | fi | ||
72 | |||
73 | if [ ! -d /proc/$pid ] | ||
74 | then | ||
75 | return 1 | ||
76 | fi | ||
77 | |||
78 | cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1` | ||
79 | |||
80 | # No syslogd? | ||
81 | # | ||
82 | if [ "$cmd" != "$binpath" ] | ||
83 | then | ||
84 | return 1 | ||
85 | fi | ||
86 | |||
87 | return 0 | ||
88 | } | ||
89 | |||
90 | case "$1" in | ||
91 | start) | ||
92 | log_begin_msg "Starting system log daemon..." | ||
93 | create_xconsole | ||
94 | start-stop-daemon --start --quiet --pidfile $pidfile_syslogd --name syslogd --startas $binpath_syslogd -- $SYSLOGD | ||
95 | test ! -x /sbin/restorecon || /sbin/restorecon -R /dev/log /var/log/ | ||
96 | log_end_msg $? | ||
97 | log_begin_msg "Starting kernel log daemon..." | ||
98 | start-stop-daemon --start --quiet --pidfile $pidfile_klogd --name klogd --startas $binpath_klogd -- $KLOGD | ||
99 | log_end_msg $? | ||
100 | ;; | ||
101 | stop) | ||
102 | log_begin_msg "Stopping system log daemon..." | ||
103 | start-stop-daemon --stop --quiet --pidfile $pidfile_syslogd --name syslogd | ||
104 | log_end_msg $? | ||
105 | log_begin_msg "Stopping kernel log daemon..." | ||
106 | start-stop-daemon --stop --quiet --retry 3 --exec $binpath_klogd --pidfile $pidfile_klogd | ||
107 | log_end_msg $? | ||
108 | ;; | ||
109 | reload|force-reload) | ||
110 | log_begin_msg "Reloading system log daemon..." | ||
111 | start-stop-daemon --stop --quiet --signal 1 --pidfile $pidfile_syslogd --name syslogd | ||
112 | log_end_msg $? | ||
113 | log_begin_msg "Reloading kernel log daemon..." | ||
114 | start-stop-daemon --stop --quiet --retry 3 --exec $binpath_klogd --pidfile $pidfile_klogd | ||
115 | start-stop-daemon --start --quiet --pidfile $pidfile_klogd --name klogd --startas $binpath_klogd -- $KLOGD | ||
116 | log_end_msg $? | ||
117 | ;; | ||
118 | restart) | ||
119 | log_begin_msg "Restarting system log daemon..." | ||
120 | start-stop-daemon --stop --retry 5 --quiet --pidfile $pidfile_syslogd --name syslogd | ||
121 | start-stop-daemon --start --quiet --pidfile $pidfile_syslogd --name syslogd --startas $binpath_syslogd -- $SYSLOGD | ||
122 | log_end_msg $? | ||
123 | log_begin_msg "Reloading kernel log daemon..." | ||
124 | start-stop-daemon --stop --quiet --retry 3 --exec $binpath_klogd --pidfile $pidfile_klogd | ||
125 | start-stop-daemon --start --quiet --pidfile $pidfile_klogd --name klogd --startas $binpath_klogd -- $KLOGD | ||
126 | log_end_msg $? | ||
127 | ;; | ||
128 | reload-or-restart) | ||
129 | if running | ||
130 | then | ||
131 | $0 reload | ||
132 | else | ||
133 | $0 start | ||
134 | fi | ||
135 | ;; | ||
136 | *) | ||
137 | log_success_msg "Usage: /etc/init.d/sysklogd {start|stop|reload|restart|force-reload|reload-or-restart}" | ||
138 | exit 1 | ||
139 | esac | ||
140 | |||
141 | exit 0 | ||
diff --git a/recipes-extended/sysklogd/sysklogd_1.5.bbappend b/recipes-extended/sysklogd/sysklogd_1.5.bbappend new file mode 100644 index 0000000..fd0bc32 --- /dev/null +++ b/recipes-extended/sysklogd/sysklogd_1.5.bbappend | |||
@@ -0,0 +1,3 @@ | |||
1 | PR .= ".1" | ||
2 | |||
3 | FILESEXTRAPATHS_prepend := "${THISDIR}/files:" | ||