Skip to content

Commit e2c6bc9

Browse files
committed
0.3 (20000902)
- Started using GNU getopt_long() instead of getopt_long_only() - Started ignoring /etc/daemon.conf if group or world writable - Added -DSVR4 in conf/solaris (doh!) - Added conditional compilation of debug functions - Added assert macro that calls dump() - Completed the daemon(1) manpage (common options weren't documented) - Fixed bug: SIG_IGN, SIG_DFL and nasty signals weren't treated specially - Made lists grow/shrink exponentially rather than linearly - Made maps grow as needed and use arbitrary hash functions and key types - Added multi-dimensional array allocator to the mem module - Added net module: clients/servers, expect/send, pack/unpack, mail - Added internal iterators and some more functions to list and map - Added examples sections to some libprog manpages - Added --user option - Added str module: decent strings + tr, regex, regsub, fmt, trim, lc, uc ... - Added vsscanf(3) implementation for systems that don't have it (e.g. solaris) - Renamed libprog to libslack (thanks, fred!) - Added socks.h - Added daemon_revoke_privileges(), daemon_file_is_safe() to daemon module - Moved revocation of setuid/setgid privileges to start for greater safety - Fixed bug: wasn't unlinking pidfile when client died of natural causes - Fixed bug: wasn't processing config file correctly - Included daemon(1) tests in distribution (not automatic, though)
1 parent 13d8b9f commit e2c6bc9

Some content is hidden

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

71 files changed

+17361
-4261
lines changed

MANIFEST

Lines changed: 59 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,67 @@
11
./Makefile
22
./daemon.c
33
./macros.mk
4-
./MANIFEST
54
./README
6-
./prog
7-
./prog/conf.c
8-
./prog/conf.h
9-
./prog/daemon.c
10-
./prog/daemon.h
11-
./prog/err.c
12-
./prog/err.h
13-
./prog/fifo.c
14-
./prog/fifo.h
15-
./prog/getopt.c
16-
./prog/getopt.h
17-
./prog/hdr.h
18-
./prog/hsort.c
19-
./prog/hsort.h
20-
./prog/lim.c
21-
./prog/lim.h
22-
./prog/list.c
23-
./prog/list.h
24-
./prog/log.c
25-
./prog/log.h
26-
./prog/mem.c
27-
./prog/mem.h
28-
./prog/msg.c
29-
./prog/msg.h
30-
./prog/prog.c
31-
./prog/prog.h
32-
./prog/sig.c
33-
./prog/sig.h
34-
./prog/snprintf.c
35-
./prog/snprintf.h
36-
./prog/opt.c
37-
./prog/opt.h
38-
./prog/rules.mk
39-
./prog/macros.mk
40-
./prog/Makefile
41-
./prog/map.c
42-
./prog/map.h
43-
./prog/prop.c
44-
./prog/prop.h
455
./rules.mk
466
./conf
477
./conf/linux
488
./conf/solaris
9+
./conf/test
10+
./libslack
11+
./libslack/conf.c
12+
./libslack/conf.h
13+
./libslack/daemon.c
14+
./libslack/daemon.h
15+
./libslack/err.c
16+
./libslack/err.h
17+
./libslack/fifo.c
18+
./libslack/fifo.h
19+
./libslack/getopt.c
20+
./libslack/getopt.h
21+
./libslack/hdr.h
22+
./libslack/hsort.c
23+
./libslack/hsort.h
24+
./libslack/lim.c
25+
./libslack/lim.h
26+
./libslack/list.c
27+
./libslack/list.h
28+
./libslack/log.c
29+
./libslack/log.h
30+
./libslack/mem.c
31+
./libslack/mem.h
32+
./libslack/msg.c
33+
./libslack/msg.h
34+
./libslack/prog.c
35+
./libslack/prog.h
36+
./libslack/sig.c
37+
./libslack/sig.h
38+
./libslack/snprintf.c
39+
./libslack/snprintf.h
40+
./libslack/opt.c
41+
./libslack/opt.h
42+
./libslack/rules.mk
43+
./libslack/macros.mk
44+
./libslack/Makefile
45+
./libslack/map.c
46+
./libslack/map.h
47+
./libslack/prop.c
48+
./libslack/prop.h
49+
./libslack/net.h
50+
./libslack/net.c
51+
./libslack/std.h
52+
./libslack/conf
53+
./libslack/conf/linux
54+
./libslack/conf/solaris
55+
./libslack/conf/test
56+
./libslack/str.h
57+
./libslack/str.c
58+
./libslack/lib.h
59+
./libslack/vsscanf.h
60+
./libslack/vsscanf.c
61+
./libslack/socks.h
62+
./libslack/README
63+
./MANIFEST
64+
./test
65+
./test/client2
66+
./test/client1
67+
./test/daemon.conf

Makefile

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
2-
# daemon: http://www.zip.com.au/~raf2/lib/software/daemon
2+
# daemon - http://libslack.org/daemon/
33
#
4-
# Copyright (C) 1999 raf <raf2@zip.com.au>
4+
# Copyright (C) 1999, 2000 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
@@ -19,6 +19,8 @@
1919
# or visit http://www.gnu.org/copyleft/gpl.html
2020
#
2121

22+
# 20000902 raf <raf@raf.org>
23+
2224
CC := gcc
2325
TEST := /usr/bin/test
2426
PREFIX := /usr/local
@@ -33,15 +35,16 @@ APP_CATDIR := $(MAN_INSDIR)/cat$(APP_MANSECT)
3335
LIB_MANDIR := $(MAN_INSDIR)/man$(LIB_MANSECT)
3436
LIB_CATDIR := $(MAN_INSDIR)/cat$(LIB_MANSECT)
3537
APP_MANSECTNAME := User Commands
36-
LIB_MANSECTNAME := C Library Functions - libprog
38+
LIB_MANSECTNAME := C Library Functions - libslack
3739

38-
CCFLAGS += -O2 # -Wall -pedantic
40+
CCFLAGS += -O2 -Wall -pedantic
3941

4042
CLEAN_FILES += tags core Makefile.bak .makefile.bak MANIFEST pod2html-*
4143

44+
DAEMON_IS_ROOT := 1
4245
DAEMON_SRCDIR := .
43-
DAEMON_INCDIRS := prog
44-
DAEMON_LIBDIRS := prog
46+
DAEMON_INCDIRS := libslack
47+
DAEMON_LIBDIRS := libslack
4548
include $(DAEMON_SRCDIR)/macros.mk
4649

4750
.PHONY: all ready test man html install uninstall
@@ -131,7 +134,8 @@ dist: distclean MANIFEST
131134
$(TEST) "$$src" != "$$dst" -a ! -e "$$dst" && ln -s $$src $$dst; \
132135
tar chzf $(DAEMON_DIST) $$dst; \
133136
$(TEST) -L "$$dst" && rm -f $$dst; \
134-
rm $$src/MANIFEST
137+
rm -f $$src/MANIFEST; \
138+
tar tzf $$dst.tar.gz
135139

136140
include $(DAEMON_SRCDIR)/rules.mk
137141

README

Lines changed: 97 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
README
22
~~~~~~
3-
This contains the source for the daemon program and the prog library.
3+
This contains the source code to daemon and libslack.
4+
5+
daemon - turns other processes into daemons
46

57
Daemon turns other processes into daemons. There are many tasks that need to
68
be performed to correctly set up a daemon process. This can be tedious.
79
Daemon performs these tasks for other processes. This is useful for writing
810
daemons in languages other than C, C++ or Perl (e.g. /bin/sh).
911

10-
The prog library contains the functionality of the daemon program in a
11-
separately linkable form. This can be useful for writing daemons in
12-
languages that can link against C functions (e.g. C, C++). The prog library
13-
also contains many other general utility functions.
12+
libslack - A UNIX/C library of general utilities for programmers with slack
13+
14+
Libslack contains many modules of general utility (including the ability to
15+
become a daemon) in a separately linkable form. This can be useful for
16+
writing daemons in languages that can link against C functions (e.g. C, C++).
17+
Libslack also contains many other general utility functions. See the
18+
documentation for details.
1419

1520
DESCRIPTION
1621
~~~~~~~~~~~
@@ -21,7 +26,7 @@ Daemon performs these tasks for other processes.
2126
The preparatory tasks that daemon performs for other processes are:
2227

2328
o Disable core file generation to prevent security holes in daemons run by
24-
root (unless the -core option is supplied).
29+
root (unless the --core option is supplied).
2530

2631
o If daemon was not invoked by init(8) or inetd(8):
2732

@@ -32,7 +37,7 @@ o If daemon was not invoked by init(8) or inetd(8):
3237
o Under SVR4, background the process again to lose process session
3338
leadership. This prevents the process from ever gaining a controlling
3439
terminal. This only happens when SVR4 is defined and
35-
NO_EXTRA_SVR4_FORK is not defined when libprog is compiled.
40+
NO_EXTRA_SVR4_FORK is not defined when libslack is compiled.
3641

3742
o Change to the root directory so as not to hamper umounts.
3843

@@ -46,56 +51,68 @@ o Open stdin, stdout and stderr to /dev/null in case something
4651
requires them to be open. Of course, this is not done if daemon was
4752
invoked by inetd(8).
4853

49-
o If the -name option is supplied, create and lock a file containing the
54+
o If the --name option is supplied, create and lock a file containing the
5055
process id of the daemon process. The presence of this locked file
5156
prevents two instances of a daemon with the same name from running at the
5257
same time.
5358

59+
If the --user option is supplied, daemon changes the user id (and possibly
60+
the group id). Only root can use this option.
61+
5462
Daemon then spawns the client command specified on its command line and
55-
waits for it to terminate. If the -syslog option is supplied, the client's
63+
waits for it to terminate. If the --syslog option is supplied, the client's
5664
standard output and error are captured by daemon and sent to the syslog
57-
destination specified in the -syslog option.
65+
destination specified in the --syslog option.
5866

59-
When the client terminates, daemon spawns it again if the -respawn option is
67+
When the client terminates, daemon respawns it if the --respawn option is
6068
supplied and the client terminated successfully after at least 600 seconds.
6169
Otherwise daemon terminates.
6270

6371
If daemon receives a SIGTERM signal, it propagates the signal to the client
6472
and then terminates.
6573

74+
Note: For security reasons, never install I<daemon> with setuid or setgid
75+
privileges. It is unnecessary. If you do, I<daemon> will revert to the real
76+
user and group for safety before doing anything else.
77+
6678
INSTALL
6779
~~~~~~~
6880
Currently this is only known to work on Linux Redhat 6.0 and Solaris 2.6.
6981
Compiling on Solaris 2.6 requires running conf/solaris in the source
70-
directory. There isn't a real configure script so you will no doubt
71-
encounter problems. An ANSI C and POSIX.1 environment will help greatly.
82+
directory. It is ready to compile on Linux as distributed so it is not
83+
necessary to run conf/linux. There isn't a real configure script so you will
84+
no doubt encounter problems on other systems. An ANSI C and POSIX
85+
environment will help greatly.
7286

73-
If your system doesn't have snprintf(3) or GNU getopt_long_only(3),
74-
uncomment the relevant lines in the prog/macros.mk file to include
75-
them in the prog libary.
87+
If your system doesn't have snprintf(3), GNU getopt_long(3) or vsscanf(3),
88+
uncomment the relevant lines in the libslack/macros.mk file to include them
89+
in libslack.
7690

77-
Requires perl to run the scripts in the conf directory.
78-
Requires gcc to compile the source.
79-
Requires pod2man (comes with perl) to make the manpages.
80-
Requires pod2html (comes with perl) to make the html manpages.
81-
Requires perl and GNU tar to make the distribution.
91+
If your system doesn't have POSIX 1003.2 compliant regex functions, either:
92+
install the GNU implementation, ftp://ftp.gnu.org/gnu/regex/regex-0.12.tar.gz
93+
[290K] (doesn't support internationalisation); or install Henry Spencer's
94+
implementation, ftp://ftp.zoo.toronto.edu/pub/regex.shar [157K].
95+
96+
If you really, really, really don't want the regular expression functions,
97+
uncomment REGEX_MISSING in libslack/macros.mk to enable the rest of the
98+
library to be compiled.
8299

83100
To build and test:
84101

85-
tar xzf daemon-0.2.tar.gz
86-
cd daemon-0.2
87-
conf/<your-system> # if applicable (i.e. solaris)
102+
tar xzf daemon-0.3.tar.gz
103+
cd daemon-0.3
104+
conf/<your-system> # if applicable (i.e. solaris)
88105
make depend
89106
make
90-
make test
107+
make test # note: compiling the tests can take ages
91108

92-
To install just the daemon program:
109+
To install just the daemon program and its manpage:
93110

94111
make install-daemon
95112

96-
To install just the prog library:
113+
To install just libslack and its manpages:
97114

98-
make install-prog
115+
make install-slack
99116

100117
To install both:
101118

@@ -105,10 +122,25 @@ For more details:
105122

106123
make help
107124

125+
The manpage for daemon is daemon(1). There is one manpage for each module in
126+
libslack (rather than one for each function). They are conf(3), daemon(3),
127+
err(3), fifo(3), hsort(3), lim(3), list(3), log(3), map(3), mem(3), msg(3),
128+
net(3), opt(3), prog(3), prop(3), sig(3) and str(3). If necessary, the
129+
manpages getopt(3), snprintf(3) and vsscanf(3) are created as well.
130+
131+
REQUIREMENTS
132+
~~~~~~~~~~~~
133+
Requires perl to run the scripts in the conf directory.
134+
Requires gcc to compile the source.
135+
Requires pod2man (comes with perl) to make the manpages.
136+
Requires pod2html (comes with perl) to make the html manpages.
137+
Requires perl and GNU tar to make the distribution.
138+
Requires POSIX 1003.2 compliant regex functions. See INSTALL.
139+
108140
COPYING
109141
~~~~~~~
110142
daemon - turns other processes into daemons
111-
Copyright (C) 1999 raf <raf2@zip.com.au>
143+
Copyright (C) 1999, 2000 raf <raf@raf.org>
112144

113145
This program is free software; you can redistribute it and/or modify
114146
it under the terms of the GNU General Public License as published by
@@ -125,8 +157,8 @@ Copyright (C) 1999 raf <raf2@zip.com.au>
125157
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
126158
or visit http://www.gnu.org/copyleft/gpl.html
127159

128-
libprog - general utilities including the ability to become a daemon
129-
Copyright (C) 1999 raf <raf2@zip.com.au>
160+
libslack - A UNIX/C library of general utilities for programmers with slack
161+
Copyright (C) 1999, 2000 raf <raf@raf.org>
130162

131163
This library is free software; you can redistribute it and/or modify
132164
it under the terms of the GNU General Public License as published by
@@ -145,6 +177,9 @@ Copyright (C) 1999 raf <raf2@zip.com.au>
145177

146178
HISTORY
147179
~~~~~~~
180+
0.1
181+
- Initial version
182+
148183
0.2
149184
- Decoupled core file prevention from daemon_init()
150185
into its own function, daemon_prevent_core()
@@ -171,15 +206,39 @@ HISTORY
171206
- Revert to real uid/gid if not same as effective uid/gid for safety
172207
- Added manpages
173208

174-
0.1
175-
Initial version
209+
0.3
210+
- Started using GNU getopt_long() instead of getopt_long_only()
211+
- Started ignoring /etc/daemon.conf if group or world writable
212+
- Added -DSVR4 in conf/solaris (doh!)
213+
- Added conditional compilation of debug functions
214+
- Added assert macro that calls dump()
215+
- Completed the daemon(1) manpage (common options weren't documented)
216+
- Fixed bug: SIG_IGN, SIG_DFL and nasty signals weren't treated specially
217+
- Made lists grow/shrink exponentially rather than linearly
218+
- Made maps grow as needed and use arbitrary hash functions and key types
219+
- Added multi-dimensional array allocator to the mem module
220+
- Added net module: clients/servers, expect/send, pack/unpack, mail
221+
- Added internal iterators and some more functions to list and map
222+
- Added examples sections to some libprog manpages
223+
- Added --user option
224+
- Added str module: decent strings + tr, regex, regsub, fmt, trim, lc, uc ...
225+
- Added vsscanf(3) implementation for systems that don't have it (e.g. solaris)
226+
- Renamed libprog to libslack (thanks, fred!)
227+
- Added socks.h
228+
- Added daemon_revoke_privileges(), daemon_file_is_safe() to daemon module
229+
- Moved revocation of setuid/setgid privileges to start for greater safety
230+
- Fixed bug: wasn't unlinking pidfile when client died of natural causes
231+
- Fixed bug: wasn't processing config file correctly
232+
- Included daemon(1) tests in distribution (not automatic, though)
176233

177234
TODO
178235
~~~~
179-
- Add configure script
236+
- Add modules: tty/pty, timo, thr
237+
- Add pool, gc(?) to mem module
238+
- Use autoconf
239+
- Use libtool
180240

181241
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
182-
URL: http://www.zip.com.au/~raf2/lib/software/daemon
183-
Date: 19991223
184-
Author: raf <raf2@zip.com.au>
185-
242+
URL: http://libslack.org/daemon/
243+
Date: 20000902
244+
Author: raf <raf@raf.org>

0 commit comments

Comments
 (0)