File: restorecond.init

package info (click to toggle)
android-platform-external-libselinux 8.1.0%2Br23-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 33,252 kB
  • sloc: ansic: 142,533; python: 23,929; makefile: 1,760; yacc: 1,367; sh: 1,108; lex: 448; xml: 176
file content (89 lines) | stat: -rw-r--r-- 1,815 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/sh
#
# restorecond:		Daemon used to maintain path file context
#
# chkconfig:	- 12 87
# description:	restorecond uses inotify to look for creation of new files \
# listed in the /etc/selinux/restorecond.conf file, and restores the \
# correct security context.
#
# processname: /usr/sbin/restorecond
# config: /etc/selinux/restorecond.conf 
# pidfile: /var/run/restorecond.pid
#
# Return values according to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running

PATH=/sbin:/bin:/usr/bin:/usr/sbin

# Source function library.
. /etc/rc.d/init.d/functions

[ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled || exit 7

# Check that we are root ... so non-root users stop here
test $EUID = 0  || exit 4

test -x /usr/sbin/restorecond  || exit 5
test -f /etc/selinux/restorecond.conf  || exit 6

RETVAL=0

start() 
{
        echo -n $"Starting restorecond: "
	unset HOME MAIL USER USERNAME
        daemon /usr/sbin/restorecond 
	RETVAL=$?
	touch /var/lock/subsys/restorecond
        echo
	return $RETVAL
}

stop() 
{
        echo -n $"Shutting down restorecond: "
	killproc restorecond
	RETVAL=$?
	rm -f  /var/lock/subsys/restorecond
        echo
	return $RETVAL
}

restart() 
{
    stop
    start
}

# See how we were called.
case "$1" in
  start)
	start
        ;;
  stop)
	stop
        ;;
  status)
	status restorecond
	RETVAL=$?
	;;
  force-reload|restart|reload)
	restart
	;;
  condrestart)
	[ -e /var/lock/subsys/restorecond ] && restart || :
	;;
  *)
        echo $"Usage: $0 {start|stop|restart|force-reload|status|condrestart}"
        RETVAL=3
esac

exit $RETVAL