Compare commits
92 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12064291e9 | ||
|
|
23f6ec028b | ||
|
|
9d7f39603e | ||
|
|
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 | ||
|
|
9f227e8b49 | ||
|
|
3bb5450320 | ||
|
|
a689fdb7be | ||
|
|
fc4f15d6cd | ||
|
|
19f329d2f4 | ||
|
|
0b86c06c3c | ||
|
|
fea9d9a7f0 | ||
|
|
9dfd2b2737 | ||
|
|
de295bd0c6 | ||
|
|
6f44445958 | ||
|
|
52dcb4aaa3 | ||
|
|
c6d6ed0c9c | ||
|
|
b778c72f81 | ||
|
|
32715e1144 | ||
|
|
ec04e08707 | ||
|
|
dd05e60ced | ||
|
|
9ef74594df | ||
|
|
59e9637647 | ||
|
|
35077afb68 | ||
|
|
02b064a591 | ||
|
|
839083bb52 | ||
|
|
1364e6631c | ||
|
|
953172c6c6 | ||
|
|
0525de4f18 | ||
|
|
9380347f04 | ||
|
|
112b69860f | ||
|
|
d21dde73ba | ||
|
|
9b08de926b | ||
|
|
f60d42e901 | ||
|
|
9e5ce59a21 | ||
|
|
95dc83bfbc | ||
|
|
14b153c1a4 | ||
|
|
3cc4c01485 | ||
|
|
414f398498 | ||
|
|
107b23819d | ||
|
|
d2b3144070 |
@@ -4,8 +4,8 @@
|
|||||||
test_task:
|
test_task:
|
||||||
freebsd_instance:
|
freebsd_instance:
|
||||||
matrix:
|
matrix:
|
||||||
image: freebsd-13-0-release-amd64
|
image: freebsd-13-1-release-amd64
|
||||||
image: freebsd-12-3-release-amd64
|
image: freebsd-12-4-release-amd64
|
||||||
env:
|
env:
|
||||||
OS: FreeBSD
|
OS: FreeBSD
|
||||||
procfs_script: >
|
procfs_script: >
|
||||||
|
|||||||
142
CODE_OF_CONDUCT.md
Normal file
142
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
# OpenRC Code of Conduct
|
||||||
|
|
||||||
|
This code of conduct outlines our expectations for participants within the
|
||||||
|
community, as well as steps for reporting unacceptable behavior. We are
|
||||||
|
committed to providing a welcoming and inspiring community for all and
|
||||||
|
expect our code of conduct to be honored. Anyone who violates this code
|
||||||
|
of conduct may be banned from the community.
|
||||||
|
|
||||||
|
## Our Pledge
|
||||||
|
|
||||||
|
We as members, contributors, and leaders pledge to make participation in our
|
||||||
|
community a harassment-free experience for everyone, regardless of age, body
|
||||||
|
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||||
|
identity and expression, level of experience, education, socio-economic status,
|
||||||
|
nationality, personal appearance, race, caste, color, religion, or sexual
|
||||||
|
identity and orientation.
|
||||||
|
|
||||||
|
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||||
|
diverse, inclusive, and healthy community.
|
||||||
|
|
||||||
|
## Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to a positive environment for our
|
||||||
|
community include:
|
||||||
|
|
||||||
|
* Demonstrating empathy and kindness toward other people
|
||||||
|
* Being respectful of differing opinions, viewpoints, and experiences
|
||||||
|
* Giving and gracefully accepting constructive feedback
|
||||||
|
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||||
|
and learning from the experience
|
||||||
|
* Focusing on what is best not just for us as individuals, but for the overall
|
||||||
|
community
|
||||||
|
|
||||||
|
Examples of unacceptable behavior include:
|
||||||
|
|
||||||
|
* The use of sexualized language or imagery, and sexual attention or advances of
|
||||||
|
any kind
|
||||||
|
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||||
|
* Public or private harassment
|
||||||
|
* Publishing others' private information, such as a physical or email address,
|
||||||
|
without their explicit permission
|
||||||
|
* Other conduct which could reasonably be considered inappropriate in a
|
||||||
|
professional setting
|
||||||
|
|
||||||
|
## Enforcement Responsibilities
|
||||||
|
|
||||||
|
Community leaders are responsible for clarifying and enforcing our standards of
|
||||||
|
acceptable behavior and will take appropriate and fair corrective action in
|
||||||
|
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||||
|
or harmful.
|
||||||
|
|
||||||
|
Community leaders have the right and responsibility to remove, edit, or reject
|
||||||
|
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||||
|
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||||
|
decisions when appropriate.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies within all community spaces, and also applies when
|
||||||
|
an individual is officially representing the community in public spaces.
|
||||||
|
Examples of representing our community include using an official e-mail address,
|
||||||
|
posting via an official social media account, or acting as an appointed
|
||||||
|
representative at an online or offline event.
|
||||||
|
|
||||||
|
## Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||||
|
reported to the community leaders responsible for enforcement via integrated
|
||||||
|
"Report Content" functionality.
|
||||||
|
See the GitHub documentation for more details:
|
||||||
|
https://docs.github.com/en/communities/maintaining-your-safety-on-github/reporting-abuse-or-spam
|
||||||
|
|
||||||
|
All complaints will be reviewed and investigated promptly and fairly.
|
||||||
|
|
||||||
|
All community leaders are obligated to respect the privacy and security of the
|
||||||
|
reporter of any incident.
|
||||||
|
|
||||||
|
## Enforcement Guidelines
|
||||||
|
|
||||||
|
Community leaders will follow these Community Impact Guidelines in determining
|
||||||
|
the consequences for any action they deem in violation of this Code of Conduct:
|
||||||
|
|
||||||
|
### 1. Correction
|
||||||
|
|
||||||
|
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||||
|
unprofessional or unwelcome in the community.
|
||||||
|
|
||||||
|
**Consequence**: A private, written warning from community leaders, providing
|
||||||
|
clarity around the nature of the violation and an explanation of why the
|
||||||
|
behavior was inappropriate. A public apology may be requested.
|
||||||
|
|
||||||
|
### 2. Warning
|
||||||
|
|
||||||
|
**Community Impact**: A violation through a single incident or series of
|
||||||
|
actions.
|
||||||
|
|
||||||
|
**Consequence**: A warning with consequences for continued behavior. No
|
||||||
|
interaction with the people involved, including unsolicited interaction with
|
||||||
|
those enforcing the Code of Conduct, for a specified period of time. This
|
||||||
|
includes avoiding interactions in community spaces as well as external channels
|
||||||
|
like social media. Violating these terms may lead to a temporary or permanent
|
||||||
|
ban.
|
||||||
|
|
||||||
|
### 3. Temporary Ban
|
||||||
|
|
||||||
|
**Community Impact**: A serious violation of community standards, including
|
||||||
|
sustained inappropriate behavior.
|
||||||
|
|
||||||
|
**Consequence**: A temporary ban from any sort of interaction or public
|
||||||
|
communication with the community for a specified period of time. No public or
|
||||||
|
private interaction with the people involved, including unsolicited interaction
|
||||||
|
with those enforcing the Code of Conduct, is allowed during this period.
|
||||||
|
Violating these terms may lead to a permanent ban.
|
||||||
|
|
||||||
|
### 4. Permanent Ban
|
||||||
|
|
||||||
|
**Community Impact**: Demonstrating a pattern of violation of community
|
||||||
|
standards, including sustained inappropriate behavior, harassment of an
|
||||||
|
individual, or aggression toward or disparagement of classes of individuals.
|
||||||
|
|
||||||
|
**Consequence**: A permanent ban from any sort of public interaction within the
|
||||||
|
community.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||||
|
version 2.1, available at
|
||||||
|
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
||||||
|
|
||||||
|
Community Impact Guidelines were inspired by
|
||||||
|
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
||||||
|
|
||||||
|
For answers to common questions about this code of conduct, see the FAQ at
|
||||||
|
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
||||||
|
[https://www.contributor-covenant.org/translations][translations].
|
||||||
|
|
||||||
|
[homepage]: https://www.contributor-covenant.org
|
||||||
|
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
||||||
|
[Mozilla CoC]: https://github.com/mozilla/diversity
|
||||||
|
[FAQ]: https://www.contributor-covenant.org/faq
|
||||||
|
[translations]: https://www.contributor-covenant.org/translations
|
||||||
|
|
||||||
2
LICENSE
2
LICENSE
@@ -1,5 +1,5 @@
|
|||||||
Copyright (c) 2007-2008, Roy Marples <roy@marples.name>
|
Copyright (c) 2007-2008, Roy Marples <roy@marples.name>
|
||||||
Copyright (c) 2007-2015, the OpenRC authors
|
Copyright (c) 2007-2023, the OpenRC authors
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|||||||
26
NEWS.md
26
NEWS.md
@@ -4,6 +4,32 @@ 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.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
|
||||||
|
|
||||||
|
The path for the reference file for the swclock service is now
|
||||||
|
configurable in conf.d/swclock.
|
||||||
|
|
||||||
|
In the past, if supervise_daemon_args was not set *or empty*, it defaulted to
|
||||||
|
`start_stop_daemon_args`. This was bad because supervise-daemon doesn't
|
||||||
|
accept the same options as `start-stop-daemon`. So if we set e.g.
|
||||||
|
`start_stop_daemon_args="--wait 50"`, but not `supervise_daemon_args`,
|
||||||
|
and the user adds `supervisor=supervise-daemon` to the corresponding
|
||||||
|
conf.d/<service> file, the service will fail to start due to
|
||||||
|
unrecognized option "wait".
|
||||||
|
It would be best to remove this fallback, but that might break some
|
||||||
|
existing scripts that depend on it. So we are changing it to
|
||||||
|
use `start_stop_daemon_args` as the default for `supervise_daemon_args`
|
||||||
|
only if `supervise_daemon_args` is not set at all, but not if it's
|
||||||
|
empty.
|
||||||
|
|
||||||
|
This fallback will be dropped in a future release.
|
||||||
|
|
||||||
|
|
||||||
## OpenRC 0.45
|
## OpenRC 0.45
|
||||||
|
|
||||||
The old make-based build system is removed in this release.
|
The old make-based build system is removed in this release.
|
||||||
|
|||||||
@@ -85,9 +85,9 @@ _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
|
||||||
@@ -105,9 +105,8 @@ _rc_service()
|
|||||||
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
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ conf_common = [
|
|||||||
'localmount',
|
'localmount',
|
||||||
'netmount',
|
'netmount',
|
||||||
'swap',
|
'swap',
|
||||||
|
'swclock',
|
||||||
]
|
]
|
||||||
|
|
||||||
conf_net = [
|
conf_net = [
|
||||||
|
|||||||
6
conf.d/swclock
Normal file
6
conf.d/swclock
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# This is the location of the reference file swclock uses to set the
|
||||||
|
# system date and time.
|
||||||
|
# This is the default path. If you are using it, you do not need to
|
||||||
|
# uncomment it. If you are using the default and have /var on its own
|
||||||
|
# file system, you need to add the appropriate rc_after setting.
|
||||||
|
# swclock_file=/var/lib/misc/openrc-shutdowntime
|
||||||
15
etc/rc.conf
15
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.
|
||||||
@@ -97,8 +97,8 @@
|
|||||||
|
|
||||||
# Below is the default list of network fstypes.
|
# Below is the default list of network fstypes.
|
||||||
#
|
#
|
||||||
# afs ceph cifs coda davfs fuse fuse.sshfs gfs glusterfs lustre ncpfs
|
# afs ceph cifs coda davfs fuse fuse.glusterfs fuse.sshfs gfs glusterfs lustre
|
||||||
# nfs nfs4 ocfs2 shfs smbfs
|
# ncpfs nfs nfs4 ocfs2 shfs smbfs
|
||||||
#
|
#
|
||||||
# If you would like to add to this list, you can do so by adding your
|
# If you would like to add to this list, you can do so by adding your
|
||||||
# own fstypes to the following variable.
|
# own fstypes to the following variable.
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -19,20 +19,18 @@ depend()
|
|||||||
|
|
||||||
start()
|
start()
|
||||||
{
|
{
|
||||||
local h source x
|
local h source
|
||||||
if [ -s /etc/hostname ] && [ -r /etc/hostname ]; then
|
if read -r h _ 2> /dev/null < @SYSCONFDIR@/hostname; then
|
||||||
read h x </etc/hostname
|
source="@SYSCONFDIR@/hostname"
|
||||||
source="from /etc/hostname"
|
elif [ -n "${hostname}" ]; then
|
||||||
else
|
h=${hostname}
|
||||||
# HOSTNAME variable used to be defined in caps in conf.d/hostname.
|
source="@SYSCONFDIR@/conf.d/${RC_SVCNAME}"
|
||||||
# It is also a magic variable in bash.
|
|
||||||
h=${hostname:-${HOSTNAME}} # checkbashisms: false positive (HOSTNAME var)
|
|
||||||
fi
|
fi
|
||||||
if [ -z "$h" ]; then
|
if [ -z "$h" ]; then
|
||||||
einfo "Using default system hostname"
|
einfo "Using default system hostname"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
ebegin "Setting hostname to $h $source"
|
ebegin "Setting hostname to $h from $source"
|
||||||
hostname "$h"
|
hostname "$h"
|
||||||
eend $? "Failed to set the hostname"
|
eend $? "Failed to set the hostname"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ get_noadjfile()
|
|||||||
{
|
{
|
||||||
if ! yesno $clock_adjfile; then
|
if ! yesno $clock_adjfile; then
|
||||||
# Some implementations don't handle adjustments
|
# Some implementations don't handle adjustments
|
||||||
if LC_ALL=C hwclock --help 2>&1 | grep -q "\-\-noadjfile"; then
|
if LC_ALL=C hwclock --help 2>&1 | grep -q -e "--noadjfile"; then
|
||||||
echo --noadjfile
|
echo --noadjfile
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -56,10 +56,10 @@ load_modules()
|
|||||||
ebegin "Loading module $x"
|
ebegin "Loading module $x"
|
||||||
case "$RC_UNAME" in
|
case "$RC_UNAME" in
|
||||||
FreeBSD) kldload "$x"; rc=$? ;;
|
FreeBSD) kldload "$x"; rc=$? ;;
|
||||||
Linux) modprobe --first-time -q --use-blacklist "$x"; rc=$? ;;
|
Linux) modprobe --first-time --use-blacklist --verbose "$x"; rc=$? ;;
|
||||||
*) ;;
|
*) ;;
|
||||||
esac
|
esac
|
||||||
eend $rc "Failed to load $x"
|
eend
|
||||||
done
|
done
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@@ -80,9 +80,10 @@ FreeBSD_modules()
|
|||||||
for x in $modules; do
|
for x in $modules; do
|
||||||
ebegin "Loading module $x"
|
ebegin "Loading module $x"
|
||||||
kldload "$x"
|
kldload "$x"
|
||||||
eend $? "Failed to load $x" && : $(( cnt += 1 ))
|
eend && : $(( cnt += 1 ))
|
||||||
done
|
done
|
||||||
einfo "Autoloaded $cnt module(s)"
|
einfo "Autoloaded $cnt module(s)"
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
Linux_modules()
|
Linux_modules()
|
||||||
@@ -122,6 +123,7 @@ Linux_modules()
|
|||||||
eval modprobe --first-time --use-blacklist --verbose "$x" "$args"
|
eval modprobe --first-time --use-blacklist --verbose "$x" "$args"
|
||||||
done
|
done
|
||||||
[ -n "$list" ] && eend
|
[ -n "$list" ] && eend
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
start()
|
start()
|
||||||
|
|||||||
@@ -49,9 +49,7 @@ start()
|
|||||||
local mountpoint
|
local mountpoint
|
||||||
for mountpoint in $(fstabinfo); do
|
for mountpoint in $(fstabinfo); do
|
||||||
case "${mountpoint}" in
|
case "${mountpoint}" in
|
||||||
/)
|
/*) # Don't remount swap etc.
|
||||||
;;
|
|
||||||
/*)
|
|
||||||
mountinfo -q "${mountpoint}" && \
|
mountinfo -q "${mountpoint}" && \
|
||||||
fstabinfo --remount "${mountpoint}"
|
fstabinfo --remount "${mountpoint}"
|
||||||
;;
|
;;
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
# except according to the terms contained in the LICENSE file.
|
# except according to the terms contained in the LICENSE file.
|
||||||
|
|
||||||
description="Sets the local clock to the mtime of a given file."
|
description="Sets the local clock to the mtime of a given file."
|
||||||
|
swclock_file="${swclock_file:-/var/lib/misc/openrc-shutdowntime}"
|
||||||
|
|
||||||
depend()
|
depend()
|
||||||
{
|
{
|
||||||
@@ -22,7 +23,7 @@ depend()
|
|||||||
start()
|
start()
|
||||||
{
|
{
|
||||||
ebegin "Setting the local clock based on last shutdown time"
|
ebegin "Setting the local clock based on last shutdown time"
|
||||||
if ! swclock 2> /dev/null; then
|
if ! swclock "${swclock_file}" 2> /dev/null; then
|
||||||
swclock --warn @SBINDIR@/openrc-run
|
swclock --warn @SBINDIR@/openrc-run
|
||||||
fi
|
fi
|
||||||
eend $?
|
eend $?
|
||||||
@@ -31,6 +32,6 @@ start()
|
|||||||
stop()
|
stop()
|
||||||
{
|
{
|
||||||
ebegin "Saving the shutdown time"
|
ebegin "Saving the shutdown time"
|
||||||
swclock --save
|
swclock --save "${swclock_file}"
|
||||||
eend $?
|
eend $?
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -37,11 +37,11 @@ Brings up any system specific stuff such as
|
|||||||
and optionally
|
and optionally
|
||||||
.Pa /sys
|
.Pa /sys
|
||||||
for Linux based systems. It also mounts
|
for Linux based systems. It also mounts
|
||||||
.Pa /lib/rc/init.d
|
.Pa /run/openrc
|
||||||
as a ramdisk using tmpfs where available unless / is mounted rw at boot.
|
as a ramdisk using tmpfs where available unless / is mounted rw at boot.
|
||||||
.Nm
|
.Nm
|
||||||
uses
|
uses
|
||||||
.Pa /lib/rc/init.d
|
.Pa /run/openrc
|
||||||
to hold state information about the services it runs.
|
to hold state information about the services it runs.
|
||||||
sysinit always runs when the host first starts should not be run again.
|
sysinit always runs when the host first starts should not be run again.
|
||||||
.It Ar boot
|
.It Ar boot
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ services.
|
|||||||
.Pp
|
.Pp
|
||||||
.Fn rc_deptree_update
|
.Fn rc_deptree_update
|
||||||
updates the service dependency tree, normally
|
updates the service dependency tree, normally
|
||||||
.Pa /lib/rc/init.d/deptree .
|
.Pa /run/openrc/deptree .
|
||||||
.Fn rc_deptree_update_needed
|
.Fn rc_deptree_update_needed
|
||||||
checks to see if the dependency tree needs updated based on the mtime of it
|
checks to see if the dependency tree needs updated based on the mtime of it
|
||||||
compared to
|
compared to
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ When a function fails it should either return false or NULL and set
|
|||||||
.Va errno
|
.Va errno
|
||||||
unless specified otherwise as above.
|
unless specified otherwise as above.
|
||||||
.Sh FILES
|
.Sh FILES
|
||||||
.Pa /lib/rc/init.d
|
.Pa /run/openrc
|
||||||
normally holds the volatile state data for services on a RAM backed disk.
|
normally holds the volatile state data for services on a RAM backed disk.
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
.Xr errno 3 ,
|
.Xr errno 3 ,
|
||||||
|
|||||||
18
meson.build
18
meson.build
@@ -1,5 +1,5 @@
|
|||||||
project('OpenRC', 'c',
|
project('OpenRC', 'c',
|
||||||
version : '0.45',
|
version : '0.47.1',
|
||||||
license: 'BSD-2',
|
license: 'BSD-2',
|
||||||
default_options : [
|
default_options : [
|
||||||
'c_std=c99',
|
'c_std=c99',
|
||||||
@@ -36,7 +36,7 @@ endif
|
|||||||
option_os = get_option('os')
|
option_os = get_option('os')
|
||||||
if option_os == ''
|
if option_os == ''
|
||||||
uname = find_program('uname')
|
uname = find_program('uname')
|
||||||
r = run_command(uname, '-s')
|
r = run_command(uname, '-s', check: true)
|
||||||
os = r.stdout().strip()
|
os = r.stdout().strip()
|
||||||
os = '-'.join(os.split('/'))
|
os = '-'.join(os.split('/'))
|
||||||
else
|
else
|
||||||
@@ -84,7 +84,7 @@ else
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if get_option('split-usr') == 'auto'
|
if get_option('split-usr') == 'auto'
|
||||||
split_usr = run_command('test', '-L', '/bin').returncode() != 0
|
split_usr = run_command('test', '-L', '/bin', check: false).returncode() != 0
|
||||||
else
|
else
|
||||||
split_usr = get_option('split-usr') == 'true'
|
split_usr = get_option('split-usr') == 'true'
|
||||||
endif
|
endif
|
||||||
@@ -192,6 +192,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>')
|
||||||
|
add_project_arguments('-DHAVE_CLOSEFROM', language: 'c')
|
||||||
|
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')
|
||||||
|
add_project_arguments('-DHAVE_CLOSE_RANGE_CLOEXEC', language: 'c')
|
||||||
|
endif
|
||||||
|
|
||||||
incdir = include_directories('src/shared')
|
incdir = include_directories('src/shared')
|
||||||
einfo_incdir = include_directories('src/libeinfo')
|
einfo_incdir = include_directories('src/libeinfo')
|
||||||
rc_incdir = include_directories('src/librc')
|
rc_incdir = include_directories('src/librc')
|
||||||
@@ -226,4 +234,6 @@ meson.add_install_script('tools/meson_runlevels.sh',
|
|||||||
get_option('sysvinit') ? 'yes' : 'no')
|
get_option('sysvinit') ? 'yes' : 'no')
|
||||||
meson.add_install_script('tools/meson_final.sh',
|
meson.add_install_script('tools/meson_final.sh',
|
||||||
rc_libexecdir,
|
rc_libexecdir,
|
||||||
os)
|
sbindir,
|
||||||
|
os,
|
||||||
|
get_option('sysvinit') ? 'yes' : 'no')
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ elif ! mountinfo -q /run; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
eend
|
||||||
fi
|
fi
|
||||||
|
|
||||||
checkpath -d "$RC_SVCDIR"
|
checkpath -d "$RC_SVCDIR"
|
||||||
|
|||||||
@@ -2,8 +2,10 @@
|
|||||||
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
|
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
|
||||||
# Released under the 2-clause BSD license.
|
# Released under the 2-clause BSD license.
|
||||||
|
|
||||||
net_fs_list="afs ceph cifs coda davfs fuse fuse.sshfs gfs glusterfs lustre
|
net_fs_list="
|
||||||
ncpfs nfs nfs4 ocfs2 shfs smbfs"
|
afs ceph cifs coda davfs fuse fuse.glusterfs fuse.sshfs gfs glusterfs lustre
|
||||||
|
ncpfs nfs nfs4 ocfs2 shfs smbfs
|
||||||
|
"
|
||||||
is_net_fs()
|
is_net_fs()
|
||||||
{
|
{
|
||||||
[ -z "$1" ] && return 1
|
[ -z "$1" ] && return 1
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ ssd_start()
|
|||||||
${directory:+--chdir} $directory \
|
${directory:+--chdir} $directory \
|
||||||
${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" \
|
${output_logger:+--stdout-logger \"$output_logger\"} \
|
||||||
${error_logger:+--stderr-logger} "$error_logger" \
|
${error_logger:+--stderr-logger \"$error_logger\"} \
|
||||||
${capabilities+--capabilities} "$capabilities" \
|
${capabilities+--capabilities} "$capabilities" \
|
||||||
${secbits:+--secbits} "$secbits" \
|
${secbits:+--secbits} "$secbits" \
|
||||||
${no_new_privs:+--no-new-privs} \
|
${no_new_privs:+--no-new-privs} \
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ supervise_start()
|
|||||||
${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}} \
|
||||||
$command \
|
$command \
|
||||||
-- $command_args $command_args_foreground
|
-- $command_args $command_args_foreground
|
||||||
rc=$?
|
rc=$?
|
||||||
|
|||||||
@@ -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,
|
||||||
@@ -89,7 +88,7 @@ static int get_dirfd(char *path, bool symlinks)
|
|||||||
|
|
||||||
if (!path || *path != '/')
|
if (!path || *path != '/')
|
||||||
eerrorx("%s: empty or relative path", applet);
|
eerrorx("%s: empty or relative path", applet);
|
||||||
dirfd = openat(dirfd, "/", O_RDONLY);
|
dirfd = openat(AT_FDCWD, "/", O_RDONLY);
|
||||||
if (dirfd == -1)
|
if (dirfd == -1)
|
||||||
eerrorx("%s: unable to open the root directory: %s",
|
eerrorx("%s: unable to open the root directory: %s",
|
||||||
applet, strerror(errno));
|
applet, strerror(errno));
|
||||||
@@ -285,7 +284,7 @@ static int do_check(char *path, uid_t uid, gid_t gid, mode_t mode,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode && (st.st_mode & 0777) != mode) {
|
if (mode && (st.st_mode & 07777) != mode) {
|
||||||
if ((type != inode_dir) && (st.st_nlink > 1)) {
|
if ((type != inode_dir) && (st.st_nlink > 1)) {
|
||||||
eerror("%s: chmod: Too many hard links to %s", applet, path);
|
eerror("%s: chmod: Too many hard links to %s", applet, path);
|
||||||
close(readfd);
|
close(readfd);
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|||||||
@@ -16,13 +16,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#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>
|
||||||
|
|
||||||
/* 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 +30,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 +44,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 +60,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;
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -15,16 +15,12 @@
|
|||||||
* 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>
|
||||||
@@ -677,15 +673,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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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__)
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|
||||||
@@ -1074,6 +1087,6 @@ rc_deptree_update(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
rc_stringlist_free(config);
|
rc_stringlist_free(config);
|
||||||
rc_deptree_free(deptree);
|
free(deptree);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|
||||||
@@ -62,7 +61,7 @@
|
|||||||
#define WARN_TIMEOUT 10 /* warn about this every N seconds */
|
#define WARN_TIMEOUT 10 /* warn about this every N seconds */
|
||||||
|
|
||||||
const char *applet = NULL;
|
const char *applet = NULL;
|
||||||
const char *extraopts = "stop | start | restart | describe | zap";
|
const char *extraopts = "stop | start | restart | status | describe | zap";
|
||||||
const char getoptstring[] = "dDsSvl:Z" getoptstring_COMMON;
|
const char getoptstring[] = "dDsSvl:Z" getoptstring_COMMON;
|
||||||
const struct option longopts[] = {
|
const struct option longopts[] = {
|
||||||
{ "debug", 0, NULL, 'd'},
|
{ "debug", 0, NULL, 'd'},
|
||||||
@@ -109,7 +108,7 @@ static void
|
|||||||
handle_signal(int sig)
|
handle_signal(int sig)
|
||||||
{
|
{
|
||||||
int serrno = errno;
|
int serrno = errno;
|
||||||
char *signame = NULL;
|
const char *signame = NULL;
|
||||||
struct winsize ws;
|
struct winsize ws;
|
||||||
|
|
||||||
switch (sig) {
|
switch (sig) {
|
||||||
@@ -135,20 +134,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 */
|
||||||
|
|
||||||
@@ -161,7 +159,7 @@ handle_signal(int sig)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unhotplug()
|
unhotplug(void)
|
||||||
{
|
{
|
||||||
char *file = NULL;
|
char *file = NULL;
|
||||||
|
|
||||||
@@ -645,7 +643,7 @@ svc_start_deps(void)
|
|||||||
bool first;
|
bool first;
|
||||||
RC_STRING *svc, *svc2;
|
RC_STRING *svc, *svc2;
|
||||||
RC_SERVICE state;
|
RC_SERVICE state;
|
||||||
int depoptions = RC_DEP_TRACE, n;
|
int depoptions = RC_DEP_TRACE;
|
||||||
size_t len;
|
size_t len;
|
||||||
char *p, *tmp;
|
char *p, *tmp;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
@@ -755,7 +753,6 @@ svc_start_deps(void)
|
|||||||
rc_stringlist_free(use_services);
|
rc_stringlist_free(use_services);
|
||||||
use_services = NULL;
|
use_services = NULL;
|
||||||
len = 0;
|
len = 0;
|
||||||
n = 0;
|
|
||||||
TAILQ_FOREACH(svc, tmplist, entries) {
|
TAILQ_FOREACH(svc, tmplist, entries) {
|
||||||
rc_service_schedule_start(svc->value, service);
|
rc_service_schedule_start(svc->value, service);
|
||||||
use_services = rc_deptree_depend(deptree,
|
use_services = rc_deptree_depend(deptree,
|
||||||
@@ -765,7 +762,6 @@ svc_start_deps(void)
|
|||||||
rc_stringlist_free(use_services);
|
rc_stringlist_free(use_services);
|
||||||
use_services = NULL;
|
use_services = NULL;
|
||||||
len += strlen(svc->value) + 2;
|
len += strlen(svc->value) + 2;
|
||||||
n++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
len += 5;
|
len += 5;
|
||||||
@@ -788,7 +784,7 @@ svc_start_deps(void)
|
|||||||
services = NULL;
|
services = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void svc_start_real()
|
static void svc_start_real(void)
|
||||||
{
|
{
|
||||||
bool started;
|
bool started;
|
||||||
RC_STRING *svc, *svc2;
|
RC_STRING *svc, *svc2;
|
||||||
@@ -1165,7 +1161,6 @@ int main(int argc, char **argv)
|
|||||||
dir = save;
|
dir = save;
|
||||||
} else
|
} else
|
||||||
file = basename_c(argv[1]);
|
file = basename_c(argv[1]);
|
||||||
ll = strlen(dir) + strlen(file) + 2;
|
|
||||||
xasprintf(&service, "%s/%s", dir, file);
|
xasprintf(&service, "%s/%s", dir, file);
|
||||||
if (stat(service, &stbuf) != 0) {
|
if (stat(service, &stbuf) != 0) {
|
||||||
free(service);
|
free(service);
|
||||||
|
|||||||
@@ -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)
|
||||||
@@ -304,7 +307,6 @@ int main(int argc, char **argv)
|
|||||||
sigaction(SIGINT, &sa, NULL);
|
sigaction(SIGINT, &sa, NULL);
|
||||||
sigaction(SIGTERM, &sa, NULL);
|
sigaction(SIGTERM, &sa, NULL);
|
||||||
while (shutdown_delay > 0) {
|
while (shutdown_delay > 0) {
|
||||||
need_warning = false;
|
|
||||||
if (shutdown_delay > 180)
|
if (shutdown_delay > 180)
|
||||||
need_warning = (shutdown_delay % 60 == 0);
|
need_warning = (shutdown_delay % 60 == 0);
|
||||||
else if (shutdown_delay > 60)
|
else if (shutdown_delay > 60)
|
||||||
@@ -313,11 +315,12 @@ int main(int argc, char **argv)
|
|||||||
need_warning = (shutdown_delay % 15 == 0);
|
need_warning = (shutdown_delay % 15 == 0);
|
||||||
else
|
else
|
||||||
need_warning = true;
|
need_warning = true;
|
||||||
|
|
||||||
if (shutdown_delay <= 5)
|
if (shutdown_delay <= 5)
|
||||||
create_nologin(shutdown_delay);
|
create_nologin(shutdown_delay);
|
||||||
if (need_warning) {
|
if (need_warning) {
|
||||||
xasprintf(&msg, "\rThe system will %s in %d minutes\r\n",
|
xasprintf(&msg, "\rThe system will %s in %d minutes\r\n",
|
||||||
state, shutdown_delay);
|
state, shutdown_delay);
|
||||||
broadcast(msg);
|
broadcast(msg);
|
||||||
free(msg);
|
free(msg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -64,8 +59,7 @@ const struct option longopts[] = {
|
|||||||
};
|
};
|
||||||
const char * const longopts_help[] = {
|
const char * const longopts_help[] = {
|
||||||
"do not stop any services",
|
"do not stop any services",
|
||||||
"override the next runlevel to change into\n",
|
"override the next runlevel to change into\nwhen leaving single user or boot runlevels",
|
||||||
"when leaving single user or boot runlevels",
|
|
||||||
"runs the service specified with the rest\nof the arguments",
|
"runs the service specified with the rest\nof the arguments",
|
||||||
"output the RC system type, if any",
|
"output the RC system type, if any",
|
||||||
longopts_help_COMMON
|
longopts_help_COMMON
|
||||||
@@ -383,7 +377,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;
|
||||||
@@ -415,15 +409,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:
|
||||||
@@ -453,7 +447,7 @@ handle_signal(int sig)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_sysinit()
|
do_sysinit(void)
|
||||||
{
|
{
|
||||||
struct utsname uts;
|
struct utsname uts;
|
||||||
const char *sys;
|
const char *sys;
|
||||||
@@ -506,7 +500,6 @@ runlevel_config(const char *service, const char *level)
|
|||||||
char *conf, *dir;
|
char *conf, *dir;
|
||||||
bool retval;
|
bool retval;
|
||||||
|
|
||||||
dir = dirname(init);
|
|
||||||
dir = dirname(init);
|
dir = 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);
|
||||||
@@ -697,7 +690,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];
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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,22 +18,22 @@
|
|||||||
#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]))
|
||||||
|
|
||||||
@@ -55,11 +55,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 +66,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 +77,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 +99,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 +108,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 +125,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;
|
||||||
|
|||||||
@@ -15,22 +15,21 @@
|
|||||||
* except according to the terms contained in the LICENSE file.
|
* except according to the terms contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/file.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/utsname.h>
|
|
||||||
|
|
||||||
#ifdef __linux__
|
|
||||||
# include <sys/sysinfo.h>
|
|
||||||
#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>
|
||||||
#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/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 +39,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;
|
||||||
|
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|||||||
@@ -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)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
@@ -354,6 +348,9 @@ int main(int argc, char **argv)
|
|||||||
#ifdef PR_SET_NO_NEW_PRIVS
|
#ifdef PR_SET_NO_NEW_PRIVS
|
||||||
bool no_new_privs = false;
|
bool no_new_privs = false;
|
||||||
#endif
|
#endif
|
||||||
|
int pipefd[2];
|
||||||
|
char readbuf[1];
|
||||||
|
ssize_t ss;
|
||||||
|
|
||||||
applet = basename_c(argv[0]);
|
applet = basename_c(argv[0]);
|
||||||
atexit(cleanup);
|
atexit(cleanup);
|
||||||
@@ -864,12 +861,17 @@ int main(int argc, char **argv)
|
|||||||
if (background)
|
if (background)
|
||||||
signal_setup(SIGCHLD, handle_signal);
|
signal_setup(SIGCHLD, handle_signal);
|
||||||
|
|
||||||
|
/* Use a pipe to sync the parent/child processes. */
|
||||||
|
if (pipe2(pipefd, O_CLOEXEC) == -1)
|
||||||
|
eerrorx("%s: pipe2: %s", applet, strerror(errno));
|
||||||
|
|
||||||
if ((pid = fork()) == -1)
|
if ((pid = fork()) == -1)
|
||||||
eerrorx("%s: fork: %s", applet, strerror(errno));
|
eerrorx("%s: fork: %s", applet, strerror(errno));
|
||||||
|
|
||||||
/* Child process - lets go! */
|
/* Child process - lets go! */
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
pid_t mypid = getpid();
|
pid_t mypid = getpid();
|
||||||
|
close(pipefd[0]); /* Close the read end of the pipe. */
|
||||||
umask(numask);
|
umask(numask);
|
||||||
|
|
||||||
#ifdef TIOCNOTTY
|
#ifdef TIOCNOTTY
|
||||||
@@ -878,11 +880,23 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
devnull_fd = open("/dev/null", O_RDWR);
|
devnull_fd = open("/dev/null", O_RDWR);
|
||||||
|
|
||||||
|
/* Must call setsid() before setting autogroup nicelevel
|
||||||
|
* but after opening tty_fd. */
|
||||||
|
setsid();
|
||||||
|
|
||||||
if (nicelevel != INT_MIN) {
|
if (nicelevel != INT_MIN) {
|
||||||
if (setpriority(PRIO_PROCESS, mypid, nicelevel) == -1)
|
if (setpriority(PRIO_PROCESS, mypid, nicelevel) == -1)
|
||||||
eerrorx("%s: setpriority %d: %s",
|
eerrorx("%s: setpriority %d: %s",
|
||||||
applet, nicelevel,
|
applet, nicelevel,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
/* Open in "r+" mode to avoid creating if non-existent. */
|
||||||
|
fp = fopen("/proc/self/autogroup", "r+");
|
||||||
|
if (fp) {
|
||||||
|
fprintf(fp, "%d\n", nicelevel);
|
||||||
|
fclose(fp);
|
||||||
|
} else if (errno != ENOENT)
|
||||||
|
eerrorx("%s: autogroup nice %d: %s", applet,
|
||||||
|
nicelevel, strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ionicec != -1 &&
|
if (ionicec != -1 &&
|
||||||
@@ -1084,8 +1098,12 @@ 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
|
||||||
|
closefrom(3);
|
||||||
|
#else
|
||||||
for (i = getdtablesize() - 1; i >= 3; --i)
|
for (i = getdtablesize() - 1; i >= 3; --i)
|
||||||
close(i);
|
close(i);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (scheduler != NULL) {
|
if (scheduler != NULL) {
|
||||||
int scheduler_index;
|
int scheduler_index;
|
||||||
@@ -1118,7 +1136,6 @@ int main(int argc, char **argv)
|
|||||||
eerrorx("Failed to set scheduler parameters: %s", strerror(errno));
|
eerrorx("Failed to set scheduler parameters: %s", strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
setsid();
|
|
||||||
execvp(exec, argv);
|
execvp(exec, argv);
|
||||||
#ifdef HAVE_PAM
|
#ifdef HAVE_PAM
|
||||||
if (changeuser != NULL && pamr == PAM_SUCCESS)
|
if (changeuser != NULL && pamr == PAM_SUCCESS)
|
||||||
@@ -1129,6 +1146,18 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Parent process */
|
/* Parent process */
|
||||||
|
|
||||||
|
close(pipefd[1]); /* Close the write end of the pipe. */
|
||||||
|
|
||||||
|
/* The child never writes to the pipe, so this read will block until
|
||||||
|
* the child calls exec or exits. */
|
||||||
|
while ((ss = read(pipefd[0], readbuf, 1)) == -1 && errno == EINTR);
|
||||||
|
if (ss == -1)
|
||||||
|
eerrorx("%s: failed to read from pipe: %s",
|
||||||
|
applet, strerror(errno));
|
||||||
|
|
||||||
|
close(pipefd[0]);
|
||||||
|
|
||||||
if (!background) {
|
if (!background) {
|
||||||
/* As we're not backgrounding the process, wait for our pid
|
/* As we're not backgrounding the process, wait for our pid
|
||||||
* to return */
|
* to return */
|
||||||
|
|||||||
@@ -22,20 +22,11 @@
|
|||||||
#define ONE_SECOND 1000000000
|
#define ONE_SECOND 1000000000
|
||||||
#define ONE_MS 1000000
|
#define ONE_MS 1000000
|
||||||
|
|
||||||
#include <sys/types.h>
|
#ifdef HAVE_CLOSE_RANGE_CLOEXEC
|
||||||
#include <sys/ioctl.h>
|
/* For close_range() */
|
||||||
#include <sys/resource.h>
|
# define _GNU_SOURCE
|
||||||
#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
|
#endif
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
@@ -47,7 +38,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>
|
||||||
|
|
||||||
@@ -191,8 +192,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);
|
||||||
@@ -207,7 +208,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",
|
||||||
@@ -353,7 +354,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;
|
||||||
@@ -391,6 +392,14 @@ static void child_process(char *exec, char **argv)
|
|||||||
if (setpriority(PRIO_PROCESS, getpid(), nicelevel) == -1)
|
if (setpriority(PRIO_PROCESS, getpid(), nicelevel) == -1)
|
||||||
eerrorx("%s: setpriority %d: %s", applet, nicelevel,
|
eerrorx("%s: setpriority %d: %s", applet, nicelevel,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
/* Open in "r+" mode to avoid creating if non-existent. */
|
||||||
|
fp = fopen("/proc/self/autogroup", "r+");
|
||||||
|
if (fp) {
|
||||||
|
fprintf(fp, "%d\n", nicelevel);
|
||||||
|
fclose(fp);
|
||||||
|
} else if (errno != ENOENT)
|
||||||
|
eerrorx("%s: autogroup nice %d: %s", applet,
|
||||||
|
nicelevel, strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ionicec != -1 && ioprio_set(1, getpid(), ionicec | ioniced) == -1)
|
if (ionicec != -1 && ioprio_set(1, getpid(), ionicec | ioniced) == -1)
|
||||||
@@ -561,8 +570,11 @@ static void child_process(char *exec, char **argv)
|
|||||||
if (redirect_stderr || rc_yesno(getenv("EINFO_QUIET")))
|
if (redirect_stderr || rc_yesno(getenv("EINFO_QUIET")))
|
||||||
dup2(stderr_fd, STDERR_FILENO);
|
dup2(stderr_fd, STDERR_FILENO);
|
||||||
|
|
||||||
for (i = getdtablesize() - 1; i >= 3; --i)
|
#ifdef HAVE_CLOSE_RANGE_CLOEXEC
|
||||||
fcntl(i, F_SETFD, FD_CLOEXEC);
|
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);
|
||||||
@@ -575,7 +587,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];
|
||||||
|
|||||||
@@ -19,22 +19,18 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#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"
|
||||||
|
|
||||||
#define RC_SHUTDOWNTIME RC_SVCDIR "/shutdowntime"
|
|
||||||
|
|
||||||
const char *applet = NULL;
|
const char *applet = NULL;
|
||||||
const char *extraopts = "file";
|
const char *extraopts = "file";
|
||||||
@@ -54,7 +50,7 @@ const char *usagestring = NULL;
|
|||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int opt, sflag = 0, wflag = 0;
|
int opt, sflag = 0, wflag = 0;
|
||||||
const char *file = RC_SHUTDOWNTIME;
|
const char *file = NULL;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
||||||
@@ -75,16 +71,16 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if (optind < argc)
|
if (optind < argc)
|
||||||
file = argv[optind++];
|
file = argv[optind++];
|
||||||
|
else
|
||||||
|
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;
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,15 @@ set -e
|
|||||||
set -u
|
set -u
|
||||||
|
|
||||||
rc_libexecdir="$1"
|
rc_libexecdir="$1"
|
||||||
os="$2"
|
sbindir="$2"
|
||||||
|
os="$3"
|
||||||
|
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 -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
|
||||||
|
ln -s openrc-init "${DESTDIR}/${sbindir}"/init
|
||||||
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user