Skip to content

Commit 6c7f5b1

Browse files
committed
0.7.1 (20210220)
- Fixed make distclean/clobber on Debian (use debian-clobber instead of clobber) (spotted by Marc Haber) - Fixed parallel make test (race condition creating test directory) (spotted by Marc Haber) - Fixed manpage header and footer and various other minor fixes and improvements - Minor improvements in a few module tests - Added configure --prefix=/opt/local for macports (spotted by Kurt Hindenburg) - Added mention of file locations on macOS/macports to the daemon(1) manpage - Added checks for gcc -W options that fail on old macosx (e.g. 10.6.8) without macports - Minor changes to usage error messages for consistency - Improved config file parsing (skip spaces around commas and added more error messages) - Added support for using $CC in configure (spotted by Ryan Schmidt) - Fixed Makefile (wasn't inheriting CPPFLAGS, CFLAGS or LDFLAGS from caller) (spotted by Ryan Schmidt)
1 parent 837423f commit 6c7f5b1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+3146
-2230
lines changed

CHANGELOG

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
CHANGELOG
22
=========
33

4+
0.7.1 (20210220)
5+
6+
- Fixed make distclean/clobber on Debian (use debian-clobber instead of clobber) (spotted by Marc Haber)
7+
- Fixed parallel make test (race condition creating test directory) (spotted by Marc Haber)
8+
- Fixed manpage header and footer and various other minor fixes and improvements
9+
- Minor improvements in a few module tests
10+
- Added configure --prefix=/opt/local for macports (spotted by Kurt Hindenburg)
11+
- Added mention of file locations on macOS/macports to the daemon(1) manpage
12+
- Added checks for gcc -W options that fail on old macosx (e.g. 10.6.8) without macports
13+
- Minor changes to usage error messages for consistency
14+
- Improved config file parsing (skip spaces around commas and added more error messages)
15+
- Added support for using $CC in configure (spotted by Ryan Schmidt)
16+
- Fixed Makefile (wasn't inheriting CPPFLAGS, CFLAGS or LDFLAGS from caller) (spotted by Ryan Schmidt)
17+
418
0.7 (20201111)
519

620
- Fixed bug: race condition causing failure with "exec daemon ..." (with Askar Safin safinaskar at mail.ru)
@@ -377,6 +391,6 @@ CHANGELOG
377391
URL: http://libslack.org/daemon
378392
URL: http://raf.org/daemon
379393
GIT: https://github.com/raforg/daemon
380-
Date: 20201111
394+
Date: 20210220
381395
Author: raf <raf@raf.org>
382396

COPYING

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ COPYING
22
=======
33
daemon - turns other processes into daemons
44

5-
Copyright (C) 1999-2004, 2010, 2020 raf <raf@raf.org>
5+
Copyright (C) 1999-2004, 2010, 2020-2021 raf <raf@raf.org>
66

77
This program is free software; you can redistribute it and/or modify
88
it under the terms of the GNU General Public License as published by
@@ -19,7 +19,7 @@ Copyright (C) 1999-2004, 2010, 2020 raf <raf@raf.org>
1919

2020
libslack - A UNIX/C library of general utilities for programmers with Slack
2121

22-
Copyright (C) 1999-2004, 2010, 2020 raf <raf@raf.org>
22+
Copyright (C) 1999-2004, 2010, 2020-2021 raf <raf@raf.org>
2323

2424
This library is free software; you can redistribute it and/or modify
2525
it under the terms of the GNU General Public License as published by
@@ -67,6 +67,6 @@ All rights reserved.
6767
URL: http://libslack.org/daemon
6868
URL: http://raf.org/daemon
6969
GIT: https://github.com/raforg/daemon
70-
Date: 20201111
70+
Date: 20210220
7171
Author: raf <raf@raf.org>
7272

INSTALL

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This version is only known to work on the following systems:
99
OpenBSD 4.7 (i386, amd64), 6.6 (amd64)
1010
FreeBSD 8.0 (i386, amd64), 12.1 (amd64)
1111
NetBSD 5.0.2 (i386, amd64), 8.1 (amd64)
12-
MacOSX 10.{4,5,6,11,14} (ppc, i386, x86_64)
12+
MacOSX/macOS 10.{4,5,6,11,14,15}, 11 (ppc, i386, x86_64, arm64)
1313
kFreeBSD 20090729 (i386)
1414
GNU/Hurd (i386)
1515

@@ -44,17 +44,32 @@ they have some very nasty bugs.
4444

4545
First, uninstall any previous version:
4646

47-
cd /usr/local/src/daemon-0.6.4
47+
cd /usr/local/src/daemon-0.7
4848
make uninstall
4949

5050
To build and test:
5151

52-
tar xzf daemon-0.7.tar.gz
53-
cd daemon-0.7
52+
tar xzf daemon-0.7.1.tar.gz
53+
cd daemon-0.7.1
5454
./configure # iff linux, openbsd, freebsd, netbsd, macosx, solaris, gnuhurd or kfreebsd
5555
make # must be gnu make
5656
make test # only tests libslack. to test daemon, see test/README
5757

58+
Note that the configure script is not a GNU autoconf script.
59+
It just has hard-coded settings for certain platforms.
60+
It does not accept all of the usual command line options.
61+
However, it does accept certain options:
62+
63+
--prefix=/opt/local
64+
Changes the installation prefix to a non-standard one (needed for macports).
65+
This also changes the directory that the config file is installed in.
66+
When --prefix=/usr or --prefix=default, the config file is installed in /etc.
67+
Otherwise (e.g. --prefix=/usr/local or --prefix=/opt/local), the config
68+
file is installed under the prefix.
69+
70+
--enable-test
71+
Include backup implementations of several functions (unnecessary)
72+
5873
To install daemon and its manpage (in /usr/local by default):
5974

6075
make install
@@ -102,43 +117,43 @@ created.
102117

103118
To install from the Fedora RPM binary package (into /usr by default):
104119

105-
rpm -i daemon-0.7-1.x86_64.rpm # or
106-
rpm -i daemon-0.7-1.i686.rpm
120+
rpm -i daemon-0.7.1-1.x86_64.rpm # or
121+
rpm -i daemon-0.7.1-1.i686.rpm
107122

108123
To install from the OpenBSD binary package (into /usr/local by default):
109124

110-
mv daemon-0.7-openbsd-amd64.tgz daemon-0.7.tgz # or
111-
mv daemon-0.7-openbsd-i386.tgz daemon-0.7.tgz
125+
mv daemon-0.7.1-openbsd-amd64.tgz daemon-0.7.1.tgz # or
126+
mv daemon-0.7.1-openbsd-i386.tgz daemon-0.7.1.tgz
112127
# then
113-
pkg_add daemon-0.7.tar.gz
128+
pkg_add daemon-0.7.1.tar.gz
114129

115130
To install from the FreeBSD binary package (into /usr/local by default):
116131

117-
pkg_add daemon-0.7-freebsd-amd64.tbz # or
118-
pkg_add daemon-0.7-freebsd-i386.tbz
132+
pkg_add daemon-0.7.1-freebsd-amd64.tbz # or
133+
pkg_add daemon-0.7.1-freebsd-i386.tbz
119134

120135
To install from the NetBSD binary package (into /usr/local by default):
121136

122-
pkg_add daemon-0.7-netbsd-amd64.tgz # or
123-
pkg_add daemon-0.7-netbsd-i386.tgz
137+
pkg_add daemon-0.7.1-netbsd-amd64.tgz # or
138+
pkg_add daemon-0.7.1-netbsd-i386.tgz
124139

125140
To install from the Mac OS X binary package (into /usr/local by default):
126141

127142
cd /usr/local
128-
tar xzf /usr/local/src/daemon-0.7-macosx-universal.tar.gz # or
129-
tar xzf /usr/local/src/daemon-0.7-macosx-x86_64.tar.gz # or
130-
tar xzf /usr/local/src/daemon-0.7-macosx-i386.tar.gz # or
131-
tar xzf /usr/local/src/daemon-0.7-macosx-powerpc.tar.gz
143+
tar xzf /usr/local/src/daemon-0.7.1-macosx-universal.tar.gz # or
144+
tar xzf /usr/local/src/daemon-0.7.1-macosx-x86_64.tar.gz # or
145+
tar xzf /usr/local/src/daemon-0.7.1-macosx-i386.tar.gz # or
146+
tar xzf /usr/local/src/daemon-0.7.1-macosx-powerpc.tar.gz
132147

133148
To install from the Solaris10 binary package (into /usr/local by default):
134149

135-
gunzip daemon-0.7-solaris-amd64.pkg.gz
136-
pkgadd -d daemon-0.7-solaris-amd64.pkg
150+
gunzip daemon-0.7.1-solaris-amd64.pkg.gz
151+
pkgadd -d daemon-0.7.1-solaris-amd64.pkg
137152

138153
or
139154

140-
gunzip daemon-0.7-solaris-i386.pkg.gz
141-
pkgadd -d daemon-0.7-solaris-i386.pkg
155+
gunzip daemon-0.7.1-solaris-i386.pkg.gz
156+
pkgadd -d daemon-0.7.1-solaris-i386.pkg
142157

143158
On debian/ubuntu systems you should be able to:
144159

@@ -189,7 +204,7 @@ filesystem entry is needed for the client and it must be unlinked after use.
189204
It's also possible for a malicious local user to deny a client access to the
190205
server. The solution is to always use UNIX domain stream sockets.
191206

192-
Solaris has an inadequate snprintf() function so libslack provides it's own
207+
Solaris has an inadequate snprintf() function so libslack provides its own
193208
implementation. When configured for Solaris, this snprintf() function will
194209
format exactly like the system's sprintf() function, even though it has
195210
incorrect behaviour with respect to the ISO C standard. I thought this was
@@ -213,6 +228,6 @@ Probably has the same UNIX domain datagram problem as Solaris.
213228
URL: http://libslack.org/daemon
214229
URL: http://raf.org/daemon
215230
GIT: https://github.com/raforg/daemon
216-
Date: 20201111
231+
Date: 20210220
217232
Author: raf <raf@raf.org>
218233

Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# daemon - http://libslack.org/daemon/
33
#
4-
# Copyright (C) 1999-2004, 2010, 2020 raf <raf@raf.org>
4+
# Copyright (C) 1999-2004, 2010, 2020-2021 raf <raf@raf.org>
55
#
66
# This program is free software; you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License as published by
@@ -17,10 +17,11 @@
1717
# along with this program; if not, see <https://www.gnu.org/licenses/>.
1818
#
1919

20-
# 20201111 raf <raf@raf.org>
20+
# 20210220 raf <raf@raf.org>
2121

2222
CC := gcc
2323
# CC := cc
24+
# CC := other
2425
AR := ar
2526
RANLIB := ranlib
2627
POD2MAN := pod2man
@@ -161,8 +162,12 @@ depend: ready $(DEPEND_CFILES) $(DEPEND_HFILES)
161162
clean::
162163
@rm -rf $(CLEAN_FILES)
163164

165+
ifeq ($(shell uname -a 2>/dev/null | grep -i Debian),)
164166
clobber::
165167
@rm -rf $(CLEAN_FILES) $(CLOBBER_FILES)
168+
else
169+
clobber:: debian-clobber
170+
endif
166171

167172
distclean:: clobber
168173
@perl -pi -e 'last if /[D]O NOT DELETE/;' $(patsubst %, %/Makefile, $(DAEMON_SRCDIR) $(DAEMON_SUBDIRS))

README.md

Lines changed: 72 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -31,111 +31,125 @@ Change the process `uid` and `gid` if the `--user` option was supplied. Only
3131
*root* can use this option. Note that the `uid` of *daemon* itself is changed,
3232
rather than just changing the `uid` of the client process.
3333

34-
Read the configuration file (`/etc/daemon.conf` by default, or specified
35-
by the `--config` option). Note: The root directory and the user must be
36-
set before access to the configuration file can be attempted so neither
37-
`--chroot` nor `--user` options may appear in the configuration file.
34+
Read the system configuration file(s) (`/etc/daemon.conf` and
35+
`/etc/daemon.conf.d/*` by default, or specified by the `--config` option)
36+
unless the C<--noconfig> option was supplied. Then read the user's personal
37+
configuration file(s) (`~/.daemonrc` and `~/.daemonrc.d/*`), if any. Note:
38+
The root directory and the user must be set before access to the
39+
configuration file(s) can be attempted so neither `--chroot` nor `--user`
40+
options may appear in the configuration file.
3841

39-
Disable core file generation to prevent leaking information in daemons run
40-
by *root* (unless the `--core` option is supplied).
42+
On *BSD* systems (except *macOS*), the system configuration file(s) are
43+
`/usr/local/etc/daemon.conf` and `/usr/local/etc/daemon.conf.d/*` by
44+
default.
45+
46+
On *macOS*, when installed via *macports*, the system configuration file(s)
47+
are `/opt/local/etc/daemon.conf` and `/opt/local/etc/daemon.conf.d/*`.
48+
49+
Disable core file generation to prevent leaking potentially sensitive
50+
information in daemons that are run by *root* (unless the `--core` option
51+
was supplied).
4152

4253
Become a daemon process:
4354

4455
* If *daemon* was not invoked by *init(8)* (i.e. pid 1) or *inetd(8)*:
4556

4657
* Ignore `SIGHUP` signals in case the current process session leader
47-
terminates while attached to a controlling terminal causing us to
58+
terminates while attached to a controlling terminal, causing us to
4859
receive a `SIGHUP` signal before we start our own process session below.
4960
This can happen when *daemon* was invoked interactively via the shell
5061
builtin `exec`. When this initial process terminates below, the terminal
51-
emulator that invoked the shell also terminates.
62+
emulator that invoked the shell also terminates, do *daemon* needs to
63+
protect itself from that.
5264

5365
* Background the process to lose process group leadership.
5466

5567
* Start a new process session.
5668

57-
* Background the process again to lose process session leadership. Under
58-
SVR4 this prevents the process from ever gaining a controlling terminal.
59-
This is only necessary under SVR4 but is always done for simplicity. Note
60-
that ignoring `SIGHUP` signals earlier means that when the newly created
61-
process session leader terminates, then even if it has a controlling
62-
terminal open, the newly backgrounded process won't receive the
63-
corresponding `SIGHUP` signal that is sent to all processes in the process
64-
session's foreground process group because it inherited signal dispositions
65-
from the initial process.
69+
* Background the process again to lose process session leadership. Under
70+
*SVR4* this prevents the process from ever gaining a controlling
71+
terminal. This is only necessary under *SVR4*, but is always done for
72+
simplicity. Note that ignoring `SIGHUP` signals earlier means that
73+
when the newly created process session leader terminates, then even if
74+
it has a controlling terminal open, the newly backgrounded process
75+
won't receive the corresponding `SIGHUP` signal that is sent to all
76+
processes in the process session's foreground process group, because
77+
it inherited signal dispositions from the initial process.
6678

67-
* Change directory to the root directory so as not to hamper umounts.
79+
* Change the current directory to the root directory so as not to hamper
80+
umounts.
6881

69-
* Clear the umask to enable explicit file creation modes.
82+
* Clear the *umask* to enable explicit file creation modes.
7083

7184
* Close all open file descriptors. If *daemon* was invoked by *inetd(8)*,
72-
`stdin`, `stdout` and `stderr` are left open since they are open to a
73-
socket.
85+
`stdin`, `stdout` and `stderr` are left open, because they are open to a
86+
socket.
7487

75-
* Open `stdin`, `stdout` and `stderr` to `/dev/null` in case something
88+
* Open `stdin`, `stdout` and `stderr` to `/dev/null`, in case something
7689
requires them to be open. Of course, this is not done if *daemon* was
7790
invoked by *inetd(8)*.
7891

7992
* If the `--name` option was supplied, create and lock a file containing the
80-
process id of the *daemon* process. The presence of this locked file
81-
prevents two instances of a daemon with the same name from running at the
82-
same time. The standard location of the pidfile is `/var/run` for *root*
83-
(`/etc` on *Solaris*) and `/tmp` for normal users. If the `--pidfiles`
84-
option was supplied, its argument specifies the directory in which the
85-
pidfile will be placed. If the `--pidfile` option was supplied, its
86-
argument specifies the name of the pidfile and the directory in which it
87-
will be placed.
88-
89-
If the `--umask` option was supplied, set the umask to its argument.
90-
Otherwise, set the umask to `022` to prevent accidentally creating group or
91-
world writable files.
93+
process id of the *daemon* process. The presence of this locked file
94+
prevents two instances of a daemon with the same name from running at
95+
the same time. The default location of the pidfile is `/var/run` for
96+
*root* (`/etc` on *Solaris*, `/opt/local/var/run` on *macOS* when
97+
installed via *macports*), and `/tmp` for normal users. If the
98+
`--pidfiles` option was supplied, its argument specifies the directory
99+
in which the pidfile will be placed. If the `--pidfile` option was
100+
supplied, its argument specifies the name of the pidfile and the
101+
directory in which it will be placed.
102+
103+
If the `--umask` option was supplied, set the *umask* to its argument, which
104+
must be a valid three-digit octal mode. Otherwise, set the *umask* to `022`,
105+
to prevent accidentally creating group- or world-writable files.
92106

93107
Set the current directory if the `--chdir` option was supplied.
94108

95109
Spawn the client command and wait for it to terminate. The client command
96-
may be specified as command line arguments or as the argument of the
110+
can be specified as command line arguments, or as the argument of the
97111
`--command` option. If both the `--command` option and command line
98112
arguments are present, the client command is the result of appending the
99113
command line arguments to the argument of the `--command` option.
100114

101115
If the `--output`, `--stdout` and/or `--stderr` option were supplied, the client's
102-
standard output and/or standard error are captured by *daemon* and sent to the
116+
standard output and/or standard error are captured by *daemon*, and sent to the
103117
respective *syslog* destinations.
104118

105119
When the client terminates, *daemon* respawns it if the `--respawn` option
106-
was supplied. If the client ran for less than 300 seconds (or the value of
107-
the `--acceptable` option), then *daemon* sees this as an error. It will
120+
was supplied. If the client ran for less than `300` seconds (or the value of
121+
the `--acceptable` option), then *daemon* sees this as a failure. It will
108122
attempt to restart the client up to five times (or the value of the
109-
`--attempts` option) before waiting for 300 seconds (or the value of the
110-
`--delay` option). This gives the administrator the chance to correct
111-
whatever is preventing the client from running without overloading system
112-
resources. If the `--limit` option was supplied, *daemon* terminates after
113-
the specified number of spawn attempt bursts. The default is zero which
114-
means never give up, never surrender.
123+
`--attempts` option), before waiting for `300` seconds (or the value of the
124+
`--delay` option). This gives the system administrator the chance to correct
125+
whatever is preventing the client from running successfully without
126+
overloading system resources. If the `--limit` option was supplied, *daemon*
127+
terminates after the specified number of respawn attempt bursts. The default
128+
is zero, which means never give up, never surrender.
115129

116-
When the client terminates and the `--respawn` option wasn't supplied,
117-
*daemon* terminates.
130+
When the client terminates, and the `--respawn` option wasn't supplied,
131+
*daemon* terminates as well.
118132

119-
If *daemon* receives a `SIGTERM` signal (e.g. from another invocation of
120-
*daemon* supplied with the `--stop` option), it propagates the signal to the
121-
client and then terminates.
133+
If *daemon* receives a `SIGTERM` signal (e.g. from a separate invocation of
134+
*daemon* with the `--stop` option), it propagates the signal to the client
135+
and then terminates.
122136

123-
If *daemon* receives a `SIGUSR1` signal (from another invocation of
124-
*daemon* supplied with the `--restart` option), it sends a `SIGTERM`
125-
signal to the client. If started with the `--respawn` option, the client
126-
process will be restarted after it is killed by the `SIGTERM` signal.
137+
If *daemon* receives a `SIGUSR1` signal (from a separate invocation of
138+
*daemon* with the `--restart` option), it sends a `SIGTERM` signal to the
139+
client. If it was started with the `--respawn` option, the client process
140+
will be restarted after it is terminated by the `SIGTERM` signal.
127141

128142
If the `--foreground` option was supplied, the client process is run as a
129-
foreground process and is not turned into a daemon. If *daemon* is
130-
connected to a terminal, so will the client process. If *daemon* is not
131-
connected to a terminal but the client needs to be connected to a terminal,
132-
use the `--pty` option.
143+
foreground process, and is not turned into a daemon at all. If *daemon* is
144+
connected to a terminal, then the client process will also be connected to
145+
it. If *daemon* is not connected to a terminal, but the client needs to be
146+
connected to a terminal, use the `--pty` option.
133147

134148
--------------------------------------------------------------------------------
135149

136150
URL: http://libslack.org/daemon
137151
URL: http://raf.org/daemon
138152
GIT: https://github.com/raforg/daemon
139-
Date: 20201111
153+
Date: 20210220
140154
Author: raf <raf@raf.org>
141155

0 commit comments

Comments
 (0)