Compare commits
37 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
49ec9a868f | ||
|
|
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:
|
||||
freebsd_instance:
|
||||
matrix:
|
||||
image: freebsd-13-0-release-amd64
|
||||
image: freebsd-12-3-release-amd64
|
||||
image: freebsd-13-1-release-amd64
|
||||
image: freebsd-12-4-release-amd64
|
||||
env:
|
||||
OS: FreeBSD
|
||||
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-2015, the OpenRC authors
|
||||
Copyright (c) 2007-2023, the OpenRC authors
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
||||
21
NEWS.md
21
NEWS.md
@@ -4,6 +4,27 @@ OpenRC NEWS
|
||||
This file will contain a list of notable changes for each release. Note
|
||||
the information in this file is in reverse order.
|
||||
|
||||
## 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
|
||||
|
||||
The old make-based build system is removed in this release.
|
||||
|
||||
@@ -7,6 +7,7 @@ conf_common = [
|
||||
'localmount',
|
||||
'netmount',
|
||||
'swap',
|
||||
'swclock',
|
||||
]
|
||||
|
||||
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
|
||||
@@ -97,8 +97,8 @@
|
||||
|
||||
# Below is the default list of network fstypes.
|
||||
#
|
||||
# afs ceph cifs coda davfs fuse fuse.sshfs gfs glusterfs lustre 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
|
||||
#
|
||||
# If you would like to add to this list, you can do so by adding your
|
||||
# own fstypes to the following variable.
|
||||
|
||||
@@ -19,20 +19,18 @@ depend()
|
||||
|
||||
start()
|
||||
{
|
||||
local h source x
|
||||
if [ -s /etc/hostname ] && [ -r /etc/hostname ]; then
|
||||
read h x </etc/hostname
|
||||
source="from /etc/hostname"
|
||||
else
|
||||
# HOSTNAME variable used to be defined in caps in conf.d/hostname.
|
||||
# It is also a magic variable in bash.
|
||||
h=${hostname:-${HOSTNAME}} # checkbashisms: false positive (HOSTNAME var)
|
||||
local h source
|
||||
if read -r h _ 2> /dev/null < @SYSCONFDIR@/hostname; then
|
||||
source="@SYSCONFDIR@/hostname"
|
||||
elif [ -n "${hostname}" ]; then
|
||||
h=${hostname}
|
||||
source="@SYSCONFDIR@/conf.d/${RC_SVCNAME}"
|
||||
fi
|
||||
if [ -z "$h" ]; then
|
||||
einfo "Using default system hostname"
|
||||
return 0
|
||||
fi
|
||||
ebegin "Setting hostname to $h $source"
|
||||
ebegin "Setting hostname to $h from $source"
|
||||
hostname "$h"
|
||||
eend $? "Failed to set the hostname"
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ get_noadjfile()
|
||||
{
|
||||
if ! yesno $clock_adjfile; then
|
||||
# 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
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -56,10 +56,10 @@ load_modules()
|
||||
ebegin "Loading module $x"
|
||||
case "$RC_UNAME" in
|
||||
FreeBSD) kldload "$x"; rc=$? ;;
|
||||
Linux) modprobe --first-time -q --use-blacklist "$x"; rc=$? ;;
|
||||
Linux) modprobe --first-time --use-blacklist --verbose "$x"; rc=$? ;;
|
||||
*) ;;
|
||||
esac
|
||||
eend $rc "Failed to load $x"
|
||||
eend
|
||||
done
|
||||
return 0
|
||||
}
|
||||
@@ -80,9 +80,10 @@ FreeBSD_modules()
|
||||
for x in $modules; do
|
||||
ebegin "Loading module $x"
|
||||
kldload "$x"
|
||||
eend $? "Failed to load $x" && : $(( cnt += 1 ))
|
||||
eend && : $(( cnt += 1 ))
|
||||
done
|
||||
einfo "Autoloaded $cnt module(s)"
|
||||
return 0
|
||||
}
|
||||
|
||||
Linux_modules()
|
||||
@@ -122,6 +123,7 @@ Linux_modules()
|
||||
eval modprobe --first-time --use-blacklist --verbose "$x" "$args"
|
||||
done
|
||||
[ -n "$list" ] && eend
|
||||
return 0
|
||||
}
|
||||
|
||||
start()
|
||||
|
||||
@@ -49,9 +49,7 @@ start()
|
||||
local mountpoint
|
||||
for mountpoint in $(fstabinfo); do
|
||||
case "${mountpoint}" in
|
||||
/)
|
||||
;;
|
||||
/*)
|
||||
/*) # Don't remount swap etc.
|
||||
mountinfo -q "${mountpoint}" && \
|
||||
fstabinfo --remount "${mountpoint}"
|
||||
;;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
# except according to the terms contained in the LICENSE file.
|
||||
|
||||
description="Sets the local clock to the mtime of a given file."
|
||||
swclock_file="${swclock_file:-/var/lib/misc/openrc-shutdowntime}"
|
||||
|
||||
depend()
|
||||
{
|
||||
@@ -22,7 +23,7 @@ depend()
|
||||
start()
|
||||
{
|
||||
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
|
||||
fi
|
||||
eend $?
|
||||
@@ -31,6 +32,6 @@ start()
|
||||
stop()
|
||||
{
|
||||
ebegin "Saving the shutdown time"
|
||||
swclock --save
|
||||
swclock --save "${swclock_file}"
|
||||
eend $?
|
||||
}
|
||||
|
||||
@@ -37,11 +37,11 @@ Brings up any system specific stuff such as
|
||||
and optionally
|
||||
.Pa /sys
|
||||
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.
|
||||
.Nm
|
||||
uses
|
||||
.Pa /lib/rc/init.d
|
||||
.Pa /run/openrc
|
||||
to hold state information about the services it runs.
|
||||
sysinit always runs when the host first starts should not be run again.
|
||||
.It Ar boot
|
||||
|
||||
@@ -47,7 +47,7 @@ services.
|
||||
.Pp
|
||||
.Fn rc_deptree_update
|
||||
updates the service dependency tree, normally
|
||||
.Pa /lib/rc/init.d/deptree .
|
||||
.Pa /run/openrc/deptree .
|
||||
.Fn rc_deptree_update_needed
|
||||
checks to see if the dependency tree needs updated based on the mtime of it
|
||||
compared to
|
||||
|
||||
@@ -204,7 +204,7 @@ When a function fails it should either return false or NULL and set
|
||||
.Va errno
|
||||
unless specified otherwise as above.
|
||||
.Sh FILES
|
||||
.Pa /lib/rc/init.d
|
||||
.Pa /run/openrc
|
||||
normally holds the volatile state data for services on a RAM backed disk.
|
||||
.Sh SEE ALSO
|
||||
.Xr errno 3 ,
|
||||
|
||||
18
meson.build
18
meson.build
@@ -1,5 +1,5 @@
|
||||
project('OpenRC', 'c',
|
||||
version : '0.45',
|
||||
version : '0.46',
|
||||
license: 'BSD-2',
|
||||
default_options : [
|
||||
'c_std=c99',
|
||||
@@ -36,7 +36,7 @@ endif
|
||||
option_os = get_option('os')
|
||||
if option_os == ''
|
||||
uname = find_program('uname')
|
||||
r = run_command(uname, '-s')
|
||||
r = run_command(uname, '-s', check: true)
|
||||
os = r.stdout().strip()
|
||||
os = '-'.join(os.split('/'))
|
||||
else
|
||||
@@ -84,7 +84,7 @@ else
|
||||
endif
|
||||
|
||||
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
|
||||
split_usr = get_option('split-usr') == 'true'
|
||||
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')
|
||||
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')
|
||||
einfo_incdir = include_directories('src/libeinfo')
|
||||
rc_incdir = include_directories('src/librc')
|
||||
@@ -226,4 +234,6 @@ meson.add_install_script('tools/meson_runlevels.sh',
|
||||
get_option('sysvinit') ? 'yes' : 'no')
|
||||
meson.add_install_script('tools/meson_final.sh',
|
||||
rc_libexecdir,
|
||||
os)
|
||||
sbindir,
|
||||
os,
|
||||
get_option('sysvinit') ? 'yes' : 'no')
|
||||
|
||||
@@ -79,6 +79,7 @@ elif ! mountinfo -q /run; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
eend
|
||||
fi
|
||||
|
||||
checkpath -d "$RC_SVCDIR"
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
|
||||
# Released under the 2-clause BSD license.
|
||||
|
||||
net_fs_list="afs ceph cifs coda davfs fuse fuse.sshfs gfs glusterfs lustre
|
||||
ncpfs nfs nfs4 ocfs2 shfs smbfs"
|
||||
net_fs_list="
|
||||
afs ceph cifs coda davfs fuse fuse.glusterfs fuse.sshfs gfs glusterfs lustre
|
||||
ncpfs nfs nfs4 ocfs2 shfs smbfs
|
||||
"
|
||||
is_net_fs()
|
||||
{
|
||||
[ -z "$1" ] && return 1
|
||||
|
||||
@@ -47,8 +47,8 @@ ssd_start()
|
||||
${directory:+--chdir} $directory \
|
||||
${output_log+--stdout} $output_log \
|
||||
${error_log+--stderr} $error_log \
|
||||
${output_logger:+--stdout-logger} "$output_logger" \
|
||||
${error_logger:+--stderr-logger} "$error_logger" \
|
||||
${output_logger:+--stdout-logger \"$output_logger\"} \
|
||||
${error_logger:+--stderr-logger \"$error_logger\"} \
|
||||
${capabilities+--capabilities} "$capabilities" \
|
||||
${secbits:+--secbits} "$secbits" \
|
||||
${no_new_privs:+--no-new-privs} \
|
||||
|
||||
@@ -41,7 +41,7 @@ supervise_start()
|
||||
${no_new_privs:+--no_new_privs} \
|
||||
${command_user+--user} $command_user \
|
||||
${umask+--umask} $umask \
|
||||
${supervise_daemon_args:-${start_stop_daemon_args}} \
|
||||
${supervise_daemon_args-${start_stop_daemon_args}} \
|
||||
$command \
|
||||
-- $command_args $command_args_foreground
|
||||
rc=$?
|
||||
|
||||
@@ -89,7 +89,7 @@ static int get_dirfd(char *path, bool symlinks)
|
||||
|
||||
if (!path || *path != '/')
|
||||
eerrorx("%s: empty or relative path", applet);
|
||||
dirfd = openat(dirfd, "/", O_RDONLY);
|
||||
dirfd = openat(AT_FDCWD, "/", O_RDONLY);
|
||||
if (dirfd == -1)
|
||||
eerrorx("%s: unable to open the root directory: %s",
|
||||
applet, strerror(errno));
|
||||
@@ -285,7 +285,7 @@ static int do_check(char *path, uid_t uid, gid_t gid, mode_t mode,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mode && (st.st_mode & 0777) != mode) {
|
||||
if (mode && (st.st_mode & 07777) != mode) {
|
||||
if ((type != inode_dir) && (st.st_nlink > 1)) {
|
||||
eerror("%s: chmod: Too many hard links to %s", applet, path);
|
||||
close(readfd);
|
||||
|
||||
@@ -1074,6 +1074,6 @@ rc_deptree_update(void)
|
||||
}
|
||||
|
||||
rc_stringlist_free(config);
|
||||
rc_deptree_free(deptree);
|
||||
free(deptree);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
#define WARN_TIMEOUT 10 /* warn about this every N seconds */
|
||||
|
||||
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 struct option longopts[] = {
|
||||
{ "debug", 0, NULL, 'd'},
|
||||
@@ -161,7 +161,7 @@ handle_signal(int sig)
|
||||
}
|
||||
|
||||
static void
|
||||
unhotplug()
|
||||
unhotplug(void)
|
||||
{
|
||||
char *file = NULL;
|
||||
|
||||
@@ -645,7 +645,7 @@ svc_start_deps(void)
|
||||
bool first;
|
||||
RC_STRING *svc, *svc2;
|
||||
RC_SERVICE state;
|
||||
int depoptions = RC_DEP_TRACE, n;
|
||||
int depoptions = RC_DEP_TRACE;
|
||||
size_t len;
|
||||
char *p, *tmp;
|
||||
pid_t pid;
|
||||
@@ -755,7 +755,6 @@ svc_start_deps(void)
|
||||
rc_stringlist_free(use_services);
|
||||
use_services = NULL;
|
||||
len = 0;
|
||||
n = 0;
|
||||
TAILQ_FOREACH(svc, tmplist, entries) {
|
||||
rc_service_schedule_start(svc->value, service);
|
||||
use_services = rc_deptree_depend(deptree,
|
||||
@@ -765,7 +764,6 @@ svc_start_deps(void)
|
||||
rc_stringlist_free(use_services);
|
||||
use_services = NULL;
|
||||
len += strlen(svc->value) + 2;
|
||||
n++;
|
||||
}
|
||||
|
||||
len += 5;
|
||||
@@ -788,7 +786,7 @@ svc_start_deps(void)
|
||||
services = NULL;
|
||||
}
|
||||
|
||||
static void svc_start_real()
|
||||
static void svc_start_real(void)
|
||||
{
|
||||
bool started;
|
||||
RC_STRING *svc, *svc2;
|
||||
@@ -1165,7 +1163,6 @@ int main(int argc, char **argv)
|
||||
dir = save;
|
||||
} else
|
||||
file = basename_c(argv[1]);
|
||||
ll = strlen(dir) + strlen(file) + 2;
|
||||
xasprintf(&service, "%s/%s", dir, file);
|
||||
if (stat(service, &stbuf) != 0) {
|
||||
free(service);
|
||||
|
||||
@@ -304,7 +304,6 @@ int main(int argc, char **argv)
|
||||
sigaction(SIGINT, &sa, NULL);
|
||||
sigaction(SIGTERM, &sa, NULL);
|
||||
while (shutdown_delay > 0) {
|
||||
need_warning = false;
|
||||
if (shutdown_delay > 180)
|
||||
need_warning = (shutdown_delay % 60 == 0);
|
||||
else if (shutdown_delay > 60)
|
||||
@@ -313,11 +312,12 @@ int main(int argc, char **argv)
|
||||
need_warning = (shutdown_delay % 15 == 0);
|
||||
else
|
||||
need_warning = true;
|
||||
|
||||
if (shutdown_delay <= 5)
|
||||
create_nologin(shutdown_delay);
|
||||
if (need_warning) {
|
||||
xasprintf(&msg, "\rThe system will %s in %d minutes\r\n",
|
||||
state, shutdown_delay);
|
||||
xasprintf(&msg, "\rThe system will %s in %d minutes\r\n",
|
||||
state, shutdown_delay);
|
||||
broadcast(msg);
|
||||
free(msg);
|
||||
}
|
||||
|
||||
@@ -64,8 +64,7 @@ const struct option longopts[] = {
|
||||
};
|
||||
const char * const longopts_help[] = {
|
||||
"do not stop any services",
|
||||
"override the next runlevel to change into\n",
|
||||
"when leaving single user or boot runlevels",
|
||||
"override the next runlevel to change into\nwhen leaving single user or boot runlevels",
|
||||
"runs the service specified with the rest\nof the arguments",
|
||||
"output the RC system type, if any",
|
||||
longopts_help_COMMON
|
||||
@@ -453,11 +452,32 @@ handle_signal(int sig)
|
||||
}
|
||||
|
||||
static void
|
||||
do_sysinit()
|
||||
do_early_hostname(void)
|
||||
{
|
||||
#ifdef __linux__
|
||||
/* Set hostname if available */
|
||||
char *buffer = NULL;
|
||||
size_t len;
|
||||
|
||||
if (rc_getfile(RC_SYSCONFDIR "/hostname", &buffer, &len)) {
|
||||
if (buffer[len - 2] == '\n')
|
||||
buffer[--len - 1] = '\0';
|
||||
if (sethostname(buffer, len)) {
|
||||
/* ignore */;
|
||||
}
|
||||
free(buffer);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
do_sysinit(void)
|
||||
{
|
||||
struct utsname uts;
|
||||
const char *sys;
|
||||
|
||||
do_early_hostname();
|
||||
|
||||
/* exec init-early.sh if it exists
|
||||
* This should just setup the console to use the correct
|
||||
* font. Maybe it should setup the keyboard too? */
|
||||
@@ -506,7 +526,6 @@ runlevel_config(const char *service, const char *level)
|
||||
char *conf, *dir;
|
||||
bool retval;
|
||||
|
||||
dir = dirname(init);
|
||||
dir = dirname(init);
|
||||
xasprintf(&conf, "%s/conf.d/%s.%s", dir, service, level);
|
||||
retval = exists(conf);
|
||||
|
||||
@@ -354,6 +354,9 @@ int main(int argc, char **argv)
|
||||
#ifdef PR_SET_NO_NEW_PRIVS
|
||||
bool no_new_privs = false;
|
||||
#endif
|
||||
int pipefd[2];
|
||||
char readbuf[1];
|
||||
ssize_t ss;
|
||||
|
||||
applet = basename_c(argv[0]);
|
||||
atexit(cleanup);
|
||||
@@ -864,12 +867,17 @@ int main(int argc, char **argv)
|
||||
if (background)
|
||||
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)
|
||||
eerrorx("%s: fork: %s", applet, strerror(errno));
|
||||
|
||||
/* Child process - lets go! */
|
||||
if (pid == 0) {
|
||||
pid_t mypid = getpid();
|
||||
close(pipefd[0]); /* Close the read end of the pipe. */
|
||||
umask(numask);
|
||||
|
||||
#ifdef TIOCNOTTY
|
||||
@@ -878,11 +886,23 @@ int main(int argc, char **argv)
|
||||
|
||||
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 (setpriority(PRIO_PROCESS, mypid, nicelevel) == -1)
|
||||
eerrorx("%s: setpriority %d: %s",
|
||||
applet, nicelevel,
|
||||
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 &&
|
||||
@@ -1084,8 +1104,12 @@ int main(int argc, char **argv)
|
||||
|| rc_yesno(getenv("EINFO_QUIET")))
|
||||
dup2(stderr_fd, STDERR_FILENO);
|
||||
|
||||
#ifdef HAVE_CLOSEFROM
|
||||
closefrom(3);
|
||||
#else
|
||||
for (i = getdtablesize() - 1; i >= 3; --i)
|
||||
close(i);
|
||||
#endif
|
||||
|
||||
if (scheduler != NULL) {
|
||||
int scheduler_index;
|
||||
@@ -1118,7 +1142,6 @@ int main(int argc, char **argv)
|
||||
eerrorx("Failed to set scheduler parameters: %s", strerror(errno));
|
||||
}
|
||||
|
||||
setsid();
|
||||
execvp(exec, argv);
|
||||
#ifdef HAVE_PAM
|
||||
if (changeuser != NULL && pamr == PAM_SUCCESS)
|
||||
@@ -1129,6 +1152,18 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
/* 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) {
|
||||
/* As we're not backgrounding the process, wait for our pid
|
||||
* to return */
|
||||
|
||||
@@ -22,6 +22,11 @@
|
||||
#define ONE_SECOND 1000000000
|
||||
#define ONE_MS 1000000
|
||||
|
||||
#ifdef HAVE_CLOSE_RANGE_CLOEXEC
|
||||
/* For close_range() */
|
||||
# define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/resource.h>
|
||||
@@ -391,6 +396,14 @@ static void child_process(char *exec, char **argv)
|
||||
if (setpriority(PRIO_PROCESS, getpid(), nicelevel) == -1)
|
||||
eerrorx("%s: setpriority %d: %s", applet, nicelevel,
|
||||
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)
|
||||
@@ -561,8 +574,11 @@ static void child_process(char *exec, char **argv)
|
||||
if (redirect_stderr || rc_yesno(getenv("EINFO_QUIET")))
|
||||
dup2(stderr_fd, STDERR_FILENO);
|
||||
|
||||
for (i = getdtablesize() - 1; i >= 3; --i)
|
||||
fcntl(i, F_SETFD, FD_CLOEXEC);
|
||||
#ifdef HAVE_CLOSE_RANGE_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);
|
||||
syslog(LOG_INFO, "Child command line: %s", cmdline);
|
||||
free(cmdline);
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
#include "misc.h"
|
||||
#include "_usage.h"
|
||||
|
||||
#define RC_SHUTDOWNTIME RC_SVCDIR "/shutdowntime"
|
||||
|
||||
const char *applet = NULL;
|
||||
const char *extraopts = "file";
|
||||
@@ -54,7 +53,7 @@ const char *usagestring = NULL;
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int opt, sflag = 0, wflag = 0;
|
||||
const char *file = RC_SHUTDOWNTIME;
|
||||
const char *file = NULL;
|
||||
struct stat sb;
|
||||
struct timeval tv;
|
||||
|
||||
@@ -75,6 +74,8 @@ int main(int argc, char **argv)
|
||||
|
||||
if (optind < argc)
|
||||
file = argv[optind++];
|
||||
else
|
||||
eerrorx("swclock: Reference file was not specified");
|
||||
|
||||
if (sflag) {
|
||||
if (stat(file, &sb) == -1) {
|
||||
|
||||
@@ -4,10 +4,15 @@ set -e
|
||||
set -u
|
||||
|
||||
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
|
||||
fi
|
||||
install -d "${DESTDIR}/${rc_libexecdir}"/tmp
|
||||
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