Compare commits
111 Commits
vapier
...
cgroup-nam
| Author | SHA1 | Date | |
|---|---|---|---|
| db5559bb50 | |||
|
|
3d30b6fdda | ||
|
|
4574b5d8e4 | ||
|
|
6b42019697 | ||
|
|
42408e7488 | ||
|
|
957140cb78 | ||
|
|
536794dfad | ||
|
|
7ac2080e31 | ||
|
|
12e1e88475 | ||
|
|
c45fe9fba5 | ||
|
|
961c479e1d | ||
|
|
f9c92d7822 | ||
|
|
97689d6c44 | ||
|
|
439cce426d | ||
|
|
bfdafe4463 | ||
|
|
179ff285ca | ||
|
|
f9bbbfbf4b | ||
|
|
59a175541d | ||
|
|
65b13eb86f | ||
|
|
fda9dcd1f2 | ||
|
|
6f180e9424 | ||
|
|
88e5d98d05 | ||
|
|
1433552435 | ||
|
|
554ccab718 | ||
|
|
228b3c6c99 | ||
|
|
965de92b37 | ||
|
|
b85d771e1f | ||
|
|
cf9286d2d8 | ||
|
|
9934e9f96e | ||
|
|
f1e5510ccf | ||
|
|
1b72c3a7ab | ||
|
|
c4785f1b99 | ||
|
|
e447562aaa | ||
|
|
c199c5cf6e | ||
|
|
5bfb592d75 | ||
|
|
b2c4eb97b5 | ||
|
|
e740913fcb | ||
|
|
1bc34a39cd | ||
|
|
c1cd3c9830 | ||
|
|
86efc43d0e | ||
|
|
cd53239701 | ||
|
|
92662ddc44 | ||
|
|
1b6a35488d | ||
|
|
1eccb7f5e6 | ||
|
|
fe37fc9322 | ||
|
|
edf5f830e3 | ||
|
|
863e1a5c87 | ||
|
|
0b9c3c0803 | ||
|
|
a3c721b682 | ||
|
|
3f82d5b1a3 | ||
|
|
0b4732520f | ||
|
|
bbd3acfc67 | ||
|
|
910e3e2a0e | ||
|
|
5f04dcc951 | ||
|
|
8f52c64c37 | ||
|
|
09d405fb3e | ||
|
|
36e4e04ba9 | ||
|
|
eb8831a141 | ||
|
|
0b5cb3abcb | ||
|
|
f6ed2c660c | ||
|
|
002bcf0b67 | ||
|
|
b9241988a7 | ||
|
|
5ae4d4edb5 | ||
|
|
95b2948e6e | ||
|
|
b73d326387 | ||
|
|
476272be0c | ||
|
|
63a5ee3d8c | ||
|
|
36cc40a9d6 | ||
|
|
ae5e38dce5 | ||
|
|
5858f980c8 | ||
|
|
db96295e00 | ||
|
|
f5ed484920 | ||
|
|
00f90f2b0e | ||
|
|
b405681926 | ||
|
|
d5700d036a | ||
|
|
616f756ca8 | ||
|
|
17cfb41d81 | ||
|
|
1bc87b7a7c | ||
|
|
f3be11a00d | ||
|
|
406ab2a4ca | ||
|
|
7878a53542 | ||
|
|
084e6b5e20 | ||
|
|
a7bd13145b | ||
|
|
28ecb38515 | ||
|
|
91737be1ab | ||
|
|
fb6ffc5713 | ||
|
|
01acbe3c27 | ||
|
|
aa5c3ccd0b | ||
|
|
d795ea183f | ||
|
|
5af3944440 | ||
|
|
01bcdb43b6 | ||
|
|
bcd1975fe7 | ||
|
|
57e194df4f | ||
|
|
dacd0ab189 | ||
|
|
7cfe93d032 | ||
|
|
893df75e30 | ||
|
|
c80d6bb2ed | ||
|
|
bfe38c98a8 | ||
|
|
e8a76ad6e6 | ||
|
|
7d63049adb | ||
|
|
dc0b3157a9 | ||
|
|
2f6b5b7ef4 | ||
|
|
eb3635dd1f | ||
|
|
459783bbad | ||
|
|
a28bdc7e5c | ||
|
|
bcae7d03b4 | ||
|
|
ccc2b71145 | ||
|
|
78c0693c50 | ||
|
|
ddf4a3a7a0 | ||
|
|
a6568c304f | ||
|
|
d6a5264a9d |
@@ -4,8 +4,8 @@
|
|||||||
test_task:
|
test_task:
|
||||||
freebsd_instance:
|
freebsd_instance:
|
||||||
matrix:
|
matrix:
|
||||||
image: freebsd-13-1-release-amd64
|
image: freebsd-13-2-release-amd64
|
||||||
image: freebsd-12-4-release-amd64
|
image: freebsd-13-3-release-amd64
|
||||||
env:
|
env:
|
||||||
OS: FreeBSD
|
OS: FreeBSD
|
||||||
procfs_script: >
|
procfs_script: >
|
||||||
|
|||||||
57
NEWS.md
57
NEWS.md
@@ -4,6 +4,63 @@ OpenRC NEWS
|
|||||||
This file will contain a list of notable changes for each release. Note
|
This file will contain a list of notable changes for each release. Note
|
||||||
the information in this file is in reverse order.
|
the information in this file is in reverse order.
|
||||||
|
|
||||||
|
## OpenRC 0.54
|
||||||
|
|
||||||
|
This release drops the support for the split-usr build option.
|
||||||
|
Also, it drops the support for ncurses/termcap and uses ansi codes
|
||||||
|
directly for color support on terminals that support them.
|
||||||
|
|
||||||
|
## OpenRC 0.53
|
||||||
|
|
||||||
|
The names of cgroups for services started by OpenRC are now prefixed by
|
||||||
|
"openrc." This is done because some services, like docker, create their
|
||||||
|
own cgroups.
|
||||||
|
|
||||||
|
It is now possible to override the mount options used to mount the
|
||||||
|
cgroups filesystems.
|
||||||
|
## OpenRC 0.52
|
||||||
|
|
||||||
|
This release drops the "runscript" and "rc" binaries.
|
||||||
|
These binaries have been deprecated for multiple years, so it should be
|
||||||
|
fine to remove them at this point.
|
||||||
|
|
||||||
|
There was an issue before this release with the default setting for
|
||||||
|
cgroups being inconsistent. This is fixed.
|
||||||
|
|
||||||
|
Start-stop-daemon did not work correctly on Linux 6.6 systems.
|
||||||
|
This has been fixed in this release as well.
|
||||||
|
|
||||||
|
## OpenRC 0.51
|
||||||
|
|
||||||
|
The default RC_CGROUP_MODE has been updated to unified.
|
||||||
|
This benefits users since it will assign each service to its own cgroup,
|
||||||
|
making resource nanagement better over all.
|
||||||
|
|
||||||
|
OUTPUT_LOGGER and ERROR_LOGGER have been implemented for
|
||||||
|
supervise-daemon. For mor einformation on these settings, please check
|
||||||
|
the man page.
|
||||||
|
|
||||||
|
## OpenRC 0.50
|
||||||
|
|
||||||
|
This is a bug fix release which fixes a significant performance issue on
|
||||||
|
musl libc systems.
|
||||||
|
|
||||||
|
## OpenRC 0.49
|
||||||
|
|
||||||
|
This release adds support for glibc's builtin
|
||||||
|
strlcpy, strlcat etc functions, which will be in posix next.
|
||||||
|
Also, it fixes completions.
|
||||||
|
|
||||||
|
|
||||||
|
## OpenRC 0.48
|
||||||
|
|
||||||
|
This release is a maintenance release; it has no user-facing changes.
|
||||||
|
|
||||||
|
## OpenRC 0.47
|
||||||
|
|
||||||
|
This release is primarily an internal cleanup release.
|
||||||
|
The only user-visible difference is that unicode is now on by default.
|
||||||
|
|
||||||
## OpenRC 0.46
|
## OpenRC 0.46
|
||||||
|
|
||||||
The path for the reference file for the swclock service is now
|
The path for the reference file for the swclock service is now
|
||||||
|
|||||||
@@ -85,29 +85,26 @@ _rc_service()
|
|||||||
else
|
else
|
||||||
# no option was typed
|
# no option was typed
|
||||||
if [[ ${COMP_CWORD} -eq 1 ]]; then # if first word typed
|
if [[ ${COMP_CWORD} -eq 1 ]]; then # if first word typed
|
||||||
words="$(rc-service --list | grep ^${cur})" # complete for init scripts
|
# complete for init scripts
|
||||||
COMPREPLY=($(for i in ${words} ; do \
|
COMPREPLY=($(for i in $(rc-service --list) ; do \
|
||||||
[[ ${i} == ${cur}* ]] && echo ${i} ; \
|
[[ ${i} == "${cur}"* ]] && echo ${i} ; \
|
||||||
done))
|
done))
|
||||||
return 0
|
return 0
|
||||||
elif [[ ${COMP_CWORD} -eq 2 ]] && [[ ${prev} != -* ]]; then # if second word typed and we didn't type in a function
|
elif [[ ${COMP_CWORD} -eq 2 ]] && [[ ${prev} != -* ]]; then # if second word typed and we didn't type in a function
|
||||||
rc-service --exists "$prev" || return
|
rc-service --exists "$prev" || return
|
||||||
shopt -s extglob
|
|
||||||
while read -r _ line; do
|
while read -r _ line; do
|
||||||
if [[ $line == +([[:alnum:]_]):* ]]; then
|
if [[ $line == +([[:alnum:]_]):* ]]; then
|
||||||
opts+="${line%%:*} "
|
opts+="${line%%:*} "
|
||||||
fi
|
fi
|
||||||
done < <(rc-service "$prev" describe 2>&1)
|
done < <(rc-service "$prev" describe 2>&1)
|
||||||
shopt -u extglob
|
|
||||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [[ ${action} == '--exists' ]] || [[ ${action} == '-e' ]] || \
|
if [[ ${action} == '--exists' ]] || [[ ${action} == '-e' ]] || \
|
||||||
[[ ${action} == '--resolve' ]] || [[ ${action} == '-r' ]]; then
|
[[ ${action} == '--resolve' ]] || [[ ${action} == '-r' ]]; then
|
||||||
words="$(rc-service --list | grep ^${cur})"
|
COMPREPLY=($(for i in $(rc-service --list) ; do \
|
||||||
COMPREPLY=($(for i in ${words} ; do \
|
[[ ${i} == "${cur}"* ]] && echo ${i} ; \
|
||||||
[[ ${i} == ${cur}* ]] && echo ${i} ; \
|
|
||||||
done))
|
done))
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|||||||
2
conf.d/cgroups
Normal file
2
conf.d/cgroups
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# override cgroup mount options
|
||||||
|
#cgroup_opts=nodev,noexec,nosuid
|
||||||
16
etc/rc.conf
16
etc/rc.conf
@@ -88,8 +88,8 @@
|
|||||||
# MISC CONFIGURATION VARIABLES
|
# MISC CONFIGURATION VARIABLES
|
||||||
# There variables are shared between many init scripts
|
# There variables are shared between many init scripts
|
||||||
|
|
||||||
# Set unicode to YES to turn on unicode support for keyboards and screens.
|
# Set unicode to NO to turn off unicode support for keyboards and screens.
|
||||||
#unicode="NO"
|
#unicode="YES"
|
||||||
|
|
||||||
# This is how long fuser should wait for a remote server to respond. The
|
# This is how long fuser should wait for a remote server to respond. The
|
||||||
# default is 60 seconds, but it can be adjusted here.
|
# default is 60 seconds, but it can be adjusted here.
|
||||||
@@ -116,12 +116,13 @@
|
|||||||
|
|
||||||
# Some daemons are started and stopped via start-stop-daemon.
|
# Some daemons are started and stopped via start-stop-daemon.
|
||||||
# We can set some things on a per service basis, like the nicelevel.
|
# We can set some things on a per service basis, like the nicelevel.
|
||||||
#SSD_NICELEVEL="0"
|
# These need to be exported
|
||||||
|
#export SSD_NICELEVEL="0"
|
||||||
# Or the ionice level. The format is class[:data] , just like the
|
# Or the ionice level. The format is class[:data] , just like the
|
||||||
# --ionice start-stop-daemon parameter.
|
# --ionice start-stop-daemon parameter.
|
||||||
#SSD_IONICELEVEL="0:0"
|
#export SSD_IONICELEVEL="0:0"
|
||||||
# Or the OOM score adjustment.
|
# Or the OOM score adjustment.
|
||||||
#SSD_OOM_SCORE_ADJ="0"
|
#export SSD_OOM_SCORE_ADJ="0"
|
||||||
|
|
||||||
# Pass ulimit parameters
|
# Pass ulimit parameters
|
||||||
# If you are using bash in POSIX mode for your shell, note that the
|
# If you are using bash in POSIX mode for your shell, note that the
|
||||||
@@ -198,7 +199,10 @@ rc_tty_number=12
|
|||||||
# cgroups version 1 on /sys/fs/cgroup.
|
# cgroups version 1 on /sys/fs/cgroup.
|
||||||
# "legacy" mounts cgroups version 1 on /sys/fs/cgroup
|
# "legacy" mounts cgroups version 1 on /sys/fs/cgroup
|
||||||
# "unified" mounts cgroups version 2 on /sys/fs/cgroup
|
# "unified" mounts cgroups version 2 on /sys/fs/cgroup
|
||||||
#rc_cgroup_mode="hybrid"
|
#rc_cgroup_mode="unified"
|
||||||
|
|
||||||
|
# override cgroup controller name
|
||||||
|
#rc_cgroup_name=openrc
|
||||||
|
|
||||||
# This is a list of controllers which should be enabled for cgroups version 2
|
# This is a list of controllers which should be enabled for cgroups version 2
|
||||||
# when hybrid mode is being used.
|
# when hybrid mode is being used.
|
||||||
|
|||||||
@@ -11,7 +11,9 @@
|
|||||||
|
|
||||||
description="Mount the control groups."
|
description="Mount the control groups."
|
||||||
|
|
||||||
cgroup_opts=nodev,noexec,nosuid
|
: "${cgroup_opts:="nodev,noexec,nosuid"}"
|
||||||
|
|
||||||
|
rc_cgroup_name=${rc_cgroup_name:-openrc}
|
||||||
|
|
||||||
depend()
|
depend()
|
||||||
{
|
{
|
||||||
@@ -29,13 +31,13 @@ cgroup1_base()
|
|||||||
eend $?
|
eend $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! mountinfo -q /sys/fs/cgroup/openrc; then
|
if ! mountinfo -q /sys/fs/cgroup/"${rc_cgroup_name}"; then
|
||||||
local agent="${RC_LIBEXECDIR}/sh/cgroup-release-agent.sh"
|
local agent="${RC_LIBEXECDIR}/sh/cgroup-release-agent.sh"
|
||||||
mkdir /sys/fs/cgroup/openrc
|
mkdir /sys/fs/cgroup/"${rc_cgroup_name}"
|
||||||
mount -n -t cgroup \
|
mount -n -t cgroup \
|
||||||
-o none,${cgroup_opts},name=openrc,release_agent="$agent" \
|
-o none,${cgroup_opts},name="${rc_cgroup_name}",release_agent="$agent" \
|
||||||
openrc /sys/fs/cgroup/openrc
|
"${rc_cgroup_name}" /sys/fs/cgroup/"${rc_cgroup_name}"
|
||||||
printf 1 > /sys/fs/cgroup/openrc/notify_on_release
|
printf 1 > /sys/fs/cgroup/"${rc_cgroup_name}"/notify_on_release
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@@ -74,6 +76,7 @@ cgroup2_base()
|
|||||||
mkdir -p "${base}"
|
mkdir -p "${base}"
|
||||||
mount -t cgroup2 none -o "${cgroup_opts},nsdelegate" "${base}" 2> /dev/null ||
|
mount -t cgroup2 none -o "${cgroup_opts},nsdelegate" "${base}" 2> /dev/null ||
|
||||||
mount -t cgroup2 none -o "${cgroup_opts}" "${base}"
|
mount -t cgroup2 none -o "${cgroup_opts}" "${base}"
|
||||||
|
mkdir -p ${base}/"${rc_cgroup_name}"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,13 +84,13 @@ cgroup2_controllers()
|
|||||||
{
|
{
|
||||||
grep -qw cgroup2 /proc/filesystems || return 0
|
grep -qw cgroup2 /proc/filesystems || return 0
|
||||||
local active cgroup_path x y
|
local active cgroup_path x y
|
||||||
cgroup_path="$(cgroup2_find_path)"
|
cgroup_path="$(cgroup2_find_path)/${rc_cgroup_name}"
|
||||||
[ -z "${cgroup_path}" ] && return 0
|
[ -z "${cgroup_path}" ] && return 0
|
||||||
[ ! -e "${cgroup_path}/cgroup.controllers" ] && return 0
|
[ ! -e "${cgroup_path}/cgroup.controllers" ] && return 0
|
||||||
[ ! -e "${cgroup_path}/cgroup.subtree_control" ]&& return 0
|
[ ! -e "${cgroup_path}/cgroup.subtree_control" ]&& return 0
|
||||||
read -r active < "${cgroup_path}/cgroup.controllers"
|
read -r active < "${cgroup_path}/cgroup.controllers"
|
||||||
for x in ${active}; do
|
for x in ${active}; do
|
||||||
case "$rc_cgroup_mode" in
|
case "${rc_cgroup_mode:-unified}" in
|
||||||
unified)
|
unified)
|
||||||
echo "+${x}" > "${cgroup_path}/cgroup.subtree_control"
|
echo "+${x}" > "${cgroup_path}/cgroup.subtree_control"
|
||||||
;;
|
;;
|
||||||
@@ -128,7 +131,7 @@ cgroups_unified()
|
|||||||
|
|
||||||
mount_cgroups()
|
mount_cgroups()
|
||||||
{
|
{
|
||||||
case "${rc_cgroup_mode:-hybrid}" in
|
case "${rc_cgroup_mode:-unified}" in
|
||||||
hybrid) cgroups_hybrid ;;
|
hybrid) cgroups_hybrid ;;
|
||||||
legacy) cgroups_legacy ;;
|
legacy) cgroups_legacy ;;
|
||||||
unified) cgroups_unified ;;
|
unified) cgroups_unified ;;
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ start()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
local wkeys= kmode="-a" msg="ASCII"
|
local wkeys= kmode="-a" msg="ASCII"
|
||||||
if yesno $unicode; then
|
if yesno ${unicode:-yes}; then
|
||||||
kmode="-u"
|
kmode="-u"
|
||||||
msg="UTF-8"
|
msg="UTF-8"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ start()
|
|||||||
# Save the encoding for use immediately at boot
|
# Save the encoding for use immediately at boot
|
||||||
if checkpath -W "$RC_LIBEXECDIR"; then
|
if checkpath -W "$RC_LIBEXECDIR"; then
|
||||||
mkdir -p "$RC_LIBEXECDIR"/console
|
mkdir -p "$RC_LIBEXECDIR"/console
|
||||||
if yesno ${unicode:-${UNICODE}}; then
|
if yesno ${unicode:-yes}; then
|
||||||
echo "" > "$RC_LIBEXECDIR"/console/unicode
|
echo "" > "$RC_LIBEXECDIR"/console/unicode
|
||||||
else
|
else
|
||||||
rm -f "$RC_LIBEXECDIR"/console/unicode
|
rm -f "$RC_LIBEXECDIR"/console/unicode
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ start()
|
|||||||
# Set terminal encoding to either ASCII or UNICODE.
|
# Set terminal encoding to either ASCII or UNICODE.
|
||||||
# See utf-8(7) for more information.
|
# See utf-8(7) for more information.
|
||||||
local termencoding="%@" termmsg="ASCII"
|
local termencoding="%@" termmsg="ASCII"
|
||||||
if yesno ${unicode}; then
|
if yesno ${unicode:-yes}; then
|
||||||
termencoding="%G"
|
termencoding="%G"
|
||||||
termmsg="UTF-8"
|
termmsg="UTF-8"
|
||||||
fi
|
fi
|
||||||
@@ -43,7 +43,7 @@ start()
|
|||||||
# Save the encoding for use immediately at boot
|
# Save the encoding for use immediately at boot
|
||||||
if checkpath -W "$RC_LIBEXECDIR"; then
|
if checkpath -W "$RC_LIBEXECDIR"; then
|
||||||
mkdir -p "$RC_LIBEXECDIR"/console
|
mkdir -p "$RC_LIBEXECDIR"/console
|
||||||
if yesno ${unicode:-${UNICODE}}; then
|
if yesno ${unicode:-yes}; then
|
||||||
echo "" > "$RC_LIBEXECDIR"/console/unicode
|
echo "" > "$RC_LIBEXECDIR"/console/unicode
|
||||||
else
|
else
|
||||||
rm -f "$RC_LIBEXECDIR"/console/unicode
|
rm -f "$RC_LIBEXECDIR"/console/unicode
|
||||||
|
|||||||
@@ -158,13 +158,6 @@ is true.
|
|||||||
prefixes the string
|
prefixes the string
|
||||||
.Fa prefix
|
.Fa prefix
|
||||||
to the above functions.
|
to the above functions.
|
||||||
.Sh IMPLEMENTATION NOTES
|
|
||||||
einfo can optionally be linked against the
|
|
||||||
.Lb libtermcap
|
|
||||||
so that we can correctly query the connected console for our color and
|
|
||||||
cursor escape codes.
|
|
||||||
If not, then we have a hard coded list of terminals we know about that support
|
|
||||||
the commonly used codes for color and cursor position.
|
|
||||||
.Sh ENVIRONMENT
|
.Sh ENVIRONMENT
|
||||||
.Va EINFO_QUIET
|
.Va EINFO_QUIET
|
||||||
when set to true makes the
|
when set to true makes the
|
||||||
|
|||||||
@@ -84,6 +84,8 @@ Print the action(s) that would be taken, but don't actually do anything.
|
|||||||
The return value is set as if the command was taken and worked.
|
The return value is set as if the command was taken and worked.
|
||||||
.It Fl v , -verbose
|
.It Fl v , -verbose
|
||||||
Print the action(s) that are taken just before doing them.
|
Print the action(s) that are taken just before doing them.
|
||||||
|
.It Fl q , -quiet
|
||||||
|
Run quietly (repeat to suppress errors).
|
||||||
.It Fl P , -progress
|
.It Fl P , -progress
|
||||||
Echo a . to the console for each second elapsed whilst waiting.
|
Echo a . to the console for each second elapsed whilst waiting.
|
||||||
.El
|
.El
|
||||||
@@ -183,10 +185,6 @@ Wait
|
|||||||
after starting and check that daemon is still running.
|
after starting and check that daemon is still running.
|
||||||
Useful for daemons that check configuration after forking or stopping race
|
Useful for daemons that check configuration after forking or stopping race
|
||||||
conditions where the pidfile is written out after forking.
|
conditions where the pidfile is written out after forking.
|
||||||
.It Fl 2 , -stderr Ar logfile
|
|
||||||
The same thing as
|
|
||||||
.Fl 1 , -stdout
|
|
||||||
but with the standard error output.
|
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
These options are only used for stopping daemons:
|
These options are only used for stopping daemons:
|
||||||
|
|||||||
@@ -158,6 +158,23 @@ The logfile can also be a named pipe.
|
|||||||
The same thing as
|
The same thing as
|
||||||
.Fl 1 , -stdout
|
.Fl 1 , -stdout
|
||||||
but with the standard error output.
|
but with the standard error output.
|
||||||
|
.It Fl -stdout-logger Ar cmd
|
||||||
|
Run cmd as a child process redirecting the standard output to the
|
||||||
|
standard input of cmd when started with
|
||||||
|
.Fl background .
|
||||||
|
Cmd must be an absolute pathname, but relative to the path optionally given with
|
||||||
|
.Fl r , -chroot .
|
||||||
|
This process must be prepared to accept input on stdin and be able to
|
||||||
|
log it or send it to another location.
|
||||||
|
.It Fl -stderr-logger Ar cmd
|
||||||
|
Run cmd as a child process and
|
||||||
|
Redirect the standard error of the process to the standard input of cmd
|
||||||
|
when started with
|
||||||
|
.Fl background .
|
||||||
|
Cmd must be an absolute pathname, but relative to the path optionally given with
|
||||||
|
.Fl r , -chroot .
|
||||||
|
This process must be prepared to accept input on stdin and be able to
|
||||||
|
log it or send it to another location.
|
||||||
.It Fl -capabilities Ar cap-list
|
.It Fl -capabilities Ar cap-list
|
||||||
Start the daemon with the listed inheritable, ambient and bounding capabilities.
|
Start the daemon with the listed inheritable, ambient and bounding capabilities.
|
||||||
The format is the same as in cap_iab(3).
|
The format is the same as in cap_iab(3).
|
||||||
|
|||||||
35
meson.build
35
meson.build
@@ -1,5 +1,5 @@
|
|||||||
project('OpenRC', 'c',
|
project('OpenRC', 'c',
|
||||||
version : '0.46',
|
version : '0.54',
|
||||||
license: 'BSD-2',
|
license: 'BSD-2',
|
||||||
default_options : [
|
default_options : [
|
||||||
'c_std=c99',
|
'c_std=c99',
|
||||||
@@ -83,16 +83,9 @@ else
|
|||||||
pkg_prefix = option_pkg_prefix
|
pkg_prefix = option_pkg_prefix
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if get_option('split-usr') == 'auto'
|
|
||||||
split_usr = run_command('test', '-L', '/bin', check: false).returncode() != 0
|
|
||||||
else
|
|
||||||
split_usr = get_option('split-usr') == 'true'
|
|
||||||
endif
|
|
||||||
|
|
||||||
rootprefix = get_option('rootprefix')
|
rootprefix = get_option('rootprefix')
|
||||||
rootprefix_default = fs.is_symlink('/bin') ? '/usr' : '/'
|
|
||||||
if rootprefix == ''
|
if rootprefix == ''
|
||||||
rootprefix = rootprefix_default
|
rootprefix = '/'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
bindir = rootprefix / get_option('bindir')
|
bindir = rootprefix / get_option('bindir')
|
||||||
@@ -133,15 +126,6 @@ else
|
|||||||
cc_selinux_flags = []
|
cc_selinux_flags = []
|
||||||
endif
|
endif
|
||||||
|
|
||||||
termcap = get_option('termcap')
|
|
||||||
if termcap != ''
|
|
||||||
termcap_dep = dependency(termcap)
|
|
||||||
termcap_flags = '-DHAVE_TERMCAP'
|
|
||||||
else
|
|
||||||
termcap_dep = []
|
|
||||||
termcap_flags = []
|
|
||||||
endif
|
|
||||||
|
|
||||||
if get_option('buildtype').startswith('debug')
|
if get_option('buildtype').startswith('debug')
|
||||||
cc_debug_flags = ['-DRC_DEBUG']
|
cc_debug_flags = ['-DRC_DEBUG']
|
||||||
else
|
else
|
||||||
@@ -176,7 +160,10 @@ cc_warning_flags_test = [
|
|||||||
'-Wsequence-point',
|
'-Wsequence-point',
|
||||||
'-Wshadow',
|
'-Wshadow',
|
||||||
'-Wwrite-strings',
|
'-Wwrite-strings',
|
||||||
|
'-Werror=implicit-int',
|
||||||
'-Werror=implicit-function-declaration',
|
'-Werror=implicit-function-declaration',
|
||||||
|
'-Werror=int-conversion',
|
||||||
|
'-Werror=incompatible-function-pointer-types',
|
||||||
]
|
]
|
||||||
cc_warning_flags = cc.get_supported_arguments(cc_warning_flags_test)
|
cc_warning_flags = cc.get_supported_arguments(cc_warning_flags_test)
|
||||||
cc_flags = [cc_debug_flags, cc_os_flags, cc_warning_flags]
|
cc_flags = [cc_debug_flags, cc_os_flags, cc_warning_flags]
|
||||||
@@ -192,12 +179,14 @@ if cc.compiles(malloc_attribute_test, name : 'malloc attribute with arguments')
|
|||||||
add_project_arguments('-DHAVE_MALLOC_EXTENDED_ATTRIBUTE', language: 'c')
|
add_project_arguments('-DHAVE_MALLOC_EXTENDED_ATTRIBUTE', language: 'c')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if cc.has_function('closefrom', prefix: '#define _GNU_SOURCE\n#include <unistd.h>')
|
if cc.has_function('close_range', prefix: '#define _GNU_SOURCE\n#include <unistd.h>')
|
||||||
add_project_arguments('-DHAVE_CLOSEFROM', language: 'c')
|
add_project_arguments('-DHAVE_CLOSE_RANGE', language: 'c')
|
||||||
|
elif cc.has_header('linux/close_range.h')
|
||||||
|
add_project_arguments('-DHAVE_LINUX_CLOSE_RANGE_H', language: 'c')
|
||||||
endif
|
endif
|
||||||
if cc.has_function('close_range', prefix: '#define _GNU_SOURCE\n#include <unistd.h>') and \
|
|
||||||
cc.has_header_symbol('unistd.h', 'CLOSE_RANGE_CLOEXEC', prefix: '#define _GNU_SOURCE')
|
if cc.has_function('strlcpy', prefix: '#define _GNU_SOURCE\n#include <string.h>')
|
||||||
add_project_arguments('-DHAVE_CLOSE_RANGE_CLOEXEC', language: 'c')
|
add_project_arguments('-DHAVE_STRLCPY', language: 'c')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
incdir = include_directories('src/shared')
|
incdir = include_directories('src/shared')
|
||||||
|
|||||||
@@ -26,14 +26,7 @@ option('selinux', type : 'feature', value : 'auto',
|
|||||||
description : 'enable SELinux support')
|
description : 'enable SELinux support')
|
||||||
option('shell', type : 'string', value : '/bin/sh',
|
option('shell', type : 'string', value : '/bin/sh',
|
||||||
description : 'Default posix compatible shell')
|
description : 'Default posix compatible shell')
|
||||||
option('split-usr', type : 'combo',
|
|
||||||
choices : ['auto', 'true', 'false'],
|
|
||||||
description : '''/bin, /sbin aren't symlinks into /usr''')
|
|
||||||
option('sysvinit', type : 'boolean', value : false,
|
option('sysvinit', type : 'boolean', value : false,
|
||||||
description : 'enable SysVinit compatibility (linux only)')
|
description : 'enable SysVinit compatibility (linux only)')
|
||||||
option('termcap', type : 'combo',
|
|
||||||
choices :
|
|
||||||
[ '', 'ncurses', 'termcap' ],
|
|
||||||
description : 'the termcap library to use')
|
|
||||||
option('zsh-completions', type : 'boolean',
|
option('zsh-completions', type : 'boolean',
|
||||||
description : 'install zsh completions')
|
description : 'install zsh completions')
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
# This file may not be copied, modified, propagated, or distributed
|
# This file may not be copied, modified, propagated, or distributed
|
||||||
# except according to the terms contained in the LICENSE file.
|
# except according to the terms contained in the LICENSE file.
|
||||||
|
|
||||||
cgroup=/sys/fs/cgroup/openrc
|
cgroup=/sys/fs/cgroup/"${rc_cgroup_name:-openrc}"
|
||||||
PATH=/bin:/usr/bin:/sbin:/usr/sbin
|
PATH=/bin:/usr/bin:/sbin:/usr/sbin
|
||||||
if [ -d ${cgroup}/"$1" ]; then
|
if [ -d ${cgroup}/"$1" ]; then
|
||||||
rmdir ${cgroup}/"$1"
|
rmdir ${cgroup}/"$1"
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
extra_stopped_commands="${extra_stopped_commands} cgroup_cleanup"
|
extra_stopped_commands="${extra_stopped_commands} cgroup_cleanup"
|
||||||
description_cgroup_cleanup="Kill all processes in the cgroup"
|
description_cgroup_cleanup="Kill all processes in the cgroup"
|
||||||
|
|
||||||
|
cg2_sv_name="${RC_SVCNAME}.sv"
|
||||||
|
|
||||||
cgroup_find_path()
|
cgroup_find_path()
|
||||||
{
|
{
|
||||||
local OIFS name dir result
|
local OIFS name dir result
|
||||||
@@ -35,9 +37,9 @@ cgroup_get_pids()
|
|||||||
cgroup_pids=
|
cgroup_pids=
|
||||||
cgroup_procs="$(cgroup2_find_path)"
|
cgroup_procs="$(cgroup2_find_path)"
|
||||||
if [ -n "${cgroup_procs}" ]; then
|
if [ -n "${cgroup_procs}" ]; then
|
||||||
cgroup_procs="${cgroup_procs}/${RC_SVCNAME}/cgroup.procs"
|
cgroup_procs="${cgroup_procs}/${rc_cgroup_name}/${cg2_sv_name}/cgroup.procs"
|
||||||
else
|
else
|
||||||
cgroup_procs="/sys/fs/cgroup/openrc/${RC_SVCNAME}/tasks"
|
cgroup_procs="/sys/fs/cgroup/"${rc_cgroup_name}"/${RC_SVCNAME}/tasks"
|
||||||
fi
|
fi
|
||||||
[ -f "${cgroup_procs}" ] || return 0
|
[ -f "${cgroup_procs}" ] || return 0
|
||||||
while read -r p; do
|
while read -r p; do
|
||||||
@@ -51,7 +53,7 @@ cgroup_running()
|
|||||||
{
|
{
|
||||||
[ -d "/sys/fs/cgroup/unified/${RC_SVCNAME}" ] ||
|
[ -d "/sys/fs/cgroup/unified/${RC_SVCNAME}" ] ||
|
||||||
[ -d "/sys/fs/cgroup/${RC_SVCNAME}" ] ||
|
[ -d "/sys/fs/cgroup/${RC_SVCNAME}" ] ||
|
||||||
[ -d "/sys/fs/cgroup/openrc/${RC_SVCNAME}" ]
|
[ -d "/sys/fs/cgroup/"${rc_cgroup_name}"/${RC_SVCNAME}" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
cgroup_set_values()
|
cgroup_set_values()
|
||||||
@@ -61,7 +63,7 @@ cgroup_set_values()
|
|||||||
local controller h
|
local controller h
|
||||||
controller="$1"
|
controller="$1"
|
||||||
h=$(cgroup_find_path "$1")
|
h=$(cgroup_find_path "$1")
|
||||||
cgroup="/sys/fs/cgroup/${1}${h}openrc_${RC_SVCNAME}"
|
cgroup="/sys/fs/cgroup/${1}${h}"${rc_cgroup_name}"_${RC_SVCNAME}"
|
||||||
[ -d "$cgroup" ] || mkdir -p "$cgroup"
|
[ -d "$cgroup" ] || mkdir -p "$cgroup"
|
||||||
|
|
||||||
set -- $2
|
set -- $2
|
||||||
@@ -108,7 +110,7 @@ cgroup_add_service()
|
|||||||
[ -w "${d}"/tasks ] && printf "%d" 0 > "${d}"/tasks
|
[ -w "${d}"/tasks ] && printf "%d" 0 > "${d}"/tasks
|
||||||
done
|
done
|
||||||
|
|
||||||
openrc_cgroup=/sys/fs/cgroup/openrc
|
openrc_cgroup=/sys/fs/cgroup/"${rc_cgroup_name}"
|
||||||
if [ -d "$openrc_cgroup" ]; then
|
if [ -d "$openrc_cgroup" ]; then
|
||||||
cgroup="$openrc_cgroup/$RC_SVCNAME"
|
cgroup="$openrc_cgroup/$RC_SVCNAME"
|
||||||
mkdir -p "$cgroup"
|
mkdir -p "$cgroup"
|
||||||
@@ -154,7 +156,7 @@ cgroup_set_limits()
|
|||||||
cgroup2_find_path()
|
cgroup2_find_path()
|
||||||
{
|
{
|
||||||
if grep -qw cgroup2 /proc/filesystems; then
|
if grep -qw cgroup2 /proc/filesystems; then
|
||||||
case "${rc_cgroup_mode:-hybrid}" in
|
case "${rc_cgroup_mode:-unified}" in
|
||||||
hybrid) printf "/sys/fs/cgroup/unified" ;;
|
hybrid) printf "/sys/fs/cgroup/unified" ;;
|
||||||
unified) printf "/sys/fs/cgroup" ;;
|
unified) printf "/sys/fs/cgroup" ;;
|
||||||
esac
|
esac
|
||||||
@@ -167,7 +169,7 @@ cgroup2_remove()
|
|||||||
local cgroup_path rc_cgroup_path
|
local cgroup_path rc_cgroup_path
|
||||||
cgroup_path="$(cgroup2_find_path)"
|
cgroup_path="$(cgroup2_find_path)"
|
||||||
[ -z "${cgroup_path}" ] && return 0
|
[ -z "${cgroup_path}" ] && return 0
|
||||||
rc_cgroup_path="${cgroup_path}/${RC_SVCNAME}"
|
rc_cgroup_path="${cgroup_path}/${rc_cgroup_name}/${cg2_sv_name}"
|
||||||
[ ! -d "${rc_cgroup_path}" ] ||
|
[ ! -d "${rc_cgroup_path}" ] ||
|
||||||
[ ! -e "${rc_cgroup_path}"/cgroup.events ] &&
|
[ ! -e "${rc_cgroup_path}"/cgroup.events ] &&
|
||||||
return 0
|
return 0
|
||||||
@@ -191,7 +193,7 @@ cgroup2_set_limits()
|
|||||||
cgroup_path="$(cgroup2_find_path)"
|
cgroup_path="$(cgroup2_find_path)"
|
||||||
[ -z "${cgroup_path}" ] && return 0
|
[ -z "${cgroup_path}" ] && return 0
|
||||||
mountinfo -q "${cgroup_path}"|| return 0
|
mountinfo -q "${cgroup_path}"|| return 0
|
||||||
rc_cgroup_path="${cgroup_path}/${RC_SVCNAME}"
|
rc_cgroup_path="${cgroup_path}/${rc_cgroup_name}/${cg2_sv_name}"
|
||||||
[ ! -d "${rc_cgroup_path}" ] && mkdir "${rc_cgroup_path}"
|
[ ! -d "${rc_cgroup_path}" ] && mkdir "${rc_cgroup_path}"
|
||||||
[ -f "${rc_cgroup_path}"/cgroup.procs ] &&
|
[ -f "${rc_cgroup_path}"/cgroup.procs ] &&
|
||||||
printf 0 > "${rc_cgroup_path}"/cgroup.procs
|
printf 0 > "${rc_cgroup_path}"/cgroup.procs
|
||||||
@@ -210,7 +212,7 @@ cgroup2_kill_cgroup() {
|
|||||||
local cgroup_path
|
local cgroup_path
|
||||||
cgroup_path="$(cgroup2_find_path)"
|
cgroup_path="$(cgroup2_find_path)"
|
||||||
[ -z "${cgroup_path}" ] && return 1
|
[ -z "${cgroup_path}" ] && return 1
|
||||||
rc_cgroup_path="${cgroup_path}/${RC_SVCNAME}"
|
rc_cgroup_path="${cgroup_path}/${rc_cgroup_name}/${cg2_sv_name}"
|
||||||
if [ -f "${rc_cgroup_path}"/cgroup.kill ]; then
|
if [ -f "${rc_cgroup_path}"/cgroup.kill ]; then
|
||||||
printf "%d" 1 > "${rc_cgroup_path}"/cgroup.kill
|
printf "%d" 1 > "${rc_cgroup_path}"/cgroup.kill
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ supervise_start()
|
|||||||
${chroot:+--chroot} $chroot \
|
${chroot:+--chroot} $chroot \
|
||||||
${output_log+--stdout} ${output_log} \
|
${output_log+--stdout} ${output_log} \
|
||||||
${error_log+--stderr} $error_log \
|
${error_log+--stderr} $error_log \
|
||||||
|
${output_logger:+--stdout-logger \"$output_logger\"} \
|
||||||
|
${error_logger:+--stderr-logger \"$error_logger\"} \
|
||||||
${pidfile:+--pidfile} $pidfile \
|
${pidfile:+--pidfile} $pidfile \
|
||||||
${respawn_delay:+--respawn-delay} $respawn_delay \
|
${respawn_delay:+--respawn-delay} $respawn_delay \
|
||||||
${respawn_max:+--respawn-max} $respawn_max \
|
${respawn_max:+--respawn-max} $respawn_max \
|
||||||
@@ -38,7 +40,7 @@ supervise_start()
|
|||||||
${healthcheck_timer:+--healthcheck-timer} $healthcheck_timer \
|
${healthcheck_timer:+--healthcheck-timer} $healthcheck_timer \
|
||||||
${capabilities+--capabilities} "$capabilities" \
|
${capabilities+--capabilities} "$capabilities" \
|
||||||
${secbits:+--secbits} "$secbits" \
|
${secbits:+--secbits} "$secbits" \
|
||||||
${no_new_privs:+--no_new_privs} \
|
${no_new_privs:+--no-new-privs} \
|
||||||
${command_user+--user} $command_user \
|
${command_user+--user} $command_user \
|
||||||
${umask+--umask} $umask \
|
${umask+--umask} $umask \
|
||||||
${supervise_daemon_args-${start_stop_daemon_args}} \
|
${supervise_daemon_args-${start_stop_daemon_args}} \
|
||||||
|
|||||||
@@ -17,25 +17,24 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#include <libgen.h>
|
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "einfo.h"
|
#include "einfo.h"
|
||||||
#include "rc.h"
|
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "selinux.h"
|
#include "selinux.h"
|
||||||
#include "_usage.h"
|
#include "_usage.h"
|
||||||
|
#include "helpers.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
inode_unknown = 0,
|
inode_unknown = 0,
|
||||||
|
|||||||
@@ -12,20 +12,17 @@
|
|||||||
|
|
||||||
#define SYSLOG_NAMES
|
#define SYSLOG_NAMES
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <stdbool.h>
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <signal.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <strings.h>
|
||||||
|
|
||||||
#include "einfo.h"
|
#include "einfo.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
@@ -81,7 +78,7 @@ int main(int argc, char **argv)
|
|||||||
if (strcmp(applet, "eend") == 0 ||
|
if (strcmp(applet, "eend") == 0 ||
|
||||||
strcmp(applet, "ewend") == 0 ||
|
strcmp(applet, "ewend") == 0 ||
|
||||||
strcmp(applet, "veend") == 0 ||
|
strcmp(applet, "veend") == 0 ||
|
||||||
strcmp(applet, "vweend") == 0 ||
|
strcmp(applet, "vewend") == 0 ||
|
||||||
strcmp(applet, "ewaitfile") == 0)
|
strcmp(applet, "ewaitfile") == 0)
|
||||||
{
|
{
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
|||||||
@@ -16,13 +16,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <spawn.h>
|
||||||
|
|
||||||
/* Yay for linux and its non liking of POSIX functions.
|
/* Yay for linux and its non liking of POSIX functions.
|
||||||
Okay, we could use getfsent but the man page says use getmntent instead
|
Okay, we could use getfsent but the man page says use getmntent instead
|
||||||
@@ -30,6 +31,7 @@
|
|||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
# define HAVE_GETMNTENT
|
# define HAVE_GETMNTENT
|
||||||
# include <mntent.h>
|
# include <mntent.h>
|
||||||
|
|
||||||
# define ENT mntent
|
# define ENT mntent
|
||||||
# define START_ENT fp = setmntent ("/etc/fstab", "r");
|
# define START_ENT fp = setmntent ("/etc/fstab", "r");
|
||||||
# define GET_ENT getmntent (fp)
|
# define GET_ENT getmntent (fp)
|
||||||
@@ -43,6 +45,7 @@
|
|||||||
#else
|
#else
|
||||||
# define HAVE_GETFSENT
|
# define HAVE_GETFSENT
|
||||||
# include <fstab.h>
|
# include <fstab.h>
|
||||||
|
|
||||||
# define ENT fstab
|
# define ENT fstab
|
||||||
# define START_ENT
|
# define START_ENT
|
||||||
# define GET_ENT getfsent ()
|
# define GET_ENT getfsent ()
|
||||||
@@ -58,8 +61,10 @@
|
|||||||
#include "einfo.h"
|
#include "einfo.h"
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "rc.h"
|
#include "rc.h"
|
||||||
#include "misc.h"
|
|
||||||
#include "_usage.h"
|
#include "_usage.h"
|
||||||
|
#include "helpers.h"
|
||||||
|
|
||||||
|
extern char **environ;
|
||||||
|
|
||||||
const char *applet = NULL;
|
const char *applet = NULL;
|
||||||
const char *extraopts = NULL;
|
const char *extraopts = NULL;
|
||||||
@@ -110,7 +115,7 @@ do_mount(struct ENT *ent, bool remount)
|
|||||||
{
|
{
|
||||||
char *argv[10];
|
char *argv[10];
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int status;
|
int status, err;
|
||||||
|
|
||||||
argv[0] = UNCONST("mount");
|
argv[0] = UNCONST("mount");
|
||||||
argv[1] = UNCONST("-o");
|
argv[1] = UNCONST("-o");
|
||||||
@@ -135,23 +140,14 @@ do_mount(struct ENT *ent, bool remount)
|
|||||||
argv[8] = NULL;
|
argv[8] = NULL;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
switch (pid = vfork()) {
|
err = posix_spawnp(&pid, argv[0], NULL, NULL, argv, environ);
|
||||||
case -1:
|
if (err)
|
||||||
eerrorx("%s: vfork: %s", applet, strerror(errno));
|
eerrorx("%s: posix_spawnp: %s", applet, strerror(err));
|
||||||
/* NOTREACHED */
|
while (waitpid(pid, &status, 0) < 0 && errno == EINTR);
|
||||||
case 0:
|
if (WIFEXITED(status))
|
||||||
execvp(argv[0], argv);
|
return WEXITSTATUS(status);
|
||||||
eerror("%s: execvp: %s", applet, strerror(errno));
|
else
|
||||||
_exit(EXIT_FAILURE);
|
return -1;
|
||||||
/* NOTREACHED */
|
|
||||||
default:
|
|
||||||
waitpid(pid, &status, 0);
|
|
||||||
if (WIFEXITED(status))
|
|
||||||
return WEXITSTATUS(status);
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
/* NOTREACHED */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define OUTPUT_FILE (1 << 1)
|
#define OUTPUT_FILE (1 << 1)
|
||||||
|
|||||||
@@ -10,13 +10,9 @@
|
|||||||
* except according to the terms contained in the LICENSE file.
|
* except according to the terms contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "rc.h"
|
#include "rc.h"
|
||||||
#include "misc.h"
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,13 +10,9 @@
|
|||||||
* except according to the terms contained in the LICENSE file.
|
* except according to the terms contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "rc.h"
|
#include "rc.h"
|
||||||
#include "misc.h"
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <limits.h>
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -28,11 +27,12 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "einfo.h"
|
#include "einfo.h"
|
||||||
#include "rc.h"
|
#include "rc.h"
|
||||||
#include "misc.h"
|
|
||||||
#include "_usage.h"
|
#include "_usage.h"
|
||||||
|
#include "helpers.h"
|
||||||
|
|
||||||
const char *applet = NULL;
|
const char *applet = NULL;
|
||||||
const char *extraopts = "[signal number]";
|
const char *extraopts = "[signal number]";
|
||||||
|
|||||||
@@ -13,13 +13,8 @@
|
|||||||
#ifndef __EINFO_H__
|
#ifndef __EINFO_H__
|
||||||
#define __EINFO_H__
|
#define __EINFO_H__
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#define EINFO_PRINTF(a, b) __attribute__((__format__(__printf__, a, b)))
|
||||||
# define EINFO_PRINTF(a, b) __attribute__((__format__(__printf__, a, b)))
|
#define EINFO_XPRINTF(a, b) __attribute__((__noreturn__, __format__(__printf__, a, b)))
|
||||||
# define EINFO_XPRINTF(a, b) __attribute__((__noreturn__,__format__(__printf__, a, b)))
|
|
||||||
#else
|
|
||||||
# define EINFO_PRINTF(a, b)
|
|
||||||
# define EINFO_XPRINTF(a, b)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
@@ -74,22 +69,22 @@ void elog(int, const char * EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
|
|||||||
* The x suffix means function will exit() returning failure.
|
* The x suffix means function will exit() returning failure.
|
||||||
*/
|
*/
|
||||||
/*@{*/
|
/*@{*/
|
||||||
int einfon(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
int einfon(const char * EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
||||||
int ewarnn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
int ewarnn(const char * EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
||||||
int eerrorn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
int eerrorn(const char * EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
||||||
int einfo(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
int einfo(const char * EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
||||||
int ewarn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
int ewarn(const char * EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
||||||
void ewarnx(const char * __EINFO_RESTRICT, ...) EINFO_XPRINTF(1, 2);
|
void ewarnx(const char * EINFO_RESTRICT, ...) EINFO_XPRINTF(1, 2);
|
||||||
int eerror(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
int eerror(const char * EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
||||||
void eerrorx(const char * __EINFO_RESTRICT, ...) EINFO_XPRINTF(1, 2);
|
void eerrorx(const char * EINFO_RESTRICT, ...) EINFO_XPRINTF(1, 2);
|
||||||
|
|
||||||
int einfovn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
int einfovn(const char * EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
||||||
int ewarnvn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
int ewarnvn(const char * EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
||||||
int ebeginvn(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
int ebeginvn(const char * EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
||||||
int eendvn(int, const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
|
int eendvn(int, const char * EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
|
||||||
int ewendvn(int, const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
|
int ewendvn(int, const char * EINFO_RESTRICT, ...) EINFO_PRINTF(2, 3);
|
||||||
int einfov(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
int einfov(const char * EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
||||||
int ewarnv(const char * __EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
int ewarnv(const char * EINFO_RESTRICT, ...) EINFO_PRINTF(1, 2);
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
||||||
/*! @ingroup ebegin
|
/*! @ingroup ebegin
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007-2015 The OpenRC Authors.
|
* Copyright (c) 2007-2024 The OpenRC Authors.
|
||||||
* See the Authors file at the top-level directory of this distribution and
|
* See the Authors file at the top-level directory of this distribution and
|
||||||
* https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS
|
* https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS
|
||||||
*
|
*
|
||||||
@@ -15,24 +15,17 @@
|
|||||||
* except according to the terms contained in the LICENSE file.
|
* except according to the terms contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/stat.h>
|
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <limits.h>
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#ifdef HAVE_TERMCAP
|
|
||||||
# include <termcap.h>
|
|
||||||
#endif
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "einfo.h"
|
#include "einfo.h"
|
||||||
@@ -57,8 +50,7 @@
|
|||||||
#define HILITE 6
|
#define HILITE 6
|
||||||
#define BRACKET 4
|
#define BRACKET 4
|
||||||
|
|
||||||
/* We fallback to these escape codes if termcap isn't available
|
/* ANSI escape codes which mimic termcap */
|
||||||
* like say /usr isn't mounted */
|
|
||||||
#define AF "\033[3%dm"
|
#define AF "\033[3%dm"
|
||||||
#define CE "\033[K"
|
#define CE "\033[K"
|
||||||
#define CH "\033[%dC"
|
#define CH "\033[%dC"
|
||||||
@@ -101,13 +93,7 @@ static char *goto_column = NULL;
|
|||||||
static const char *term = NULL;
|
static const char *term = NULL;
|
||||||
static bool term_is_cons25 = false;
|
static bool term_is_cons25 = false;
|
||||||
|
|
||||||
/* Termcap buffers and pointers
|
/* Hardcoded list of colour capable terms
|
||||||
* Static buffers suck hard, but some termcap implementations require them */
|
|
||||||
#ifdef HAVE_TERMCAP
|
|
||||||
static char termcapbuf[2048];
|
|
||||||
static char tcapbuf[512];
|
|
||||||
#else
|
|
||||||
/* No curses support, so we hardcode a list of colour capable terms
|
|
||||||
* Only terminals without "color" in the name need to be explicitly listed */
|
* Only terminals without "color" in the name need to be explicitly listed */
|
||||||
static const char *const color_terms[] = {
|
static const char *const color_terms[] = {
|
||||||
"Eterm",
|
"Eterm",
|
||||||
@@ -146,13 +132,11 @@ static const char *const color_terms[] = {
|
|||||||
"wsvt25",
|
"wsvt25",
|
||||||
"xterm",
|
"xterm",
|
||||||
"xterm-debian",
|
"xterm-debian",
|
||||||
|
"xterm-kitty",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
/* strlcat and strlcpy are nice, shame glibc does not define them */
|
#ifndef HAVE_STRLCPY
|
||||||
#ifdef __GLIBC__
|
|
||||||
# if !defined (__UCLIBC__) && !defined (__dietlibc__)
|
|
||||||
static size_t
|
static size_t
|
||||||
strlcat(char *dst, const char *src, size_t size)
|
strlcat(char *dst, const char *src, size_t size)
|
||||||
{
|
{
|
||||||
@@ -180,7 +164,6 @@ strlcat(char *dst, const char *src, size_t size)
|
|||||||
|
|
||||||
return dst_n + (s - src);
|
return dst_n + (s - src);
|
||||||
}
|
}
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
@@ -243,7 +226,6 @@ is_verbose(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Fake tgoto call - very crapy, but works for our needs */
|
/* Fake tgoto call - very crapy, but works for our needs */
|
||||||
#ifndef HAVE_TERMCAP
|
|
||||||
static char *
|
static char *
|
||||||
tgoto(const char *cap, int col, int line)
|
tgoto(const char *cap, int col, int line)
|
||||||
{
|
{
|
||||||
@@ -306,7 +288,6 @@ tgoto(const char *cap, int col, int line)
|
|||||||
*p = '\0';
|
*p = '\0';
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
colour_terminal(FILE * EINFO_RESTRICT f)
|
colour_terminal(FILE * EINFO_RESTRICT f)
|
||||||
@@ -319,9 +300,6 @@ colour_terminal(FILE * EINFO_RESTRICT f)
|
|||||||
const char *bold;
|
const char *bold;
|
||||||
char tmp[100];
|
char tmp[100];
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
#ifdef HAVE_TERMCAP
|
|
||||||
char *bp;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (f && !isatty(fileno(f)))
|
if (f && !isatty(fileno(f)))
|
||||||
return false;
|
return false;
|
||||||
@@ -343,65 +321,33 @@ colour_terminal(FILE * EINFO_RESTRICT f)
|
|||||||
if (strcmp(term, "cons25") == 0)
|
if (strcmp(term, "cons25") == 0)
|
||||||
term_is_cons25 = true;
|
term_is_cons25 = true;
|
||||||
|
|
||||||
#ifdef HAVE_TERMCAP
|
if (strstr(term, "color"))
|
||||||
/* Check termcap to see if we can do colour or not */
|
in_colour = 1;
|
||||||
if (tgetent(termcapbuf, term) == 1) {
|
|
||||||
bp = tcapbuf;
|
|
||||||
_af = tgetstr("AF", &bp);
|
|
||||||
_ce = tgetstr("ce", &bp);
|
|
||||||
_ch = tgetstr("ch", &bp);
|
|
||||||
/* Our ch use also works with RI .... for now */
|
|
||||||
if (!_ch)
|
|
||||||
_ch = tgetstr("RI", &bp);
|
|
||||||
_md = tgetstr("md", &bp);
|
|
||||||
_me = tgetstr("me", &bp);
|
|
||||||
_up = tgetstr("up", &bp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Cheat here as vanilla BSD has the whole termcap info in /usr
|
while (color_terms[i] && in_colour != 1) {
|
||||||
* which is not available to us when we boot */
|
if (strcmp(color_terms[i], term) == 0) {
|
||||||
if (term_is_cons25 || strcmp(term, "wsvt25") == 0) {
|
|
||||||
#else
|
|
||||||
if (strstr(term, "color"))
|
|
||||||
in_colour = 1;
|
in_colour = 1;
|
||||||
|
|
||||||
while (color_terms[i] && in_colour != 1) {
|
|
||||||
if (strcmp(color_terms[i], term) == 0) {
|
|
||||||
in_colour = 1;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
|
i++;
|
||||||
if (in_colour != 1) {
|
|
||||||
in_colour = 0;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (!_af)
|
|
||||||
_af = AF;
|
|
||||||
if (!_ce)
|
|
||||||
_ce = CE;
|
|
||||||
if (!_ch)
|
|
||||||
_ch = CH;
|
|
||||||
if (!_md)
|
|
||||||
_md = MD;
|
|
||||||
if (!_me)
|
|
||||||
_me = ME;
|
|
||||||
if (!_up)
|
|
||||||
_up = UP;
|
|
||||||
#ifdef HAVE_TERMCAP
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_af || !_ce || !_me || !_md || !_up) {
|
if (in_colour != 1) {
|
||||||
in_colour = 0;
|
in_colour = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Many termcap databases don't have ch or RI even though they
|
if (!_af)
|
||||||
* do work */
|
_af = AF;
|
||||||
|
if (!_ce)
|
||||||
|
_ce = CE;
|
||||||
if (!_ch)
|
if (!_ch)
|
||||||
_ch = CH;
|
_ch = CH;
|
||||||
#endif
|
if (!_md)
|
||||||
|
_md = MD;
|
||||||
|
if (!_me)
|
||||||
|
_me = ME;
|
||||||
|
if (!_up)
|
||||||
|
_up = UP;
|
||||||
|
|
||||||
/* Now setup our colours */
|
/* Now setup our colours */
|
||||||
p = ebuffer;
|
p = ebuffer;
|
||||||
@@ -677,15 +623,14 @@ ewarn(const char *EINFO_RESTRICT fmt, ...)
|
|||||||
void
|
void
|
||||||
ewarnx(const char *EINFO_RESTRICT fmt, ...)
|
ewarnx(const char *EINFO_RESTRICT fmt, ...)
|
||||||
{
|
{
|
||||||
int retval;
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
if (fmt && !is_quiet()) {
|
if (fmt && !is_quiet()) {
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
elogv(LOG_WARNING, fmt, ap);
|
elogv(LOG_WARNING, fmt, ap);
|
||||||
retval = _ewarnvn(fmt, ap);
|
_ewarnvn(fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
retval += fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
libeinfo_version = '1'
|
libeinfo_version = '1'
|
||||||
|
|
||||||
libeinfo = library('einfo', ['libeinfo.c'],
|
libeinfo = library('einfo', ['libeinfo.c'],
|
||||||
c_args : termcap_flags,
|
|
||||||
include_directories : incdir,
|
include_directories : incdir,
|
||||||
dependencies : termcap_dep,
|
|
||||||
link_depends : 'einfo.map',
|
link_depends : 'einfo.map',
|
||||||
version : libeinfo_version,
|
version : libeinfo_version,
|
||||||
install : true,
|
install : true,
|
||||||
|
|||||||
@@ -15,10 +15,21 @@
|
|||||||
* except according to the terms contained in the LICENSE file.
|
* except according to the terms contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <limits.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "librc.h"
|
#include "librc.h"
|
||||||
|
#include "helpers.h"
|
||||||
|
|
||||||
#if defined(__linux__) || (defined (__FreeBSD_kernel__) && defined(__GLIBC__)) \
|
#if defined(__linux__) || (defined (__FreeBSD_kernel__) && defined(__GLIBC__)) \
|
||||||
|| defined(__GNU__)
|
|| defined(__GNU__)
|
||||||
@@ -391,7 +402,7 @@ rc_service_daemon_set(const char *service, const char *exec,
|
|||||||
bool retval = false;
|
bool retval = false;
|
||||||
DIR *dp;
|
DIR *dp;
|
||||||
struct dirent *d;
|
struct dirent *d;
|
||||||
RC_STRINGLIST *match;
|
RC_STRINGLIST *match, *renamelist;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
@@ -405,11 +416,17 @@ rc_service_daemon_set(const char *service, const char *exec,
|
|||||||
/* Regardless, erase any existing daemon info */
|
/* Regardless, erase any existing daemon info */
|
||||||
if ((dp = opendir(dirpath))) {
|
if ((dp = opendir(dirpath))) {
|
||||||
match = _match_list(exec, argv, pidfile);
|
match = _match_list(exec, argv, pidfile);
|
||||||
|
renamelist = rc_stringlist_new();
|
||||||
while ((d = readdir(dp))) {
|
while ((d = readdir(dp))) {
|
||||||
if (d->d_name[0] == '.')
|
if (d->d_name[0] == '.')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
xasprintf(&file, "%s/%s", dirpath, d->d_name);
|
xasprintf(&file, "%s/%s", dirpath, d->d_name);
|
||||||
|
if (rc_stringlist_find(renamelist, file)) {
|
||||||
|
free(file);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
nfiles++;
|
nfiles++;
|
||||||
|
|
||||||
if (!*oldfile) {
|
if (!*oldfile) {
|
||||||
@@ -421,11 +438,15 @@ rc_service_daemon_set(const char *service, const char *exec,
|
|||||||
} else {
|
} else {
|
||||||
rename(file, oldfile);
|
rename(file, oldfile);
|
||||||
strlcpy(oldfile, file, sizeof(oldfile));
|
strlcpy(oldfile, file, sizeof(oldfile));
|
||||||
|
/* Add renamed file to renamelist, as this new file name could
|
||||||
|
* be read again from readdir() */
|
||||||
|
rc_stringlist_add(renamelist, oldfile);
|
||||||
}
|
}
|
||||||
free(file);
|
free(file);
|
||||||
}
|
}
|
||||||
closedir(dp);
|
closedir(dp);
|
||||||
rc_stringlist_free(match);
|
rc_stringlist_free(match);
|
||||||
|
rc_stringlist_free(renamelist);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now store our daemon info */
|
/* Now store our daemon info */
|
||||||
|
|||||||
@@ -16,9 +16,22 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "librc.h"
|
#include "librc.h"
|
||||||
|
#include "helpers.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
#define GENDEP RC_LIBEXECDIR "/sh/gendepends.sh"
|
#define GENDEP RC_LIBEXECDIR "/sh/gendepends.sh"
|
||||||
|
|
||||||
|
|||||||
@@ -16,11 +16,21 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <fnmatch.h>
|
#include <fnmatch.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <strings.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "librc.h"
|
#include "librc.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
bool
|
bool
|
||||||
rc_yesno(const char *value)
|
rc_yesno(const char *value)
|
||||||
@@ -117,7 +127,7 @@ rc_getline(char **line, size_t *len, FILE *fp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
rc_proc_getent(const char *ent _unused)
|
rc_proc_getent(const char *ent RC_UNUSED)
|
||||||
{
|
{
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
@@ -277,6 +287,7 @@ static RC_STRINGLIST *rc_config_kcl(RC_STRINGLIST *config)
|
|||||||
overrides = rc_stringlist_new();
|
overrides = rc_stringlist_new();
|
||||||
|
|
||||||
/* A list of variables which may be overridden on the kernel command line */
|
/* A list of variables which may be overridden on the kernel command line */
|
||||||
|
rc_stringlist_add(overrides, "rc_interactive");
|
||||||
rc_stringlist_add(overrides, "rc_parallel");
|
rc_stringlist_add(overrides, "rc_parallel");
|
||||||
|
|
||||||
TAILQ_FOREACH(override, overrides, entries) {
|
TAILQ_FOREACH(override, overrides, entries) {
|
||||||
|
|||||||
@@ -15,8 +15,14 @@
|
|||||||
* except according to the terms contained in the LICENSE file.
|
* except according to the terms contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "librc.h"
|
#include "librc.h"
|
||||||
|
#include "helpers.h"
|
||||||
|
|
||||||
RC_STRINGLIST *
|
RC_STRINGLIST *
|
||||||
rc_stringlist_new(void)
|
rc_stringlist_new(void)
|
||||||
|
|||||||
@@ -15,9 +15,26 @@
|
|||||||
* except according to the terms contained in the LICENSE file.
|
* except according to the terms contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <helpers.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <libgen.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <regex.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "librc.h"
|
#include "librc.h"
|
||||||
#include <helpers.h>
|
#include "misc.h"
|
||||||
|
#include "rc.h"
|
||||||
#ifdef __FreeBSD__
|
#ifdef __FreeBSD__
|
||||||
# include <sys/sysctl.h>
|
# include <sys/sysctl.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -232,7 +249,7 @@ detect_prefix(const char *systype)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
detect_container(const char *systype _unused)
|
detect_container(const char *systype RC_UNUSED)
|
||||||
{
|
{
|
||||||
#ifdef __FreeBSD__
|
#ifdef __FreeBSD__
|
||||||
if (systype) {
|
if (systype) {
|
||||||
@@ -296,7 +313,7 @@ detect_container(const char *systype _unused)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
detect_vm(const char *systype _unused)
|
detect_vm(const char *systype RC_UNUSED)
|
||||||
{
|
{
|
||||||
#ifdef __NetBSD__
|
#ifdef __NetBSD__
|
||||||
if (systype) {
|
if (systype) {
|
||||||
@@ -755,8 +772,10 @@ rc_service_mark(const char *service, const RC_SERVICE state)
|
|||||||
RC_SVCDIR "/%s/%s",
|
RC_SVCDIR "/%s/%s",
|
||||||
rc_parse_service_state(RC_SERVICE_WASINACTIVE),
|
rc_parse_service_state(RC_SERVICE_WASINACTIVE),
|
||||||
base);
|
base);
|
||||||
if (symlink(init, was) == -1)
|
if (symlink(init, was) == -1) {
|
||||||
|
free(init);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
skip_wasinactive = true;
|
skip_wasinactive = true;
|
||||||
}
|
}
|
||||||
if (unlink(file) == -1) {
|
if (unlink(file) == -1) {
|
||||||
|
|||||||
@@ -25,7 +25,6 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|||||||
@@ -10,24 +10,18 @@
|
|||||||
* except according to the terms contained in the LICENSE file.
|
* except according to the terms contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <ctype.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <syslog.h>
|
#include <sys/types.h>
|
||||||
#include <time.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "einfo.h"
|
#include "einfo.h"
|
||||||
#include "rc.h"
|
#include "rc.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
#include "helpers.h"
|
||||||
|
|
||||||
const char *applet = NULL;
|
const char *applet = NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -15,15 +15,14 @@
|
|||||||
* except according to the terms contained in the LICENSE file.
|
* except according to the terms contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/param.h>
|
|
||||||
|
|
||||||
#if defined(__DragonFly__) || defined(__FreeBSD__)
|
#if defined(__DragonFly__) || defined(__FreeBSD__)
|
||||||
# include <sys/ucred.h>
|
# include <sys/ucred.h>
|
||||||
# include <sys/mount.h>
|
# include <sys/mount.h>
|
||||||
|
|
||||||
# define F_FLAGS f_flags
|
# define F_FLAGS f_flags
|
||||||
#elif defined(BSD) && !defined(__GNU__)
|
#elif defined(BSD) && !defined(__GNU__)
|
||||||
# include <sys/statvfs.h>
|
# include <sys/statvfs.h>
|
||||||
|
|
||||||
# define statfs statvfs
|
# define statfs statvfs
|
||||||
# define F_FLAGS f_flag
|
# define F_FLAGS f_flag
|
||||||
#elif defined(__linux__) || (defined(__FreeBSD_kernel__) && \
|
#elif defined(__linux__) || (defined(__FreeBSD_kernel__) && \
|
||||||
@@ -33,17 +32,19 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <limits.h>
|
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "einfo.h"
|
#include "einfo.h"
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "rc.h"
|
#include "rc.h"
|
||||||
#include "misc.h"
|
|
||||||
#include "_usage.h"
|
#include "_usage.h"
|
||||||
|
#include "helpers.h"
|
||||||
|
|
||||||
const char *applet = NULL;
|
const char *applet = NULL;
|
||||||
const char *procmounts = "/proc/mounts";
|
const char *procmounts = "/proc/mounts";
|
||||||
|
|||||||
@@ -27,16 +27,16 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/reboot.h>
|
#include <sys/reboot.h>
|
||||||
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
#include <utmp.h>
|
||||||
|
|
||||||
#ifdef HAVE_SELINUX
|
#ifdef HAVE_SELINUX
|
||||||
# include <selinux/selinux.h>
|
# include <selinux/selinux.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "helpers.h"
|
|
||||||
#include "rc.h"
|
#include "rc.h"
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
#include "wtmp.h"
|
#include "wtmp.h"
|
||||||
|
|||||||
@@ -6,12 +6,3 @@ executable('openrc-run',
|
|||||||
include_directories: [incdir, einfo_incdir, rc_incdir],
|
include_directories: [incdir, einfo_incdir, rc_incdir],
|
||||||
install: true,
|
install: true,
|
||||||
install_dir: sbindir)
|
install_dir: sbindir)
|
||||||
|
|
||||||
executable('runscript',
|
|
||||||
['openrc-run.c', misc_c, plugin_c, selinux_c, usage_c, version_h],
|
|
||||||
c_args : [cc_audit_flags, cc_branding_flags, cc_pam_flags, cc_selinux_flags],
|
|
||||||
link_with: [libeinfo, librc],
|
|
||||||
dependencies: [audit_dep, dl_dep, pam_dep, pam_misc_dep, selinux_dep, util_dep, crypt_dep],
|
|
||||||
include_directories: [incdir, einfo_incdir, rc_incdir],
|
|
||||||
install: true,
|
|
||||||
install_dir: sbindir)
|
|
||||||
|
|||||||
@@ -15,28 +15,26 @@
|
|||||||
* except according to the terms contained in the LICENSE file.
|
* except according to the terms contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <sys/file.h>
|
|
||||||
#include <sys/param.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <fnmatch.h>
|
#include <fnmatch.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
#include <limits.h>
|
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/file.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#if defined(__linux__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__)) \
|
#if defined(__linux__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__)) \
|
||||||
|| defined(__GNU__)
|
|| defined(__GNU__)
|
||||||
@@ -54,6 +52,7 @@
|
|||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
#include "selinux.h"
|
#include "selinux.h"
|
||||||
#include "_usage.h"
|
#include "_usage.h"
|
||||||
|
#include "helpers.h"
|
||||||
|
|
||||||
#define PREFIX_LOCK RC_SVCDIR "/prefix.lock"
|
#define PREFIX_LOCK RC_SVCDIR "/prefix.lock"
|
||||||
|
|
||||||
@@ -108,8 +107,9 @@ static RC_STRINGLIST *deptypes_mwua; /* need+want+use+after deps for stopping */
|
|||||||
static void
|
static void
|
||||||
handle_signal(int sig)
|
handle_signal(int sig)
|
||||||
{
|
{
|
||||||
int serrno = errno;
|
int serrno = errno, status;
|
||||||
char *signame = NULL;
|
pid_t pid;
|
||||||
|
const char *signame = NULL;
|
||||||
struct winsize ws;
|
struct winsize ws;
|
||||||
|
|
||||||
switch (sig) {
|
switch (sig) {
|
||||||
@@ -118,12 +118,13 @@ handle_signal(int sig)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SIGCHLD:
|
case SIGCHLD:
|
||||||
if (signal_pipe[1] > -1) {
|
while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
|
||||||
if (write(signal_pipe[1], &sig, sizeof(sig)) == -1)
|
if (signal_pipe[1] > -1 && pid == service_pid) {
|
||||||
eerror("%s: send: %s",
|
if (write(signal_pipe[1], &status, sizeof(status)) == -1)
|
||||||
service, strerror(errno));
|
eerror("%s: send: %s",
|
||||||
} else
|
service, strerror(errno));
|
||||||
rc_waitpid(-1);
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SIGWINCH:
|
case SIGWINCH:
|
||||||
@@ -135,20 +136,19 @@ handle_signal(int sig)
|
|||||||
|
|
||||||
case SIGINT:
|
case SIGINT:
|
||||||
if (!signame)
|
if (!signame)
|
||||||
xasprintf(&signame, "SIGINT");
|
signame = "SIGINT";
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
if (!signame)
|
if (!signame)
|
||||||
xasprintf(&signame, "SIGTERM");
|
signame = "SIGTERM";
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
case SIGQUIT:
|
case SIGQUIT:
|
||||||
if (!signame)
|
if (!signame)
|
||||||
xasprintf(&signame, "SIGQUIT");
|
signame = "SIGQUIT";
|
||||||
/* Send the signal to our children too */
|
/* Send the signal to our children too */
|
||||||
if (service_pid > 0)
|
if (service_pid > 0)
|
||||||
kill(service_pid, sig);
|
kill(service_pid, sig);
|
||||||
eerror("%s: caught %s, aborting", applet, signame);
|
eerror("%s: caught %s, aborting", applet, signame);
|
||||||
free(signame);
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
|
|
||||||
@@ -440,6 +440,7 @@ svc_exec(const char *arg1, const char *arg2)
|
|||||||
if (errno != EINTR) {
|
if (errno != EINTR) {
|
||||||
eerror("%s: poll: %s",
|
eerror("%s: poll: %s",
|
||||||
service, strerror(errno));
|
service, strerror(errno));
|
||||||
|
ret = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -450,9 +451,20 @@ svc_exec(const char *arg1, const char *arg2)
|
|||||||
write_prefix(buffer, bytes, &prefixed);
|
write_prefix(buffer, bytes, &prefixed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only SIGCHLD signals come down this pipe */
|
/* signal_pipe receives service_pid's exit status */
|
||||||
if (fd[0].revents & (POLLIN | POLLHUP))
|
if (fd[0].revents & (POLLIN | POLLHUP)) {
|
||||||
|
if ((s = read(signal_pipe[0], &ret, sizeof(ret))) != sizeof(ret)) {
|
||||||
|
eerror("%s: receive failed: %s", service,
|
||||||
|
s < 0 ? strerror(errno) : "short read");
|
||||||
|
ret = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ret = WEXITSTATUS(ret);
|
||||||
|
if (ret != 0 && errno == ECHILD)
|
||||||
|
/* killall5 -9 could cause this */
|
||||||
|
ret = 0;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -475,11 +487,6 @@ svc_exec(const char *arg1, const char *arg2)
|
|||||||
master_tty = -1;
|
master_tty = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = rc_waitpid(service_pid);
|
|
||||||
ret = WEXITSTATUS(ret);
|
|
||||||
if (ret != 0 && errno == ECHILD)
|
|
||||||
/* killall5 -9 could cause this */
|
|
||||||
ret = 0;
|
|
||||||
service_pid = 0;
|
service_pid = 0;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -614,7 +621,7 @@ svc_start_check(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (exclusive_fd == -1)
|
if (exclusive_fd == -1)
|
||||||
exclusive_fd = svc_lock(applet);
|
exclusive_fd = svc_lock(applet, !deps);
|
||||||
if (exclusive_fd == -1) {
|
if (exclusive_fd == -1) {
|
||||||
if (errno == EACCES)
|
if (errno == EACCES)
|
||||||
eerrorx("%s: superuser access required", applet);
|
eerrorx("%s: superuser access required", applet);
|
||||||
@@ -866,7 +873,7 @@ svc_stop_check(RC_SERVICE *state)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
if (exclusive_fd == -1)
|
if (exclusive_fd == -1)
|
||||||
exclusive_fd = svc_lock(applet);
|
exclusive_fd = svc_lock(applet, !deps);
|
||||||
if (exclusive_fd == -1) {
|
if (exclusive_fd == -1) {
|
||||||
if (errno == EACCES)
|
if (errno == EACCES)
|
||||||
eerrorx("%s: superuser access required", applet);
|
eerrorx("%s: superuser access required", applet);
|
||||||
@@ -1043,26 +1050,6 @@ svc_stop(void)
|
|||||||
static void
|
static void
|
||||||
svc_restart(void)
|
svc_restart(void)
|
||||||
{
|
{
|
||||||
/* This is hairy and a better way needs to be found I think!
|
|
||||||
* The issue is this - openvpn need net and dns. net can restart
|
|
||||||
* dns via resolvconf, so you could have openvpn trying to restart
|
|
||||||
* dnsmasq which in turn is waiting on net which in turn is waiting
|
|
||||||
* on dnsmasq.
|
|
||||||
* The work around is for resolvconf to restart its services with
|
|
||||||
* --nodeps which means just that.
|
|
||||||
* The downside is that there is a small window when our status is
|
|
||||||
* invalid.
|
|
||||||
* One workaround would be to introduce a new status,
|
|
||||||
* or status locking. */
|
|
||||||
if (!deps) {
|
|
||||||
RC_SERVICE state = rc_service_state(service);
|
|
||||||
if (state & RC_SERVICE_STARTED || state & RC_SERVICE_INACTIVE)
|
|
||||||
svc_exec("stop", "start");
|
|
||||||
else
|
|
||||||
svc_exec("start", NULL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(rc_service_state(service) & RC_SERVICE_STOPPED)) {
|
if (!(rc_service_state(service) & RC_SERVICE_STOPPED)) {
|
||||||
get_started_services();
|
get_started_services();
|
||||||
svc_stop();
|
svc_stop();
|
||||||
@@ -1110,7 +1097,6 @@ service_plugable(void)
|
|||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
bool doneone = false;
|
bool doneone = false;
|
||||||
bool runscript = false;
|
|
||||||
int retval, opt, depoptions = RC_DEP_TRACE;
|
int retval, opt, depoptions = RC_DEP_TRACE;
|
||||||
RC_STRING *svc;
|
RC_STRING *svc;
|
||||||
char *path = NULL;
|
char *path = NULL;
|
||||||
@@ -1128,8 +1114,6 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
applet = basename_c(argv[0]);
|
applet = basename_c(argv[0]);
|
||||||
if (strcmp(applet, "runscript") == 0)
|
|
||||||
runscript = true;
|
|
||||||
|
|
||||||
if (stat(argv[1], &stbuf) != 0) {
|
if (stat(argv[1], &stbuf) != 0) {
|
||||||
fprintf(stderr, "openrc-run `%s': %s\n",
|
fprintf(stderr, "openrc-run `%s': %s\n",
|
||||||
@@ -1302,9 +1286,6 @@ int main(int argc, char **argv)
|
|||||||
applet_list = rc_stringlist_new();
|
applet_list = rc_stringlist_new();
|
||||||
rc_stringlist_add(applet_list, applet);
|
rc_stringlist_add(applet_list, applet);
|
||||||
|
|
||||||
if (runscript)
|
|
||||||
ewarn("%s uses runscript, please convert to openrc-run.", service);
|
|
||||||
|
|
||||||
/* Now run each option */
|
/* Now run each option */
|
||||||
retval = EXIT_SUCCESS;
|
retval = EXIT_SUCCESS;
|
||||||
while (optind < argc) {
|
while (optind < argc) {
|
||||||
|
|||||||
@@ -12,24 +12,23 @@
|
|||||||
* This file may not be copied, modified, propagated, or distributed
|
* This file may not be copied, modified, propagated, or distributed
|
||||||
* except according to the terms contained in the LICENSE file.
|
* except according to the terms contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
#include <ctype.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/sysmacros.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <utmp.h>
|
|
||||||
#include <utmpx.h>
|
|
||||||
#include <pwd.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <paths.h>
|
||||||
|
#include <pwd.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <paths.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/sysmacros.h>
|
||||||
|
#include <sys/types.h>
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <utmpx.h>
|
||||||
|
|
||||||
#include "broadcast.h"
|
#include "broadcast.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
@@ -43,12 +42,7 @@ static sigjmp_buf jbuf;
|
|||||||
/*
|
/*
|
||||||
* Alarm handler
|
* Alarm handler
|
||||||
*/
|
*/
|
||||||
/*ARGSUSED*/
|
RC_NORETURN static void handler(int arg RC_UNUSED)
|
||||||
# ifdef __GNUC__
|
|
||||||
static void handler(int arg __attribute__((unused)))
|
|
||||||
# else
|
|
||||||
static void handler(int arg)
|
|
||||||
# endif
|
|
||||||
{
|
{
|
||||||
siglongjmp(jbuf, 1);
|
siglongjmp(jbuf, 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
* except according to the terms contained in the LICENSE file.
|
* except according to the terms contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
@@ -26,9 +27,11 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/utsname.h>
|
#include <strings.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <utmp.h>
|
||||||
|
|
||||||
#include "broadcast.h"
|
#include "broadcast.h"
|
||||||
#include "einfo.h"
|
#include "einfo.h"
|
||||||
@@ -167,13 +170,13 @@ static void sleep_no_interrupt(int seconds)
|
|||||||
duration = remaining;
|
duration = remaining;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stop_shutdown(int sig)
|
RC_NORETURN static void stop_shutdown(int sig)
|
||||||
{
|
{
|
||||||
(void) sig;
|
(void) sig;
|
||||||
unlink(nologin_file);
|
unlink(nologin_file);
|
||||||
unlink(shutdown_pid);
|
unlink(shutdown_pid);
|
||||||
einfo("Shutdown canceled");
|
einfo("Shutdown cancelled");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
|
|||||||
@@ -17,11 +17,10 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdlib.h>
|
#include <stddef.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "einfo.h"
|
#include "einfo.h"
|
||||||
#include "sysvinit.h"
|
#include "sysvinit.h"
|
||||||
|
|||||||
@@ -6,12 +6,3 @@ executable('openrc',
|
|||||||
include_directories: [incdir, einfo_incdir, rc_incdir],
|
include_directories: [incdir, einfo_incdir, rc_incdir],
|
||||||
install: true,
|
install: true,
|
||||||
install_dir: sbindir)
|
install_dir: sbindir)
|
||||||
|
|
||||||
executable('rc',
|
|
||||||
['rc.c', 'rc-logger.c', misc_c, plugin_c, usage_c, version_h],
|
|
||||||
c_args : cc_branding_flags,
|
|
||||||
link_with: [libeinfo, librc],
|
|
||||||
dependencies: [dl_dep, util_dep],
|
|
||||||
include_directories: [incdir, einfo_incdir, rc_incdir],
|
|
||||||
install: true,
|
|
||||||
install_dir: sbindir)
|
|
||||||
|
|||||||
@@ -16,10 +16,7 @@
|
|||||||
* except according to the terms contained in the LICENSE file.
|
* except according to the terms contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <errno.h>
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
@@ -27,6 +24,9 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -42,9 +42,9 @@
|
|||||||
|
|
||||||
#include "einfo.h"
|
#include "einfo.h"
|
||||||
#include "rc-logger.h"
|
#include "rc-logger.h"
|
||||||
#include "queue.h"
|
|
||||||
#include "rc.h"
|
#include "rc.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
#include "helpers.h"
|
||||||
|
|
||||||
#define TMPLOG RC_SVCDIR "/rc.log"
|
#define TMPLOG RC_SVCDIR "/rc.log"
|
||||||
#define DEFAULTLOG "/var/log/rc.log"
|
#define DEFAULTLOG "/var/log/rc.log"
|
||||||
|
|||||||
@@ -13,6 +13,9 @@
|
|||||||
#ifndef RC_LOGGER_H
|
#ifndef RC_LOGGER_H
|
||||||
#define RC_LOGGER_H
|
#define RC_LOGGER_H
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
extern pid_t rc_logger_pid;
|
extern pid_t rc_logger_pid;
|
||||||
extern int rc_logger_tty;
|
extern int rc_logger_tty;
|
||||||
extern bool rc_in_logger;
|
extern bool rc_in_logger;
|
||||||
|
|||||||
114
src/openrc/rc.c
114
src/openrc/rc.c
@@ -20,26 +20,21 @@
|
|||||||
* except according to the terms contained in the LICENSE file.
|
* except according to the terms contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <sys/param.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/utsname.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <ctype.h>
|
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
#include <limits.h>
|
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <strings.h>
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/utsname.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
@@ -49,9 +44,9 @@
|
|||||||
#include "rc-logger.h"
|
#include "rc-logger.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
|
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include "_usage.h"
|
#include "_usage.h"
|
||||||
|
#include "helpers.h"
|
||||||
|
|
||||||
const char *extraopts = NULL;
|
const char *extraopts = NULL;
|
||||||
const char getoptstring[] = "a:no:s:S" getoptstring_COMMON;
|
const char getoptstring[] = "a:no:s:S" getoptstring_COMMON;
|
||||||
@@ -92,6 +87,7 @@ static RC_HOOK hook_out;
|
|||||||
struct termios *termios_orig = NULL;
|
struct termios *termios_orig = NULL;
|
||||||
|
|
||||||
RC_PIDLIST service_pids;
|
RC_PIDLIST service_pids;
|
||||||
|
RC_PIDLIST free_these_pids;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clean_failed(void)
|
clean_failed(void)
|
||||||
@@ -121,8 +117,7 @@ clean_failed(void)
|
|||||||
static void
|
static void
|
||||||
cleanup(void)
|
cleanup(void)
|
||||||
{
|
{
|
||||||
RC_PID *p1 = LIST_FIRST(&service_pids);
|
RC_PID *p, *tmp;
|
||||||
RC_PID *p2;
|
|
||||||
|
|
||||||
if (!rc_in_logger && !rc_in_plugin &&
|
if (!rc_in_logger && !rc_in_plugin &&
|
||||||
applet && (strcmp(applet, "rc") == 0 || strcmp(applet, "openrc") == 0))
|
applet && (strcmp(applet, "rc") == 0 || strcmp(applet, "openrc") == 0))
|
||||||
@@ -144,10 +139,13 @@ cleanup(void)
|
|||||||
rc_logger_close();
|
rc_logger_close();
|
||||||
}
|
}
|
||||||
|
|
||||||
while (p1) {
|
LIST_FOREACH_SAFE(p, &service_pids, entries, tmp) {
|
||||||
p2 = LIST_NEXT(p1, entries);
|
LIST_REMOVE(p, entries);
|
||||||
free(p1);
|
free(p);
|
||||||
p1 = p2;
|
}
|
||||||
|
LIST_FOREACH_SAFE(p, &free_these_pids, entries, tmp) {
|
||||||
|
LIST_REMOVE(p, entries);
|
||||||
|
free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
rc_stringlist_free(main_hotplugged_services);
|
rc_stringlist_free(main_hotplugged_services);
|
||||||
@@ -349,22 +347,46 @@ static char *get_krunlevel(void)
|
|||||||
static void
|
static void
|
||||||
add_pid(pid_t pid)
|
add_pid(pid_t pid)
|
||||||
{
|
{
|
||||||
|
sigset_t sset, old;
|
||||||
RC_PID *p = xmalloc(sizeof(*p));
|
RC_PID *p = xmalloc(sizeof(*p));
|
||||||
p->pid = pid;
|
p->pid = pid;
|
||||||
|
|
||||||
|
/* this list will be accessed inside the SIGCHLD signal handler.
|
||||||
|
* so we need to ensure that the SIGCHLD handler doesn't get invoked
|
||||||
|
* while the list is at an inconsistent state.
|
||||||
|
*/
|
||||||
|
sigemptyset(&sset);
|
||||||
|
sigaddset(&sset, SIGCHLD);
|
||||||
|
sigprocmask(SIG_SETMASK, &sset, &old);
|
||||||
LIST_INSERT_HEAD(&service_pids, p, entries);
|
LIST_INSERT_HEAD(&service_pids, p, entries);
|
||||||
|
sigprocmask(SIG_SETMASK, &old, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
remove_pid(pid_t pid)
|
remove_pid(pid_t pid, bool inside_signal)
|
||||||
{
|
{
|
||||||
RC_PID *p;
|
sigset_t sset, old;
|
||||||
|
RC_PID *p, *tmp;
|
||||||
|
|
||||||
LIST_FOREACH(p, &service_pids, entries)
|
/* same rationale for blocking SIGCHLD as add_pid() */
|
||||||
if (p->pid == pid) {
|
sigemptyset(&sset);
|
||||||
LIST_REMOVE(p, entries);
|
sigaddset(&sset, SIGCHLD);
|
||||||
free(p);
|
sigprocmask(SIG_SETMASK, &sset, &old);
|
||||||
return;
|
LIST_FOREACH(p, &service_pids, entries) {
|
||||||
}
|
if (p->pid == pid) {
|
||||||
|
LIST_REMOVE(p, entries);
|
||||||
|
LIST_INSERT_HEAD(&free_these_pids, p, entries);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* only call free if we're not inside a signal handler */
|
||||||
|
if (!inside_signal) {
|
||||||
|
LIST_FOREACH_SAFE(p, &free_these_pids, entries, tmp) {
|
||||||
|
LIST_REMOVE(p, entries);
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sigprocmask(SIG_SETMASK, &old, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -382,7 +404,7 @@ static void
|
|||||||
handle_signal(int sig)
|
handle_signal(int sig)
|
||||||
{
|
{
|
||||||
int serrno = errno;
|
int serrno = errno;
|
||||||
char *signame = NULL;
|
const char *signame = NULL;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
RC_PID *pi;
|
RC_PID *pi;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
@@ -402,7 +424,7 @@ handle_signal(int sig)
|
|||||||
|
|
||||||
/* Remove that pid from our list */
|
/* Remove that pid from our list */
|
||||||
if (pid > 0)
|
if (pid > 0)
|
||||||
remove_pid(pid);
|
remove_pid(pid, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SIGWINCH:
|
case SIGWINCH:
|
||||||
@@ -414,15 +436,15 @@ handle_signal(int sig)
|
|||||||
|
|
||||||
case SIGINT:
|
case SIGINT:
|
||||||
if (!signame)
|
if (!signame)
|
||||||
xasprintf(&signame, "SIGINT");
|
signame = "SIGINT";
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
if (!signame)
|
if (!signame)
|
||||||
xasprintf(&signame, "SIGTERM");
|
signame = "SIGTERM";
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
case SIGQUIT:
|
case SIGQUIT:
|
||||||
if (!signame)
|
if (!signame)
|
||||||
xasprintf(&signame, "SIGQUIT");
|
signame = "SIGQUIT";
|
||||||
eerrorx("%s: caught %s, aborting", applet, signame);
|
eerrorx("%s: caught %s, aborting", applet, signame);
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
case SIGUSR1:
|
case SIGUSR1:
|
||||||
@@ -451,33 +473,12 @@ handle_signal(int sig)
|
|||||||
errno = serrno;
|
errno = serrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
do_early_hostname(void)
|
|
||||||
{
|
|
||||||
#ifdef __linux__
|
|
||||||
/* Set hostname if available */
|
|
||||||
char *buffer = NULL;
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
if (rc_getfile(RC_SYSCONFDIR "/hostname", &buffer, &len)) {
|
|
||||||
if (buffer[len - 2] == '\n')
|
|
||||||
buffer[--len - 1] = '\0';
|
|
||||||
if (sethostname(buffer, len)) {
|
|
||||||
/* ignore */;
|
|
||||||
}
|
|
||||||
free(buffer);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_sysinit(void)
|
do_sysinit(void)
|
||||||
{
|
{
|
||||||
struct utsname uts;
|
struct utsname uts;
|
||||||
const char *sys;
|
const char *sys;
|
||||||
|
|
||||||
do_early_hostname();
|
|
||||||
|
|
||||||
/* exec init-early.sh if it exists
|
/* exec init-early.sh if it exists
|
||||||
* This should just setup the console to use the correct
|
* This should just setup the console to use the correct
|
||||||
* font. Maybe it should setup the keyboard too? */
|
* font. Maybe it should setup the keyboard too? */
|
||||||
@@ -526,7 +527,7 @@ runlevel_config(const char *service, const char *level)
|
|||||||
char *conf, *dir;
|
char *conf, *dir;
|
||||||
bool retval;
|
bool retval;
|
||||||
|
|
||||||
dir = dirname(init);
|
dir = dirname(dirname(init));
|
||||||
xasprintf(&conf, "%s/conf.d/%s.%s", dir, service, level);
|
xasprintf(&conf, "%s/conf.d/%s.%s", dir, service, level);
|
||||||
retval = exists(conf);
|
retval = exists(conf);
|
||||||
free(conf);
|
free(conf);
|
||||||
@@ -632,7 +633,7 @@ stop:
|
|||||||
add_pid(pid);
|
add_pid(pid);
|
||||||
if (!parallel) {
|
if (!parallel) {
|
||||||
rc_waitpid(pid);
|
rc_waitpid(pid);
|
||||||
remove_pid(pid);
|
remove_pid(pid, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -698,7 +699,7 @@ do_start_services(const RC_STRINGLIST *start_services, bool parallel)
|
|||||||
add_pid(pid);
|
add_pid(pid);
|
||||||
if (!parallel) {
|
if (!parallel) {
|
||||||
rc_waitpid(pid);
|
rc_waitpid(pid);
|
||||||
remove_pid(pid);
|
remove_pid(pid, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -716,7 +717,7 @@ do_start_services(const RC_STRINGLIST *start_services, bool parallel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RC_DEBUG
|
#ifdef RC_DEBUG
|
||||||
static void
|
RC_NORETURN static void
|
||||||
handle_bad_signal(int sig)
|
handle_bad_signal(int sig)
|
||||||
{
|
{
|
||||||
char pid[10];
|
char pid[10];
|
||||||
@@ -771,6 +772,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
applet = basename_c(argv[0]);
|
applet = basename_c(argv[0]);
|
||||||
LIST_INIT(&service_pids);
|
LIST_INIT(&service_pids);
|
||||||
|
LIST_INIT(&free_these_pids);
|
||||||
atexit(cleanup);
|
atexit(cleanup);
|
||||||
if (!applet)
|
if (!applet)
|
||||||
eerrorx("arguments required");
|
eerrorx("arguments required");
|
||||||
@@ -835,8 +837,6 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(applet, "rc") == 0)
|
|
||||||
ewarn("rc is deprecated, please use openrc instead.");
|
|
||||||
newlevel = argv[optind++];
|
newlevel = argv[optind++];
|
||||||
/* To make life easier, we only have the shutdown runlevel as
|
/* To make life easier, we only have the shutdown runlevel as
|
||||||
* nothing really needs to know that we're rebooting.
|
* nothing really needs to know that we're rebooting.
|
||||||
|
|||||||
@@ -10,20 +10,11 @@
|
|||||||
* except according to the terms contained in the LICENSE file.
|
* except according to the terms contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <ctype.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <syslog.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "einfo.h"
|
#include "einfo.h"
|
||||||
|
|
||||||
|
|||||||
@@ -15,27 +15,20 @@
|
|||||||
* except according to the terms contained in the LICENSE file.
|
* except according to the terms contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <limits.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <utime.h>
|
|
||||||
|
|
||||||
#include "einfo.h"
|
#include "einfo.h"
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "rc.h"
|
#include "rc.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "_usage.h"
|
#include "_usage.h"
|
||||||
|
#include "helpers.h"
|
||||||
|
|
||||||
const char *applet = NULL;
|
const char *applet = NULL;
|
||||||
const char *extraopts = NULL;
|
const char *extraopts = NULL;
|
||||||
|
|||||||
@@ -15,7 +15,9 @@
|
|||||||
* except according to the terms contained in the LICENSE file.
|
* except according to the terms contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -24,8 +26,8 @@
|
|||||||
#include "einfo.h"
|
#include "einfo.h"
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "rc.h"
|
#include "rc.h"
|
||||||
#include "misc.h"
|
|
||||||
#include "_usage.h"
|
#include "_usage.h"
|
||||||
|
#include "helpers.h"
|
||||||
|
|
||||||
const char *applet = NULL;
|
const char *applet = NULL;
|
||||||
const char *extraopts = NULL;
|
const char *extraopts = NULL;
|
||||||
|
|||||||
@@ -16,17 +16,21 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <strings.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include "einfo.h"
|
#include "einfo.h"
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "rc.h"
|
#include "rc.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "_usage.h"
|
#include "_usage.h"
|
||||||
|
#include "helpers.h"
|
||||||
|
|
||||||
enum format_t {
|
enum format_t {
|
||||||
FORMAT_DEFAULT,
|
FORMAT_DEFAULT,
|
||||||
@@ -61,8 +65,8 @@ const char * const longopts_help[] = {
|
|||||||
longopts_help_COMMON
|
longopts_help_COMMON
|
||||||
};
|
};
|
||||||
const char *usagestring = "" \
|
const char *usagestring = "" \
|
||||||
"Usage: rc-status [options] -f ini <runlevel>...\n" \
|
"Usage: rc-status [options] [-f ini] <runlevel>...\n" \
|
||||||
" or: rc-status [options] [-a | -c | -l | -m | -r | -s | -u]";
|
" or: rc-status [options] [-f ini] [-a | -c | -l | -m | -r | -s | -u]";
|
||||||
|
|
||||||
static RC_DEPTREE *deptree;
|
static RC_DEPTREE *deptree;
|
||||||
static RC_STRINGLIST *types;
|
static RC_STRINGLIST *types;
|
||||||
@@ -293,6 +297,7 @@ int main(int argc, char **argv)
|
|||||||
TAILQ_FOREACH(l, levels, entries)
|
TAILQ_FOREACH(l, levels, entries)
|
||||||
printf("%s\n", l->value);
|
printf("%s\n", l->value);
|
||||||
goto exit;
|
goto exit;
|
||||||
|
/* NOTREACHED */
|
||||||
case 'm':
|
case 'm':
|
||||||
services = rc_services_in_runlevel(NULL);
|
services = rc_services_in_runlevel(NULL);
|
||||||
levels = rc_runlevel_list();
|
levels = rc_runlevel_list();
|
||||||
@@ -312,8 +317,9 @@ int main(int argc, char **argv)
|
|||||||
free(s->value);
|
free(s->value);
|
||||||
free(s);
|
free(s);
|
||||||
}
|
}
|
||||||
print_services(NULL, services, FORMAT_DEFAULT);
|
print_services(NULL, services, format);
|
||||||
goto exit;
|
goto exit;
|
||||||
|
/* NOTREACHED */
|
||||||
case 'r':
|
case 'r':
|
||||||
runlevel = rc_runlevel_get();
|
runlevel = rc_runlevel_get();
|
||||||
printf("%s\n", runlevel);
|
printf("%s\n", runlevel);
|
||||||
@@ -324,12 +330,12 @@ int main(int argc, char **argv)
|
|||||||
TAILQ_FOREACH_SAFE(s, services, entries, t)
|
TAILQ_FOREACH_SAFE(s, services, entries, t)
|
||||||
if (!rc_service_value_get(s->value, "child_pid"))
|
if (!rc_service_value_get(s->value, "child_pid"))
|
||||||
TAILQ_REMOVE(services, s, entries);
|
TAILQ_REMOVE(services, s, entries);
|
||||||
print_services(NULL, services, FORMAT_DEFAULT);
|
print_services(NULL, services, format);
|
||||||
goto exit;
|
goto exit;
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
case 's':
|
case 's':
|
||||||
services = rc_services_in_runlevel(NULL);
|
services = rc_services_in_runlevel(NULL);
|
||||||
print_services(NULL, services, FORMAT_DEFAULT);
|
print_services(NULL, services, format);
|
||||||
goto exit;
|
goto exit;
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
case 'u':
|
case 'u':
|
||||||
@@ -344,7 +350,7 @@ int main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print_services(NULL, services, FORMAT_DEFAULT);
|
print_services(NULL, services, format);
|
||||||
goto exit;
|
goto exit;
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
|
|
||||||
@@ -444,6 +450,7 @@ int main(int argc, char **argv)
|
|||||||
* be added to the list
|
* be added to the list
|
||||||
*/
|
*/
|
||||||
unsetenv("RC_SVCNAME");
|
unsetenv("RC_SVCNAME");
|
||||||
|
|
||||||
print_level("Dynamic", "needed/wanted", format);
|
print_level("Dynamic", "needed/wanted", format);
|
||||||
print_services(NULL, nservices, format);
|
print_services(NULL, nservices, format);
|
||||||
print_level("Dynamic", "manual", format);
|
print_level("Dynamic", "manual", format);
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <limits.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -29,6 +28,7 @@
|
|||||||
#include "rc.h"
|
#include "rc.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "_usage.h"
|
#include "_usage.h"
|
||||||
|
#include "helpers.h"
|
||||||
|
|
||||||
const char *applet = NULL;
|
const char *applet = NULL;
|
||||||
const char *extraopts = NULL;
|
const char *extraopts = NULL;
|
||||||
@@ -88,7 +88,7 @@ delete(const char *runlevel, const char *service)
|
|||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
if (rc_service_delete(runlevel, service)) {
|
if (rc_service_delete(runlevel, service)) {
|
||||||
einfo("service %s removed from runlevel %s",
|
einfo("service %s deleted from runlevel %s",
|
||||||
service, runlevel);
|
service, runlevel);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ delete(const char *runlevel, const char *service)
|
|||||||
eerror("%s: service `%s' is not in the runlevel `%s'",
|
eerror("%s: service `%s' is not in the runlevel `%s'",
|
||||||
applet, service, runlevel);
|
applet, service, runlevel);
|
||||||
else
|
else
|
||||||
eerror("%s: failed to remove service `%s' from runlevel `%s': %s",
|
eerror("%s: failed to delete service `%s' from runlevel `%s': %s",
|
||||||
applet, service, runlevel, strerror (errno));
|
applet, service, runlevel, strerror (errno));
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
@@ -144,7 +144,7 @@ static int
|
|||||||
delstack(const char *runlevel, const char *stack)
|
delstack(const char *runlevel, const char *stack)
|
||||||
{
|
{
|
||||||
if (rc_runlevel_unstack(runlevel, stack)) {
|
if (rc_runlevel_unstack(runlevel, stack)) {
|
||||||
einfo("runlevel %s removed from runlevel %s", stack, runlevel);
|
einfo("runlevel %s deleted from runlevel %s", stack, runlevel);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,7 +152,7 @@ delstack(const char *runlevel, const char *stack)
|
|||||||
eerror("%s: runlevel `%s' is not in the runlevel `%s'",
|
eerror("%s: runlevel `%s' is not in the runlevel `%s'",
|
||||||
applet, stack, runlevel);
|
applet, stack, runlevel);
|
||||||
else
|
else
|
||||||
eerror("%s: failed to remove runlevel `%s' from runlevel `%s': %s",
|
eerror("%s: failed to delete runlevel `%s' from runlevel `%s': %s",
|
||||||
applet, stack, runlevel, strerror (errno));
|
applet, stack, runlevel, strerror (errno));
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2022 The OpenRC Authors.
|
* Copyright (c) 2022-2023 The OpenRC Authors.
|
||||||
* See the Authors file at the top-level directory of this distribution and
|
* See the Authors file at the top-level directory of this distribution and
|
||||||
* https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS
|
* https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS
|
||||||
*
|
*
|
||||||
@@ -30,12 +30,12 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <endian.h>
|
#include <endian.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "rc.h"
|
|
||||||
#include "einfo.h"
|
#include "einfo.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
#include "_usage.h"
|
#include "_usage.h"
|
||||||
@@ -455,7 +455,7 @@ int main(int argc, char **argv)
|
|||||||
static const char seedrng_prefix[] = "SeedRNG v1 Old+New Prefix";
|
static const char seedrng_prefix[] = "SeedRNG v1 Old+New Prefix";
|
||||||
static const char seedrng_failure[] = "SeedRNG v1 No New Seed Failure";
|
static const char seedrng_failure[] = "SeedRNG v1 No New Seed Failure";
|
||||||
int opt, fd, dfd, program_ret = 0;
|
int opt, fd, dfd, program_ret = 0;
|
||||||
char *seed_dir = NULL;
|
const char *seed_dir = NULL;
|
||||||
uint8_t new_seed[MAX_SEED_LEN];
|
uint8_t new_seed[MAX_SEED_LEN];
|
||||||
size_t new_seed_len;
|
size_t new_seed_len;
|
||||||
bool new_seed_creditable;
|
bool new_seed_creditable;
|
||||||
@@ -470,7 +470,7 @@ int main(int argc, char **argv)
|
|||||||
switch (opt) {
|
switch (opt) {
|
||||||
case LONGOPT_SEED_DIR:
|
case LONGOPT_SEED_DIR:
|
||||||
if (!seed_dir)
|
if (!seed_dir)
|
||||||
seed_dir = xstrdup(optarg);
|
seed_dir = optarg;
|
||||||
break;
|
break;
|
||||||
case LONGOPT_SKIP_CREDIT:
|
case LONGOPT_SKIP_CREDIT:
|
||||||
skip_credit = true;
|
skip_credit = true;
|
||||||
@@ -479,7 +479,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!seed_dir)
|
if (!seed_dir)
|
||||||
seed_dir = xstrdup(DEFAULT_SEED_DIR);
|
seed_dir = DEFAULT_SEED_DIR;
|
||||||
if (getuid())
|
if (getuid())
|
||||||
eerrorx("%s: superuser access is required", applet);
|
eerrorx("%s: superuser access is required", applet);
|
||||||
umask(0077);
|
umask(0077);
|
||||||
|
|||||||
@@ -10,24 +10,16 @@
|
|||||||
* except according to the terms contained in the LICENSE file.
|
* except according to the terms contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <ctype.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <signal.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <syslog.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "einfo.h"
|
#include "einfo.h"
|
||||||
#include "rc.h"
|
#include "rc.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
#include "helpers.h"
|
||||||
|
|
||||||
const char *applet = NULL;
|
const char *applet = NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -13,19 +13,13 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "rc.h"
|
#include "rc.h"
|
||||||
#include "misc.h"
|
|
||||||
#include "_usage.h"
|
#include "_usage.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
#include "helpers.h"
|
||||||
|
|
||||||
#if lint
|
|
||||||
# define _noreturn
|
|
||||||
#endif
|
|
||||||
#if __GNUC__ > 2 || defined(__INTEL_COMPILER)
|
|
||||||
# define _noreturn __attribute__ ((__noreturn__))
|
|
||||||
#else
|
|
||||||
# define _noreturn
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void set_quiet_options(void)
|
void set_quiet_options(void)
|
||||||
{
|
{
|
||||||
@@ -42,7 +36,7 @@ void set_quiet_options(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_noreturn void show_version(void)
|
RC_NORETURN void show_version(void)
|
||||||
{
|
{
|
||||||
const char *systype = NULL;
|
const char *systype = NULL;
|
||||||
|
|
||||||
@@ -57,7 +51,7 @@ _noreturn void show_version(void)
|
|||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
_noreturn void usage(int exit_status)
|
RC_NORETURN void usage(int exit_status)
|
||||||
{
|
{
|
||||||
const char * const has_arg[] = { "", "<arg>", "[arg]" };
|
const char * const has_arg[] = { "", "<arg>", "[arg]" };
|
||||||
int i;
|
int i;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define getoptstring_COMMON "ChqVv"
|
#define getoptstring_COMMON "ChqVv"
|
||||||
|
|
||||||
|
|||||||
@@ -18,29 +18,27 @@
|
|||||||
#ifndef __HELPERS_H__
|
#ifndef __HELPERS_H__
|
||||||
#define __HELPERS_H__
|
#define __HELPERS_H__
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#define ERRX fprintf (stderr, "out of memory\n"); exit (1)
|
#define ERRX fprintf (stderr, "out of memory\n"); exit (1)
|
||||||
|
|
||||||
#define UNCONST(a) ((void *)(unsigned long)(const void *)(a))
|
#define UNCONST(a) ((void *)(uintptr_t)(const void *)(a))
|
||||||
|
|
||||||
#ifdef lint
|
#define RC_UNUSED __attribute__((__unused__))
|
||||||
# define _unused
|
#define RC_NORETURN __attribute__((__noreturn__))
|
||||||
#endif
|
#define RC_PRINTF(a, b) __attribute__((__format__(__printf__, a, b)))
|
||||||
#if __GNUC__ > 2 || defined(__INTEL_COMPILER)
|
|
||||||
# define _dead __attribute__((__noreturn__))
|
|
||||||
# define _unused __attribute__((__unused__))
|
|
||||||
# define _xasprintf(a, b) __attribute__((__format__(__printf__, a, b)))
|
|
||||||
#else
|
|
||||||
# define _dead
|
|
||||||
# define _unused
|
|
||||||
# define _xasprintf(a, b)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
||||||
|
|
||||||
#ifdef __GLIBC__
|
#ifndef HAVE_STRLCPY
|
||||||
# if !defined (__UCLIBC__) && !defined (__dietlibc__)
|
|
||||||
# define strlcpy(dst, src, size) snprintf(dst, size, "%s", src)
|
# define strlcpy(dst, src, size) snprintf(dst, size, "%s", src)
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef timespecsub
|
#ifndef timespecsub
|
||||||
@@ -55,11 +53,7 @@
|
|||||||
} while (/* CONSTCOND */ 0)
|
} while (/* CONSTCOND */ 0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdarg.h>
|
RC_UNUSED static void *xmalloc (size_t size)
|
||||||
#include <stdbool.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
|
|
||||||
_unused static void *xmalloc (size_t size)
|
|
||||||
{
|
{
|
||||||
void *value = malloc(size);
|
void *value = malloc(size);
|
||||||
|
|
||||||
@@ -70,7 +64,7 @@ _unused static void *xmalloc (size_t size)
|
|||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
_unused static void *xrealloc(void *ptr, size_t size)
|
RC_UNUSED static void *xrealloc(void *ptr, size_t size)
|
||||||
{
|
{
|
||||||
void *value = realloc(ptr, size);
|
void *value = realloc(ptr, size);
|
||||||
|
|
||||||
@@ -81,7 +75,7 @@ _unused static void *xrealloc(void *ptr, size_t size)
|
|||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
_unused static char *xstrdup(const char *str)
|
RC_UNUSED static char *xstrdup(const char *str)
|
||||||
{
|
{
|
||||||
char *value;
|
char *value;
|
||||||
|
|
||||||
@@ -103,7 +97,7 @@ _unused static char *xstrdup(const char *str)
|
|||||||
* basename_c never modifies the argument. As such, if there is a trailing
|
* basename_c never modifies the argument. As such, if there is a trailing
|
||||||
* slash then an empty string is returned.
|
* slash then an empty string is returned.
|
||||||
*/
|
*/
|
||||||
_unused static const char *basename_c(const char *path)
|
RC_UNUSED static const char *basename_c(const char *path)
|
||||||
{
|
{
|
||||||
const char *slash = strrchr(path, '/');
|
const char *slash = strrchr(path, '/');
|
||||||
|
|
||||||
@@ -112,14 +106,14 @@ _unused static const char *basename_c(const char *path)
|
|||||||
return (path);
|
return (path);
|
||||||
}
|
}
|
||||||
|
|
||||||
_unused static bool exists(const char *pathname)
|
RC_UNUSED static bool exists(const char *pathname)
|
||||||
{
|
{
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
|
|
||||||
return (stat(pathname, &buf) == 0);
|
return (stat(pathname, &buf) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
_unused static bool existss(const char *pathname)
|
RC_UNUSED static bool existss(const char *pathname)
|
||||||
{
|
{
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
|
|
||||||
@@ -129,12 +123,12 @@ _unused static bool existss(const char *pathname)
|
|||||||
/*
|
/*
|
||||||
* This is an OpenRC specific version of the asprintf() function.
|
* This is an OpenRC specific version of the asprintf() function.
|
||||||
* We do this to avoid defining the _GNU_SOURCE feature test macro on
|
* We do this to avoid defining the _GNU_SOURCE feature test macro on
|
||||||
* glibc systems and to insure that we have a consistent function across
|
* glibc systems and to ensure that we have a consistent function across
|
||||||
* platforms. This also allows us to call our xmalloc and xrealloc
|
* platforms. This also allows us to call our xmalloc and xrealloc
|
||||||
* functions to handle memory allocation.
|
* functions to handle memory allocation.
|
||||||
* this function was originally written by Mike Frysinger.
|
* this function was originally written by Mike Frysinger.
|
||||||
*/
|
*/
|
||||||
_unused _xasprintf(2,3) static int xasprintf(char **strp, const char *fmt, ...)
|
RC_UNUSED RC_PRINTF(2,3) static int xasprintf(char **strp, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int len;
|
int len;
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ schedules_c = files([
|
|||||||
'schedules.c',
|
'schedules.c',
|
||||||
])
|
])
|
||||||
|
|
||||||
|
pipes_c = files([
|
||||||
|
'pipes.c',
|
||||||
|
])
|
||||||
|
|
||||||
if selinux_dep.found()
|
if selinux_dep.found()
|
||||||
selinux_c = files([
|
selinux_c = files([
|
||||||
'selinux.c',
|
'selinux.c',
|
||||||
|
|||||||
@@ -15,22 +15,30 @@
|
|||||||
* except according to the terms contained in the LICENSE file.
|
* except according to the terms contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/file.h>
|
#ifdef HAVE_CLOSE_RANGE
|
||||||
#include <sys/types.h>
|
/* For close_range() */
|
||||||
#include <sys/utsname.h>
|
# define _GNU_SOURCE
|
||||||
|
|
||||||
#ifdef __linux__
|
|
||||||
# include <sys/sysinfo.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#ifdef HAVE_LINUX_CLOSE_RANGE_H
|
||||||
|
# include <linux/close_range.h>
|
||||||
|
#endif
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sys/file.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#ifdef __linux__
|
||||||
|
# include <sys/syscall.h> /* for close_range */
|
||||||
|
# include <sys/sysinfo.h>
|
||||||
|
#endif
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/utsname.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <utime.h>
|
#include <utime.h>
|
||||||
@@ -40,6 +48,7 @@
|
|||||||
#include "rc.h"
|
#include "rc.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
#include "helpers.h"
|
||||||
|
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
|
||||||
@@ -234,7 +243,7 @@ signal_setup_restart(int sig, void (*handler)(int))
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
svc_lock(const char *applet)
|
svc_lock(const char *applet, bool ignore_lock_failure)
|
||||||
{
|
{
|
||||||
char *file = NULL;
|
char *file = NULL;
|
||||||
int fd;
|
int fd;
|
||||||
@@ -245,6 +254,14 @@ svc_lock(const char *applet)
|
|||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
return -1;
|
return -1;
|
||||||
if (flock(fd, LOCK_EX | LOCK_NB) == -1) {
|
if (flock(fd, LOCK_EX | LOCK_NB) == -1) {
|
||||||
|
if (ignore_lock_failure) {
|
||||||
|
/* Two services with a need b, and b's start()
|
||||||
|
* calling restart --no-deps on a would cause
|
||||||
|
* harmless errors: just ignore them.
|
||||||
|
* See https://github.com/OpenRC/openrc/issues/224
|
||||||
|
*/
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
eerror("Call to flock failed: %s", strerror(errno));
|
eerror("Call to flock failed: %s", strerror(errno));
|
||||||
close(fd);
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -274,7 +291,7 @@ exec_service(const char *service, const char *arg)
|
|||||||
sigset_t old;
|
sigset_t old;
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
|
|
||||||
fd = svc_lock(basename_c(service));
|
fd = svc_lock(basename_c(service), false);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@@ -492,3 +509,30 @@ pid_t get_pid(const char *applet,const char *pidfile)
|
|||||||
|
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef HAVE_CLOSE_RANGE
|
||||||
|
static inline int close_range(int first RC_UNUSED,
|
||||||
|
int last RC_UNUSED,
|
||||||
|
unsigned int flags RC_UNUSED)
|
||||||
|
{
|
||||||
|
#ifdef SYS_close_range
|
||||||
|
return syscall(SYS_close_range, first, last, flags);
|
||||||
|
#else
|
||||||
|
errno = ENOSYS;
|
||||||
|
return -1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifndef CLOSE_RANGE_CLOEXEC
|
||||||
|
# define CLOSE_RANGE_CLOEXEC (1U << 2)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void
|
||||||
|
cloexec_fds_from(int first)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
if (close_range(first, UINT_MAX, CLOSE_RANGE_CLOEXEC) < 0) {
|
||||||
|
for (i = getdtablesize() - 1; i >= first; --i)
|
||||||
|
fcntl(i, F_SETFD, FD_CLOEXEC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#define __RC_MISC_H__
|
#define __RC_MISC_H__
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -27,6 +28,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
#include "rc.h"
|
||||||
|
|
||||||
#define RC_LEVEL_BOOT "boot"
|
#define RC_LEVEL_BOOT "boot"
|
||||||
#define RC_LEVEL_DEFAULT "default"
|
#define RC_LEVEL_DEFAULT "default"
|
||||||
@@ -48,7 +50,7 @@ void env_filter(void);
|
|||||||
void env_config(void);
|
void env_config(void);
|
||||||
int signal_setup(int sig, void (*handler)(int));
|
int signal_setup(int sig, void (*handler)(int));
|
||||||
int signal_setup_restart(int sig, void (*handler)(int));
|
int signal_setup_restart(int sig, void (*handler)(int));
|
||||||
int svc_lock(const char *);
|
int svc_lock(const char *, bool);
|
||||||
int svc_unlock(const char *, int);
|
int svc_unlock(const char *, int);
|
||||||
pid_t exec_service(const char *, const char *);
|
pid_t exec_service(const char *, const char *);
|
||||||
|
|
||||||
@@ -71,4 +73,6 @@ void from_time_t(char *time_string, time_t tv);
|
|||||||
time_t to_time_t(char *timestring);
|
time_t to_time_t(char *timestring);
|
||||||
pid_t get_pid(const char *applet, const char *pidfile);
|
pid_t get_pid(const char *applet, const char *pidfile);
|
||||||
|
|
||||||
|
void cloexec_fds_from(int);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -16,8 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "pipes.h"
|
#include "pipes.h"
|
||||||
|
|
||||||
@@ -17,12 +17,10 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <limits.h>
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -32,8 +30,8 @@
|
|||||||
#include "einfo.h"
|
#include "einfo.h"
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "rc.h"
|
#include "rc.h"
|
||||||
#include "misc.h"
|
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
|
#include "helpers.h"
|
||||||
|
|
||||||
#define RC_PLUGIN_HOOK "rc_plugin_hook"
|
#define RC_PLUGIN_HOOK "rc_plugin_hook"
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,11 @@
|
|||||||
#ifndef __LIBRC_PLUGIN_H__
|
#ifndef __LIBRC_PLUGIN_H__
|
||||||
#define __LIBRC_PLUGIN_H__
|
#define __LIBRC_PLUGIN_H__
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "rc.h"
|
||||||
|
|
||||||
/* A simple flag to say if we're in a plugin process or not.
|
/* A simple flag to say if we're in a plugin process or not.
|
||||||
* Mainly used in atexit code. */
|
* Mainly used in atexit code. */
|
||||||
extern bool rc_in_plugin;
|
extern bool rc_in_plugin;
|
||||||
|
|||||||
@@ -30,16 +30,11 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
|
||||||
|
|
||||||
#include "einfo.h"
|
#include "einfo.h"
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "rc.h"
|
#include "rc.h"
|
||||||
#include "misc.h"
|
|
||||||
#include "schedules.h"
|
#include "schedules.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,9 @@
|
|||||||
#ifndef __RC_SCHEDULES_H
|
#ifndef __RC_SCHEDULES_H
|
||||||
#define __RC_SCHEDULES_H
|
#define __RC_SCHEDULES_H
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
void free_schedulelist(void);
|
void free_schedulelist(void);
|
||||||
int parse_signal(const char *applet, const char *sig);
|
int parse_signal(const char *applet, const char *sig);
|
||||||
void parse_schedule(const char *applet, const char *string, int timeout);
|
void parse_schedule(const char *applet, const char *string, int timeout);
|
||||||
|
|||||||
@@ -15,14 +15,12 @@
|
|||||||
* except according to the terms contained in the LICENSE file.
|
* except according to the terms contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
|
#include <utmp.h>
|
||||||
|
|
||||||
#include "wtmp.h"
|
#include "wtmp.h"
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#define __RC_WTMP_H__
|
#define __RC_WTMP_H__
|
||||||
|
|
||||||
#include <utmp.h>
|
#include <utmp.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
void log_wtmp(const char *user, const char *id, pid_t pid, int type,
|
void log_wtmp(const char *user, const char *id, pid_t pid, int type,
|
||||||
const char *line);
|
const char *line);
|
||||||
|
|||||||
@@ -10,14 +10,9 @@
|
|||||||
* except according to the terms contained in the LICENSE file.
|
* except according to the terms contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
executable('start-stop-daemon',
|
executable('start-stop-daemon',
|
||||||
['start-stop-daemon.c', 'pipes.c', misc_c, schedules_c,
|
['start-stop-daemon.c', pipes_c, misc_c, schedules_c,
|
||||||
selinux_c, usage_c, version_h],
|
selinux_c, usage_c, version_h],
|
||||||
c_args : [cc_audit_flags, cc_branding_flags, cc_pam_flags, cc_cap_flags, cc_selinux_flags],
|
c_args : [cc_audit_flags, cc_branding_flags, cc_pam_flags, cc_cap_flags, cc_selinux_flags],
|
||||||
link_with: [libeinfo, librc],
|
link_with: [libeinfo, librc],
|
||||||
|
|||||||
@@ -26,47 +26,44 @@
|
|||||||
# define _GNU_SOURCE
|
# define _GNU_SOURCE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <sys/resource.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <termios.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
|
|
||||||
#ifdef __linux__
|
|
||||||
#include <sys/syscall.h> /* For io priority */
|
|
||||||
#include <sys/prctl.h> /* For prctl */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
|
#include <sched.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#ifdef __linux__
|
||||||
|
# include <sys/syscall.h> /* For io priority */
|
||||||
|
# include <sys/prctl.h> /* For prctl */
|
||||||
|
#endif
|
||||||
|
#include <termios.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#ifdef HAVE_PAM
|
#ifdef HAVE_PAM
|
||||||
#include <security/pam_appl.h>
|
# include <security/pam_appl.h>
|
||||||
|
|
||||||
/* We are not supporting authentication conversations */
|
/* We are not supporting authentication conversations */
|
||||||
static struct pam_conv conv = { NULL, NULL};
|
static struct pam_conv conv = { NULL, NULL};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CAP
|
#ifdef HAVE_CAP
|
||||||
#include <sys/capability.h>
|
# include <sys/capability.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sched.h>
|
|
||||||
|
|
||||||
#include "einfo.h"
|
#include "einfo.h"
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "rc.h"
|
#include "rc.h"
|
||||||
@@ -182,9 +179,9 @@ extern char **environ;
|
|||||||
# define SYS_ioprio_set __NR_ioprio_set
|
# define SYS_ioprio_set __NR_ioprio_set
|
||||||
#endif
|
#endif
|
||||||
#if !defined(__DragonFly__)
|
#if !defined(__DragonFly__)
|
||||||
static inline int ioprio_set(int which _unused,
|
static inline int ioprio_set(int which RC_UNUSED,
|
||||||
int who _unused,
|
int who RC_UNUSED,
|
||||||
int ioprio _unused)
|
int ioprio RC_UNUSED)
|
||||||
{
|
{
|
||||||
#ifdef SYS_ioprio_set
|
#ifdef SYS_ioprio_set
|
||||||
return syscall(SYS_ioprio_set, which, who, ioprio);
|
return syscall(SYS_ioprio_set, which, who, ioprio);
|
||||||
@@ -207,20 +204,20 @@ handle_signal(int sig)
|
|||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
int serrno = errno;
|
int serrno = errno;
|
||||||
char *signame = NULL;
|
const char *signame = NULL;
|
||||||
|
|
||||||
switch (sig) {
|
switch (sig) {
|
||||||
case SIGINT:
|
case SIGINT:
|
||||||
if (!signame)
|
if (!signame)
|
||||||
xasprintf(&signame, "SIGINT");
|
signame = "SIGINT";
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
if (!signame)
|
if (!signame)
|
||||||
xasprintf(&signame, "SIGTERM");
|
signame = "SIGTERM";
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
case SIGQUIT:
|
case SIGQUIT:
|
||||||
if (!signame)
|
if (!signame)
|
||||||
xasprintf(&signame, "SIGQUIT");
|
signame = "SIGQUIT";
|
||||||
eerrorx("%s: caught %s, aborting", applet, signame);
|
eerrorx("%s: caught %s, aborting", applet, signame);
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
|
|
||||||
@@ -239,9 +236,6 @@ handle_signal(int sig)
|
|||||||
eerror("%s: caught unknown signal %d", applet, sig);
|
eerror("%s: caught unknown signal %d", applet, sig);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* free signame */
|
|
||||||
free(signame);
|
|
||||||
|
|
||||||
/* Restore errno */
|
/* Restore errno */
|
||||||
errno = serrno;
|
errno = serrno;
|
||||||
}
|
}
|
||||||
@@ -1104,12 +1098,7 @@ int main(int argc, char **argv)
|
|||||||
|| rc_yesno(getenv("EINFO_QUIET")))
|
|| rc_yesno(getenv("EINFO_QUIET")))
|
||||||
dup2(stderr_fd, STDERR_FILENO);
|
dup2(stderr_fd, STDERR_FILENO);
|
||||||
|
|
||||||
#ifdef HAVE_CLOSEFROM
|
cloexec_fds_from(3);
|
||||||
closefrom(3);
|
|
||||||
#else
|
|
||||||
for (i = getdtablesize() - 1; i >= 3; --i)
|
|
||||||
close(i);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (scheduler != NULL) {
|
if (scheduler != NULL) {
|
||||||
int scheduler_index;
|
int scheduler_index;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
executable('supervise-daemon',
|
executable('supervise-daemon',
|
||||||
['supervise-daemon.c', misc_c, plugin_c, schedules_c, usage_c, version_h],
|
['supervise-daemon.c', pipes_c, misc_c, plugin_c, schedules_c, usage_c, version_h],
|
||||||
c_args : [cc_branding_flags, cc_pam_flags, cc_cap_flags, cc_selinux_flags],
|
c_args : [cc_branding_flags, cc_pam_flags, cc_cap_flags, cc_selinux_flags],
|
||||||
link_with: [libeinfo, librc],
|
link_with: [libeinfo, librc],
|
||||||
dependencies: [dl_dep, pam_dep, cap_dep, util_dep, selinux_dep],
|
dependencies: [dl_dep, pam_dep, cap_dep, util_dep, selinux_dep],
|
||||||
|
|||||||
@@ -22,25 +22,6 @@
|
|||||||
#define ONE_SECOND 1000000000
|
#define ONE_SECOND 1000000000
|
||||||
#define ONE_MS 1000000
|
#define ONE_MS 1000000
|
||||||
|
|
||||||
#ifdef HAVE_CLOSE_RANGE_CLOEXEC
|
|
||||||
/* For close_range() */
|
|
||||||
# define _GNU_SOURCE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <sys/resource.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <termios.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
|
|
||||||
#ifdef __linux__
|
|
||||||
#include <sys/syscall.h> /* For io priority */
|
|
||||||
#include <sys/prctl.h> /* For prctl */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
@@ -52,7 +33,17 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <strings.h>
|
||||||
|
#ifdef __linux__
|
||||||
|
# include <sys/syscall.h> /* For io priority */
|
||||||
|
# include <sys/prctl.h> /* For prctl */
|
||||||
|
#endif
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
@@ -71,6 +62,7 @@ static struct pam_conv conv = { NULL, NULL};
|
|||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "rc.h"
|
#include "rc.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
#include "pipes.h"
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
#include "schedules.h"
|
#include "schedules.h"
|
||||||
#include "_usage.h"
|
#include "_usage.h"
|
||||||
@@ -88,6 +80,8 @@ enum {
|
|||||||
LONGOPT_OOM_SCORE_ADJ,
|
LONGOPT_OOM_SCORE_ADJ,
|
||||||
LONGOPT_NO_NEW_PRIVS,
|
LONGOPT_NO_NEW_PRIVS,
|
||||||
LONGOPT_SECBITS,
|
LONGOPT_SECBITS,
|
||||||
|
LONGOPT_STDERR_LOGGER,
|
||||||
|
LONGOPT_STDOUT_LOGGER,
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *applet = NULL;
|
const char *applet = NULL;
|
||||||
@@ -119,6 +113,8 @@ const struct option longopts[] = {
|
|||||||
{ "user", 1, NULL, 'u'},
|
{ "user", 1, NULL, 'u'},
|
||||||
{ "stdout", 1, NULL, '1'},
|
{ "stdout", 1, NULL, '1'},
|
||||||
{ "stderr", 1, NULL, '2'},
|
{ "stderr", 1, NULL, '2'},
|
||||||
|
{ "stdout-logger",1, NULL, LONGOPT_STDOUT_LOGGER},
|
||||||
|
{ "stderr-logger",1, NULL, LONGOPT_STDERR_LOGGER},
|
||||||
{ "reexec", 0, NULL, '3'},
|
{ "reexec", 0, NULL, '3'},
|
||||||
longopts_COMMON
|
longopts_COMMON
|
||||||
};
|
};
|
||||||
@@ -147,6 +143,8 @@ const char * const longopts_help[] = {
|
|||||||
"Change the process user",
|
"Change the process user",
|
||||||
"Redirect stdout to file",
|
"Redirect stdout to file",
|
||||||
"Redirect stderr to file",
|
"Redirect stderr to file",
|
||||||
|
"Redirect stdout to process",
|
||||||
|
"Redirect stderr to process",
|
||||||
"reexec (used internally)",
|
"reexec (used internally)",
|
||||||
longopts_help_COMMON
|
longopts_help_COMMON
|
||||||
};
|
};
|
||||||
@@ -169,6 +167,8 @@ static int stdout_fd;
|
|||||||
static int stderr_fd;
|
static int stderr_fd;
|
||||||
static char *redirect_stderr = NULL;
|
static char *redirect_stderr = NULL;
|
||||||
static char *redirect_stdout = NULL;
|
static char *redirect_stdout = NULL;
|
||||||
|
static char *stderr_process = NULL;
|
||||||
|
static char *stdout_process = NULL;
|
||||||
#ifdef TIOCNOTTY
|
#ifdef TIOCNOTTY
|
||||||
static int tty_fd = -1;
|
static int tty_fd = -1;
|
||||||
#endif
|
#endif
|
||||||
@@ -196,8 +196,8 @@ extern char **environ;
|
|||||||
# define SYS_ioprio_set __NR_ioprio_set
|
# define SYS_ioprio_set __NR_ioprio_set
|
||||||
#endif
|
#endif
|
||||||
#if !defined(__DragonFly__)
|
#if !defined(__DragonFly__)
|
||||||
static inline int ioprio_set(int which _unused, int who _unused,
|
static inline int ioprio_set(int which RC_UNUSED, int who RC_UNUSED,
|
||||||
int ioprio _unused)
|
int ioprio RC_UNUSED)
|
||||||
{
|
{
|
||||||
#ifdef SYS_ioprio_set
|
#ifdef SYS_ioprio_set
|
||||||
return syscall(SYS_ioprio_set, which, who, ioprio);
|
return syscall(SYS_ioprio_set, which, who, ioprio);
|
||||||
@@ -212,7 +212,7 @@ static void cleanup(void)
|
|||||||
free(changeuser);
|
free(changeuser);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void re_exec_supervisor(void)
|
RC_NORETURN static void re_exec_supervisor(void)
|
||||||
{
|
{
|
||||||
syslog(LOG_WARNING, "Re-executing for %s", svcname);
|
syslog(LOG_WARNING, "Re-executing for %s", svcname);
|
||||||
execlp("supervise-daemon", "supervise-daemon", svcname, "--reexec",
|
execlp("supervise-daemon", "supervise-daemon", svcname, "--reexec",
|
||||||
@@ -358,7 +358,7 @@ static pid_t exec_command(const char *cmd)
|
|||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void child_process(char *exec, char **argv)
|
RC_NORETURN static void child_process(char *exec, char **argv)
|
||||||
{
|
{
|
||||||
RC_STRINGLIST *env_list;
|
RC_STRINGLIST *env_list;
|
||||||
RC_STRING *env;
|
RC_STRING *env;
|
||||||
@@ -558,6 +558,12 @@ static void child_process(char *exec, char **argv)
|
|||||||
eerrorx("%s: unable to open the logfile"
|
eerrorx("%s: unable to open the logfile"
|
||||||
" for stdout `%s': %s",
|
" for stdout `%s': %s",
|
||||||
applet, redirect_stdout, strerror(errno));
|
applet, redirect_stdout, strerror(errno));
|
||||||
|
} else if (stdout_process) {
|
||||||
|
stdout_fd = rc_pipe_command(stdout_process);
|
||||||
|
if (stdout_fd == -1)
|
||||||
|
eerrorx("%s: unable to open the logging process"
|
||||||
|
" for stdout `%s': %s",
|
||||||
|
applet, stdout_process, strerror(errno));
|
||||||
}
|
}
|
||||||
if (redirect_stderr) {
|
if (redirect_stderr) {
|
||||||
if ((stderr_fd = open(redirect_stderr,
|
if ((stderr_fd = open(redirect_stderr,
|
||||||
@@ -566,19 +572,22 @@ static void child_process(char *exec, char **argv)
|
|||||||
eerrorx("%s: unable to open the logfile"
|
eerrorx("%s: unable to open the logfile"
|
||||||
" for stderr `%s': %s",
|
" for stderr `%s': %s",
|
||||||
applet, redirect_stderr, strerror(errno));
|
applet, redirect_stderr, strerror(errno));
|
||||||
|
} else if (stderr_process) {
|
||||||
|
stderr_fd = rc_pipe_command(stderr_process);
|
||||||
|
if (stderr_fd == -1)
|
||||||
|
eerrorx("%s: unable to open the logging process"
|
||||||
|
" for stderr `%s': %s",
|
||||||
|
applet, stderr_process, strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
dup2(stdin_fd, STDIN_FILENO);
|
dup2(stdin_fd, STDIN_FILENO);
|
||||||
if (redirect_stdout || rc_yesno(getenv("EINFO_QUIET")))
|
if (redirect_stdout || stdout_process || rc_yesno(getenv("EINFO_QUIET")))
|
||||||
dup2(stdout_fd, STDOUT_FILENO);
|
dup2(stdout_fd, STDOUT_FILENO);
|
||||||
if (redirect_stderr || rc_yesno(getenv("EINFO_QUIET")))
|
if (redirect_stderr || stderr_process || rc_yesno(getenv("EINFO_QUIET")))
|
||||||
dup2(stderr_fd, STDERR_FILENO);
|
dup2(stderr_fd, STDERR_FILENO);
|
||||||
|
|
||||||
#ifdef HAVE_CLOSE_RANGE_CLOEXEC
|
cloexec_fds_from(3);
|
||||||
if (close_range(3, UINT_MAX, CLOSE_RANGE_CLOEXEC) < 0)
|
|
||||||
#endif
|
|
||||||
for (i = getdtablesize() - 1; i >= 3; --i)
|
|
||||||
fcntl(i, F_SETFD, FD_CLOEXEC);
|
|
||||||
cmdline = make_cmdline(argv);
|
cmdline = make_cmdline(argv);
|
||||||
syslog(LOG_INFO, "Child command line: %s", cmdline);
|
syslog(LOG_INFO, "Child command line: %s", cmdline);
|
||||||
free(cmdline);
|
free(cmdline);
|
||||||
@@ -591,7 +600,7 @@ static void child_process(char *exec, char **argv)
|
|||||||
eerrorx("%s: failed to exec `%s': %s", applet, exec,strerror(errno));
|
eerrorx("%s: failed to exec `%s': %s", applet, exec,strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void supervisor(char *exec, char **argv)
|
RC_NORETURN static void supervisor(char *exec, char **argv)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char buf[2048];
|
char buf[2048];
|
||||||
@@ -1051,6 +1060,14 @@ int main(int argc, char **argv)
|
|||||||
reexec = true;
|
reexec = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case LONGOPT_STDOUT_LOGGER: /* --stdout-logger "command to run for stdout logging" */
|
||||||
|
stdout_process = optarg;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LONGOPT_STDERR_LOGGER: /* --stderr-logger "command to run for stderr logging" */
|
||||||
|
stderr_process = optarg;
|
||||||
|
break;
|
||||||
|
|
||||||
case_RC_COMMON_GETOPT
|
case_RC_COMMON_GETOPT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,20 +19,17 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <utime.h>
|
#include <utime.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "einfo.h"
|
#include "einfo.h"
|
||||||
#include "rc.h"
|
|
||||||
#include "misc.h"
|
|
||||||
#include "_usage.h"
|
#include "_usage.h"
|
||||||
|
#include "helpers.h"
|
||||||
|
|
||||||
|
|
||||||
const char *applet = NULL;
|
const char *applet = NULL;
|
||||||
@@ -78,14 +75,12 @@ int main(int argc, char **argv)
|
|||||||
eerrorx("swclock: Reference file was not specified");
|
eerrorx("swclock: Reference file was not specified");
|
||||||
|
|
||||||
if (sflag) {
|
if (sflag) {
|
||||||
if (stat(file, &sb) == -1) {
|
int fd = open(file, O_WRONLY | O_CREAT, 0644);
|
||||||
opt = open(file, O_WRONLY | O_CREAT, 0644);
|
if (fd == -1)
|
||||||
if (opt == -1)
|
eerrorx("swclock: open: %s", strerror(errno));
|
||||||
eerrorx("swclock: open: %s", strerror(errno));
|
if (futimens(fd, NULL) == -1)
|
||||||
close(opt);
|
eerrorx("swclock: futimens: %s", strerror(errno));
|
||||||
} else
|
close(fd);
|
||||||
if (utime(file, NULL) == -1)
|
|
||||||
eerrorx("swclock: utime: %s", strerror(errno));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,24 +12,14 @@
|
|||||||
|
|
||||||
#define SYSLOG_NAMES
|
#define SYSLOG_NAMES
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <signal.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <syslog.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "einfo.h"
|
#include "einfo.h"
|
||||||
#include "rc.h"
|
#include "rc.h"
|
||||||
#include "misc.h"
|
#include "helpers.h"
|
||||||
|
|
||||||
const char *applet = NULL;
|
const char *applet = NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -1,55 +1,54 @@
|
|||||||
Using supervise-daemon
|
# Using supervise-daemon
|
||||||
======================
|
|
||||||
|
|
||||||
Beginning with OpenRC-0.21 we have our own daemon supervisor,
|
Beginning with OpenRC-0.21 we have our own daemon supervisor,
|
||||||
supervise-daemon., which can start a daemon and restart it if it
|
`supervise-daemon`, which can start a daemon and restart it if it
|
||||||
terminates unexpectedly.
|
terminates unexpectedly.
|
||||||
|
|
||||||
The following is a brief guide on using this capability.
|
The following is a brief guide on using this capability.
|
||||||
|
|
||||||
* Use Default start, stop and status functions
|
* **Use Default start, stop and status functions**.
|
||||||
If you write your own start, stop and status functions in your service
|
If you write your own start, stop and status functions in your service
|
||||||
script, none of this will work. You must allow OpenRC to use the default
|
script, none of this will work. You must allow OpenRC to use the default
|
||||||
functions.
|
functions.
|
||||||
|
|
||||||
* Daemons must not fork
|
* **Daemons must not fork**.
|
||||||
Any daemon that you would like to have monitored by supervise-daemon
|
Any daemon that you would like to have monitored by `supervise-daemon`
|
||||||
must not fork. Instead, it must stay in the foreground. If the daemon
|
must not fork. Instead, it must stay in the foreground. If the daemon
|
||||||
forks, the supervisor will be unable to monitor it.
|
forks, the supervisor will be unable to monitor it.
|
||||||
|
|
||||||
If the daemon can be configured to not fork, this should be done in the
|
If the daemon can be configured to not fork, this should be done in the
|
||||||
daemon's configuration file, or by adding a command line option that
|
daemon's configuration file, or by adding a command line option that
|
||||||
instructs it not to fork to the command_args_foreground variable shown
|
instructs it not to fork to the `command_args_foreground` variable shown
|
||||||
below.
|
below.
|
||||||
|
|
||||||
# Health Checks
|
## Health checks
|
||||||
|
|
||||||
Health checks are a way to make sure a service monitored by
|
Health checks are a way to make sure a service monitored by
|
||||||
supervise-daemon stays healthy. To configure a health check for a
|
`supervise-daemon` stays healthy. To configure a health check for a
|
||||||
service, you need to write a healthcheck() function, and optionally an
|
service, you need to write a `healthcheck()` function, and optionally an
|
||||||
unhealthy() function in the service script. Also, you will need to set
|
`unhealthy()` function in the service script. Also, you will need to set
|
||||||
the healthcheck_timer and optionally healthcheck_delay variables.
|
the `healthcheck_timer` and optionally `healthcheck_delay` variables.
|
||||||
|
|
||||||
## healthcheck() function
|
### healthcheck() function
|
||||||
|
|
||||||
The healthcheck() function is run repeatedly based on the settings of
|
The `healthcheck()` function is run repeatedly based on the settings of
|
||||||
the healthcheck_* variables. This function should return zero if the
|
the `healthcheck_*` variables. This function should return zero if the
|
||||||
service is currently healthy or non-zero otherwise.
|
service is currently healthy or non-zero otherwise.
|
||||||
|
|
||||||
## unhealthy() function
|
### unhealthy() function
|
||||||
|
|
||||||
If the healthcheck() function returns non-zero, the unhealthy() function
|
If the `healthcheck()` function returns non-zero, the `unhealthy()` function
|
||||||
is run, then the service is restarted. Since the service will be
|
is run, then the service is restarted. Since the service will be
|
||||||
restarted by the supervisor, the unhealthy function should not try to
|
restarted by the supervisor, the unhealthy function should not try to
|
||||||
restart it; the purpose of the function is to allow any cleanup tasks
|
restart it; the purpose of the function is to allow any cleanup tasks
|
||||||
other than restarting the service to be run.
|
other than restarting the service to be run.
|
||||||
|
|
||||||
# Variable Settings
|
## Variable settings
|
||||||
|
|
||||||
The most important setting is the supervisor variable. At the top of
|
The most important setting is the supervisor variable. At the top of
|
||||||
your service script, you should set this variable as follows:
|
your service script, you should set this variable as follows:
|
||||||
|
|
||||||
``` sh
|
```sh
|
||||||
supervisor=supervise-daemon
|
supervisor=supervise-daemon
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -57,29 +56,29 @@ Several other variables affect the way services behave under
|
|||||||
supervise-daemon. They are documented on the openrc-run man page, but I
|
supervise-daemon. They are documented on the openrc-run man page, but I
|
||||||
will list them here for convenience:
|
will list them here for convenience:
|
||||||
|
|
||||||
``` sh
|
```sh
|
||||||
command_args_foreground="arguments"
|
command_args_foreground="arguments"
|
||||||
```
|
```
|
||||||
|
|
||||||
This should be used if the daemon you want to monitor
|
This should be used if the daemon you want to monitor
|
||||||
forks and goes to the background by default. This should be set to the
|
forks and goes to the background by default. This should be set to the
|
||||||
command line option that instructs the daemon to stay in the foreground.
|
command line option that instructs the daemon to stay in the foreground.
|
||||||
|
|
||||||
``` sh
|
```sh
|
||||||
healthcheck_delay=seconds
|
healthcheck_delay=seconds
|
||||||
```
|
```
|
||||||
|
|
||||||
This is the delay, in seconds, before the first health check is run.
|
This is the delay, in seconds, before the first health check is run.
|
||||||
If it is not set, we use the value of healthcheck_timer.
|
If it is not set, we use the value of `healthcheck_timer`.
|
||||||
|
|
||||||
``` sh
|
```sh
|
||||||
healthcheck_timer=seconds
|
healthcheck_timer=seconds
|
||||||
```
|
```
|
||||||
|
|
||||||
This is the number of seconds between health checks. If it is not set,
|
This is the number of seconds between health checks. If it is not set,
|
||||||
no health checks will be run.
|
no health checks will be run.
|
||||||
|
|
||||||
``` sh
|
```sh
|
||||||
respawn_delay
|
respawn_delay
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -87,7 +86,7 @@ This is the number of seconds to delay before attempting to respawn a
|
|||||||
supervised process after it dies unexpectedly.
|
supervised process after it dies unexpectedly.
|
||||||
The default is to respawn immediately.
|
The default is to respawn immediately.
|
||||||
|
|
||||||
``` sh
|
```sh
|
||||||
respawn_max=x
|
respawn_max=x
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -95,17 +94,17 @@ This is the maximum number of times to respawn a supervised process
|
|||||||
during the given respawn period.
|
during the given respawn period.
|
||||||
The default is 10. 0 means unlimited.
|
The default is 10. 0 means unlimited.
|
||||||
|
|
||||||
``` sh
|
```sh
|
||||||
respawn_period=seconds
|
respawn_period=seconds
|
||||||
```
|
```
|
||||||
|
|
||||||
This works in conjunction with respawn_max and respawn_delay above to
|
This works in conjunction with `respawn_max` and `respawn_delay` above to
|
||||||
decide if a process should not be respawned for some reason.
|
decide if a process should not be respawned for some reason.
|
||||||
|
|
||||||
For example, if respawn period is 10 and respawn_max is 2, the process
|
For example, if respawn period is 10 and `respawn_max` is 2, the process
|
||||||
would need to die 3 times within 10 seconds to no longer be respawned.
|
would need to die 3 times within 10 seconds to no longer be respawned.
|
||||||
Note that respawn_delay will delay all of this, so in the above scenario
|
Note that `respawn_delay` will delay all of this, so in the above scenario
|
||||||
a respawn_delay of greater than 5 will cause infinite respawns.
|
a `respawn_delay` of greater than 5 will cause infinite respawns.
|
||||||
|
|
||||||
By default, this is unset and respawn_max applies to the entire lifetime
|
By default, this is unset and `respawn_max` applies to the entire lifetime
|
||||||
of the service.
|
of the service.
|
||||||
|
|||||||
@@ -11,8 +11,7 @@ sysvinit="$4"
|
|||||||
if [ "${os}" != Linux ]; then
|
if [ "${os}" != Linux ]; then
|
||||||
install -d "${DESTDIR}/${rc_libexecdir}"/init.d
|
install -d "${DESTDIR}/${rc_libexecdir}"/init.d
|
||||||
fi
|
fi
|
||||||
install -d "${DESTDIR}/${rc_libexecdir}"/tmp
|
|
||||||
install -m 644 "${MESON_BUILD_ROOT}/src/shared/version" "${DESTDIR}/${rc_libexecdir}"
|
install -m 644 "${MESON_BUILD_ROOT}/src/shared/version" "${DESTDIR}/${rc_libexecdir}"
|
||||||
if [ "${os}" = Linux ] && [ "${sysvinit}" = yes ]; then
|
if [ "${os}" = Linux ] && [ "${sysvinit}" = yes ]; then
|
||||||
ln -s openrc-init "${DESTDIR}/${sbindir}"/init
|
ln -sf openrc-init "${DESTDIR}/${sbindir}"/init
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user