Compare commits
	
		
			5 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					3e5420b911 | ||
| 
						 | 
					9666279210 | ||
| 
						 | 
					c7032602dd | ||
| 
						 | 
					c253eb0412 | ||
| 
						 | 
					8accc2d780 | 
@@ -4,8 +4,8 @@
 | 
			
		||||
test_task:
 | 
			
		||||
  freebsd_instance:
 | 
			
		||||
    matrix:
 | 
			
		||||
      image: freebsd-13-1-release-amd64
 | 
			
		||||
      image: freebsd-12-4-release-amd64
 | 
			
		||||
      image: freebsd-13-0-release-amd64
 | 
			
		||||
      image: freebsd-12-3-release-amd64
 | 
			
		||||
  env:
 | 
			
		||||
    OS: FreeBSD
 | 
			
		||||
  procfs_script: >
 | 
			
		||||
 
 | 
			
		||||
@@ -1,142 +0,0 @@
 | 
			
		||||
# 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-2023, the OpenRC authors
 | 
			
		||||
Copyright (c) 2007-2015, the OpenRC authors
 | 
			
		||||
All rights reserved.
 | 
			
		||||
 | 
			
		||||
Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										21
									
								
								NEWS.md
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								NEWS.md
									
									
									
									
									
								
							@@ -4,27 +4,6 @@ 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,7 +7,6 @@ conf_common = [
 | 
			
		||||
  'localmount',
 | 
			
		||||
  'netmount',
 | 
			
		||||
  'swap',
 | 
			
		||||
  'swclock',
 | 
			
		||||
  ]
 | 
			
		||||
 | 
			
		||||
conf_net = [
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +0,0 @@
 | 
			
		||||
# 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.glusterfs fuse.sshfs gfs glusterfs lustre
 | 
			
		||||
# ncpfs nfs nfs4 ocfs2 shfs smbfs
 | 
			
		||||
# afs ceph cifs coda davfs fuse 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.
 | 
			
		||||
 
 | 
			
		||||
@@ -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 -e "--noadjfile"; then
 | 
			
		||||
		if LC_ALL=C hwclock --help 2>&1 | grep -q "\-\-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 --use-blacklist --verbose "$x"; rc=$? ;;
 | 
			
		||||
			Linux) modprobe --first-time -q --use-blacklist "$x"; rc=$? ;;
 | 
			
		||||
			*) ;;
 | 
			
		||||
		esac
 | 
			
		||||
		eend
 | 
			
		||||
		eend $rc "Failed to load $x"
 | 
			
		||||
	done
 | 
			
		||||
	return 0
 | 
			
		||||
}
 | 
			
		||||
@@ -80,10 +80,9 @@ FreeBSD_modules()
 | 
			
		||||
	for x in $modules; do
 | 
			
		||||
		ebegin "Loading module $x"
 | 
			
		||||
		kldload "$x"
 | 
			
		||||
		eend && : $(( cnt += 1 ))
 | 
			
		||||
		eend $? "Failed to load $x" && : $(( cnt += 1 ))
 | 
			
		||||
	done
 | 
			
		||||
	einfo "Autoloaded $cnt module(s)"
 | 
			
		||||
	return 0
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Linux_modules()
 | 
			
		||||
@@ -123,7 +122,6 @@ Linux_modules()
 | 
			
		||||
		eval modprobe --first-time --use-blacklist --verbose "$x" "$args"
 | 
			
		||||
	done
 | 
			
		||||
	[ -n "$list" ] && eend
 | 
			
		||||
	return 0
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
start()
 | 
			
		||||
 
 | 
			
		||||
@@ -49,7 +49,9 @@ start()
 | 
			
		||||
	local mountpoint
 | 
			
		||||
	for mountpoint in $(fstabinfo); do
 | 
			
		||||
		case "${mountpoint}" in
 | 
			
		||||
			/*) # Don't remount swap etc.
 | 
			
		||||
			/)
 | 
			
		||||
			;;
 | 
			
		||||
			/*)
 | 
			
		||||
				mountinfo -q "${mountpoint}" && \
 | 
			
		||||
					fstabinfo --remount "${mountpoint}"
 | 
			
		||||
			;;
 | 
			
		||||
 
 | 
			
		||||
@@ -10,7 +10,6 @@
 | 
			
		||||
# 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()
 | 
			
		||||
{
 | 
			
		||||
@@ -23,7 +22,7 @@ depend()
 | 
			
		||||
start()
 | 
			
		||||
{
 | 
			
		||||
	ebegin "Setting the local clock based on last shutdown time"
 | 
			
		||||
	if ! swclock "${swclock_file}" 2> /dev/null; then
 | 
			
		||||
	if ! swclock 2> /dev/null; then
 | 
			
		||||
	swclock --warn @SBINDIR@/openrc-run
 | 
			
		||||
	fi
 | 
			
		||||
	eend $?
 | 
			
		||||
@@ -32,6 +31,6 @@ start()
 | 
			
		||||
stop()
 | 
			
		||||
{
 | 
			
		||||
	ebegin "Saving the shutdown time"
 | 
			
		||||
	swclock --save "${swclock_file}"
 | 
			
		||||
	swclock --save
 | 
			
		||||
	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 /run/openrc
 | 
			
		||||
.Pa /lib/rc/init.d
 | 
			
		||||
as a ramdisk using tmpfs where available unless / is mounted rw at boot.
 | 
			
		||||
.Nm
 | 
			
		||||
uses
 | 
			
		||||
.Pa /run/openrc
 | 
			
		||||
.Pa /lib/rc/init.d
 | 
			
		||||
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 /run/openrc/deptree .
 | 
			
		||||
.Pa /lib/rc/init.d/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 /run/openrc
 | 
			
		||||
.Pa /lib/rc/init.d
 | 
			
		||||
normally holds the volatile state data for services on a RAM backed disk.
 | 
			
		||||
.Sh SEE ALSO
 | 
			
		||||
.Xr errno 3 ,
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										14
									
								
								meson.build
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								meson.build
									
									
									
									
									
								
							@@ -1,5 +1,5 @@
 | 
			
		||||
project('OpenRC', 'c',
 | 
			
		||||
  version : '0.46',
 | 
			
		||||
  version : '0.45.2',
 | 
			
		||||
  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', check: true)
 | 
			
		||||
  r = run_command(uname, '-s')
 | 
			
		||||
  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', check: false).returncode() != 0
 | 
			
		||||
  split_usr = run_command('test', '-L', '/bin').returncode() != 0
 | 
			
		||||
else
 | 
			
		||||
  split_usr = get_option('split-usr') == 'true'
 | 
			
		||||
endif
 | 
			
		||||
@@ -192,14 +192,6 @@ 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')
 | 
			
		||||
 
 | 
			
		||||
@@ -79,7 +79,6 @@ elif ! mountinfo -q /run; then
 | 
			
		||||
			exit 1
 | 
			
		||||
		fi
 | 
			
		||||
	fi
 | 
			
		||||
	eend
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
checkpath -d "$RC_SVCDIR"
 | 
			
		||||
 
 | 
			
		||||
@@ -2,10 +2,8 @@
 | 
			
		||||
# 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.glusterfs fuse.sshfs gfs glusterfs lustre
 | 
			
		||||
	ncpfs nfs nfs4 ocfs2 shfs smbfs
 | 
			
		||||
"
 | 
			
		||||
net_fs_list="afs ceph cifs coda davfs fuse fuse.sshfs gfs glusterfs lustre
 | 
			
		||||
ncpfs nfs nfs4 ocfs2 shfs smbfs"
 | 
			
		||||
is_net_fs()
 | 
			
		||||
{
 | 
			
		||||
	[ -z "$1" ] && return 1
 | 
			
		||||
 
 | 
			
		||||
@@ -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(AT_FDCWD, "/", O_RDONLY);
 | 
			
		||||
	dirfd = openat(dirfd, "/", 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 & 07777) != mode) {
 | 
			
		||||
		if (mode && (st.st_mode & 0777) != 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);
 | 
			
		||||
	free(deptree);
 | 
			
		||||
	rc_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 | status | describe | zap";
 | 
			
		||||
const char *extraopts = "stop | start | restart | 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(void)
 | 
			
		||||
unhotplug()
 | 
			
		||||
{
 | 
			
		||||
	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;
 | 
			
		||||
	int depoptions = RC_DEP_TRACE, n;
 | 
			
		||||
	size_t len;
 | 
			
		||||
	char *p, *tmp;
 | 
			
		||||
	pid_t pid;
 | 
			
		||||
@@ -755,6 +755,7 @@ 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,
 | 
			
		||||
@@ -764,6 +765,7 @@ svc_start_deps(void)
 | 
			
		||||
			rc_stringlist_free(use_services);
 | 
			
		||||
			use_services = NULL;
 | 
			
		||||
			len += strlen(svc->value) + 2;
 | 
			
		||||
			n++;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		len += 5;
 | 
			
		||||
@@ -786,7 +788,7 @@ svc_start_deps(void)
 | 
			
		||||
	services = NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void svc_start_real(void)
 | 
			
		||||
static void svc_start_real()
 | 
			
		||||
{
 | 
			
		||||
	bool started;
 | 
			
		||||
	RC_STRING *svc, *svc2;
 | 
			
		||||
@@ -1163,6 +1165,7 @@ 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,6 +304,7 @@ 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)
 | 
			
		||||
@@ -312,12 +313,11 @@ 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,7 +64,8 @@ const struct option longopts[] = {
 | 
			
		||||
};
 | 
			
		||||
const char * const longopts_help[] = {
 | 
			
		||||
	"do not stop any services",
 | 
			
		||||
	"override the next runlevel to change into\nwhen leaving single user or boot runlevels",
 | 
			
		||||
	"override the next runlevel to change into\n",
 | 
			
		||||
	"when 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
 | 
			
		||||
@@ -452,32 +453,11 @@ handle_signal(int sig)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
do_early_hostname(void)
 | 
			
		||||
{
 | 
			
		||||
#ifdef __linux__
 | 
			
		||||
	/* Set hostname if available */
 | 
			
		||||
	char *buffer = NULL;
 | 
			
		||||
	size_t len;
 | 
			
		||||
 | 
			
		||||
	if (rc_getfile(RC_SYSCONFDIR "/hostname", &buffer, &len)) {
 | 
			
		||||
		if (buffer[len - 2] == '\n')
 | 
			
		||||
			buffer[--len - 1] = '\0';
 | 
			
		||||
		if (sethostname(buffer, len)) {
 | 
			
		||||
			/* ignore */;
 | 
			
		||||
		}
 | 
			
		||||
		free(buffer);
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
do_sysinit(void)
 | 
			
		||||
do_sysinit()
 | 
			
		||||
{
 | 
			
		||||
	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? */
 | 
			
		||||
@@ -526,6 +506,7 @@ 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,9 +354,6 @@ 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);
 | 
			
		||||
@@ -867,17 +864,12 @@ 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
 | 
			
		||||
@@ -886,23 +878,11 @@ 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 &&
 | 
			
		||||
@@ -1104,12 +1084,8 @@ 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;
 | 
			
		||||
@@ -1142,6 +1118,7 @@ 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)
 | 
			
		||||
@@ -1152,18 +1129,6 @@ 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,11 +22,6 @@
 | 
			
		||||
#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>
 | 
			
		||||
@@ -396,14 +391,6 @@ 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)
 | 
			
		||||
@@ -574,11 +561,8 @@ static void child_process(char *exec, char **argv)
 | 
			
		||||
	if (redirect_stderr || rc_yesno(getenv("EINFO_QUIET")))
 | 
			
		||||
		dup2(stderr_fd, STDERR_FILENO);
 | 
			
		||||
 | 
			
		||||
#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);
 | 
			
		||||
	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,6 +34,7 @@
 | 
			
		||||
#include "misc.h"
 | 
			
		||||
#include "_usage.h"
 | 
			
		||||
 | 
			
		||||
#define RC_SHUTDOWNTIME    RC_SVCDIR "/shutdowntime"
 | 
			
		||||
 | 
			
		||||
const char *applet = NULL;
 | 
			
		||||
const char *extraopts = "file";
 | 
			
		||||
@@ -53,7 +54,7 @@ const char *usagestring = NULL;
 | 
			
		||||
int main(int argc, char **argv)
 | 
			
		||||
{
 | 
			
		||||
	int opt, sflag = 0, wflag = 0;
 | 
			
		||||
	const char *file = NULL;
 | 
			
		||||
	const char *file = RC_SHUTDOWNTIME;
 | 
			
		||||
	struct stat sb;
 | 
			
		||||
	struct timeval tv;
 | 
			
		||||
 | 
			
		||||
@@ -74,8 +75,6 @@ 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) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user