Codebase list openrc / 4cfda59
Merge tag '0.42' into debian release 0.42 Benda Xu 3 years ago
81 changed file(s) with 1719 addition(s) and 2091 deletion(s). Raw diff Collapse all Expand all
0 # Cirrus CI integration
1 # https://cirrus-ci.org
2
3 test_task:
4 freebsd_instance:
5 matrix:
6 image: freebsd-12-0-release-amd64
7 image: freebsd-11-2-release-amd64
8 env:
9 OS: FreeBSD
10 procfs_script: >
11 [ -f /proc/curproc ] || mount -t procfs proc /proc
12 pkg_install_script: pkg install -y bash gawk gmake gsed
13 gsed_hack_script: rm /usr/bin/sed && ln -s /usr/local/bin/gsed /usr/bin/sed
14 test_script: bash ci/cirrus.sh
88 compiler:
99 - gcc
1010 - clang
11 - musl-gcc
12
13 addons:
14 apt:
15 packages:
16 - musl-tools
17
18 notifications:
19 irc:
20 channels:
21 - "irc.freenode.org#openrc"
22 on_success: change # options: [always|never|change] default: always
23 on_failure: always # options: [always|never|change] default: always
24 on_start: false # default: false
1125
1226 script:
13 - ./test/travis.sh
27 - ./ci/travis.sh
8181 Sergei Trofimovich <slyfox@gentoo.org>
8282 Seth Robertson <in-gentoo@baka.org>
8383 S. Gilles <sgilles@umd.edu>
84 Sony Interactive Entertainment, llc.
8485 Stefan Knoblich <s.knoblich@axsentis.de>
8586 Stef Simoens <stef.simoens@scarlet.be>
8687 Steve L <slong@rathaus.eclipse.co.uk>
0 commit 63e40f31bfc7d8908fee8059ea383038832dd84f
0 commit ed24d281631d564321d099a0d5e78be232d7de78
1 Author: William Hubbs <william.hubbs@sony.com>
2 Commit: William Hubbs <william.hubbs@sony.com>
3
4 update sysvinit support files
5
6 commit 1bc96141e6846a5f9b3cf2c2bcaf53f2ed9ca33d
7 Author: William Hubbs <william.hubbs@sony.com>
8 Commit: William Hubbs <william.hubbs@sony.com>
9
10 fix single user mode
11
12 commit c7000aeaabf34262375a2a96b5d5b8f7fcd8a793
13 Author: William Hubbs <william.hubbs@sony.com>
14 Commit: William Hubbs <william.hubbs@sony.com>
15
16 optimize loops for installing gettys
17
18 commit 5c5129b534bd8a0ebd0e525c87241d6c6ef0ec8c
19 Author: William Hubbs <william.hubbs@sony.com>
20 Commit: William Hubbs <william.hubbs@sony.com>
21
22 Remove "single" runlevel directory
23
24 Single user mode should be handled in the init process directly.
25
26 commit 0dabda6f6ff3744c6f1b1d2afd57845554384977
27 Author: William Hubbs <william.hubbs@sony.com>
28 Commit: William Hubbs <william.hubbs@sony.com>
29
30 fix sysvinit compatibility
31
32 This allows openrc to direct sysvinit to shut down the system by setting
33 the INIT_HALT environment variable appropriately. Also, we do not try to
34 communicate with sysvinit if its fifo does not exist.
35
36 commit 92de9a693b0e4156e404bc69ab230fe2355c22ca
37 Author: William Hubbs <william.hubbs@sony.com>
38 Commit: William Hubbs <william.hubbs@sony.com>
39
40 Add documentation for openrc-init and update the NEWS file
41
42 commit a71aebcae123d2684c4a326559749bc94b2796be
43 Author: William Hubbs <william.hubbs@sony.com>
44 Commit: William Hubbs <william.hubbs@sony.com>
45
46 init.d/agetty: provide the getty virtual service
47
48 commit 61596b16d228c15888033da3b4138c1e405e1cb9
49 Author: William Hubbs <william.hubbs@sony.com>
50 Commit: William Hubbs <william.hubbs@sony.com>
51
52 Install gettys if the MKSYSVINIT switch is set to yes
53
54 The default is to put one getty in the "single" runlevel and 6 in the
55 "default" runlevel.
56
57 commit 104eb3420b9332b441ce9965ef69ba5b099519ae
58 Author: William Hubbs <william.hubbs@sony.com>
59 Commit: William Hubbs <william.hubbs@sony.com>
60
61 Add the "single" runlevel
62
63 commit 70b8df3e9c7fed156e1a81ee7efe8a51c1010cb6
64 Author: Chloe Kudryavtsev <toast@toast.cafe>
65 Commit: William Hubbs <william.hubbs@sony.com>
66
67 clarify supervise-daemon-guide
68
69 1. The given default for respawn_max is wrong.
70 2. The example for respawn_period is nonsensical.
71
72 This fixes #311.
73
74 commit cac41092e4180a8d16edacab0c8552585d94328b
75 Author: William Hubbs <william.hubbs@sony.com>
76 Commit: William Hubbs <william.hubbs@sony.com>
77
78 add ability for openrc-shutdown to communicate with sysvinit
79
80 This fixes #315.
81
82 commit 7ddc281ab6fd11b63f41059818b0de4748e2821f
83 Author: Martin Wilke <miwi@ixsystems.com>
84 Commit: William Hubbs <william.hubbs@sony.com>
85
86 Fix build with Clang
87
88 This fixes #313.
89
90 commit c092ff6da174c12b913027ffa33d32622d39b9a0
91 Author: William Hubbs <william.hubbs@sony.com>
92 Commit: William Hubbs <w.d.hubbs@gmail.com>
93
94 Add Sony Interactive Entertainment as an author
95
96 commit 54780a45826f789f1291742eb2c99be369bfe64c
97 Author: William Hubbs <w.d.hubbs@gmail.com>
98 Commit: William Hubbs <w.d.hubbs@gmail.com>
99
100 supervise-daemon: allow --respawn-max to be zero
101
102 commit 44f5a72d1aeb131cc2cb464a53809a5a8d90c46e
103 Author: William Hubbs <w.d.hubbs@gmail.com>
104 Commit: William Hubbs <w.d.hubbs@gmail.com>
105
106 remove hidden-visibility.h
107
108 I am removing this on the advice of a member of the Gentoo toolchain
109 team. It was explained to me that this doesn't offer any significant
110 benefits to OpenRC.
111
112 If anyone ffeels differently, please open a pull request reverting
113 this and adding an explanation of what it does and how to know which
114 functions to mark hidden in the future.
115
116 This fixes #301.
117
118 commit 0d378974bfbd69c5427d44c0a43a9f36389aa235
119 Author: William Hubbs <w.d.hubbs@gmail.com>
120 Commit: William Hubbs <w.d.hubbs@gmail.com>
121
122 openrc-init: fix waitpid checks
123
124 The do_openrc() function was not waiting properly for the child process
125 which started the runlevel to return. We need to repeatedly call
126 waitpid() until its return value matches the pid of the child process or
127 the child process does not exist.
128
129 This fixes #216.
130 This fixes #300.
131
132 commit 028da5c2e37d81d4e242a546eb48a20eafe0cc56
133 Author: William Hubbs <w.d.hubbs@gmail.com>
134 Commit: William Hubbs <w.d.hubbs@gmail.com>
135
136 librc: fix potential buffer overflow in pid_is_argv
137
138 This fixes #299.
139
140 commit d8dbb890aaca34fc9b342772de0f23a7ea3efaaa
141 Author: William Hubbs <w.d.hubbs@gmail.com>
142 Commit: William Hubbs <w.d.hubbs@gmail.com>
143
144 Revert "src/librc/librc-daemon.c: fix buffer overrun in pid_is_argv"
145
146 This reverts commit 084877eb52971faf8f52c780ddd08ed9af140eb6.
147 The mentioned commit caused some systems to have some services reported
148 as crashed.
149
150 This fixes #297.
151 This fixes #298.
152
153 commit 56c006ebd68d572e303c01c38291a1f5f4fc1c30
154 Author: William Hubbs <w.d.hubbs@gmail.com>
155 Commit: William Hubbs <w.d.hubbs@gmail.com>
156
157 Update ChangeLog
158
159 commit 067088bbff42ca2fb9106acf309f1d9ce3e78ada
160 Author: William Hubbs <w.d.hubbs@gmail.com>
161 Commit: William Hubbs <w.d.hubbs@gmail.com>
162
163 move ci scripts to their own directory
164
165 This fixes #296.
166
167 commit 52d4e566743f57b9de81c77fdb605c171c02eacb
168 Author: William Hubbs <w.d.hubbs@gmail.com>
169 Commit: William Hubbs <w.d.hubbs@gmail.com>
170
171 combine test directories
172
173 This fixes #295.
174
175 commit 6e6902c28b715826fdfc7b42a592db88459b9a57
176 Author: William Hubbs <w.d.hubbs@gmail.com>
177 Commit: William Hubbs <w.d.hubbs@gmail.com>
178
179 remove unused test ignore patterns
180
181 commit 084823182aec4aef6fb880d642bba2d0ef91a3ad
182 Author: William Hubbs <w.d.hubbs@gmail.com>
183 Commit: William Hubbs <w.d.hubbs@gmail.com>
184
185 remove unused test data files
186
187 commit 7478c104fc479067d71d191dccfa4cbf541311d8
188 Author: Georgy Yakovlev <gyakovlev@gentoo.org>
189 Commit: William Hubbs <w.d.hubbs@gmail.com>
190
191 librc/librc-depend.c: fix NULL pointer dereference
192
193 In some cases deptree or depinfo can be NULL, check
194 before dereferencing.
195
196 Fixes https://github.com/OpenRC/openrc/issues/293
197 Fixes https://github.com/OpenRC/openrc/pulls/294
198 X-Gentoo-Bug: 659906
199 X-Gentoo-Bug-URL: https://bugs.gentoo.org/659906
200
201 commit 065b7ecc0d4ddd046cc235d60de20140db1a6fe8
202 Author: Georgy Yakovlev <gyakovlev@gentoo.org>
203 Commit: William Hubbs <w.d.hubbs@gmail.com>
204
205 use cirrus-ci for FreeBSD builds
206
207 This fixes #265.
208
209 commit b054aca50b31fc46fc736a542ec2719de2d23d30
210 Author: Sergei Trofimovich <slyfox@gentoo.org>
211 Commit: William Hubbs <w.d.hubbs@gmail.com>
212
213 src/test/runtests.sh: drop 'readelf'-based tests
214
215 The 'readelf'-based tests cover a few situations:
216 1. undefined symbols in shared libraries
217 2. unexpected exports in shared libraries
218
219 Bug #575958 shows that [2.] implementation is too simplistic
220 in assuming that presence of relocation equals to export presence.
221
222 It is incorrect for PLT stubs and local symbols.
223 Let's just drop these tests.
224
225 If one needs to cover [1.] it is better to use LDFLAGS=-Wl,--no-undefined.
226
227 This closes #292.
228
229 X-Reported-by: Benda Xu
230 X-Gentoo-Bug: https://bugs.gentoo.org/575958
231 X-Gentoo-Bug-URL: https://bugs.gentoo.org/575958
232
233 commit f9e7a00ba9c9b179c697fc0af83a19e923c831b0
234 Author: William Hubbs <w.d.hubbs@gmail.com>
235 Commit: William Hubbs <w.d.hubbs@gmail.com>
236
237 rc-status: style fixes
238
239 commit f1f48011acb266db309922f145653b86f11e0baf
240 Author: William Hubbs <w.d.hubbs@gmail.com>
241 Commit: William Hubbs <w.d.hubbs@gmail.com>
242
243 update ChangeLog
244
245 commit 427a1ce2995b376ed6d112c5c5b422217f815fbb
246 Author: William Hubbs <w.d.hubbs@gmail.com>
247 Commit: William Hubbs <w.d.hubbs@gmail.com>
248
249 rc-status: add -f option to allow formatting output
250
251 The -f option can be used when showing the status of services in
252 runlevels to allow making the output more easily parsable.
253 Currently, the .ini format is the only one supported.
254
255 commit f43cec34ca0201031fc10b584bcb391859f302cd
256 Author: William Hubbs <w.d.hubbs@gmail.com>
257 Commit: William Hubbs <w.d.hubbs@gmail.com>
258
259 rc-status.c: small style changes
260
261 commit d64c9d205083ca82823f9f5ff178a5581f6c8b2a
262 Author: William Hubbs <w.d.hubbs@gmail.com>
263 Commit: William Hubbs <w.d.hubbs@gmail.com>
264
265 add experimental support for an alternate shell for service scripts
266
267 This is for #288.
268
269 commit b2b2c57a3898c945b33b8bf0a10b658483be09c1
270 Author: Edan Bedrik <3d4nb3@gmail.com>
271 Commit: William Hubbs <w.d.hubbs@gmail.com>
272
273 librc: fix realpath() return value check
274
275 This fixes #226.
276
277 commit 155b8451945f8a17cd61ad56be3bb09541c3719a
278 Author: William Hubbs <w.d.hubbs@gmail.com>
279 Commit: William Hubbs <w.d.hubbs@gmail.com>
280
281 improve shutdown documentation
282
283 This fixes #290.
284
285 commit 9b578808fb67682780adb17157330934a5c2cce7
286 Author: Austin English <austinenglish@gmail.com>
287 Commit: William Hubbs <w.d.hubbs@gmail.com>
288
289 travis: try enabling musl-gcc
290
291 This fixes #261.
292
293 commit 03164dd38d9e8d9a93141e5d6b495f306875bcd9
294 Author: Austin English <austinenglish@gmail.com>
295 Commit: William Hubbs <w.d.hubbs@gmail.com>
296
297 fix build with muslc
298
299 This fixes #261.
300
301 commit 2b82766452adec4eb99f61902d62f0fa2e369fa4
302 Author: Austin English <austinenglish@gmail.com>
303 Commit: William Hubbs <w.d.hubbs@gmail.com>
304
305 test/skel.runtests.sh: remove unused file
306
307 git grep shows no usage, and `make test` passes
308
309 This fixes #256.
310
311 commit 3eef6e91274f2e07bd566f206e89d9b0b9c45fb9
312 Author: Felix Neumärker <xdch47@posteo.de>
313 Commit: William Hubbs <w.d.hubbs@gmail.com>
314
315 zsh-completion: _rc-service support extra actions
316
317 - use rc-service <service> describe to get action list
318
319 This is for #285.
320
321 commit 77f09900a2e0eeb1475e9ee404b6e7ff76ff8e9d
322 Author: Felix Neumärker <xdch47@posteo.de>
323 Commit: William Hubbs <w.d.hubbs@gmail.com>
324
325 zsh-completion: _rc-service fix flag/command combinations
326
327 - handle `rc-service -<flag> <service> <action>` correctly
328
329 This is for #285.
330
331 commit 50d77a4e5d8c321cc89565295db13e60b2fb2cc7
332 Author: Kim Jahn <kim@maisspace.org>
333 Commit: William Hubbs <w.d.hubbs@gmail.com>
334
335 man/openrc.8: add openrc-run.8 to see also
336
337 This fixes #283.
338
339 commit 2d31b0a3f8b4be7290e596cb7072b78361e1734b
340 Author: Mike Frysinger <vapier@gentoo.org>
341 Commit: Mike Frysinger <vapier@gentoo.org>
342
343 man: supervise-daemon: fix various style issues
344
345 The .Dt header is supposed to be all caps. This was mixing case.
346
347 The options block was being incorrectly indented due to a missing .El.
348
349 Some of the new options were missing the .It block, so add that.
350
351 Finally, the -D option was missing capitalization.
352
353 commit b84d0bac4d3f23ff969827d74808fd7bd1c621c3
354 Author: William Hubbs <w.d.hubbs@gmail.com>
355 Commit: William Hubbs <w.d.hubbs@gmail.com>
356
357 travis-ci: add IRC notifications
358
359 commit 1ff3a37c60e89da31c5c06bb4edd184770c91923
360 Author: William Hubbs <w.d.hubbs@gmail.com>
361 Commit: William Hubbs <w.d.hubbs@gmail.com>
362
363 start-stop-daemon: fix compiler warning
364
365 commit 7e95d924c9067d9d643fc3b533f777ea7a5234d7
366 Author: William Hubbs <w.d.hubbs@gmail.com>
367 Commit: William Hubbs <w.d.hubbs@gmail.com>
368
369 bash-completions/rc-service: allow tab to be used again
370
371 X-Gentoo-Bug: 670290
372 X-Gentoo-Bug-URL: https://bugs.gentoo.org/670290
373
374 commit a15b532a02094b3afe9d698f6b98e70f0fd4506a
375 Author: artoo <artoo@artixlinux.org>
376 Commit: William Hubbs <w.d.hubbs@gmail.com>
377
378 scripts: fix halt, poweroff and reboot wrappers
379
380 These are designed to emulate the sysvinit equivalents, so pass "now" as
381 the time argument if no arguments are given.
382
383 This fixes #268.
384
385 commit 3e00fbc9b08dde9e2c7fc26ecb9e831417012dd1
386 Author: philhofer <phofer@umich.edu>
387 Commit: William Hubbs <w.d.hubbs@gmail.com>
388
389 fix leading whitespace
390
391 Clean up code indented with mixed tabs and spaces.
392 No actual code changes.
393
394 This fixes #280.
395
396 commit 846e4600754dab3f0cb49edb4ad9e2b2b73d3f47
397 Author: philhofer <phofer@umich.edu>
398 Commit: William Hubbs <w.d.hubbs@gmail.com>
399
400 fix potential out-of-bounds reads
401
402 readlink(3) does not nul-terminate the result it sticks
403 into the supplied buffer. Consequently, the code
404
405 rc = readlink(path, buf, sizeof(buf));
406
407 does not necessarily produce a C string.
408
409 The code in rc_find_pid() produces some C strings this way
410 and passes them to strlen() and strcmp(), which can lead
411 to an out-of-bounds read.
412
413 In this case, since the code already takes care to
414 zero-initialize the buffers before passing them
415 to readlink(3), only allow sizeof(buf)-1 bytes to
416 be returned.
417
418 (While fixing this issue, I fixed two other locations that
419 used the same problematic pattern.)
420
421 This fixes #270.
422
423 commit a32b14bbb43e9888acaaea6f764fb8dcb34fb941
424 Author: William Hubbs <w.d.hubbs@gmail.com>
425 Commit: William Hubbs <w.d.hubbs@gmail.com>
426
427 Do not use UT_LINESIZE or __UT_LINESIZE
428
429 These are not standard.
430 For more information see issue #279.
431 This fixes #279.
432
433 commit 084877eb52971faf8f52c780ddd08ed9af140eb6
434 Author: philhofer <phofer@umich.edu>
435 Commit: William Hubbs <w.d.hubbs@gmail.com>
436
437 src/librc/librc-daemon.c: fix buffer overrun in pid_is_argv
438
439 The contents of /proc/<pid>/cmdline are read into
440 a stack buffer using
441
442 bytes = read(fd, buffer, sizeof(buffer));
443
444 followed by appending a null terminator to the buffer with
445
446 buffer[bytes] = '\0';
447
448 If bytes == sizeof(buffer), then this write is out-of-bounds.
449
450 Refactor the code to use rc_getfile instead, since PATH_MAX
451 is not the maximum size of /proc/<pid>/cmdline. (I hit this
452 issue in practice while compiling Linux; it tripped the
453 stack-smashing protector.)
454
455 This is roughly the same buffer overflow condition
456 that was fixed by commit 0ddee9b7d2b8dea810e252ca6a95c457876df120
457 This fixes #269.
458
459 commit 97e74f97347f5798e01a47057efab00906754546
460 Author: philhofer <phofer@umich.edu>
461 Commit: William Hubbs <w.d.hubbs@gmail.com>
462
463 src/rc/supervise-daemon.c: formatting fixes
464
465 Fix misleading indentation and other erroneous whitespace.
466 This fixes #273.
467
468 commit d328de198d0ad980188b105decc09405652aa3d6
469 Author: William Hubbs <w.d.hubbs@gmail.com>
470 Commit: William Hubbs <w.d.hubbs@gmail.com>
471
472 remove /run migration script again
473
474 This time it was done correctly.
475 I missed a '\' the last time.
476
477 commit a9fc26ac1367ac887eab76007e8834dfe787edcd
478 Author: philhofer <phofer@umich.edu>
479 Commit: Mike Frysinger <vapier@gmail.com>
480
481 src/rc/supervise-daemon.c: do not pass NULL to strcmp
482
483 The following will cause a segfault due to NULL being
484 passed to strcmp(3)
485
486 $ RC_SVCNAME=foo supervise-daemon
487
488 Fix the bounds check on argc in main. If argc<=1, then
489 it is not safe to dereference argv[1].
490
491 commit 40f70466969b340ee5e277c98a4b27a9117b795e
492 Author: philhofer <phofer@umich.edu>
493 Commit: Mike Frysinger <vapier@gmail.com>
494
495 src/rc/openrc-run.c: remove duplicate statement
496
497 The statement
498
499 ll = strlen(applet);
500
501 appears twice in the same block without any
502 intervening assignment to the variables
503 'll' or 'applet'
504
505 Remove the second (duplicate) statement.
506
507 commit 894995176e827eef16bf90b6479b7c285677ceef
508 Author: William Hubbs <w.d.hubbs@gmail.com>
509 Commit: William Hubbs <w.d.hubbs@gmail.com>
510
511 Revert "remove /run migration script"
512 For some reason removing this broke the build.
513
514 This reverts commit 5246ea7b6f8c6a247403f725f8301457f6ddfffd.
515
516 commit 5246ea7b6f8c6a247403f725f8301457f6ddfffd
517 Author: William Hubbs <w.d.hubbs@gmail.com>
518 Commit: William Hubbs <w.d.hubbs@gmail.com>
519
520 remove /run migration script
521
522 We have used /run for some time now and we have had this migration
523 script for 6 years. Linux users should have upgraded by now to a version
524 of OpenRC which stores its information in /run.
525
526 commit ed8b768c4a68042eed0c21c8305640841b22f006
1527 Author: William Hubbs <w.d.hubbs@gmail.com>
2528 Commit: William Hubbs <w.d.hubbs@gmail.com>
3529
4530 fix compiler warnings
5531
6 commit e43ee29eb4310ff23c438d1877ef79c56539b002
532 commit 825caa14de6160c966d44d64d5c0254f4038d9a0
7533 Author: William Hubbs <w.d.hubbs@gmail.com>
8534 Commit: William Hubbs <w.d.hubbs@gmail.com>
9535
16542
17543 This is for #271.
18544
19 commit a3555b144291b7d32f7c14fd9bd0dbe3ee6e33f9
545 commit d5c396cbfc49ce88f58d944c8ab01d2c36ccdc7b
20546 Author: William Hubbs <w.d.hubbs@gmail.com>
21547 Commit: William Hubbs <w.d.hubbs@gmail.com>
22548
25551 This will make it easier to track down why the supervisor intermittently
26552 hangs after it runs for a long time.
27553
28 commit eb863156fbcbce236c60dec0e90338edbd9de686
29 Author: William Hubbs <w.d.hubbs@gmail.com>
30 Commit: William Hubbs <w.d.hubbs@gmail.com>
31
32 version 0.40.3
33
34 commit ac76b24b85d3767a9561b76ac0fee5569383a63a
35 Author: William Hubbs <w.d.hubbs@gmail.com>
36 Commit: William Hubbs <w.d.hubbs@gmail.com>
37
38 Update ChangeLog
39
40 commit b8e57c693a973528799c9a5fdf86135b658dcce2
554 commit 5427783fdf3d183ea4e63afc507c31d88f0d2c9c
555 Author: William Hubbs <w.d.hubbs@gmail.com>
556 Commit: William Hubbs <w.d.hubbs@gmail.com>
557
558 standardize the default shell
559
560 I do not know of a need to have the default shell be a build-time
561 configurable setting. All *nix systems I am aware of have /bin/sh as a
562 default posix compatible shell.
563 If some systems running OpenRC do not make that assumption about
564 /bin/sh, I will consider bringing this back, so feel free to open an
565 issue.
566
567 commit d95425b08a1675efb66def056d0f92e6b2d78a77
568 Author: William Hubbs <w.d.hubbs@gmail.com>
569 Commit: William Hubbs <w.d.hubbs@gmail.com>
570
571 rc-cgroup.sh: remove shebang line
572
573 This is not a stand-alone script, so it does not need the shebang line.
574 This also means it is not necessary to run this through sed.
575
576 commit 76420d9849e6832a52aa4c1ba1fd2895b7d51a08
41577 Author: William Hubbs <w.d.hubbs@gmail.com>
42578 Commit: William Hubbs <w.d.hubbs@gmail.com>
43579
51587 If an agetty is respawning faster than 10 times in 60 seconds, this
52588 seems to be too fast.
53589
54 commit 5df12e24146cd091de71c77737c07eed5a14101f
590 commit bebc604438f9586f26d0cad8bd72749ae84b4335
55591 Author: William Hubbs <w.d.hubbs@gmail.com>
56592 Commit: William Hubbs <w.d.hubbs@gmail.com>
57593
59595
60596 This fixes #264.
61597
62 commit 461df0c78b1b8a58bb272958dce4af39fc2549c0
63 Author: William Hubbs <w.d.hubbs@gmail.com>
64 Commit: William Hubbs <w.d.hubbs@gmail.com>
65
66 version 0.40.2
67
68 commit cefae65392568afac83f64773b6ad33462791c38
69 Author: William Hubbs <w.d.hubbs@gmail.com>
70 Commit: William Hubbs <w.d.hubbs@gmail.com>
71
72 Update ChangeLog
73
74 commit 69fbd129938522cdd9b82fea2b83c857796a32af
598 commit 9dae4f2e38ceae227933673e25db9583e8f610a6
75599 Author: Alexander Zubkov <green@msu.ru>
76600 Commit: William Hubbs <w.d.hubbs@gmail.com>
77601
79603
80604 This fixes #239.
81605
82 commit 4aa5686d9037132b27d7554436738fa98e8e9057
83 Author: William Hubbs <w.d.hubbs@gmail.com>
84 Commit: William Hubbs <w.d.hubbs@gmail.com>
85
86 version 0.40.1
606 commit d126542dc626c8295b0f2cfcdee7bf5aa79daff1
607 Author: William Hubbs <w.d.hubbs@gmail.com>
608 Commit: William Hubbs <w.d.hubbs@gmail.com>
609
610 version 0.41
87611
88612 commit ab6c8d56f155564f56d61553c4b1af9e7f63a9d2
89613 Author: William Hubbs <w.d.hubbs@gmail.com>
459983
460984 Nanosleep is the safer call to use in case we need to use alarms
461985 eventually.
462
463 commit 7cb8d943236fe651ac54c64f8167f7c4369f649c
464 Author: William Hubbs <w.d.hubbs@gmail.com>
465 Commit: William Hubbs <w.d.hubbs@gmail.com>
466
467 Stop mounting efivarfs read-only
468
469 We do not need to do this any longer since all supported linux kernels
470 make efivarfs immutable and the tools that manipulate it are aware of
471 this feature.
472
473 This fixes https://github.com/openrc/openrc/issues/238.
474
475 commit 84ed570eaefcbb55b99ba425030bf7d1d1d46137
476 Author: Zac Medico <zmedico@gmail.com>
477 Commit: William Hubbs <w.d.hubbs@gmail.com>
478
479 librc: fix EACCES errno false-positive crash
480
481 Use errno != EACCES to fix false-positive for non-root users
482 with grsecurity kernels.
483
484 Fixes: 37e29442721a ("librc: Add check for crashed state")
485 This fixes #237
486
487 commit 2eea73bfd5ce2f9993d52293fe7d25c0c804d592
488 Author: William Hubbs <w.d.hubbs@gmail.com>
489 Commit: William Hubbs <w.d.hubbs@gmail.com>
490
491 rc-functions.sh: Remove addon support
492
493 This is an old relic from Gentoo baselayout-1.x which should not be used
494 any longer.
495
496 commit a571a42421b337380b6f5751635c55906bb8b508
497 Author: William Hubbs <w.d.hubbs@gmail.com>
498 Commit: William Hubbs <w.d.hubbs@gmail.com>
499
500 modules: remove the ability to rename modules on the fly
501
502 Kmod doesn't support the -o switch, so if you have been using this your
503 module loads have been failing.
504
505 commit 79648ac1c6355975abca6acf6076e7022037523f
506 Author: Holger Hoffstätte <holger@applied-asynchrony.com>
507 Commit: William Hubbs <w.d.hubbs@gmail.com>
508
509 rc-status: initialize uptime pointer to prevent memory corruption
510
511 This fixes #231.
512
513 commit 02af762e83640ec23bf64c5b814f0d3424d90e10
514 Author: William Hubbs <w.d.hubbs@gmail.com>
515 Commit: William Hubbs <w.d.hubbs@gmail.com>
516
517 version 0.39
518
519 commit 01c34c28e6d6d7bfecc0f88bdf1fb15e97ab8823
520 Author: William Hubbs <w.d.hubbs@gmail.com>
521 Commit: William Hubbs <w.d.hubbs@gmail.com>
522
523 Update ChangeLog
524
525 commit 56ddda54b5aa01474bf563d5a662075c35152858
526 Author: William Hubbs <w.d.hubbs@gmail.com>
527 Commit: William Hubbs <w.d.hubbs@gmail.com>
528
529 supervise-daemon.c: clean up memory leaks
530
531 commit 3a803b3135837665d51ef4dd7a8b913c78e71ff6
532 Author: William Hubbs <w.d.hubbs@gmail.com>
533 Commit: William Hubbs <w.d.hubbs@gmail.com>
534
535 librc-daemon.c: fix memory leaks
536
537 commit 72df51e17ba0e1a0f94451b4bbfb338288c4625c
538 Author: William Hubbs <w.d.hubbs@gmail.com>
539 Commit: William Hubbs <w.d.hubbs@gmail.com>
540
541 librc-daemon: convert most snprintf calls to xasprintf
542
543 commit b2f5531194e33c229462e9f52fa1d9388463f7b7
544 Author: William Hubbs <w.d.hubbs@gmail.com>
545 Commit: William Hubbs <w.d.hubbs@gmail.com>
546
547 librc-misc: convert snprintf calls to xasprintf
548
549 commit 19bf49a710f27d4774ed4c6372d87d6ba15f189e
550 Author: William Hubbs <w.d.hubbs@gmail.com>
551 Commit: William Hubbs <w.d.hubbs@gmail.com>
552
553 libeinfo: convert remaining snprintf calls to xasprintf
554
555 commit 64354831da2adeba5cb2f91a81fa0f56e1ce4ed9
556 Author: William Hubbs <w.d.hubbs@gmail.com>
557 Commit: William Hubbs <w.d.hubbs@gmail.com>
558
559 openrc: convert snprintf calls to xasprintf
560
561 commit e14edd765fdc4ed43356d2eef35fa99228e5d461
562 Author: William Hubbs <w.d.hubbs@gmail.com>
563 Commit: William Hubbs <w.d.hubbs@gmail.com>
564
565 supervise-daemon: convert snprintf calls to xasprintf
566
567 commit f9d41243d8499c5d7027177d5aa716d5b5859cd6
568 Author: William Hubbs <w.d.hubbs@gmail.com>
569 Commit: William Hubbs <w.d.hubbs@gmail.com>
570
571 start-stop-daemon: convert snprintf calls to xasprintf
572
573 commit be7ad06d4a0efce2a1144b2cf6f0cc361f2a81e4
574 Author: William Hubbs <w.d.hubbs@gmail.com>
575 Commit: William Hubbs <w.d.hubbs@gmail.com>
576
577 rc-status: convert snprintf calls to xasprintf
578
579 commit a6165168953b9c7a62c089ce946476b23b73fb12
580 Author: William Hubbs <w.d.hubbs@gmail.com>
581 Commit: William Hubbs <w.d.hubbs@gmail.com>
582
583 rc-status: fix gcc 7 warnings
584
585 commit 04721ece03b15503aa220f60e7c6159d01ee75e1
586 Author: William Hubbs <w.d.hubbs@gmail.com>
587 Commit: William Hubbs <w.d.hubbs@gmail.com>
588
589 start-stop-daemon: fix gcc 7 warnings
590
591 commit c7e8f1133a42152cc293e6b637985f81bcf8b310
592 Author: William Hubbs <w.d.hubbs@gmail.com>
593 Commit: William Hubbs <w.d.hubbs@gmail.com>
594
595 checkpath: fix gcc 7 warnings
596
597 commit 47e4bfae57402eedd017d6098b432c2c411cd374
598 Author: William Hubbs <w.d.hubbs@gmail.com>
599 Commit: William Hubbs <w.d.hubbs@gmail.com>
600
601 fix gcc 7 warnings in pipe routines
602
603 commit 8a945194afb106428bc700e751078ef9944ee617
604 Author: William Hubbs <w.d.hubbs@gmail.com>
605 Commit: William Hubbs <w.d.hubbs@gmail.com>
606
607 libeinfo: clean up gcc 7 compiler warnings
608
609 commit aa4a004c297ec7a1fb794ad2e53ef3ac8b3f4fd1
610 Author: William Hubbs <w.d.hubbs@gmail.com>
611 Commit: William Hubbs <w.d.hubbs@gmail.com>
612
613 version 0.38
614
615 commit 9ec5d36bdddf5bb0e96b0c561bc5d013a8a2da2a
616 Author: William Hubbs <w.d.hubbs@gmail.com>
617 Commit: William Hubbs <w.d.hubbs@gmail.com>
618
619 Update ChangeLog
620
621 commit a097933edab9d7221df1831e098415d604437c98
622 Author: William Hubbs <w.d.hubbs@gmail.com>
623 Commit: William Hubbs <w.d.hubbs@gmail.com>
624
625 sh/start-stop-daemon.sh: fix processing of the logger arguments
626
627 commit a6f5b1bb63070c24145df72040fa7b465948003c
628 Author: William Hubbs <w.d.hubbs@gmail.com>
629 Commit: William Hubbs <w.d.hubbs@gmail.com>
630
631 Update ChangeLog
632
633 commit e6d01471fe2a8eb8a15bb906d7c91c11805d1bef
634 Author: William Hubbs <w.d.hubbs@gmail.com>
635 Commit: William Hubbs <w.d.hubbs@gmail.com>
636
637 start-stop-daemon: add ability to log stdout or stderr to processes
638
639 commit d4501a9f06c807f87be04f128e535a74b370fdb4
640 Author: William Hubbs <w.d.hubbs@gmail.com>
641 Commit: William Hubbs <w.d.hubbs@gmail.com>
642
643 fix a typo
644
645 commit ec8abea4605395a2a59b26906ce4677a578e3c60
646 Author: Mike Gilbert <floppym@gentoo.org>
647 Commit: William Hubbs <w.d.hubbs@gmail.com>
648
649 Add helper to spawn process with stdin connected to a pipe
650
651 commit e4ddfa38e0e0318abf442b7aa07e0d8206191dd7
652 Author: William Hubbs <w.d.hubbs@gmail.com>
653 Commit: William Hubbs <w.d.hubbs@gmail.com>
654
655 user-guide.md: small cleanups
656
657 commit 21d30bc6d9caca31d007631717a480a552b89701
658 Author: William Hubbs <w.d.hubbs@gmail.com>
659 Commit: William Hubbs <w.d.hubbs@gmail.com>
660
661 service-script-guide.md: small cleanups
662
663 commit 2a1ff6e49c6603bb81eec3cafe2c587fa734289f
664 Author: William Hubbs <w.d.hubbs@gmail.com>
665 Commit: William Hubbs <w.d.hubbs@gmail.com>
666
667 version 0.37
668
669 commit 6762cb875c9c039b79dcc447b9d0eb65356a7708
670 Author: William Hubbs <w.d.hubbs@gmail.com>
671 Commit: William Hubbs <w.d.hubbs@gmail.com>
672
673 Update ChangeLog
674
675 commit 6edf516a1fe0ad4f4e8738f9fdd1bf0bc7718361
676 Author: Austin English <austinenglish@gmail.com>
677 Commit: Doug Freed <dwfreed@mtu.edu>
678
679 sh/supervise-daemon.sh: use start_stop_daemon_args if supervise_daemon_args is undefined
680
681 commit 7e56a49e23c810673b83e48eb9ca36229bb4016e
682 Author: William Hubbs <w.d.hubbs@gmail.com>
683 Commit: William Hubbs <w.d.hubbs@gmail.com>
684
685 Logger: only log printable characters and newlines
686
687 X-Gentoo-Bug: 651412
688 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=651412
689
690 commit fa5aea80c50fb724d2c98a6542307adbafd0e62d
691 Author: William Hubbs <w.d.hubbs@gmail.com>
692 Commit: William Hubbs <w.d.hubbs@gmail.com>
693
694 openrc-run.sh: move crashed test outside started test
695
696 This is handled inside librc, so we don't need the nesting in this
697 script.
698
699 commit 0f4fa41574a4ebf8117493e5411f8ab522010467
700 Author: William Hubbs <w.d.hubbs@gmail.com>
701 Commit: William Hubbs <w.d.hubbs@gmail.com>
702
703 Add mark_service_crashed binary
704
705 commit 5d6dd97bba3559b57fb1c1de35e644c6dbd6baa7
706 Author: William Hubbs <w.d.hubbs@gmail.com>
707 Commit: William Hubbs <w.d.hubbs@gmail.com>
708
709 rc-misc: add the crashed state
710
711 commit 37e29442721af0dc3846e87ef2b85a474af3cf2b
712 Author: William Hubbs <w.d.hubbs@gmail.com>
713 Commit: William Hubbs <w.d.hubbs@gmail.com>
714
715 librc: Add check for crashed state
716
717 In rc_service_state,, call rc_service_daemons_crashed to check for
718 a crashed daemon if the service is started.
719
720 commit 4e0eace837287845504c9895429dc9f64872d075
721 Author: William Hubbs <w.d.hubbs@gmail.com>
722 Commit: William Hubbs <w.d.hubbs@gmail.com>
723
724 librc: Add crashed state
725
726 commit faa8318b3ba278544413a39d4a5ae4457711793f
727 Author: William Hubbs <w.d.hubbs@gmail.com>
728 Commit: William Hubbs <w.d.hubbs@gmail.com>
729
730 Remove the _rc_can_find_pids function
731
732 This test to find if we could see pid 1 was being used inconsistently in
733 rc-status and mark_service_crashed to decide whether we could test to
734 see if the daemon for the service was crashed, and it was not part of
735 the librc library.
736
737 I am removing it from the executables because of inconsistent usage. I
738 will add it to the library if it is needed there.
739
740 commit 08da36149c0b41c64a09369c3eef5e2f5a6fa39c
741 Author: William Hubbs <w.d.hubbs@gmail.com>
742 Commit: William Hubbs <w.d.hubbs@gmail.com>
743
744 rc-service: add --ifstarted and --ifstopped options
745
746 commit 56870d0db18209396f8276bdc05d413fe4dd7a88
747 Author: William Hubbs <w.d.hubbs@gmail.com>
748 Commit: William Hubbs <w.d.hubbs@gmail.com>
749
750 Man: rc-service man page cleanups
751
752 commit 4d47ce440c3e8f193cff82a77e6691ee6e7fac33
753 Author: William Hubbs <w.d.hubbs@gmail.com>
754 Commit: William Hubbs <w.d.hubbs@gmail.com>
755
756 rc-service: add -d/--debug and -D/--nodeps options
757
758 commit 958f57d895b6573b39e62097e5e9881f16174715
759 Author: William Hubbs <w.d.hubbs@gmail.com>
760 Commit: William Hubbs <w.d.hubbs@gmail.com>
761
762 openrc-run: respect the RC_NODEPS environment variable
763
764 commit 04886efd85328988657c34440da9ba6aa2841cfd
765 Author: William Hubbs <w.d.hubbs@gmail.com>
766 Commit: William Hubbs <w.d.hubbs@gmail.com>
767
768 Add RC_DEBUG and RC_NODEPS to environment whitelist
769
770 These are needed so rc-service can pass debug and nodeps options to
771 openrc-run.
772
773 commit d980798d6444bbfc508796a233e962bf4dd61275
774 Author: William Hubbs <w.d.hubbs@gmail.com>
775 Commit: William Hubbs <w.d.hubbs@gmail.com>
776
777 openrc-run: respect the IN_DRYRUN environment variable
778
779 This allows rc-service to pass the tryrun option to openrc-run.
780
781 This is for #225.
782
783 commit 414a9aae6ce066d2a6ad42e7e24d1c12a7b46409
784 Author: William Hubbs <w.d.hubbs@gmail.com>
785 Commit: William Hubbs <w.d.hubbs@gmail.com>
786
787 rc-misc.c: Add IN_DRYRUN to environment whitelist
788
789 This allows rc-service to pass the dryrun option to openrc-run.
790
791 This is for #225.
792
793 commit a7f475ca04856ef8232364c5b0c3191566b0696c
794 Author: William Hubbs <w.d.hubbs@gmail.com>
795 Commit: William Hubbs <w.d.hubbs@gmail.com>
796
797 rc-service: add a --dry-run option
798
799 This is for #225.
800
801 commit 3c53680018c1799d0d804e241a9fa4d3b9423896
802 Author: William Hubbs <w.d.hubbs@gmail.com>
803 Commit: William Hubbs <w.d.hubbs@gmail.com>
804
805 build: standardize installation modes
806
807 Gentoo was changing some of our installation modes from 0444 to 0644.
808 There isn't a reason to install things 0444, so we are switching these
809 to 0644 so the Gentoo ebuild doesn't need this extra step.
810
811 commit f0ad647303daca528cb9b75f9a07d422318635c2
812 Author: William Hubbs <w.d.hubbs@gmail.com>
813 Commit: William Hubbs <w.d.hubbs@gmail.com>
814
815 Revert "savecache: stop saving the dependency tree"
816
817 It is safe to save the deptree, but we also need to regenerate it at
818 boot time.
819
820 commit b35e03b6b1acc841ac33f601dd39c1152523621e
821 Author: William Hubbs <w.d.hubbs@gmail.com>
822 Commit: William Hubbs <w.d.hubbs@gmail.com>
823
824 Revert "Logger: only log printable characters and newlines"
825
826 This reverts commit 2b1392af2fe9e5dfc8eda2f19d896efdc41840bf.
827 This seems to create issues shutting down, so I need to look into it
828 further.
829
830 commit 2b1392af2fe9e5dfc8eda2f19d896efdc41840bf
831 Author: William Hubbs <w.d.hubbs@gmail.com>
832 Commit: William Hubbs <w.d.hubbs@gmail.com>
833
834 Logger: only log printable characters and newlines
835
836 X-Gentoo-Bug: 651412
837 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=651412
838
839 commit a3d0e293eebcb92564c473e61ca42724844fb279
840 Author: William Hubbs <w.d.hubbs@gmail.com>
841 Commit: William Hubbs <w.d.hubbs@gmail.com>
842
843 Remove localmount from dependencies for linux-only services
844
845 This removes localmount from the dependencies of the consolefont,
846 keymaps, numlock and procfs services.
847
848 These services are Linux only and the default modern linux system has /
849 and /usr on the same file system.
850
851 This also fixes the following issue.
852
853 X-Gentoo-Bug: 651998
854 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=651998
855
856 commit 0200002b8cbd061ac79b6aed4024220cd0386d2c
857 Author: Andrey Utkin <andrey_utkin@gentoo.org>
858 Commit: William Hubbs <w.d.hubbs@gmail.com>
859
860 start-stop-daemon: don't fail stopping if pidfile is gone
861
862 If pidfile does not exist when we are stopping the daemon, assume it is
863 already stopped, and report success.
864
865 hostapd is an example of a daemon which removes its pidfile when it is
866 exiting. If this daemon terminates prematurely, that is, without s-s-d
867 involvement, then openrc fails to restart it, because s-s-d "stop"
868 command fails when pidfile is missing.
869
870 X-Gentoo-Bug: 646274
871 X-Gentoo-Bug-URL: https://bugs.gentoo.org/646274
872
873 commit f4e2142089487b7f5c99da949d7bf8d038724df7
874 Author: William Hubbs <w.d.hubbs@gmail.com>
875 Commit: William Hubbs <w.d.hubbs@gmail.com>
876
877 Add _POSIX_C_SOURCE definition to Linux build
878
879 We need this to allow builds on uclibc-ng based systems.
880
881 X-Gentoo-Bug: 650908
882 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=650908
883
884 commit 49a90f27a848ba02a363fc0c844d6284728bdd73
885 Author: William Hubbs <w.d.hubbs@gmail.com>
886 Commit: William Hubbs <w.d.hubbs@gmail.com>
887
888 typo fix
889
890 commit 2ae60ca0419d60c86904a8e15e71e902549e18d4
891 Author: Scall <Scall@users.noreply.github.com>
892 Commit: Doug Freed <dwfreed@mtu.edu>
893
894 rc-update: fix typo
895
896 commit 6b475ab26992f1dd8815700828df46abc4b71d27
897 Author: William Hubbs <w.d.hubbs@gmail.com>
898 Commit: William Hubbs <w.d.hubbs@gmail.com>
899
900 init.d/modules: add code from modules-load service
901
902 There is no reason for these to be separate services. I did add a
903 provide so that we don't break backward compatibility.
904
905 commit b302b0c094c2c99b810aec9c8877adcd1effabac
906 Author: William Hubbs <w.d.hubbs@gmail.com>
907 Commit: William Hubbs <w.d.hubbs@gmail.com>
908
909 net-online: always start after net
910
911 X-Gentoo-Bug: 650600
912 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=650600
913
914 commit 40aa69cf3a99fa080375a702631da4d2311ebf3e
915 Author: William Hubbs <w.d.hubbs@gmail.com>
916 Commit: William Hubbs <w.d.hubbs@gmail.com>
917
918 agetty.in: allow status to be displayed
919
920 commit 5346fbf2c90b33b3abc01588e4727d4402f8db62
921 Author: William Hubbs <w.d.hubbs@gmail.com>
922 Commit: William Hubbs <w.d.hubbs@gmail.com>
923
924 supervise-daemon: fix off-by-one error
925
926 commit 92e6bdee12fa9d87a2535446ceccee261305e87c
927 Author: William Hubbs <w.d.hubbs@gmail.com>
928 Commit: William Hubbs <w.d.hubbs@gmail.com>
929
930 Use _BSD_SOURCE on FreeBSD
931
932 commit 71f275b2aa04d9a9323a49d1421796c4d50b1436
933 Author: William Hubbs <w.d.hubbs@gmail.com>
934 Commit: William Hubbs <w.d.hubbs@gmail.com>
935
936 typo fix
937
938 commit 6dc0d0af333592203fabd4746279bb15d2801c0b
939 Author: William Hubbs <w.d.hubbs@gmail.com>
940 Commit: William Hubbs <w.d.hubbs@gmail.com>
941
942 Remove _XOPEN_SOURCE macros from builds
943
944 commit 59a9e53378891be7b12ed304ccb609e27da70751
945 Author: William Hubbs <w.d.hubbs@gmail.com>
946 Commit: William Hubbs <w.d.hubbs@gmail.com>
947
948 Add _POSIX_C_SOURCE macro to FreeBSD build
949
950 commit 122768d339175c925a1a228792f4725b7c802f46
951 Author: William Hubbs <w.d.hubbs@gmail.com>
952 Commit: William Hubbs <w.d.hubbs@gmail.com>
953
954 man: document default retry specification for supervise-daemon
955
956 commit fa3c60c0d8fd2267be5c1b156530b136a2503088
957 Author: William Hubbs <w.d.hubbs@gmail.com>
958 Commit: William Hubbs <w.d.hubbs@gmail.com>
959
960 man: document default retry sppecification for start-stop-daemon
961
962 commit 61905bfcf560219939c902dbb8fe9bc5088a42cf
963 Author: William Hubbs <w.d.hubbs@gmail.com>
964 Commit: William Hubbs <w.d.hubbs@gmail.com>
965
966 Clean up cgroups v2 code
967
968 Remove the IFS manipulation and simplify the loop that processes the
969 settings.
970
971 commit 3e68013631765e00eddf118bc24e38254e7f6d64
972 Author: Scall <Scall@users.noreply.github.com>
973 Commit: Doug Freed <dwfreed@mtu.edu>
974
975 init.d: swap should always be started after root
976
977 Otherwise if a swap file is being used, and swap is started before
978 root, swapon may fail because of a read-only filesystem.
979
980 commit b46123f2e19a5eb8dc02b898e8c20a2ccc211615
981 Author: Chris Cromer <cromerc@users.noreply.github.com>
982 Commit: Doug Freed <dwfreed@mtu.edu>
983
984 openrc-run: fix memory size (#213)
985
986 Fixes #212
987
988 commit 109869641f7b58d07819f6b65d7b085abf75083b
989 Author: William Hubbs <w.d.hubbs@gmail.com>
990 Commit: William Hubbs <w.d.hubbs@gmail.com>
991
992 fix build on FreeBSD
993
994 commit e8a2305de0320dc98bf187bb97f936e2dc4a4554
995 Author: William Hubbs <w.d.hubbs@gmail.com>
996 Commit: William Hubbs <w.d.hubbs@gmail.com>
997
998 version 0.36
999
1000 commit f62975a1f8c4d5d4abdf78d8cad5509216138f03
1001 Author: William Hubbs <w.d.hubbs@gmail.com>
1002 Commit: William Hubbs <w.d.hubbs@gmail.com>
1003
1004 Update ChangeLog
1005
1006 commit 5bb6f9aa318a6d0507971b74d88c3fd2803bae4b
1007 Author: Jason Zaman <jason@perfinion.com>
1008 Commit: William Hubbs <w.d.hubbs@gmail.com>
1009
1010 init.sh: apply SELinux label for /run early in boot
1011
1012 Some initramfs mount /run which then ends up with the wrong labels.
1013 Force relabel all of /run right after its mounted to fix.
1014
1015 commit 1ab8541a6ccb9d72c6faeaf2d616fc49f6cdfaf6
1016 Author: Jason Zaman <jason@perfinion.com>
1017 Commit: William Hubbs <w.d.hubbs@gmail.com>
1018
1019 init-early.sh.Linux.in: apply the selinux label to /dev/console early
1020
1021 /dev/console is relabelled later in the devfs init script, but by then we
1022 have already missed some of the messages, so fix that label early.
1023
1024 commit 038c03bef315314ddb1e460c67d29b2599b494ad
1025 Author: William Hubbs <w.d.hubbs@gmail.com>
1026 Commit: William Hubbs <w.d.hubbs@gmail.com>
1027
1028 supervise-daemon: make an error message more verbose
1029
1030 commit e51dc29e2f3b2718a62347e8588115e786a9f3c8
1031 Author: William Hubbs <w.d.hubbs@gmail.com>
1032 Commit: William Hubbs <w.d.hubbs@gmail.com>
1033
1034 cgroups: fix indentation
1035
1036 commit c6047f887a362cb8d96624fbd73484ca703acf53
1037 Author: William Hubbs <w.d.hubbs@gmail.com>
1038 Commit: William Hubbs <w.d.hubbs@gmail.com>
1039
1040 cgroups: add rc_cgroup_memory_use_hierarchy setting for cgroups v1
1041
1042 commit 0506d68427e342366d826aae4bfbbc6cc0adecc2
1043 Author: William Hubbs <w.d.hubbs@gmail.com>
1044 Commit: William Hubbs <w.d.hubbs@gmail.com>
1045
1046 fstabinfo: fix an error message
1047
1048 commit c3d666acaf51c771671b0fa54bd8ec0f5d29859e
1049 Author: William Hubbs <w.d.hubbs@gmail.com>
1050 Commit: William Hubbs <w.d.hubbs@gmail.com>
1051
1052 openrc: remove unused #define's.
1053
1054 commit e93b1d76d150c4477015052fc3df9b94647e5b5d
1055 Author: William Hubbs <w.d.hubbs@gmail.com>
1056 Commit: William Hubbs <w.d.hubbs@gmail.com>
1057
1058 openrc: convert another execl() call to execlp()
1059
1060 commit acf1e43f815898c4a4957db352f71f3fb629edf3
1061 Author: William Hubbs <w.d.hubbs@gmail.com>
1062 Commit: William Hubbs <w.d.hubbs@gmail.com>
1063
1064 openrc-init: convert execl calls to execlp
1065
1066 commit f383fd87b121492a04362ca9041f686d981718f1
1067 Author: William Hubbs <w.d.hubbs@gmail.com>
1068 Commit: William Hubbs <w.d.hubbs@gmail.com>
1069
1070 kill_all: change execl call to execlp
1071
1072 commit cfded513cd9b7febe4b7cf39a80411e4303f0655
1073 Author: William Hubbs <w.d.hubbs@gmail.com>
1074 Commit: William Hubbs <w.d.hubbs@gmail.com>
1075
1076 openrc-init: set a default path
1077
1078 The default path provided by the system if one isn't set only includes
1079 "/bin:/usr/bin". This adds the default path setting from sysvinit.
1080
1081 commit 16ff3cd8df6169f73e3d7cf00758a4703f62cbf0
1082 Author: Christian Brauner <christian.brauner@ubuntu.com>
1083 Commit: William Hubbs <w.d.hubbs@gmail.com>
1084
1085 check whether /sys/fs/cgroup is a mountpoint
1086
1087 The current check only tries to detect whether /sys/fs/cgroup exists and
1088 whether it is writable or not. But when the init system doesn't mount
1089 cgroups then /sys/fs/cgroup will just be an empty directory. When paired
1090 with unprivileged containers that mount sysfs this will cause misleading
1091 errors to be printed since /sys/fs/cgroup will be owned by user
1092 nobody:nogroup in this case. Independent of this specific problem this
1093 check will also be misleading when the /sys/fs/cgroup exists and is in
1094 fact writable by the init system but isn't actually a mountpoint.
1095
1096 Note from William. "grep -qs" doesn't need to redirect output to
1097 /dev/null since it is completely silent.
1098
1099 This fixes #209.
1100
1101 commit 38032626a6c2f8e869197999f32ac3634667cc86
1102 Author: William Hubbs <w.d.hubbs@gmail.com>
1103 Commit: William Hubbs <w.d.hubbs@gmail.com>
1104
1105 improve cgroup configuration checks
1106
1107 make the base/controller functions return successfully if cgroups v1/v2
1108 are not configured in the kernel
1109
1110 commit aa7d3a7911b658c550e7ce76cd6d7d46541fc323
1111 Author: William Hubbs <w.d.hubbs@gmail.com>
1112 Commit: William Hubbs <w.d.hubbs@gmail.com>
1113
1114 openrc: force deptree update for sysinit runlevel
1115
1116 commit 98262647a9d2f3c65a7ceb1aaa81095522c1ef06
1117 Author: William Hubbs <w.d.hubbs@gmail.com>
1118 Commit: William Hubbs <w.d.hubbs@gmail.com>
1119
1120 supervise-daemon: zero out the cmdline buffer when it is allocated
1121
1122 commit 5868abe97babcc287794dcb36ad8e77989b6ddcf
1123 Author: William Hubbs <w.d.hubbs@gmail.com>
1124 Commit: William Hubbs <w.d.hubbs@gmail.com>
1125
1126 start-stop-daemon: compiler warning cleanup
1127
1128 commit 71aad16256604e0e9e146221957a9b00cfe67b99
1129 Author: William Hubbs <w.d.hubbs@gmail.com>
1130 Commit: William Hubbs <w.d.hubbs@gmail.com>
1131
1132 openrc-run: clean up a compiler warning
1133
1134 commit e275da84de1589253da5ff6a7c272cf1c82f8567
1135 Author: William Hubbs <w.d.hubbs@gmail.com>
1136 Commit: William Hubbs <w.d.hubbs@gmail.com>
1137
1138 supervise-daemon: remove references to PATH_MAX
1139
1140 commit a6cc7f06cf3807a0e0590697e1f14e6ab9055271
1141 Author: William Hubbs <w.d.hubbs@gmail.com>
1142 Commit: William Hubbs <w.d.hubbs@gmail.com>
1143
1144 rc.c: remove PATH_MAX references
1145
1146 commit c1178c8eebb92c9f3702e981cd4af9ef41f51884
1147 Author: William Hubbs <w.d.hubbs@gmail.com>
1148 Commit: William Hubbs <w.d.hubbs@gmail.com>
1149
1150 rc-selinux.c: remove references to path_max
1151
1152 commit 3c031ca9780c555817fe9ccb8b23ceb231129724
1153 Author: William Hubbs <w.d.hubbs@gmail.com>
1154 Commit: William Hubbs <w.d.hubbs@gmail.com>
1155
1156 rc-plubin.c: remove references to PATH_MAX
1157
1158 commit 8e02406d8fbf92167c30431987d5de8de72cd7df
1159 Author: William Hubbs <w.d.hubbs@gmail.com>
1160 Commit: William Hubbs <w.d.hubbs@gmail.com>
1161
1162 rc-misc.c: remove references to PATH_MAX
1163
1164 commit 8dbdabcc5e0df8ac36722a4ba7bfe30664cc9919
1165 Author: William Hubbs <w.d.hubbs@gmail.com>
1166 Commit: William Hubbs <w.d.hubbs@gmail.com>
1167
1168 start-stop-daemon: clean up string handling
1169
1170 commit 488d8989c518d9256f183899aac02024c679b93e
1171 Author: William Hubbs <w.d.hubbs@gmail.com>
1172 Commit: William Hubbs <w.d.hubbs@gmail.com>
1173
1174 openrc-run: clean up string handling
1175
1176 - remove references to PATH_MAX
1177 - use xasprintf to create strings
1178
1179 commit 9e14b35da8942bd8fa552363617c3415887f485f
1180 Author: William Hubbs <w.d.hubbs@gmail.com>
1181 Commit: William Hubbs <w.d.hubbs@gmail.com>
1182
1183 rc-update: remove reference to PATH_MAX
1184
1185 commit 7b4879cb72e907414b70553663bd9b6fda8d4408
1186 Author: William Hubbs <w.d.hubbs@gmail.com>
1187 Commit: William Hubbs <w.d.hubbs@gmail.com>
1188
1189 mountinfo: create strings with xasprintf
1190
1191 commit 74cfb455c59298f86849541e724ae346ff205c3d
1192 Author: William Hubbs <w.d.hubbs@gmail.com>
1193 Commit: William Hubbs <w.d.hubbs@gmail.com>
1194
1195 kill_all: create strings with xasprintf
1196
1197 commit 0110487722646ebf9bc2c4e12b4b4a3c358cb10d
1198 Author: William Hubbs <w.d.hubbs@gmail.com>
1199 Commit: William Hubbs <w.d.hubbs@gmail.com>
1200
1201 helpers.h: silence compiler warnings about xasprintf
1202
1203 commit 68b9b0bc2a11d144870d14fcb8ac24e6c9c63354
1204 Author: William Hubbs <w.d.hubbs@gmail.com>
1205 Commit: William Hubbs <w.d.hubbs@gmail.com>
1206
1207 xasprintf: exit if return value of vsnprintf is invalid
1208
1209 commit 4616f8f809ee8566904ca37f2b8bf0409a487475
1210 Author: William Hubbs <w.d.hubbs@gmail.com>
1211 Commit: William Hubbs <w.d.hubbs@gmail.com>
1212
1213 helpers.h: add xasprintf function
1214
1215 This is our own version of asprintf(). This original code was written by
1216 Mike Frysinger, and I was able to modify it to use our memory helper
1217 functions.
1218
1219 We need a version of this code because it is not available on glibc at
1220 least without defining _GNU_SOURCE, and I would rather not do that.
1221
1222 This is the first step in improving string handling in OpenRC for #207.
1223
1224 commit 287d71bd2591ddec73efe356db081020e65cd922
1225 Author: William Hubbs <w.d.hubbs@gmail.com>
1226 Commit: William Hubbs <w.d.hubbs@gmail.com>
1227
1228 helpers.h: style fix
1229
1230 commit c1ffe4d9f2e10b6853464cc298d1922c81ae92f4
1231 Author: Michael Orlitzky <michael@orlitzky.com>
1232 Commit: William Hubbs <w.d.hubbs@gmail.com>
1233
1234 man/openrc-run.8: fix mountinfo args.
1235
1236 The "Ar" tag for the mountinfo command contained a typo (leading
1237 space) that resulted in the tag being output verbatim; that is,
1238
1239 mountinfo ... .Ar mount1 mount2
1240
1241 rather than e.g.
1242
1243 mountinfo ... <mount1> <mount2>
1244
1245 This commit deletes the leading space to fix the output.
1246
1247 This fixes #204.
1248
1249 commit 4c517bdb2b69eac36f004ae41bb9cbb212fe0a51
1250 Author: Michael Orlitzky <michael@orlitzky.com>
1251 Commit: William Hubbs <w.d.hubbs@gmail.com>
1252
1253 man/openrc-run.8: add missing "Xo" tags for fstabinfo and mountinfo.
1254
1255 The BUILTINS are all surrounded by Xo...Xc tags, but the opening "Xo"
1256 was missing from the two commands fstabinfo and mountinfo. This commit
1257 adds them, and thereby fixes the spacing when viewed by man.
1258
1259 This is for #204.
1260
1261 commit 110582491ff02db061b567636a237460afbc489c
1262 Author: William Hubbs <w.d.hubbs@gmail.com>
1263 Commit: William Hubbs <w.d.hubbs@gmail.com>
1264
1265 service-script-guide.md cleanups
1266
1267 Refer to /var/run in the documentation instead of /run, and make it
1268 clear at the top of the pidfile section that we use /run under Linux.
1269
1270 This is for #202.
1271
1272 commit 5dd1d39d20c118064d31ed65dc7ae2de75dd7908
1273 Author: William Hubbs <w.d.hubbs@gmail.com>
1274 Commit: William Hubbs <w.d.hubbs@gmail.com>
1275
1276 typo fix
1277
1278 commit 1771bc2a83fe65bfe6ec3e93ea7632609e697a38
1279 Author: William Hubbs <w.d.hubbs@gmail.com>
1280 Commit: William Hubbs <w.d.hubbs@gmail.com>
1281
1282 checkpath: use fchown and fchmod to handle ownership and mode changes
1283
1284 This is related to #195.
1285
1286 This is an attempt to shorten the window for the first two issues
1287 discussed by using a file descriptor which does not follow symbolic
1288 links and using the fchmod and fchown calls instead of chown and chmod.
1289 with.
1290
1291 commit 87c98ebb01873120eecc1757e615b3a4c14a2f1f
1292 Author: William Hubbs <w.d.hubbs@gmail.com>
1293 Commit: William Hubbs <w.d.hubbs@gmail.com>
1294
1295 checkpath: fix lchown error message
1296
1297 X-Gentoo-Bug: 643084
1298 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=643084
1299
1300 commit 4af5a80b0c516773286cc30e743dc90a2d19df23
1301 Author: William Hubbs <w.d.hubbs@gmail.com>
1302 Commit: William Hubbs <w.d.hubbs@gmail.com>
1303
1304 _rc_deptree_load - return NULL if the stat() call is not successful
1305
1306 X-Gentoo-Bug: 643084
1307 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=643084
1308
1309 commit fee2ffe559bc39beec16585daf557b902a53137b
1310 Author: William Hubbs <w.d.hubbs@gmail.com>
1311 Commit: William Hubbs <w.d.hubbs@gmail.com>
1312
1313 Reformat and fix titles in documentation
1314
1315 commit 8878f8916b7682a333d1e40af991cd7354192be1
1316 Author: William Hubbs <w.d.hubbs@gmail.com>
1317 Commit: William Hubbs <w.d.hubbs@gmail.com>
1318
1319 Rename guide.md to user-guide.md to better describe its purpose
1320
1321 commit 14e3359a9e4174da3e422957d9de56907f025875
1322 Author: William Hubbs <w.d.hubbs@gmail.com>
1323 Commit: William Hubbs <w.d.hubbs@gmail.com>
1324
1325 move developer documentation from guide.md to service-script-guide.md
1326
1327 commit 918d955fd2de1f594b83508f5ddd5271534e3591
1328 Author: William Hubbs <w.d.hubbs@gmail.com>
1329 Commit: William Hubbs <w.d.hubbs@gmail.com>
1330
1331 checkpath: use lchown instead of chown
1332
1333 Checkpath should never follow symbolic links when changing ownership of a file.
1334
1335 This is for https://github.com/openrc/openrc/issues/195.
1336
1337 commit 92cfa0e543d380ab290d06e98e2fef1b283349fe
1338 Author: William Hubbs <w.d.hubbs@gmail.com>
1339 Commit: William Hubbs <w.d.hubbs@gmail.com>
1340
1341 service-script-guide.md: formatting changes
1342
1343 Add a title, adjust the headings and update the example that referred to
1344 "net.lo" to refer to "loopback".
1345
1346 commit c2bd33e4838eb56bebe2707f6ca6bd05e9df5b24
1347 Author: Michael Orlitzky <michael@orlitzky.com>
1348 Commit: William Hubbs <w.d.hubbs@gmail.com>
1349
1350 service-script-guide.md: new guide for service script authors.
1351
1352 This fixes #162.
1353
1354 commit f42ec82f21f3760b829507344ad0ae761e1d59aa
1355 Author: 3PO <r2d2@freakmail.de>
1356 Commit: William Hubbs <w.d.hubbs@gmail.com>
1357
1358 net-online: only process symbolic links in /sys/class/net
1359
1360 The /sys/class/net directory contains files which are not symlinks if
1361 the system has bonded devices [1]. We should ignore these files.
1362
1363 This fixes #196.
1364
1365 [1] https://elkano.org/blog/manage-interface-bondings-sysfs-interface/
3232 SUBDIR+= zsh-completion
3333 endif
3434
35 # We need to ensure that runlevels is done last
35 # We need to ensure that runlevels is done last other than test
3636 SUBDIR+= runlevels
37 SUBDIR+= test
3738
3839 INSTALLAFTER= _installafter
3940
00 NAME= openrc
1 VERSION= 0.40.3
1 VERSION= 0.42
22 PKG= ${NAME}-${VERSION}
22
33 This file will contain a list of notable changes for each release. Note
44 the information in this file is in reverse order.
5
6 ## OpenRC 0.42
7
8 openrc-shutdown now has the ability to shut down sysvinit-based systems.
9
10 A guide has been added for migrating systems using another init system
11 to openrc-init.
12
13 ## OpenRC 0.41.
14
15 This version adds the ability to format the output of rc-status when
16 showing the status of services in a runlevel so that it may be parsed.
17 Currently, the -f switch only accepts ini as an argument which
18 causes the output to be in the .ini format.
19
20 This version adds an experimental build time switch to allow setting the
21 default shell to use for service scripts.
22 By default, this is set to /bin/sh if it is changed, the new shell must
23 be able to understand posix-compatible syntax.
524
625 ## OpenRC 0.40
726
3737 LOCAL_PREFIX=/usr/local
3838 PREFIX=/usr/local
3939 BRANDING=\"Gentoo/$(uname -s)\"
40 SH=/bin/sh
4041 ```
4142
4243 ## Notes
9090 done))
9191 return 0
9292 elif [[ ${COMP_CWORD} -eq 2 ]] && [[ ${prev} != -* ]]; then # if second word typed and we didn't type in a function
93 filename=$(rc-service --resolve ${prev})
94 opts=$(cat ${filename} | grep "^\w*()" | sed "s/().*$//") # Greps the functions included in the init script
95 if [[ "x${opts}" == "x" ]] ; then # if no options found loosen the grep algorhythm
96 opts=$(cat ${filename} | grep "\w*()" | sed "s/().*$//")
97 fi
93 rc-service --exists "$prev" || return
94 shopt -s extglob
95 while read -r _ line; do
96 if [[ $line == +([[:alnum:]_]):* ]]; then
97 opts+="${line%%:*} "
98 fi
99 done < <(rc-service "$prev" describe 2>&1)
100 shopt -u extglob
98101 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
99102 return 0
100103 fi
0 #!/bin/bash
1 # Copyright (c) 2007-2018 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 set -e
12 set -u
13 set -x
14
15 # These are steps to run on Cirrus CI under a jailed FreeBSD system.
16 # See $TOP/.cirrus.yml for more info about the Cirrus CI setup.
17
18 cpus=$(getconf NPROCESSORS_CONF || echo 1)
19 gmake -j"${cpus}" -O
20 gmake test
0 #!/bin/bash
1 # Copyright (c) 2007-2018 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 set -e
12 set -u
13 set -x
14
15 # These are steps to run on TravisCI under a containerized Ubuntu system.
16 # See $TOP/.travis.yml for more info about the TravisCI setup.
17
18 cpus=$(getconf _NPROCESSORS_CONF || echo 1)
19 # make on TravisCI doesn't support -O yet
20 make -j"${cpus}"
21
22 make test
0 #!@SHELL@
0 #!/bin/sh
11 # Copyright (c) 2007-2015 The OpenRC Authors.
22 # See the Authors file at the top-level directory of this distribution and
33 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
0 #!@SHELL@
0 #!/bin/sh
11 # Copyright (c) 2007-2015 The OpenRC Authors.
22 # See the Authors file at the top-level directory of this distribution and
33 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
0 # OpenRC init process guide
1
2 OpenRC now includes an init process which can be used on Linux systems
3 in place of sysvinit.
4
5 ## migrating a live system to openrc-init
6
7 Configuring a live system to use this init process is very
8 straight-forward, but the steps must be completed in this order.
9
10 * have your boot loader add "init=/sbin/openrc-init" to the kernel command line
11
12 The details of how to do this will vary from distro to distro, so they are
13 out of scope for this document.
14
15 * Install gettys into the runlevels where you need them.
16
17 If you are using the provided /etc/init.d/agetty script,, you should
18 first create symlinks in /etc/init.d to it for the ports where you
19 want gettys to run, e.g. the following will work if you want gettys on
20 tty1-tty6.
21
22 ```
23 # cd /etc/init.d
24 # for x in tty1 tty2 tty3 tty4 tty5 tty6; do
25 ln -snf agetty agetty.$x
26 done
27 ```
28
29 Once this is done, use ```rc-update``` as normal to install the agetty
30 services in the appropriate runlevels.
31
32 * Reboot your system.
33
34 At this point you are running under openrc-init, and you should use
35 openrc-shutdown to handle shutting down, powering off, rebooting etc.
36
37 ## optional sysvinit compatibility
38
39 If you build and install OpenRC with MKSYSVINIT=yes, you will build and install
40 wrappers that make openrc-init compatible with sysvinit -- you will have
41 commands like "halt" "shutdown" "reboot" and "poweroff".
42
43 If you want this functionality on a live system, you should first
44 migrate the system to openrc-init, remove sysvinit, then rebuild and
45 install this package with MKSYSVINIT=yes.
46
47 package.
48 migrating your system to openrc-init.
49
2020 depend() {
2121 after local
2222 keyword -prefix
23 provide getty
2324 }
2425
2526 start_pre() {
1616 .Sh SYNOPSIS
1717 .Nm
1818 .Op Fl c , -cancel
19 .Nm
20 .Op Fl R , -reexec
21 .Nm
22 .Op Fl w , -write-only
23 .Nm
1924 .Op Fl d , -no-write
2025 .Op Fl D , -dry-run
2126 .Op Fl H , -halt
27 time
28 .Nm
29 .Op Fl d , -no-write
30 .Op Fl D , -dry-run
2231 .Op Fl k , -kexec
32 time
33 .Nm
34 .Op Fl d , -no-write
35 .Op Fl D , -dry-run
2336 .Op Fl p , -poweroff
24 .Op Fl R , -reexec
37 time
38 .Nm
39 .Op Fl d , -no-write
40 .Op Fl D , -dry-run
2541 .Op Fl r , -reboot
42 time
43 .Nm
44 .Op Fl d , -no-write
45 .Op Fl D , -dry-run
2646 .Op Fl s , -single
27 .Op Fl w , -write-only
47 time
2848 .Sh DESCRIPTION
2949 .Nm
3050 is the utility that communicates with
5575 .It Fl s , -single
5676 Stop all services, kill all processes and move to single user mode.
5777 .It Fl w , -write-only
58 Stop all services, kill all processes and move to single user mode.
78 Wrrite a wtmp shutdown record and do nothing else.
5979 .El
6080 .Sh SEE ALSO
6181 .Xr openrc-init 8 ,
6565 .Xr shutdown 8
6666 and let them call these special runlevels.
6767 .Sh SEE ALSO
68 .Xr openrc-run 8 ,
6869 .Xr rc-status 8 ,
6970 .Xr rc-update 8 ,
7071 .Xr init 8 ,
1616 .Sh SYNOPSIS
1717 .Nm
1818 .Op Fl aclsuC
19 .Op Fl f Ar ini
1920 .Op Ar runlevel
2021 .Sh DESCRIPTION
2122 .Nm
3637 Show all runlevels and their services.
3738 .It Fl c , -crashed
3839 List all services that have crashed.
40 .It Fl f , -format
41 Select a format for the output. Currently, the only one that can be
42 specified is ini, which outputs in *.ini format.
3943 .It Fl l , -list
4044 List all defined runlevels.
4145 .It Fl m , -manual
88 .\" except according to the terms contained in the LICENSE file.
99 .\"
1010 .Dd April 27, 2016
11 .Dt supervise-DAEMON 8 SMM
11 .Dt SUPERVISE-DAEMON 8 SMM
1212 .Os OpenRC
1313 .Sh NAME
1414 .Nm supervise-daemon
8787 name here also.
8888 .It Fl v , -verbose
8989 Print the action(s) that are taken just before doing them.
90 .El
9091 .Pp
9192 The options are as follows:
9293 .Bl -tag -width indent
93 .Fl a , -healthcheck-timer Ar seconds
94 .It Fl a , -healthcheck-timer Ar seconds
9495 Run the healthcheck() command, possibly followed by the unhealthy()
9596 command every time this number of seconds passes.
96 .Fl A , -healthcheck-delay Ar seconds
97 .It Fl A , -healthcheck-delay Ar seconds
9798 Wait this long before the first health check.
9899 .It Fl D , -respawn-delay Ar seconds
99 wait this number of seconds before restarting a daemon after it crashes.
100 Wait this number of seconds before restarting a daemon after it crashes.
100101 The default is 0.
101102 .It Fl d , -chdir Ar path
102103 chdir to this directory before starting the daemon.
1010 SFX= .Linux.in
1111 PKG_PREFIX?= /usr
1212
13 CPPFLAGS+= -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L
13 CPPFLAGS+= -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L -D_BSD_SOURCE -D_XOPEN_SOURCE
1414 LIBDL= -Wl,-Bdynamic -ldl
1515
1616 ifeq (${MKSELINUX},yes)
1818 _LCL_SED_SH= if test "${PREFIX}" = "${LOCAL_PREFIX}"; then echo "-e 's:@LOCAL_PREFIX@::g'"; else echo "-e 's:@LOCAL_PREFIX@:${LOCAL_PREFIX}:g'"; fi
1919 _LCL_SED:= $(shell ${_LCL_SED_SH})
2020
21 SED_REPLACE= -e 's:@SHELL@:${SH}:g' -e 's:@LIB@:${LIBNAME}:g' -e 's:@SYSCONFDIR@:${SYSCONFDIR}:g' -e 's:@LIBEXECDIR@:${LIBEXECDIR}:g' -e 's:@PREFIX@:${PREFIX}:g' -e 's:@BINDIR@:${BINDIR}:g' -e 's:@SBINDIR@:${SBINDIR}:g' ${_PKG_SED} ${_LCL_SED}
21 SED_REPLACE= -e 's:@SHELL@:${SH}:' -e 's:@LIB@:${LIBNAME}:g' -e 's:@SYSCONFDIR@:${SYSCONFDIR}:g' -e 's:@LIBEXECDIR@:${LIBEXECDIR}:g' -e 's:@PREFIX@:${PREFIX}:g' -e 's:@BINDIR@:${BINDIR}:g' -e 's:@SBINDIR@:${SBINDIR}:g' ${_PKG_SED} ${_LCL_SED}
2222
2323 # Tweak our shell scripts
2424 %.sh: %.sh.in
5252 install: all realinstall ${INSTALLAFTER}
5353
5454 check test::
55 @if test -e runtests.sh ; then ./runtests.sh || exit $$? ; fi
5655
5756 # A lot of scripts don't have anything to clean
5857 # Also, some rm implentation require a file argument regardless of error
8989 fi; \
9090 ln -snf ${INITDIR}/"$$x" ${SHUTDOWNDIR}/"$$x" || exit $$?; done \
9191 fi
92 if test "${MKSYSVINIT}" = yes && test "${OS}" = Linux; then \
93 for x in tty1 tty2 tty3 tty4 tty5 tty6; do \
94 ln -snf ${INITDIR}/agetty ${DESTDIR}/${INITDIR}/"agetty.$$x" || exit $$?; \
95 ln -snf ${INITDIR}/agetty.$$x ${DEFAULTDIR}/"agetty.$$x" || exit $$?; \
96 done; \
97 fi
9298
9399 check test::
94100
0 #!@SHELL@
0 #!/bin/sh
11
22 option_arg=
33 poweroff_arg=
2020 poweroff_arg=--poweroff
2121 fi
2222
23 exec @SBINDIR@/openrc-shutdown ${option_arg} ${poweroff_arg} "$@"
23 script_args="$@"
24 if [ -z "${script_args}" ]; then
25 script_args=now
26 fi
27
28 exec @SBINDIR@/openrc-shutdown ${option_arg} ${poweroff_arg} "${script_args}"
0 #!@SHELL@
0 #!/bin/sh
11
22 option_arg=
33 poweroff_arg=
1919 poweroff_arg=--poweroff
2020 fi
2121
22 exec @SBINDIR@/openrc-shutdown ${option_arg} ${poweroff_arg} "$@"
22 script_args="$@"
23 if [ -z "${script_args}" ]; then
24 script_args=now
25 fi
26
27 exec @SBINDIR@/openrc-shutdown ${option_arg} ${poweroff_arg} "${script_args}"
0 #!@SHELL@
0 #!/bin/sh
11 # Copyright (c) 2015 The OpenRC Authors.
22 # See the Authors file at the top-level directory of this distribution and
33 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
0 #!@SHELL@
0 #!/bin/sh
11
22 option_arg=
33 poweroff_arg=
2121 poweroff_arg=--reboot
2222 fi
2323
24 exec @SBINDIR@/openrc-shutdown ${option_arg} ${poweroff_arg} "$@"
24 script_args="$@"
25 if [ -z "${script_args}" ]; then
26 script_args=now
27 fi
28
29 exec @SBINDIR@/openrc-shutdown ${option_arg} ${poweroff_arg} "${script_args}"
0 #!@SHELL@
0 #!/bin/sh
11
22 shutdown_arg=
33 while getopts :akrhPHfFnct: opt; do
33 cgroup-release-agent.sh
44 init.sh
55 init-early.sh
6 rc-cgroup.sh
7 migrate-to-run.sh
86 binfmt.sh
11 SRCS= init.sh.in functions.sh.in gendepends.sh.in \
22 openrc-run.sh.in ${SRCS-${OS}}
33 INC= rc-mount.sh functions.sh rc-functions.sh runit.sh s6.sh \
4 start-stop-daemon.sh supervise-daemon.sh
4 start-stop-daemon.sh supervise-daemon.sh ${INC-${OS}}
55 BIN= gendepends.sh init.sh openrc-run.sh ${BIN-${OS}}
66
77 INSTALLAFTER= _installafter
1212 SRCS-FreeBSD=
1313 BIN-FreeBSD=
1414
15 SRCS-Linux= binfmt.sh.in cgroup-release-agent.sh.in init-early.sh.in \
16 migrate-to-run.sh.in rc-cgroup.sh.in
17 BIN-Linux= binfmt.sh cgroup-release-agent.sh init-early.sh migrate-to-run.sh \
18 rc-cgroup.sh
15 SRCS-Linux= binfmt.sh.in cgroup-release-agent.sh.in init-early.sh.in
16 BIN-Linux= binfmt.sh cgroup-release-agent.sh init-early.sh
17 INC-Linux= rc-cgroup.sh
1918
2019 SRCS-NetBSD=
2120 BIN-NetBSD=
3130 ln -snf ${LIBEXECDIR}/sh/functions.sh ${DESTDIR}/${INITDIR} || exit $$?
3231
3332 check test::
34 ./runtests.sh
0 #!@SHELL@
0 #!/bin/sh
11 # This is a reimplementation of the systemd binfmt.d code to register
22 # misc binary formats with the kernel.
33 #
0 #!@SHELL@
0 #!/bin/sh
11 # This is run by the kernel after the last task is removed from a
22 # control group in the openrc hierarchy.
33
0 #!@SHELL@
0 #!/bin/sh
11 # Copyright (c) 2007-2015 The OpenRC Authors.
22 # See the Authors file at the top-level directory of this distribution and
33 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
0 #!@SHELL@
0 #!/bin/sh
11 # Copyright (c) 2007-2015 The OpenRC Authors.
22 # See the Authors file at the top-level directory of this distribution and
33 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
0 #!@SHELL@
0 #!/bin/sh
11 # Copyright (c) 2007-2015 The OpenRC Authors.
22 # See the Authors file at the top-level directory of this distribution and
33 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
0 #!@SHELL@
0 #!/bin/sh
11 # Copyright (c) 2007-2015 The OpenRC Authors.
22 # See the Authors file at the top-level directory of this distribution and
33 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
0 #!@SHELL@
0 #!/bin/sh
11 # Copyright (c) 1999-2007 Gentoo Foundation
22 # Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
33 # Released under the 2-clause BSD license.
+0
-36
sh/migrate-to-run.sh.in less more
0 #!@SHELL@
1 # Copyright (c) 2012-2015 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 . "@LIBEXECDIR@/sh/functions.sh"
12
13 if [ -e /run/openrc/softlevel ]; then
14 einfo "The OpenRC dependency data has already been migrated."
15 exit 0
16 fi
17
18 if [ ! -d /run ]; then
19 eerror "/run is not a directory."
20 eerror "moving /run to /run.pre-openrc"
21 mv /run /run.pre-openrc
22 mkdir /run
23 fi
24
25 rm -rf /run/openrc
26
27 if ! mountinfo -q -f tmpfs /run; then
28 ln -s "@LIBEXECDIR@"/init.d /run/openrc
29 else
30 cp -a "@LIBEXECDIR@/init.d" /run/openrc
31 rc-update -u
32 fi
33
34 einfo "The OpenRC dependency data was migrated successfully."
35 exit 0
0 # Copyright (c) 2012-2015 The OpenRC Authors.
1 # See the Authors file at the top-level directory of this distribution and
2 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
3 #
4 # This file is part of OpenRC. It is subject to the license terms in
5 # the LICENSE file found in the top-level directory of this
6 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
7 # This file may not be copied, modified, propagated, or distributed
8 # except according to the terms contained in the LICENSE file.
9
10 extra_stopped_commands="${extra_stopped_commands} cgroup_cleanup"
11 description_cgroup_cleanup="Kill all processes in the cgroup"
12
13 cgroup_find_path()
14 {
15 local OIFS name dir result
16 [ -n "$1" ] || return 0
17 OIFS="$IFS"
18 IFS=":"
19 while read -r _ name dir; do
20 [ "$name" = "$1" ] && result="$dir"
21 done < /proc/1/cgroup
22 IFS="$OIFS"
23 printf "%s" "${result}"
24 }
25
26 cgroup_get_pids()
27 {
28 local cgroup_procs p pids
29 cgroup_procs="$(cgroup2_find_path)"
30 [ -n "${cgroup_procs}" ] &&
31 cgroup_procs="${cgroup_procs}/${RC_SVCNAME}/cgroup.procs" ||
32 cgroup_procs="/sys/fs/cgroup/openrc/${RC_SVCNAME}/tasks"
33 [ -f "${cgroup_procs}" ] || return 0
34 while read -r p; do
35 [ "$p" -eq $$ ] || pids="${pids} ${p}"
36 done < "${cgroup_procs}"
37 printf "%s" "${pids}"
38 return 0
39 }
40
41 cgroup_running()
42 {
43 [ -d "/sys/fs/cgroup/unified/${RC_SVCNAME}" ] ||
44 [ -d "/sys/fs/cgroup/${RC_SVCNAME}" ] ||
45 [ -d "/sys/fs/cgroup/openrc/${RC_SVCNAME}" ]
46 }
47
48 cgroup_set_values()
49 {
50 [ -n "$1" ] && [ -n "$2" ] && [ -d "/sys/fs/cgroup/$1" ] || return 0
51
52 local controller h
53 controller="$1"
54 h=$(cgroup_find_path "$1")
55 cgroup="/sys/fs/cgroup/${1}${h}openrc_${RC_SVCNAME}"
56 [ -d "$cgroup" ] || mkdir -p "$cgroup"
57
58 set -- $2
59 local name val
60 while [ -n "$1" ] && [ "$controller" != "cpuacct" ]; do
61 case "$1" in
62 $controller.*)
63 if [ -n "${name}" ] && [ -w "${cgroup}/${name}" ] &&
64 [ -n "${val}" ]; then
65 veinfo "$RC_SVCNAME: Setting $cgroup/$name to $val"
66 printf "%s" "$val" > "$cgroup/$name"
67 fi
68 name=$1
69 val=
70 ;;
71 *)
72 [ -n "$val" ] &&
73 val="$val $1" ||
74 val="$1"
75 ;;
76 esac
77 shift
78 done
79 if [ -n "${name}" ] && [ -w "${cgroup}/${name}" ] && [ -n "${val}" ]; then
80 veinfo "$RC_SVCNAME: Setting $cgroup/$name to $val"
81 printf "%s" "$val" > "$cgroup/$name"
82 fi
83
84 if [ -w "$cgroup/tasks" ]; then
85 veinfo "$RC_SVCNAME: adding to $cgroup/tasks"
86 printf "%d" 0 > "$cgroup/tasks"
87 fi
88
89 return 0
90 }
91
92 cgroup_add_service()
93 {
94 # relocate starting process to the top of the cgroup
95 # it prevents from unwanted inheriting of the user
96 # cgroups. But may lead to a problems where that inheriting
97 # is needed.
98 for d in /sys/fs/cgroup/* ; do
99 [ -w "${d}"/tasks ] && printf "%d" 0 > "${d}"/tasks
100 done
101
102 openrc_cgroup=/sys/fs/cgroup/openrc
103 if [ -d "$openrc_cgroup" ]; then
104 cgroup="$openrc_cgroup/$RC_SVCNAME"
105 mkdir -p "$cgroup"
106 [ -w "$cgroup/tasks" ] && printf "%d" 0 > "$cgroup/tasks"
107 fi
108 }
109
110 cgroup_set_limits()
111 {
112 local blkio="${rc_cgroup_blkio:-$RC_CGROUP_BLKIO}"
113 [ -n "$blkio" ] && cgroup_set_values blkio "$blkio"
114
115 local cpu="${rc_cgroup_cpu:-$RC_CGROUP_CPU}"
116 [ -n "$cpu" ] && cgroup_set_values cpu "$cpu"
117
118 local cpuacct="${rc_cgroup_cpuacct:-$RC_CGROUP_CPUACCT}"
119 [ -n "$cpuacct" ] && cgroup_set_values cpuacct "$cpuacct"
120
121 local cpuset="${rc_cgroup_cpuset:-$RC_CGROUP_cpuset}"
122 [ -n "$cpuset" ] && cgroup_set_values cpuset "$cpuset"
123
124 local devices="${rc_cgroup_devices:-$RC_CGROUP_DEVICES}"
125 [ -n "$devices" ] && cgroup_set_values devices "$devices"
126
127 local hugetlb="${rc_cgroup_hugetlb:-$RC_CGROUP_HUGETLB}"
128 [ -n "$hugetlb" ] && cgroup_set_values hugetlb "$hugetlb"
129
130 local memory="${rc_cgroup_memory:-$RC_CGROUP_MEMORY}"
131 [ -n "$memory" ] && cgroup_set_values memory "$memory"
132
133 local net_cls="${rc_cgroup_net_cls:-$RC_CGROUP_NET_CLS}"
134 [ -n "$net_cls" ] && cgroup_set_values net_cls "$net_cls"
135
136 local net_prio="${rc_cgroup_net_prio:-$RC_CGROUP_NET_PRIO}"
137 [ -n "$net_prio" ] && cgroup_set_values net_prio "$net_prio"
138
139 local pids="${rc_cgroup_pids:-$RC_CGROUP_PIDS}"
140 [ -n "$pids" ] && cgroup_set_values pids "$pids"
141
142 return 0
143 }
144
145 cgroup2_find_path()
146 {
147 if grep -qw cgroup2 /proc/filesystems; then
148 case "${rc_cgroup_mode:-hybrid}" in
149 hybrid) printf "/sys/fs/cgroup/unified" ;;
150 unified) printf "/sys/fs/cgroup" ;;
151 esac
152 fi
153 return 0
154 }
155
156 cgroup2_remove()
157 {
158 local cgroup_path rc_cgroup_path
159 cgroup_path="$(cgroup2_find_path)"
160 [ -z "${cgroup_path}" ] && return 0
161 rc_cgroup_path="${cgroup_path}/${RC_SVCNAME}"
162 [ ! -d "${rc_cgroup_path}" ] ||
163 [ ! -e "${rc_cgroup_path}"/cgroup.events ] &&
164 return 0
165 grep -qx "$$" "${rc_cgroup_path}/cgroup.procs" &&
166 printf "%d" 0 > "${cgroup_path}/cgroup.procs"
167 local key populated vvalue
168 while read -r key value; do
169 case "${key}" in
170 populated) populated=${value} ;;
171 *) ;;
172 esac
173 done < "${rc_cgroup_path}/cgroup.events"
174 [ "${populated}" = 1 ] && return 0
175 rmdir "${rc_cgroup_path}"
176 return 0
177 }
178
179 cgroup2_set_limits()
180 {
181 local cgroup_path
182 cgroup_path="$(cgroup2_find_path)"
183 [ -d "${cgroup_path}" ] || return 0
184 rc_cgroup_path="${cgroup_path}/${RC_SVCNAME}"
185 [ ! -d "${rc_cgroup_path}" ] && mkdir "${rc_cgroup_path}"
186 [ -f "${rc_cgroup_path}"/cgroup.procs ] &&
187 printf 0 > "${rc_cgroup_path}"/cgroup.procs
188 [ -z "${rc_cgroup_settings}" ] && return 0
189 echo "${rc_cgroup_settings}" | while read -r key value; do
190 [ -z "${key}" ] && continue
191 [ -z "${value}" ] && continue
192 [ ! -f "${rc_cgroup_path}/${key}" ] && continue
193 veinfo "${RC_SVCNAME}: cgroups: setting ${key} to ${value}"
194 printf "%s\n" "${value}" > "${rc_cgroup_path}/${key}"
195 done
196 return 0
197 }
198
199 cgroup_cleanup()
200 {
201 cgroup_running || return 0
202 ebegin "starting cgroups cleanup"
203 local pids loops=0
204 pids="$(cgroup_get_pids)"
205 if [ -n "${pids}" ]; then
206 kill -s CONT ${pids} 2> /dev/null
207 kill -s "${stopsig:-TERM}" ${pids} 2> /dev/null
208 yesno "${rc_send_sighup:-no}" &&
209 kill -s HUP ${pids} 2> /dev/null
210 kill -s "${stopsig:-TERM}" ${pids} 2> /dev/null
211 while [ -n "$(cgroup_get_pids)" ] &&
212 [ "${loops}" -lt "${rc_timeout_stopsec:-90}" ]; do
213 loops=$((loops+1))
214 sleep 1
215 done
216 pids="$(cgroup_get_pids)"
217 [ -n "${pids}" ] && yesno "${rc_send_sigkill:-yes}" &&
218 kill -s KILL ${pids} 2> /dev/null
219 fi
220 cgroup2_remove
221 [ -z "$(cgroup_get_pids)" ]
222 eend $? "Unable to stop all processes"
223 return 0
224 }
+0
-226
sh/rc-cgroup.sh.in less more
0 #!@SHELL@
1 # Copyright (c) 2012-2015 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 extra_stopped_commands="${extra_stopped_commands} cgroup_cleanup"
12 description_cgroup_cleanup="Kill all processes in the cgroup"
13
14 cgroup_find_path()
15 {
16 local OIFS name dir result
17 [ -n "$1" ] || return 0
18 OIFS="$IFS"
19 IFS=":"
20 while read -r _ name dir; do
21 [ "$name" = "$1" ] && result="$dir"
22 done < /proc/1/cgroup
23 IFS="$OIFS"
24 printf "%s" "${result}"
25 }
26
27 cgroup_get_pids()
28 {
29 local cgroup_procs p pids
30 cgroup_procs="$(cgroup2_find_path)"
31 [ -n "${cgroup_procs}" ] &&
32 cgroup_procs="${cgroup_procs}/${RC_SVCNAME}/cgroup.procs" ||
33 cgroup_procs="/sys/fs/cgroup/openrc/${RC_SVCNAME}/tasks"
34 [ -f "${cgroup_procs}" ] || return 0
35 while read -r p; do
36 [ "$p" -eq $$ ] || pids="${pids} ${p}"
37 done < "${cgroup_procs}"
38 printf "%s" "${pids}"
39 return 0
40 }
41
42 cgroup_running()
43 {
44 [ -d "/sys/fs/cgroup/unified/${RC_SVCNAME}" ] ||
45 [ -d "/sys/fs/cgroup/${RC_SVCNAME}" ] ||
46 [ -d "/sys/fs/cgroup/openrc/${RC_SVCNAME}" ]
47 }
48
49 cgroup_set_values()
50 {
51 [ -n "$1" ] && [ -n "$2" ] && [ -d "/sys/fs/cgroup/$1" ] || return 0
52
53 local controller h
54 controller="$1"
55 h=$(cgroup_find_path "$1")
56 cgroup="/sys/fs/cgroup/${1}${h}openrc_${RC_SVCNAME}"
57 [ -d "$cgroup" ] || mkdir -p "$cgroup"
58
59 set -- $2
60 local name val
61 while [ -n "$1" ] && [ "$controller" != "cpuacct" ]; do
62 case "$1" in
63 $controller.*)
64 if [ -n "${name}" ] && [ -w "${cgroup}/${name}" ] &&
65 [ -n "${val}" ]; then
66 veinfo "$RC_SVCNAME: Setting $cgroup/$name to $val"
67 printf "%s" "$val" > "$cgroup/$name"
68 fi
69 name=$1
70 val=
71 ;;
72 *)
73 [ -n "$val" ] &&
74 val="$val $1" ||
75 val="$1"
76 ;;
77 esac
78 shift
79 done
80 if [ -n "${name}" ] && [ -w "${cgroup}/${name}" ] && [ -n "${val}" ]; then
81 veinfo "$RC_SVCNAME: Setting $cgroup/$name to $val"
82 printf "%s" "$val" > "$cgroup/$name"
83 fi
84
85 if [ -w "$cgroup/tasks" ]; then
86 veinfo "$RC_SVCNAME: adding to $cgroup/tasks"
87 printf "%d" 0 > "$cgroup/tasks"
88 fi
89
90 return 0
91 }
92
93 cgroup_add_service()
94 {
95 # relocate starting process to the top of the cgroup
96 # it prevents from unwanted inheriting of the user
97 # cgroups. But may lead to a problems where that inheriting
98 # is needed.
99 for d in /sys/fs/cgroup/* ; do
100 [ -w "${d}"/tasks ] && printf "%d" 0 > "${d}"/tasks
101 done
102
103 openrc_cgroup=/sys/fs/cgroup/openrc
104 if [ -d "$openrc_cgroup" ]; then
105 cgroup="$openrc_cgroup/$RC_SVCNAME"
106 mkdir -p "$cgroup"
107 [ -w "$cgroup/tasks" ] && printf "%d" 0 > "$cgroup/tasks"
108 fi
109 }
110
111 cgroup_set_limits()
112 {
113 local blkio="${rc_cgroup_blkio:-$RC_CGROUP_BLKIO}"
114 [ -n "$blkio" ] && cgroup_set_values blkio "$blkio"
115
116 local cpu="${rc_cgroup_cpu:-$RC_CGROUP_CPU}"
117 [ -n "$cpu" ] && cgroup_set_values cpu "$cpu"
118
119 local cpuacct="${rc_cgroup_cpuacct:-$RC_CGROUP_CPUACCT}"
120 [ -n "$cpuacct" ] && cgroup_set_values cpuacct "$cpuacct"
121
122 local cpuset="${rc_cgroup_cpuset:-$RC_CGROUP_cpuset}"
123 [ -n "$cpuset" ] && cgroup_set_values cpuset "$cpuset"
124
125 local devices="${rc_cgroup_devices:-$RC_CGROUP_DEVICES}"
126 [ -n "$devices" ] && cgroup_set_values devices "$devices"
127
128 local hugetlb="${rc_cgroup_hugetlb:-$RC_CGROUP_HUGETLB}"
129 [ -n "$hugetlb" ] && cgroup_set_values hugetlb "$hugetlb"
130
131 local memory="${rc_cgroup_memory:-$RC_CGROUP_MEMORY}"
132 [ -n "$memory" ] && cgroup_set_values memory "$memory"
133
134 local net_cls="${rc_cgroup_net_cls:-$RC_CGROUP_NET_CLS}"
135 [ -n "$net_cls" ] && cgroup_set_values net_cls "$net_cls"
136
137 local net_prio="${rc_cgroup_net_prio:-$RC_CGROUP_NET_PRIO}"
138 [ -n "$net_prio" ] && cgroup_set_values net_prio "$net_prio"
139
140 local pids="${rc_cgroup_pids:-$RC_CGROUP_PIDS}"
141 [ -n "$pids" ] && cgroup_set_values pids "$pids"
142
143 return 0
144 }
145
146 cgroup2_find_path()
147 {
148 if grep -qw cgroup2 /proc/filesystems; then
149 case "${rc_cgroup_mode:-hybrid}" in
150 hybrid) printf "/sys/fs/cgroup/unified" ;;
151 unified) printf "/sys/fs/cgroup" ;;
152 esac
153 fi
154 return 0
155 }
156
157 cgroup2_remove()
158 {
159 local cgroup_path rc_cgroup_path
160 cgroup_path="$(cgroup2_find_path)"
161 [ -z "${cgroup_path}" ] && return 0
162 rc_cgroup_path="${cgroup_path}/${RC_SVCNAME}"
163 [ ! -d "${rc_cgroup_path}" ] ||
164 [ ! -e "${rc_cgroup_path}"/cgroup.events ] &&
165 return 0
166 grep -qx "$$" "${rc_cgroup_path}/cgroup.procs" &&
167 printf "%d" 0 > "${cgroup_path}/cgroup.procs"
168 local key populated vvalue
169 while read -r key value; do
170 case "${key}" in
171 populated) populated=${value} ;;
172 *) ;;
173 esac
174 done < "${rc_cgroup_path}/cgroup.events"
175 [ "${populated}" = 1 ] && return 0
176 rmdir "${rc_cgroup_path}"
177 return 0
178 }
179
180 cgroup2_set_limits()
181 {
182 local cgroup_path
183 cgroup_path="$(cgroup2_find_path)"
184 [ -d "${cgroup_path}" ] || return 0
185 rc_cgroup_path="${cgroup_path}/${RC_SVCNAME}"
186 [ ! -d "${rc_cgroup_path}" ] && mkdir "${rc_cgroup_path}"
187 [ -f "${rc_cgroup_path}"/cgroup.procs ] &&
188 printf 0 > "${rc_cgroup_path}"/cgroup.procs
189 [ -z "${rc_cgroup_settings}" ] && return 0
190 echo "${rc_cgroup_settings}" | while read -r key value; do
191 [ -z "${key}" ] && continue
192 [ -z "${value}" ] && continue
193 [ ! -f "${rc_cgroup_path}/${key}" ] && continue
194 veinfo "${RC_SVCNAME}: cgroups: setting ${key} to ${value}"
195 printf "%s\n" "${value}" > "${rc_cgroup_path}/${key}"
196 done
197 return 0
198 }
199
200 cgroup_cleanup()
201 {
202 cgroup_running || return 0
203 ebegin "starting cgroups cleanup"
204 local pids loops=0
205 pids="$(cgroup_get_pids)"
206 if [ -n "${pids}" ]; then
207 kill -s CONT ${pids} 2> /dev/null
208 kill -s "${stopsig:-TERM}" ${pids} 2> /dev/null
209 yesno "${rc_send_sighup:-no}" &&
210 kill -s HUP ${pids} 2> /dev/null
211 kill -s "${stopsig:-TERM}" ${pids} 2> /dev/null
212 while [ -n "$(cgroup_get_pids)" ] &&
213 [ "${loops}" -lt "${rc_timeout_stopsec:-90}" ]; do
214 loops=$((loops+1))
215 sleep 1
216 done
217 pids="$(cgroup_get_pids)"
218 [ -n "${pids}" ] && yesno "${rc_send_sigkill:-yes}" &&
219 kill -s KILL ${pids} 2> /dev/null
220 fi
221 cgroup2_remove
222 [ -z "$(cgroup_get_pids)" ]
223 eend $? "Unable to stop all processes"
224 return 0
225 }
+0
-34
sh/runtests.sh less more
0 #!/bin/sh
1 # Copyright (c) 2008-2015 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 : ${top_srcdir:=..}
12 . $top_srcdir/test/setup_env.sh
13
14 ret=0
15
16 tret=0
17 ebegin "Testing yesno()"
18 for f in yes YES Yes true TRUE True 1 ; do
19 if ! yesno $f; then
20 : $(( tret += 1 ))
21 echo "!$f!"
22 fi
23 done
24 for f in no NO No false FALSE False 0 ; do
25 if yesno $f; then
26 : $(( tret += 1 ))
27 echo "!$f!"
28 fi
29 done
30 eend $tret
31 : $(( ret += $tret ))
32
33 exit $ret
00 # Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
11 # Released under the 2-clause BSD license.
22
3 SUBDIR= test libeinfo librc rc
3 SUBDIR= libeinfo librc rc
44
55 MK= ../mk
66 include ${MK}/subdir.mk
+0
-26
src/includes/hidden-visibility.h less more
0 /*
1 * Written by Mike Frysinger
2 * Placed in the Public Domain
3 */
4
5 #ifndef _HIDDEN_VISIBILITY_H_
6 #define _HIDDEN_VISIBILITY_H_
7
8 #if defined(__ELF__) && defined(__GNUC__)
9 # define __hidden_asmname(name) __hidden_asmname1 (__USER_LABEL_PREFIX__, name)
10 # define __hidden_asmname1(prefix, name) __hidden_asmname2(prefix, name)
11 # define __hidden_asmname2(prefix, name) #prefix name
12 # define __hidden_proto(name, internal) \
13 extern __typeof (name) name __asm__ (__hidden_asmname (#internal)) \
14 __attribute__ ((visibility ("hidden")));
15 # define __hidden_ver(local, internal, name) \
16 extern __typeof (name) __EI_##name __asm__(__hidden_asmname (#internal)); \
17 extern __typeof (name) __EI_##name __attribute__((alias (__hidden_asmname1 (,#local))))
18 # define hidden_proto(name) __hidden_proto(name, __RC_##name)
19 # define hidden_def(name) __hidden_ver(__RC_##name, name, name);
20 #else
21 # define hidden_proto(name)
22 # define hidden_def(name)
23 #endif
24
25 #endif
1414 * except according to the terms contained in the LICENSE file.
1515 */
1616
17 const char libeinfo_copyright[] = "Copyright (c) 2007-2008 Roy Marples";
17 static const char libeinfo_copyright[] = "Copyright (c) 2007-2008 Roy Marples";
1818
1919 #include <sys/types.h>
2020 #include <sys/ioctl.h>
3838
3939 #include "einfo.h"
4040 #include "helpers.h"
41 #include "hidden-visibility.h"
42
43 hidden_proto(ecolor)
44 hidden_proto(ebegin)
45 hidden_proto(ebeginv)
46 hidden_proto(ebracket)
47 hidden_proto(eend)
48 hidden_proto(eendv)
49 hidden_proto(eerror)
50 hidden_proto(eerrorn)
51 hidden_proto(eerrorx)
52 hidden_proto(eindent)
53 hidden_proto(eindentv)
54 hidden_proto(einfo)
55 hidden_proto(einfon)
56 hidden_proto(einfov)
57 hidden_proto(einfovn)
58 hidden_proto(elog)
59 hidden_proto(eoutdent)
60 hidden_proto(eoutdentv)
61 hidden_proto(eprefix)
62 hidden_proto(ewarn)
63 hidden_proto(ewarnn)
64 hidden_proto(ewarnv)
65 hidden_proto(ewarnvn)
66 hidden_proto(ewarnx)
67 hidden_proto(ewend)
68 hidden_proto(ewendv)
6941
7042 /* Incase we cannot work out how many columns from ioctl, supply a default */
7143 #define DEFAULT_COLS 80
509481 {
510482 _eprefix = prefix;
511483 }
512 hidden_def(eprefix)
513484
514485 static void EINFO_PRINTF(2, 0)
515486 elogv(int level, const char *EINFO_RESTRICT fmt, va_list ap)
536507 elogv(level, fmt, ap);
537508 va_end(ap);
538509 }
539 hidden_def(elog)
540510
541511 static int
542512 _eindent(FILE * EINFO_RESTRICT stream)
575545 return ecolors_str[i];
576546 return "";
577547 }
578 hidden_def(ecolor)
579548
580549 const char *
581550 ecolor(ECOLOR color)
642611 LASTCMD("einfon");
643612 return retval;
644613 }
645 hidden_def(einfon)
646614
647615 int
648616 ewarnn(const char *EINFO_RESTRICT fmt, ...)
658626 LASTCMD("ewarnn");
659627 return retval;
660628 }
661 hidden_def(ewarnn)
662629
663630 int
664631 eerrorn(const char *EINFO_RESTRICT fmt, ...)
674641 LASTCMD("errorn");
675642 return retval;
676643 }
677 hidden_def(eerrorn)
678644
679645 int
680646 einfo(const char *EINFO_RESTRICT fmt, ...)
691657 LASTCMD("einfo");
692658 return retval;
693659 }
694 hidden_def(einfo)
695660
696661 int
697662 ewarn(const char *EINFO_RESTRICT fmt, ...)
709674 LASTCMD("ewarn");
710675 return retval;
711676 }
712 hidden_def(ewarn)
713677
714678 void
715679 ewarnx(const char *EINFO_RESTRICT fmt, ...)
726690 }
727691 exit(EXIT_FAILURE);
728692 }
729 hidden_def(ewarnx)
730693
731694 int
732695 eerror(const char *EINFO_RESTRICT fmt, ...)
744707 LASTCMD("eerror");
745708 return retval;
746709 }
747 hidden_def(eerror)
748710
749711 void
750712 eerrorx(const char *EINFO_RESTRICT fmt, ...)
760722 }
761723 exit(EXIT_FAILURE);
762724 }
763 hidden_def(eerrorx)
764725
765726 int
766727 ebegin(const char *EINFO_RESTRICT fmt, ...)
779740 LASTCMD("ebegin");
780741 return retval;
781742 }
782 hidden_def(ebegin)
783743
784744 static void
785745 _eend(FILE * EINFO_RESTRICT fp, int col, ECOLOR color, const char *msg)
853813 LASTCMD("eend");
854814 return retval;
855815 }
856 hidden_def(eend)
857816
858817 int
859818 ewend(int retval, const char *EINFO_RESTRICT fmt, ...)
868827 LASTCMD("ewend");
869828 return retval;
870829 }
871 hidden_def(ewend)
872830
873831 void
874832 ebracket(int col, ECOLOR color, const char *msg)
875833 {
876834 _eend(stdout, col, color, msg);
877835 }
878 hidden_def(ebracket)
879836
880837 void
881838 eindent(void)
897854 setenv("EINFO_INDENT", num, 1);
898855 free(num);
899856 }
900 hidden_def(eindent)
901857
902858 void eoutdent(void)
903859 {
923879 }
924880 errno = serrno;
925881 }
926 hidden_def(eoutdent)
927882
928883 int
929884 einfovn(const char *EINFO_RESTRICT fmt, ...)
939894 LASTCMD("einfovn");
940895 return retval;
941896 }
942 hidden_def(einfovn)
943897
944898 int
945899 ewarnvn(const char *EINFO_RESTRICT fmt, ...)
955909 LASTCMD("ewarnvn");
956910 return retval;
957911 }
958 hidden_def(ewarnvn)
959912
960913 int
961914 einfov(const char *EINFO_RESTRICT fmt, ...)
972925 LASTCMD("einfov");
973926 return retval;
974927 }
975 hidden_def(einfov)
976928
977929 int
978930 ewarnv(const char *EINFO_RESTRICT fmt, ...)
989941 LASTCMD("ewarnv");
990942 return retval;
991943 }
992 hidden_def(ewarnv)
993944
994945 int
995946 ebeginv(const char *EINFO_RESTRICT fmt, ...)
1009960 LASTCMD("ebeginv");
1010961 return retval;
1011962 }
1012 hidden_def(ebeginv)
1013963
1014964 int
1015965 eendv(int retval, const char *EINFO_RESTRICT fmt, ...)
1024974 LASTCMD("eendv");
1025975 return retval;
1026976 }
1027 hidden_def(eendv)
1028977
1029978 int
1030979 ewendv(int retval, const char *EINFO_RESTRICT fmt, ...)
1039988 LASTCMD("ewendv");
1040989 return retval;
1041990 }
1042 hidden_def(ewendv)
1043991
1044992 void
1045993 eindentv(void)
1047995 if (is_verbose())
1048996 eindent();
1049997 }
1050 hidden_def(eindentv)
1051998
1052999 void
10531000 eoutdentv(void)
10551002 if (is_verbose())
10561003 eoutdent();
10571004 }
1058 hidden_def(eoutdentv)
5858 free(cmdline);
5959 return false;
6060 }
61 bytes = read(fd, buffer, sizeof(buffer));
61 bytes = read(fd, buffer, sizeof(buffer) - 1);
6262 close(fd);
6363 free(cmdline);
6464 if (bytes == -1)
140140 memset(my_ns, 0, sizeof(my_ns));
141141 memset(proc_ns, 0, sizeof(proc_ns));
142142 if (exists("/proc/self/ns/pid")) {
143 rc = readlink("/proc/self/ns/pid", my_ns, sizeof(my_ns));
143 rc = readlink("/proc/self/ns/pid", my_ns, sizeof(my_ns)-1);
144144 if (rc <= 0)
145145 my_ns[0] = '\0';
146146 }
154154 continue;
155155 xasprintf(&buffer, "/proc/%d/ns/pid", p);
156156 if (exists(buffer)) {
157 rc = readlink(buffer, proc_ns, sizeof(proc_ns));
157 rc = readlink(buffer, proc_ns, sizeof(proc_ns)-1);
158158 if (rc <= 0)
159159 proc_ns[0] = '\0';
160160 }
207207 closedir(procdir);
208208 return pids;
209209 }
210 librc_hidden_def(rc_find_pids)
211210
212211 #elif BSD
213212
312311
313312 return pids;
314313 }
315 librc_hidden_def(rc_find_pids)
316314
317315 #else
318316 # error "Platform not supported!"
454452 free(dirpath);
455453 return retval;
456454 }
457 librc_hidden_def(rc_service_daemon_set)
458455
459456 bool
460457 rc_service_started_daemon(const char *service,
494491 free(dirpath);
495492 return retval;
496493 }
497 librc_hidden_def(rc_service_started_daemon)
498494
499495 bool
500496 rc_service_daemons_crashed(const char *service)
614610 i = 0;
615611 TAILQ_FOREACH(s, list, entries)
616612 argv[i++] = s->value;
617 argv[i] = '\0';
613 argv[i] = NULL;
618614 }
619615 }
620616
652648
653649 return retval;
654650 }
655 librc_hidden_def(rc_service_daemons_crashed)
7777 }
7878 free(deptree);
7979 }
80 librc_hidden_def(rc_deptree_free)
8180
8281 static RC_DEPINFO *
8382 get_depinfo(const RC_DEPTREE *deptree, const char *service)
8483 {
8584 RC_DEPINFO *di;
86
87 TAILQ_FOREACH(di, deptree, entries)
88 if (strcmp(di->service, service) == 0)
89 return di;
85 if (deptree) {
86 TAILQ_FOREACH(di, deptree, entries)
87 if (strcmp(di->service, service) == 0)
88 return di;
89 }
9090 return NULL;
9191 }
9292
9595 {
9696 RC_DEPTYPE *dt;
9797
98 TAILQ_FOREACH(dt, &depinfo->depends, entries)
99 if (strcmp(dt->type, type) == 0)
100 return dt;
98 if (depinfo) {
99 TAILQ_FOREACH(dt, &depinfo->depends, entries)
100 if (strcmp(dt->type, type) == 0)
101 return dt;
102 }
101103 return NULL;
102104 }
103105
105107 rc_deptree_load(void) {
106108 return rc_deptree_load_file(RC_DEPTREE_CACHE);
107109 }
108 librc_hidden_def(rc_deptree_load)
109110
110111 RC_DEPTREE *
111112 rc_deptree_load_file(const char *deptree_file)
169170
170171 return deptree;
171172 }
172 librc_hidden_def(rc_deptree_load_file)
173173
174174 static bool
175175 valid_service(const char *runlevel, const char *service, const char *type)
455455 rc_stringlist_add(svcs, svc->value);
456456 return svcs;
457457 }
458 librc_hidden_def(rc_deptree_depend)
459458
460459 RC_STRINGLIST *
461460 rc_deptree_depends(const RC_DEPTREE *deptree,
483482 rc_stringlist_free(visited);
484483 return sorted;
485484 }
486 librc_hidden_def(rc_deptree_depends)
487485
488486 RC_STRINGLIST *
489487 rc_deptree_order(const RC_DEPTREE *deptree, const char *runlevel, int options)
539537 rc_stringlist_free(types);
540538 return services;
541539 }
542 librc_hidden_def(rc_deptree_order)
543540
544541
545542 /* Given a time, recurse the target path to find out if there are
615612 return false;
616613 mtime = buf.st_mtime;
617614
618 retval = deep_mtime_check(target,newer,&mtime,file);
619 if (rel) {
620 *rel = mtime;
621 }
622 return retval;
615 retval = deep_mtime_check(target,newer,&mtime,file);
616 if (rel) {
617 *rel = mtime;
618 }
619 return retval;
623620 }
624621
625622 bool
629626
630627 return mtime_check(source, target, true, newest, file);
631628 }
632 librc_hidden_def(rc_newer_than)
633629
634630 bool
635631 rc_older_than(const char *source, const char *target,
637633 {
638634 return mtime_check(source, target, false, oldest, file);
639635 }
640 librc_hidden_def(rc_older_than)
641636
642637 typedef struct deppair
643638 {
733728
734729 return newer;
735730 }
736 librc_hidden_def(rc_deptree_update_needed)
737731
738732 /* This is a 7 phase operation
739733 Phase 1 is a shell script which loads each init script and config in turn
10801074 rc_deptree_free(deptree);
10811075 return retval;
10821076 }
1083 librc_hidden_def(rc_deptree_update)
4242
4343 return false;
4444 }
45 librc_hidden_def(rc_yesno)
4645
4746
4847 /**
9089 fclose(fp);
9190 return ret;
9291 }
93 librc_hidden_def(rc_getfile)
9492
9593 ssize_t
9694 rc_getline(char **line, size_t *len, FILE *fp)
115113 }
116114 return last;
117115 }
118 librc_hidden_def(rc_getline)
119116
120117 char *
121118 rc_proc_getent(const char *ent _unused)
162159 return NULL;
163160 #endif
164161 }
165 librc_hidden_def(rc_proc_getent)
166162
167163 RC_STRINGLIST *
168164 rc_config_list(const char *file)
201197
202198 return list;
203199 }
204 librc_hidden_def(rc_config_list)
205200
206201 static void rc_config_set_value(RC_STRINGLIST *config, char *value)
207202 {
372367
373368 return config;
374369 }
375 librc_hidden_def(rc_config_load)
376370
377371 char *
378372 rc_config_value(RC_STRINGLIST *list, const char *entry)
391385 }
392386 return NULL;
393387 }
394 librc_hidden_def(rc_config_value)
395388
396389 /* Global for caching the strings loaded from rc.conf to avoid reparsing for
397390 * each rc_conf_value call */
422415 }
423416
424417 rc_conf = rc_config_directory(rc_conf);
425 rc_conf = rc_config_kcl(rc_conf);
418 rc_conf = rc_config_kcl(rc_conf);
426419
427420 /* Convert old uppercase to lowercase */
428421 TAILQ_FOREACH(s, rc_conf, entries) {
437430
438431 return rc_config_value(rc_conf, setting);
439432 }
440 librc_hidden_def(rc_conf_value)
2424 TAILQ_INIT(l);
2525 return l;
2626 }
27 librc_hidden_def(rc_stringlist_new)
2827
2928 RC_STRING *
3029 rc_stringlist_add(RC_STRINGLIST *list, const char *value)
3534 TAILQ_INSERT_TAIL(list, s, entries);
3635 return s;
3736 }
38 librc_hidden_def(rc_stringlist_add)
3937
4038 RC_STRING *
4139 rc_stringlist_addu(RC_STRINGLIST *list, const char *value)
5048
5149 return rc_stringlist_add(list, value);
5250 }
53 librc_hidden_def(rc_stringlist_addu)
5451
5552 bool
5653 rc_stringlist_delete(RC_STRINGLIST *list, const char *value)
6865 errno = EEXIST;
6966 return false;
7067 }
71 librc_hidden_def(rc_stringlist_delete)
7268
7369 RC_STRING *
7470 rc_stringlist_find(RC_STRINGLIST *list, const char *value)
8278 }
8379 return NULL;
8480 }
85 librc_hidden_def(rc_stringlist_find)
8681
8782 RC_STRINGLIST *
8883 rc_stringlist_split(const char *value, const char *sep)
9792
9893 return list;
9994 }
100 librc_hidden_def(rc_stringlist_split)
10195
10296 void
10397 rc_stringlist_sort(RC_STRINGLIST **list)
127121 free(l);
128122 *list = new;
129123 }
130 librc_hidden_def(rc_stringlist_sort)
131124
132125 void
133126 rc_stringlist_free(RC_STRINGLIST *list)
147140 }
148141 free(list);
149142 }
150 librc_hidden_def(rc_stringlist_free)
1414 * except according to the terms contained in the LICENSE file.
1515 */
1616
17 const char librc_copyright[] = "Copyright (c) 2007-2008 Roy Marples";
17 static const char librc_copyright[] = "Copyright (c) 2007-2008 Roy Marples";
1818
1919 #include "queue.h"
2020 #include "librc.h"
350350
351351 return sys;
352352 }
353 librc_hidden_def(rc_sys)
354353
355354 static const char *
356355 rc_parse_service_state(RC_SERVICE state)
425424 {
426425 return exists(RC_STARTING);
427426 }
428 librc_hidden_def(rc_runlevel_starting)
429427
430428 bool
431429 rc_runlevel_stopping(void)
432430 {
433431 return exists(RC_STOPPING);
434432 }
435 librc_hidden_def(rc_runlevel_stopping)
436433
437434 RC_STRINGLIST *rc_runlevel_list(void)
438435 {
439436 return ls_dir(RC_RUNLEVELDIR, LS_DIR);
440437 }
441 librc_hidden_def(rc_runlevel_list)
442438
443439 char *
444440 rc_runlevel_get(void)
465461
466462 return runlevel;
467463 }
468 librc_hidden_def(rc_runlevel_get)
469464
470465 bool
471466 rc_runlevel_set(const char *runlevel)
478473 fclose(fp);
479474 return true;
480475 }
481 librc_hidden_def(rc_runlevel_set)
482476
483477 bool
484478 rc_runlevel_exists(const char *runlevel)
493487 return true;
494488 return false;
495489 }
496 librc_hidden_def(rc_runlevel_exists)
497490
498491 bool
499492 rc_runlevel_stack(const char *dst, const char *src)
506499 snprintf(d, sizeof(s), "%s/%s/%s", RC_RUNLEVELDIR, dst, src);
507500 return (symlink(s, d) == 0 ? true : false);
508501 }
509 librc_hidden_def(rc_runlevel_stack)
510502
511503 bool
512504 rc_runlevel_unstack(const char *dst, const char *src)
516508 snprintf(path, sizeof(path), "%s/%s/%s", RC_RUNLEVELDIR, dst, src);
517509 return (unlink(path) == 0 ? true : false);
518510 }
519 librc_hidden_def(rc_runlevel_unstack)
520511
521512 RC_STRINGLIST *
522513 rc_runlevel_stacks(const char *runlevel)
529520 rc_stringlist_free(ancestor_list);
530521 return stack;
531522 }
532 librc_hidden_def(rc_runlevel_stacks)
533523
534524 /* Resolve a service name to its full path */
535525 char *
557547
558548 if (*file) {
559549 memset(buffer, 0, sizeof(buffer));
560 r = readlink(file, buffer, sizeof(buffer));
550 r = readlink(file, buffer, sizeof(buffer)-1);
561551 if (r > 0)
562552 return xstrdup(buffer);
563553 }
583573
584574 return NULL;
585575 }
586 librc_hidden_def(rc_service_resolve)
587576
588577 bool
589578 rc_service_exists(const char *service)
622611 free(file);
623612 return retval;
624613 }
625 librc_hidden_def(rc_service_exists)
626614
627615 #define OPTSTR \
628616 ". '%s'; echo $extra_commands $extra_started_commands $extra_stopped_commands"
664652 free(cmd);
665653 return commands;
666654 }
667 librc_hidden_def(rc_service_extra_commands)
668655
669656 #define DESCSTR ". '%s'; echo \"${description%s%s}\""
670657 char *
694681 free(cmd);
695682 return desc;
696683 }
697 librc_hidden_def(rc_service_description)
698684
699685 bool
700686 rc_service_in_runlevel(const char *service, const char *runlevel)
705691 runlevel, basename_c(service));
706692 return exists(file);
707693 }
708 librc_hidden_def(rc_service_in_runlevel)
709694
710695 bool
711696 rc_service_mark(const char *service, const RC_SERVICE state)
825810 free(init);
826811 return true;
827812 }
828 librc_hidden_def(rc_service_mark)
829813
830814 RC_SERVICE
831815 rc_service_state(const char *service)
868852
869853 return state;
870854 }
871 librc_hidden_def(rc_service_state)
872855
873856 char *
874857 rc_service_value_get(const char *service, const char *option)
883866
884867 return buffer;
885868 }
886 librc_hidden_def(rc_service_value_get)
887869
888870 bool
889871 rc_service_value_set(const char *service, const char *option,
908890 }
909891 return true;
910892 }
911 librc_hidden_def(rc_service_value_set)
912893
913894
914895 bool
935916 free(init);
936917 return retval;
937918 }
938 librc_hidden_def(rc_service_schedule_start)
939919
940920 bool
941921 rc_service_schedule_clear(const char *service)
948928 return true;
949929 return false;
950930 }
951 librc_hidden_def(rc_service_schedule_clear)
952931
953932 RC_STRINGLIST *
954933 rc_services_in_runlevel(const char *runlevel)
986965 list = rc_stringlist_new();
987966 return list;
988967 }
989 librc_hidden_def(rc_services_in_runlevel)
990968
991969 RC_STRINGLIST *
992970 rc_services_in_runlevel_stacked(const char *runlevel)
1003981 }
1004982 return list;
1005983 }
1006 librc_hidden_def(rc_services_in_runlevel_stacked)
1007984
1008985 RC_STRINGLIST *
1009986 rc_services_in_state(RC_SERVICE state)
10371014 rc_stringlist_free(dirs);
10381015 return list;
10391016 }
1040 librc_hidden_def(rc_services_in_state)
10411017
10421018 bool
10431019 rc_service_add(const char *runlevel, const char *service)
10461022 char *init;
10471023 char file[PATH_MAX];
10481024 char path[MAXPATHLEN] = { '\0' };
1049 char *p = NULL;
10501025 char binit[PATH_MAX];
10511026 char *i;
10521027
10671042 /* We need to ensure that only things in /etc/init.d are added
10681043 * to the boot runlevel */
10691044 if (strcmp(runlevel, RC_LEVEL_BOOT) == 0) {
1070 p = realpath(dirname(init), path);
1071 if (!*p) {
1045 if (realpath(dirname(init), path) == NULL) {
10721046 free(init);
10731047 return false;
10741048 }
10851059 free(init);
10861060 return retval;
10871061 }
1088 librc_hidden_def(rc_service_add)
10891062
10901063 bool
10911064 rc_service_delete(const char *runlevel, const char *service)
10981071 return true;
10991072 return false;
11001073 }
1101 librc_hidden_def(rc_service_delete)
11021074
11031075 RC_STRINGLIST *
11041076 rc_services_scheduled_by(const char *service)
11171089 rc_stringlist_free(dirs);
11181090 return list;
11191091 }
1120 librc_hidden_def(rc_services_scheduled_by)
11211092
11221093 RC_STRINGLIST *
11231094 rc_services_scheduled(const char *service)
11281099 basename_c(service));
11291100 return ls_dir(dir, LS_INITD);
11301101 }
1131 librc_hidden_def(rc_services_scheduled)
5555 #include "rc.h"
5656 #include "rc-misc.h"
5757
58 #include "hidden-visibility.h"
59 #define librc_hidden_proto(x) hidden_proto(x)
60 #define librc_hidden_def(x) hidden_def(x)
61
62 librc_hidden_proto(rc_conf_value)
63 librc_hidden_proto(rc_config_list)
64 librc_hidden_proto(rc_config_load)
65 librc_hidden_proto(rc_config_value)
66 librc_hidden_proto(rc_deptree_depend)
67 librc_hidden_proto(rc_deptree_depends)
68 librc_hidden_proto(rc_deptree_free)
69 librc_hidden_proto(rc_deptree_load)
70 librc_hidden_proto(rc_deptree_load_file)
71 librc_hidden_proto(rc_deptree_order)
72 librc_hidden_proto(rc_deptree_update)
73 librc_hidden_proto(rc_deptree_update_needed)
74 librc_hidden_proto(rc_find_pids)
75 librc_hidden_proto(rc_getfile)
76 librc_hidden_proto(rc_getline)
77 librc_hidden_proto(rc_newer_than)
78 librc_hidden_proto(rc_proc_getent)
79 librc_hidden_proto(rc_older_than)
80 librc_hidden_proto(rc_runlevel_exists)
81 librc_hidden_proto(rc_runlevel_get)
82 librc_hidden_proto(rc_runlevel_list)
83 librc_hidden_proto(rc_runlevel_set)
84 librc_hidden_proto(rc_runlevel_stack)
85 librc_hidden_proto(rc_runlevel_stacks)
86 librc_hidden_proto(rc_runlevel_starting)
87 librc_hidden_proto(rc_runlevel_stopping)
88 librc_hidden_proto(rc_runlevel_unstack)
89 librc_hidden_proto(rc_service_add)
90 librc_hidden_proto(rc_service_daemons_crashed)
91 librc_hidden_proto(rc_service_daemon_set)
92 librc_hidden_proto(rc_service_delete)
93 librc_hidden_proto(rc_service_description)
94 librc_hidden_proto(rc_service_exists)
95 librc_hidden_proto(rc_service_extra_commands)
96 librc_hidden_proto(rc_service_in_runlevel)
97 librc_hidden_proto(rc_service_mark)
98 librc_hidden_proto(rc_service_resolve)
99 librc_hidden_proto(rc_service_schedule_clear)
100 librc_hidden_proto(rc_service_schedule_start)
101 librc_hidden_proto(rc_services_in_runlevel)
102 librc_hidden_proto(rc_services_in_runlevel_stacked)
103 librc_hidden_proto(rc_services_in_state)
104 librc_hidden_proto(rc_services_scheduled)
105 librc_hidden_proto(rc_services_scheduled_by)
106 librc_hidden_proto(rc_service_started_daemon)
107 librc_hidden_proto(rc_service_state)
108 librc_hidden_proto(rc_service_value_get)
109 librc_hidden_proto(rc_service_value_set)
110 librc_hidden_proto(rc_stringlist_add)
111 librc_hidden_proto(rc_stringlist_addu)
112 librc_hidden_proto(rc_stringlist_delete)
113 librc_hidden_proto(rc_stringlist_find)
114 librc_hidden_proto(rc_stringlist_free)
115 librc_hidden_proto(rc_stringlist_new)
116 librc_hidden_proto(rc_stringlist_split)
117 librc_hidden_proto(rc_stringlist_sort)
118 librc_hidden_proto(rc_sys)
119 librc_hidden_proto(rc_yesno)
120
12158 #endif
1313 endif
1414
1515 ifeq (${OS},Linux)
16 SRCS+= kill_all.c openrc-init.c openrc-shutdown.c broadcast.c rc-wtmp.c
16 SRCS+= kill_all.c openrc-init.c openrc-shutdown.c rc-sysvinit.c broadcast.c \
17 rc-wtmp.c
1718 endif
1819
1920 CLEANFILES= version.h rc-selinux.o
111112 fstabinfo: fstabinfo.o _usage.o rc-misc.o
112113 ${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
113114
114 openrc-init: openrc-init.o rc-wtmp.o
115 openrc-init: openrc-init.o rc-plugin.o rc-wtmp.o
115116 ${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
116117
117118 is_newer_than: is_newer_than.o rc-misc.o
133134 openrc rc: rc.o rc-logger.o rc-misc.o rc-plugin.o _usage.o
134135 ${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
135136
136 openrc-shutdown: openrc-shutdown.o rc-misc.o _usage.o broadcast.o rc-wtmp.o
137 openrc-shutdown: openrc-shutdown.o rc-misc.o _usage.o broadcast.o rc-wtmp.o rc-sysvinit.o
137138 ${CC} ${LOCAL_CFLAGS} ${LOCAL_LDFLAGS} ${CFLAGS} ${LDFLAGS} -o $@ $^ ${LDADD}
138139
139140 openrc-run runscript: openrc-run.o _usage.o rc-misc.o rc-plugin.o
3636 # define _PATH_DEV "/dev/"
3737 #endif
3838
39 #ifndef UT_LINESIZE
40 #define UT_LINESIZE __UT_LINESIZE
41 #endif
42
4339 static sigjmp_buf jbuf;
4440
4541 /*
6157 uid_t uid;
6258 char *tty;
6359 static char uidbuf[32];
64 static char ttynm[UT_LINESIZE + 4];
60 char *ttynm = NULL;
6561
6662 uid = getuid();
6763 if ((pwd = getpwuid(uid)) != NULL) {
8177 if (tty[0] == '/')
8278 tty++;
8379 }
84 snprintf(ttynm, sizeof(ttynm), "(%.*s) ",
85 UT_LINESIZE, tty);
86 } else
87 ttynm[0] = 0;
80 xasprintf(&ttynm, "(%s) ", tty);
81 }
8882
8983 *userp = uidbuf;
9084 *ttyp = ttynm;
155149
156150 xasprintf(&line, "\007\r\nBroadcast message from %s@%s %s(%s):\r\n\r\n",
157151 user, name.nodename, tty, date);
152 free(tty);
158153
159154 /*
160155 * Fork to avoid hanging in a write()
3434
3535 const char *applet = NULL;
3636
37 static int syslog_decode(char *name, CODE *codetab)
37 static int syslog_decode(char *name, const CODE *codetab)
3838 {
39 CODE *c;
39 const CODE *c;
4040
4141 if (isdigit((unsigned char)*name))
4242 return atoi(name);
1818 */
1919
2020 #include <errno.h>
21 #include <pwd.h>
2122 #include <signal.h>
2223 #include <stdbool.h>
2324 #include <stdio.h>
3637
3738 #include "helpers.h"
3839 #include "rc.h"
40 #include "rc-plugin.h"
3941 #include "rc-wtmp.h"
4042 #include "version.h"
4143
4244 static const char *path_default = "/sbin:/usr/sbin:/bin:/usr/bin";
4345 static const char *rc_default_runlevel = "default";
4446
45 static pid_t do_openrc(const char *runlevel)
47 static void do_openrc(const char *runlevel)
4648 {
4749 pid_t pid;
48 sigset_t signals;
49
50 sigset_t all_signals;
51 sigset_t our_signals;
52
53 sigfillset(&all_signals);
54 /* block all signals */
55 sigprocmask(SIG_BLOCK, &all_signals, &our_signals);
5056 pid = fork();
5157 switch (pid) {
5258 case -1:
5359 perror("fork");
60 exit(1);
5461 break;
5562 case 0:
5663 setsid();
5764 /* unblock all signals */
58 sigemptyset(&signals);
59 sigprocmask(SIG_SETMASK, &signals, NULL);
65 sigprocmask(SIG_UNBLOCK, &all_signals, NULL);
6066 printf("Starting %s runlevel\n", runlevel);
6167 execlp("openrc", "openrc", runlevel, NULL);
6268 perror("exec");
69 exit(1);
6370 break;
6471 default:
65 break;
66 }
67 return pid;
72 /* restore our signal mask */
73 sigprocmask(SIG_SETMASK, &our_signals, NULL);
74 while (waitpid(pid, NULL, 0) != pid)
75 if (errno == ECHILD)
76 break;
77 break;
78 }
6879 }
6980
7081 static void init(const char *default_runlevel)
7182 {
7283 const char *runlevel = NULL;
73 pid_t pid;
74
75 pid = do_openrc("sysinit");
76 waitpid(pid, NULL, 0);
77 pid = do_openrc("boot");
78 waitpid(pid, NULL, 0);
84 do_openrc("sysinit");
85 do_openrc("boot");
7986 if (default_runlevel)
8087 runlevel = default_runlevel;
8188 else
8693 printf("%s is an invalid runlevel\n", runlevel);
8794 runlevel = rc_default_runlevel;
8895 }
89 pid = do_openrc(runlevel);
90 waitpid(pid, NULL, 0);
96 do_openrc(runlevel);
9197 log_wtmp("reboot", "~~", 0, RUN_LVL, "~~");
9298 }
9399
99105
100106 static void handle_shutdown(const char *runlevel, int cmd)
101107 {
102 pid_t pid;
103108 struct timespec ts;
104109
105 pid = do_openrc(runlevel);
106 while (waitpid(pid, NULL, 0) != pid);
110 do_openrc(runlevel);
107111 printf("Sending the final term signal\n");
108112 kill(-1, SIGTERM);
109113 ts.tv_sec = 3;
115119 reboot(cmd);
116120 }
117121
122 static void run_program(const char *prog)
123 {
124 sigset_t full;
125 sigset_t old;
126 pid_t pid;
127
128 /* We need to block signals until we have forked */
129 sigfillset(&full);
130 sigprocmask(SIG_SETMASK, &full, &old);
131 pid = fork();
132 if (pid == -1) {
133 perror("init");
134 return;
135 }
136 if (pid == 0) {
137 /* Unmask signals */
138 sigprocmask(SIG_SETMASK, &old, NULL);
139 execl(prog, prog, (char *)NULL);
140 perror("init");
141 exit(1);
142 }
143 /* Unmask signals and wait for child */
144 sigprocmask(SIG_SETMASK, &old, NULL);
145 if (rc_waitpid(pid) == -1)
146 perror("init");
147 }
148
149 static void open_shell(void)
150 {
151 const char *shell;
152 struct passwd *pw;
153
154 #ifdef __linux__
155 const char *sys = rc_sys();
156
157 /* VSERVER systems cannot really drop to shells */
158 if (sys && strcmp(sys, RC_SYS_VSERVER) == 0)
159 {
160 execlp("halt", "halt", "-f", (char *) NULL);
161 perror("init");
162 return;
163 }
164 #endif
165
166 shell = rc_conf_value("rc_shell");
167 /* No shell set, so obey env, then passwd, then default to /bin/sh */
168 if (!shell) {
169 shell = getenv("SHELL");
170 if (!shell) {
171 pw = getpwuid(getuid());
172 if (pw)
173 shell = pw->pw_shell;
174 if (!shell)
175 shell = "/bin/sh";
176 }
177 }
178 run_program(shell);
179 }
180
118181 static void handle_single(void)
119182 {
120 pid_t pid;
121
122 pid = do_openrc("single");
123 while (waitpid(pid, NULL, 0) != pid);
183 do_openrc("single");
124184 }
125185
126186 static void reap_zombies(void)
248308 handle_shutdown("reboot", RB_AUTOBOOT);
249309 else if (strcmp(buf, "reexec") == 0)
250310 handle_reexec(argv[0]);
251 else if (strcmp(buf, "single") == 0)
311 else if (strcmp(buf, "single") == 0) {
252312 handle_single();
313 open_shell();
314 init(default_runlevel);
315 }
253316 }
254317 return 0;
255318 }
11191119 char *dir, *save = NULL, *saveLnk = NULL;
11201120 char *pidstr = NULL;
11211121 size_t l = 0, ll;
1122 const char *file;
1122 const char *file;
11231123 struct stat stbuf;
11241124
11251125 /* Show help if insufficient args */
11511151 }
11521152 lnk = xmalloc(4096);
11531153 memset(lnk, 0, 4096);
1154 if (readlink(argv[1], lnk, 4096)) {
1154 if (readlink(argv[1], lnk, 4096-1)) {
11551155 dir = dirname(path);
11561156 if (strchr(lnk, '/')) {
11571157 save = xstrdup(dir);
12221222
12231223 /* Make our prefix string */
12241224 prefix = xmalloc(sizeof(char) * l + 1);
1225 ll = strlen(applet);
12261225 memcpy(prefix, applet, ll);
12271226 memset(prefix + ll, ' ', l - ll);
12281227 memset(prefix + l, 0, 1);
3434 #include "rc.h"
3535 #include "helpers.h"
3636 #include "rc-misc.h"
37 #include "rc-sysvinit.h"
38 #include "rc-wtmp.h"
3739 #include "_usage.h"
38 #include "rc-wtmp.h"
3940
4041 const char *applet = NULL;
4142 const char *extraopts = NULL;
6667 "write wtmp boot record and exit",
6768 longopts_help_COMMON
6869 };
69 const char *usagestring = NULL;
70 const char *usagestring = "" \
71 "Usage: openrc-shutdown -c | --cancel\n" \
72 " or: openrc-shutdown -R | --reexec\n" \
73 " or: openrc-shutdown -w | --write-only\n" \
74 " or: openmrc-shutdown -H | --halt time\n" \
75 " or: openrc-shutdown -K | --kexec time\n" \
76 " or: openrc-shutdown -p | --poweroff time\n" \
77 " or: openrc-shutdown -r | --reboot time\n" \
78 " or: openrc-shutdown -s | --single time";
7079 const char *exclusive = "Select one of "
7180 "--cancel, --halt, --kexec, --poweroff, --reexec, --reboot, --single or \n"
7281 "--write-only";
110119 t += 60 * mins;
111120
112121 if ((fp = fopen(nologin_file, "w")) != NULL) {
113 fprintf(fp, "\rThe system is going down on %s\r\n", ctime(&t));
114 fclose(fp);
122 fprintf(fp, "\rThe system is going down on %s\r\n", ctime(&t));
123 fclose(fp);
115124 }
116125 }
117126
121130 static void send_cmd(const char *cmd)
122131 {
123132 FILE *fifo;
124 size_t ignored;
133 size_t ignored;
125134
126135 if (do_dryrun) {
127136 einfo("Would send %s to init", cmd);
319328 syslog(LOG_NOTICE, "The system will %s now", state);
320329 unlink(nologin_file);
321330 unlink(shutdown_pid);
322 if (do_halt)
323 send_cmd("halt");
324 else if (do_kexec)
331 if (do_halt) {
332 if (exists("/run/initctl")) {
333 sysvinit_setenv("INIT_HALT", "HALT");
334 sysvinit_runlevel('0');
335 } else
336 send_cmd("halt");
337 } else if (do_kexec)
325338 send_cmd("kexec");
326 else if (do_poweroff)
327 send_cmd("poweroff");
328 else if (do_reboot)
329 send_cmd("reboot");
330 else if (do_single)
331 send_cmd("single");
339 else if (do_poweroff) {
340 if (exists("/run/initctl")) {
341 sysvinit_setenv("INIT_HALT", "POWEROFF");
342 sysvinit_runlevel('0');
343 } else
344 send_cmd("poweroff");
345 } else if (do_reboot) {
346 if (exists("/run/initctl"))
347 sysvinit_runlevel('6');
348 else
349 send_cmd("reboot");
350 } else if (do_single) {
351 if (exists("/run/initctl"))
352 sysvinit_runlevel('S');
353 else
354 send_cmd("single");
355 }
332356 return 0;
333357 }
2626 #include "rc-misc.h"
2727 #include "_usage.h"
2828
29 enum format_t {
30 FORMAT_DEFAULT,
31 FORMAT_INI,
32 };
33
2934 const char *applet = NULL;
3035 const char *extraopts = NULL;
31 const char *getoptstring = "aclmrsSu" getoptstring_COMMON;
36 const char *getoptstring = "acf:lmrsSu" getoptstring_COMMON;
3237 const struct option longopts[] = {
3338 {"all", 0, NULL, 'a'},
3439 {"crashed", 0, NULL, 'c'},
40 {"format", 1, NULL, 'f'},
3541 {"list", 0, NULL, 'l'},
3642 {"manual", 0, NULL, 'm'},
3743 {"runlevel", 0, NULL, 'r'},
4349 const char * const longopts_help[] = {
4450 "Show services from all run levels",
4551 "Show crashed services",
52 "format status to be parsable (currently arg must be ini)",
4653 "Show list of run levels",
4754 "Show manually started services",
4855 "Show the name of the current runlevel",
5259 longopts_help_COMMON
5360 };
5461 const char *usagestring = "" \
55 "Usage: rc-status [options] <runlevel>...\n" \
62 "Usage: rc-status [options] -f ini <runlevel>...\n" \
5663 " or: rc-status [options] [-a | -c | -l | -m | -r | -s | -u]";
5764
5865 static RC_DEPTREE *deptree;
6168 static RC_STRINGLIST *levels, *services, *tmp, *alist;
6269 static RC_STRINGLIST *sservices, *nservices, *needsme;
6370
64 static void
65 print_level(const char *prefix, const char *level)
66 {
67 if (prefix)
68 printf("%s ", prefix);
69 printf ("Runlevel: ");
70 if (isatty(fileno(stdout)))
71 printf("%s%s%s\n",
72 ecolor(ECOLOR_HILITE),
73 level,
74 ecolor(ECOLOR_NORMAL));
75 else
76 printf("%s\n", level);
71 static void print_level(const char *prefix, const char *level,
72 enum format_t format)
73 {
74 switch (format) {
75 case FORMAT_DEFAULT:
76 if (prefix)
77 printf("%s ", prefix);
78 printf ("Runlevel: ");
79 if (isatty(fileno(stdout)))
80 printf("%s%s%s\n",
81 ecolor(ECOLOR_HILITE), level, ecolor(ECOLOR_NORMAL));
82 else
83 printf("%s\n", level);
84 break;
85 case FORMAT_INI:
86 printf("%s", "[");
87 if (prefix)
88 printf("%s ", prefix);
89 printf("%s]\n", level);
90 break;
91 }
7792 }
7893
7994 static char *get_uptime(const char *service)
124139 return uptime;
125140 }
126141
127 static void
128 print_service(const char *service)
142 static void print_service(const char *service, enum format_t format)
129143 {
130144 char *status = NULL;
131145 char *uptime = NULL;
132146 char *child_pid = NULL;
133147 char *start_time = NULL;
134 int cols = printf(" %s", service);
148 int cols;
135149 const char *c = ecolor(ECOLOR_GOOD);
136150 RC_SERVICE state = rc_service_state(service);
137151 ECOLOR color = ECOLOR_BAD;
175189 xasprintf(&status, " stopped ");
176190
177191 errno = 0;
178 if (c && *c && isatty(fileno(stdout)))
179 printf("\n");
180 ebracket(cols, color, status);
192 switch (format) {
193 case FORMAT_DEFAULT:
194 cols = printf(" %s", service);
195 if (c && *c && isatty(fileno(stdout)))
196 printf("\n");
197 ebracket(cols, color, status);
198 break;
199 case FORMAT_INI:
200 printf("%s = %s\n", service, status);
201 break;
202 }
181203 free(status);
182204 }
183205
184 static void
185 print_services(const char *runlevel, RC_STRINGLIST *svcs)
206 static void print_services(const char *runlevel, RC_STRINGLIST *svcs,
207 enum format_t format)
186208 {
187209 RC_STRINGLIST *l = NULL;
188210 RC_STRING *s;
196218 TAILQ_FOREACH(s, svcs, entries)
197219 if (!runlevel ||
198220 rc_service_in_runlevel(s->value, runlevel))
199 print_service(s->value);
221 print_service(s->value, format);
200222 return;
201223 }
202224 if (!types) {
216238 if (!rc_stringlist_find(svcs, s->value))
217239 continue;
218240 if (!runlevel || rc_service_in_runlevel(s->value, runlevel))
219 print_service(s->value);
241 print_service(s->value, format);
220242 }
221243 rc_stringlist_free(l);
222244 }
223245
224 static void
225 print_stacked_services(const char *runlevel)
246 static void print_stacked_services(const char *runlevel, enum format_t format)
226247 {
227248 RC_STRINGLIST *stackedlevels, *servicelist;
228249 RC_STRING *stackedlevel;
231252 TAILQ_FOREACH(stackedlevel, stackedlevels, entries) {
232253 if (rc_stringlist_find(levels, stackedlevel->value) != NULL)
233254 continue;
234 print_level("Stacked", stackedlevel->value);
255 print_level("Stacked", stackedlevel->value, format);
235256 servicelist = rc_services_in_runlevel(stackedlevel->value);
236 print_services(stackedlevel->value, servicelist);
257 print_services(stackedlevel->value, servicelist, format);
237258 rc_stringlist_free(servicelist);
238259 }
239260 rc_stringlist_free(stackedlevels);
243264 int main(int argc, char **argv)
244265 {
245266 RC_SERVICE state;
246 RC_STRING *s, *l, *t, *level;
267 RC_STRING *s, *l, *t, *level;
268 enum format_t format = FORMAT_DEFAULT;
269 bool levels_given = false;
247270 bool show_all = false;
248271 char *p, *runlevel = NULL;
249272 int opt, retval = 0;
266289 }
267290 goto exit;
268291 /* NOTREACHED */
292 case 'f':
293 if (strcasecmp(optarg, "ini") == 0)
294 format = FORMAT_INI;
295 else
296 eerrorx("%s: invalid argument to --format switch\n", applet);
297 break;
269298 case 'l':
270299 levels = rc_runlevel_list();
271300 TAILQ_FOREACH(l, levels, entries)
290319 free(s->value);
291320 free(s);
292321 }
293 print_services(NULL, services);
322 print_services(NULL, services, FORMAT_DEFAULT);
294323 goto exit;
295324 case 'r':
296325 runlevel = rc_runlevel_get();
302331 TAILQ_FOREACH_SAFE(s, services, entries, t)
303332 if (!rc_service_value_get(s->value, "child_pid"))
304333 TAILQ_REMOVE(services, s, entries);
305 print_services(NULL, services);
334 print_services(NULL, services, FORMAT_DEFAULT);
306335 goto exit;
307336 /* NOTREACHED */
308337 case 's':
309338 services = rc_services_in_runlevel(NULL);
310 print_services(NULL, services);
339 print_services(NULL, services, FORMAT_DEFAULT);
311340 goto exit;
312341 /* NOTREACHED */
313342 case 'u':
322351 break;
323352 }
324353 }
325 print_services(NULL, services);
354 print_services(NULL, services, FORMAT_DEFAULT);
326355 goto exit;
327356 /* NOTREACHED */
328357
334363 opt = (optind < argc) ? 0 : 1;
335364 while (optind < argc) {
336365 if (rc_runlevel_exists(argv[optind])) {
366 levels_given = true;
337367 rc_stringlist_add(levels, argv[optind++]);
338368 opt++;
339369 } else
350380 deptree = _rc_deptree_load(0, NULL);
351381
352382 TAILQ_FOREACH(l, levels, entries) {
353 print_level(NULL, l->value);
383 print_level(NULL, l->value, format);
354384 services = rc_services_in_runlevel(l->value);
355 print_services(l->value, services);
356 print_stacked_services(l->value);
385 print_services(l->value, services, format);
386 print_stacked_services(l->value, format);
357387 rc_stringlist_free(nservices);
358388 nservices = NULL;
359389 rc_stringlist_free(services);
360390 services = NULL;
361391 }
362392
363 if (show_all || argc < 2) {
393 if (show_all || !levels_given) {
364394 /* Show hotplugged services */
365 print_level("Dynamic", "hotplugged");
395 print_level("Dynamic", "hotplugged", format);
366396 services = rc_services_in_state(RC_SERVICE_HOTPLUGGED);
367 print_services(NULL, services);
397 print_services(NULL, services, format);
368398 rc_stringlist_free(services);
369399 services = NULL;
370400
421451 * be added to the list
422452 */
423453 unsetenv("RC_SVCNAME");
424 print_level("Dynamic", "needed/wanted");
425 print_services(NULL, nservices);
426 print_level("Dynamic", "manual");
427 print_services(NULL, services);
454 print_level("Dynamic", "needed/wanted", format);
455 print_services(NULL, nservices, format);
456 print_level("Dynamic", "manual", format);
457 print_services(NULL, services, format);
428458 }
429459
430460 exit:
0 /*
1 * rc-sysvinit.c
2 * Helper to send a runlevel change to sysvinit
3 */
4
5 /*
6 * Copyright (c) 2019 The OpenRC Authors.
7 * See the Authors file at the top-level directory of this distribution and
8 * https://github.com/OpenRC/openrc/blob/master/AUTHORS
9 *
10 * This file is part of OpenRC. It is subject to the license terms in
11 * the LICENSE file found in the top-level directory of this
12 * distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
13 * This file may not be copied, modified, propagated, or distributed
14 * except according to the terms contained in the LICENSE file.
15 */
16
17 #include <errno.h>
18 #include <fcntl.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <unistd.h>
22 #include <sys/stat.h>
23 #include <sys/types.h>
24
25 #include "einfo.h"
26 #include "rc-sysvinit.h"
27
28 static void sysvinit_send_cmd(struct init_request *request)
29 {
30 int fd;
31 char *p;
32 size_t bytes;
33 ssize_t r;
34
35 fd = open("/run/initctl", O_WRONLY|O_NONBLOCK|O_CLOEXEC|O_NOCTTY);
36 if (fd < 0) {
37 if (errno != ENOENT)
38 eerror("Failed to open initctl fifo: %s", strerror(errno));
39 return;
40 }
41 p = (char *) request;
42 bytes = sizeof(*request);
43 do {
44 r = write(fd, p, bytes);
45 if (r < 0) {
46 if ((errno == EAGAIN) || (errno == EINTR))
47 continue;
48 eerror("Failed to write to /run/initctl: %s", strerror(errno));
49 return;
50 }
51 p += r;
52 bytes -= r;
53 } while (bytes > 0);
54 }
55
56 void sysvinit_runlevel(char rl)
57 {
58 struct init_request request;
59
60 if (!rl)
61 return;
62
63 request = (struct init_request) {
64 .magic = INIT_MAGIC,
65 .sleeptime = 0,
66 .cmd = INIT_CMD_RUNLVL,
67 .runlevel = rl,
68 };
69 sysvinit_send_cmd(&request);
70 return;
71 }
72
73 /*
74 * Set environment variables in the init process.
75 */
76 void sysvinit_setenv(char *name, char *value)
77 {
78 struct init_request request;
79 size_t nl;
80 size_t vl;
81
82 memset(&request, 0, sizeof(request));
83 request.magic = INIT_MAGIC;
84 request.cmd = INIT_CMD_SETENV;
85 nl = strlen(name);
86 if (value)
87 vl = strlen(value);
88 else
89 vl = 0;
90
91 if (nl + vl + 3 >= (int)sizeof(request.i.data))
92 return -1;
93
94 memcpy(request.i.data, name, nl);
95 if (value) {
96 request.i.data[nl] = '=';
97 memcpy(request.i.data + nl + 1, value, vl);
98 }
99 sysvinit_send_cmd(&request);
100 return 0;
101 }
0 /*
1 * rc-sysvinit.h - Interface to communicate with sysvinit via /run/initctl.
2 */
3
4 /*
5 * Copyright (c) 2019 The OpenRC Authors.
6 * See the Authors file at the top-level directory of this distribution and
7 * https://github.com/OpenRC/openrc/blob/master/AUTHORS
8 *
9 * This file is part of OpenRC. It is subject to the license terms in
10 * the LICENSE file found in the top-level directory of this
11 * distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
12 * This file may not be copied, modified, propagated, or distributed
13 * except according to the terms contained in the LICENSE file.
14 */
15
16 #ifndef _RC_SYSVINIT_H
17 #define _RC_SYSVINIT_H
18
19 /*
20 * The #defines and structures below are taken from initreq.h in
21 * sysvinit and must be used by any program wishing to communicate with
22 * it.
23 */
24
25 #define INIT_MAGIC 0x03091969
26 #define INIT_CMD_START 0
27 #define INIT_CMD_RUNLVL 1
28 #define INIT_CMD_POWERFAIL 2
29 #define INIT_CMD_POWERFAILNOW 3
30 #define INIT_CMD_POWEROK 4
31 #define INIT_CMD_BSD 5
32 #define INIT_CMD_SETENV 6
33 #define INIT_CMD_UNSETENV 7
34
35 /*
36 * This is what BSD 4.4 uses when talking to init.
37 * Linux doesn't use this right now.
38 */
39 struct init_request_bsd {
40 char gen_id[8]; /* Beats me.. telnetd uses "fe" */
41 char tty_id[16]; /* Tty name minus /dev/tty */
42 char host[64]; /* Hostname */
43 char term_type[16]; /* Terminal type */
44 int signal; /* Signal to send */
45 int pid; /* Process to send to */
46 char exec_name[128]; /* Program to execute */
47 char reserved[128]; /* For future expansion. */
48 };
49
50 /*
51 * Because of legacy interfaces, "runlevel" and "sleeptime"
52 * aren't in a seperate struct in the union.
53 *
54 * The weird sizes are because init expects the whole
55 * struct to be 384 bytes.
56 */
57 struct init_request {
58 int magic; /* Magic number */
59 int cmd; /* What kind of request */
60 int runlevel; /* Runlevel to change to */
61 int sleeptime; /* Time between TERM and KILL */
62 union {
63 struct init_request_bsd bsd;
64 char data[368];
65 } i;
66 };
67
68 void sysvinit_runlevel(char rl);
69 void sysvinit_setenv(char *name, char *value);
70
71 #endif
4242 strncpy(utmp.ut_id , id , sizeof(utmp.ut_id ));
4343 strncpy(utmp.ut_line, line, sizeof(utmp.ut_line));
4444
45 /* Put the OS version in place of the hostname */
46 if (uname(&uname_buf) == 0)
45 /* Put the OS version in place of the hostname */
46 if (uname(&uname_buf) == 0)
4747 strncpy(utmp.ut_host, uname_buf.release, sizeof(utmp.ut_host));
4848
4949 updwtmp(WTMP_FILE, &utmp);
1919 * except according to the terms contained in the LICENSE file.
2020 */
2121
22 const char rc_copyright[] = "Copyright (c) 2007-2008 Roy Marples";
22 static const char rc_copyright[] = "Copyright (c) 2007-2008 Roy Marples";
2323
2424 #include <sys/types.h>
2525 #include <sys/ioctl.h>
491491 startas = optarg;
492492 break;
493493 case 'w':
494 if (sscanf(optarg, "%d", &start_wait) != 1)
494 if (sscanf(optarg, "%u", &start_wait) != 1)
495495 eerrorx("%s: `%s' not a number",
496496 applet, optarg);
497497 break;
546546 } else if (name) {
547547 *--argv = name;
548548 ++argc;
549 } else if (exec) {
549 } else if (exec) {
550550 *--argv = exec;
551551 ++argc;
552552 };
668668 nav[len++] = p;
669669 for (i = 0; i < opt; i++)
670670 nav[i + len] = argv[i];
671 nav[i + len] = '\0';
671 nav[i + len] = NULL;
672672 }
673673 }
674674 }
236236 ppath++;
237237
238238 if (!home) {
239 free(opath);
239 free(opath);
240240 return xstrdup(path);
241241 }
242242 if (!ppath) {
534534 sigaction(SIGTERM, &sa, NULL);
535535
536536 fp = fopen(pidfile, "w");
537 if (! fp)
537 if (!fp)
538538 eerrorx("%s: fopen `%s': %s", applet, pidfile, strerror(errno));
539539 fprintf(fp, "%d\n", getpid());
540540 fclose(fp);
556556 alarm(healthcheckdelay);
557557 else if (healthchecktimer)
558558 alarm(healthchecktimer);
559 failing = 0;
559 failing = 0;
560560 while (!exiting) {
561561 healthcheck_respawn = 0;
562 fifo_fd = open(fifopath, O_RDONLY);
562 fifo_fd = open(fifopath, O_RDONLY);
563563 if (fifo_fd > 0) {
564564 memset(buf, 0, sizeof(buf));
565565 count = read(fifo_fd, buf, sizeof(buf) - 1);
603603 healthcheck_respawn = 1;
604604 }
605605 }
606 if (exiting ) {
606 if (exiting) {
607607 alarm(0);
608608 syslog(LOG_INFO, "stopping %s, pid %d", exec, child_pid);
609609 nkilled = run_stop_schedule(applet, NULL, NULL, child_pid, 0,
719719 eerrorx("%s: The RC_SVCNAME environment variable is not set", applet);
720720 openlog(applet, LOG_PID, LOG_DAEMON);
721721
722 if (argc >= 1 && svcname && strcmp(argv[1], svcname))
722 if (argc <= 1 || strcmp(argv[1], svcname))
723723 eerrorx("%s: the first argument is %s and must be %s",
724724 applet, argv[1], svcname);
725725
834834
835835 case 'm': /* --respawn-max count */
836836 n = sscanf(optarg, "%d", &respawn_max);
837 if (n != 1 || respawn_max < 1)
837 if (n != 1 || respawn_max < 0)
838838 eerrorx("Invalid respawn-max value '%s'", optarg);
839839 break;
840840
10611061 c++;
10621062 }
10631063 xasprintf(&varbuf, "%d", x);
1064 rc_service_value_set(svcname, "argc", varbuf);
1065 free(varbuf);
1064 rc_service_value_set(svcname, "argc", varbuf);
1065 free(varbuf);
10661066 rc_service_value_set(svcname, "exec", exec);
10671067 supervisor(exec, argv);
10681068 } else
+0
-6
src/test/.gitignore less more
0 einfo.data.out
1 einfo.funcs.out
2 librc.funcs.hidden.out
3 librc.funcs.hidden.list
4 rc.data.out
5 rc.funcs.out
+0
-14
src/test/Makefile less more
0 all:
1
2 install:
3
4 ignore:
5
6 check test::
7 ./runtests.sh
8
9 verbose-test:
10 VERBOSE=yes ./runtests.sh
11
12 clean:
13 rm -rf *.out tmp-*
+0
-1
src/test/einfo.data.list less more
0 EINFO_1.0
+0
-52
src/test/einfo.funcs.list less more
0 ebegin
1 ebegin@@EINFO_1.0
2 ebeginv
3 ebeginv@@EINFO_1.0
4 ebracket
5 ebracket@@EINFO_1.0
6 ecolor
7 ecolor@@EINFO_1.0
8 eend
9 eend@@EINFO_1.0
10 eendv
11 eendv@@EINFO_1.0
12 eerror
13 eerror@@EINFO_1.0
14 eerrorn
15 eerrorn@@EINFO_1.0
16 eerrorx
17 eerrorx@@EINFO_1.0
18 eindent
19 eindent@@EINFO_1.0
20 eindentv
21 eindentv@@EINFO_1.0
22 einfo
23 einfo@@EINFO_1.0
24 einfon
25 einfon@@EINFO_1.0
26 einfov
27 einfov@@EINFO_1.0
28 einfovn
29 einfovn@@EINFO_1.0
30 elog
31 elog@@EINFO_1.0
32 eoutdent
33 eoutdent@@EINFO_1.0
34 eoutdentv
35 eoutdentv@@EINFO_1.0
36 eprefix
37 eprefix@@EINFO_1.0
38 ewarn
39 ewarn@@EINFO_1.0
40 ewarnn
41 ewarnn@@EINFO_1.0
42 ewarnv
43 ewarnv@@EINFO_1.0
44 ewarnvn
45 ewarnvn@@EINFO_1.0
46 ewarnx
47 ewarnx@@EINFO_1.0
48 ewend
49 ewend@@EINFO_1.0
50 ewendv
51 ewendv@@EINFO_1.0
+0
-3
src/test/rc.data.list less more
0 RC_1.0
1 rc_environ_fd
2 rc_environ_fd@@RC_1.0
+0
-116
src/test/rc.funcs.list less more
0 rc_conf_value
1 rc_conf_value@@RC_1.0
2 rc_config_list
3 rc_config_list@@RC_1.0
4 rc_config_load
5 rc_config_load@@RC_1.0
6 rc_config_value
7 rc_config_value@@RC_1.0
8 rc_deptree_depend
9 rc_deptree_depend@@RC_1.0
10 rc_deptree_depends
11 rc_deptree_depends@@RC_1.0
12 rc_deptree_free
13 rc_deptree_free@@RC_1.0
14 rc_deptree_load
15 rc_deptree_load@@RC_1.0
16 rc_deptree_load_file
17 rc_deptree_load_file@@RC_1.0
18 rc_deptree_order
19 rc_deptree_order@@RC_1.0
20 rc_deptree_update
21 rc_deptree_update@@RC_1.0
22 rc_deptree_update_needed
23 rc_deptree_update_needed@@RC_1.0
24 rc_find_pids
25 rc_find_pids@@RC_1.0
26 rc_getfile
27 rc_getfile@@RC_1.0
28 rc_getline
29 rc_getline@@RC_1.0
30 rc_newer_than
31 rc_newer_than@@RC_1.0
32 rc_older_than
33 rc_older_than@@RC_1.0
34 rc_proc_getent
35 rc_proc_getent@@RC_1.0
36 rc_runlevel_exists
37 rc_runlevel_exists@@RC_1.0
38 rc_runlevel_get
39 rc_runlevel_get@@RC_1.0
40 rc_runlevel_list
41 rc_runlevel_list@@RC_1.0
42 rc_runlevel_set
43 rc_runlevel_set@@RC_1.0
44 rc_runlevel_stack
45 rc_runlevel_stack@@RC_1.0
46 rc_runlevel_stacks
47 rc_runlevel_stacks@@RC_1.0
48 rc_runlevel_starting
49 rc_runlevel_starting@@RC_1.0
50 rc_runlevel_stopping
51 rc_runlevel_stopping@@RC_1.0
52 rc_runlevel_unstack
53 rc_runlevel_unstack@@RC_1.0
54 rc_service_add
55 rc_service_add@@RC_1.0
56 rc_service_daemon_set
57 rc_service_daemon_set@@RC_1.0
58 rc_service_daemons_crashed
59 rc_service_daemons_crashed@@RC_1.0
60 rc_service_delete
61 rc_service_delete@@RC_1.0
62 rc_service_description
63 rc_service_description@@RC_1.0
64 rc_service_exists
65 rc_service_exists@@RC_1.0
66 rc_service_extra_commands
67 rc_service_extra_commands@@RC_1.0
68 rc_service_in_runlevel
69 rc_service_in_runlevel@@RC_1.0
70 rc_service_mark
71 rc_service_mark@@RC_1.0
72 rc_service_resolve
73 rc_service_resolve@@RC_1.0
74 rc_service_schedule_clear
75 rc_service_schedule_clear@@RC_1.0
76 rc_service_schedule_start
77 rc_service_schedule_start@@RC_1.0
78 rc_service_started_daemon
79 rc_service_started_daemon@@RC_1.0
80 rc_service_state
81 rc_service_state@@RC_1.0
82 rc_service_value_get
83 rc_service_value_get@@RC_1.0
84 rc_service_value_set
85 rc_service_value_set@@RC_1.0
86 rc_services_in_runlevel
87 rc_services_in_runlevel@@RC_1.0
88 rc_services_in_runlevel_stacked
89 rc_services_in_runlevel_stacked@@RC_1.0
90 rc_services_in_state
91 rc_services_in_state@@RC_1.0
92 rc_services_scheduled
93 rc_services_scheduled@@RC_1.0
94 rc_services_scheduled_by
95 rc_services_scheduled_by@@RC_1.0
96 rc_stringlist_add
97 rc_stringlist_add@@RC_1.0
98 rc_stringlist_addu
99 rc_stringlist_addu@@RC_1.0
100 rc_stringlist_delete
101 rc_stringlist_delete@@RC_1.0
102 rc_stringlist_find
103 rc_stringlist_find@@RC_1.0
104 rc_stringlist_free
105 rc_stringlist_free@@RC_1.0
106 rc_stringlist_new
107 rc_stringlist_new@@RC_1.0
108 rc_stringlist_sort
109 rc_stringlist_sort@@RC_1.0
110 rc_stringlist_split
111 rc_stringlist_split@@RC_1.0
112 rc_sys
113 rc_sys@@RC_1.0
114 rc_yesno
115 rc_yesno@@RC_1.0
+0
-139
src/test/runtests.sh less more
0 #!/bin/sh
1
2 top_srcdir=${top_srcdir:-../..}
3 . ${top_srcdir}/test/setup_env.sh
4
5 libeinfo_srcdir="${srcdir}/../libeinfo"
6 libeinfo_builddir="${builddir}/../libeinfo"
7 librc_srcdir="${srcdir}/../librc"
8 librc_builddir="${builddir}/../librc"
9 rc_srcdir="${srcdir}/../rc"
10 rc_builddir="${builddir}/../rc"
11
12 checkit() {
13 local base=$1; shift
14 echo "$@" | tr ' ' '\n' > ${base}.out
15 diff -u ${base}.list ${base}.out
16 eend $?
17 : $(( ret += $? ))
18 }
19
20 ret=0
21
22 fail_on_out() {
23 if [ -n "${out}" ]; then
24 eerror "Last command failed; failing"
25 exit 1
26 fi
27 }
28
29 ebegin "Checking exported symbols in libeinfo.so (data)"
30 checkit einfo.data $(
31 readelf -Ws ${libeinfo_builddir}/libeinfo.so \
32 | awk '$4 == "OBJECT" && $5 == "GLOBAL" && $7 != "UND" {print $NF}' \
33 | LC_ALL=C sort -u
34 )
35
36 ebegin "Checking exported symbols in libeinfo.so (functions)"
37 checkit einfo.funcs $(
38 readelf -Ws ${libeinfo_builddir}/libeinfo.so \
39 | awk '$4 == "FUNC" && $5 == "GLOBAL" && $7 != "UND" {print $NF}' \
40 | LC_ALL=C sort -u \
41 | egrep -v \
42 -e '^_(init|fini)$'
43 )
44
45 ebegin "Checking exported symbols in librc.so (data)"
46 checkit rc.data $(
47 readelf -Ws ${librc_builddir}/librc.so \
48 | awk '$4 == "OBJECT" && $5 == "GLOBAL" && $7 != "UND" {print $NF}' \
49 | LC_ALL=C sort -u
50 )
51
52 ebegin "Checking exported symbols in librc.so (functions)"
53 checkit rc.funcs $(
54 readelf -Ws ${librc_builddir}/librc.so \
55 | awk '$4 == "FUNC" && $5 == "GLOBAL" && $7 != "UND" {print $NF}' \
56 | LC_ALL=C sort -u \
57 | egrep -v \
58 -e '^_(init|fini)$'
59 )
60
61 ebegin "Checking hidden functions in librc.so"
62 sed -n '/^librc_hidden_proto/s:.*(\(.*\))$:\1:p' ${librc_srcdir}/librc.h \
63 | LC_ALL=C sort -u \
64 > librc.funcs.hidden.list
65 readelf -Wr $(grep -l '#include[[:space:]]"librc\.h"' ${librc_srcdir}/*.c | sed 's:\.c$:.o:') \
66 | egrep -v -e 'R_PARISC_(DP|SEG)REL' \
67 | awk '$5 ~ /^rc_/ {print $5}' \
68 | LC_ALL=C sort -u \
69 | egrep -v '^rc_environ_fd$' \
70 > librc.funcs.hidden.out
71 syms=$(diff -u librc.funcs.hidden.list librc.funcs.hidden.out | sed -n '/^+[^+]/s:^+::p')
72 [ -z "${syms}" ]
73 eend $? "Missing hidden defs:"$'\n'"${syms}"
74 : $(( ret += $? ))
75
76 ebegin "Checking trailing whitespace in code"
77 # XXX: Should we check man pages too ?
78 out=$(cd ${top_srcdir}; find */ \
79 '(' -name '*.[ch]' -o -name '*.in' -o -name '*.sh' ')' \
80 -exec grep -n -E '[[:space:]]+$' {} +)
81 [ -z "${out}" ]
82 eend $? "Trailing whitespace needs to be deleted:"$'\n'"${out}"
83 fail_on_out
84
85 ebegin "Checking trailing newlines in code"
86 out=$(cd ${top_srcdir};
87 for f in `find */ -name '*.[ch]'` ; do
88 sed -n -e :a -e '/^\n*$/{$q1;N;ba' -e '}' $f || echo $f
89 done)
90 [ -z "${out}" ]
91 eend $? "Trailing newlines need to be deleted:"$'\n'"${out}"
92 fail_on_out
93
94 ebegin "Checking for obsolete functions"
95 out=$(cd ${top_srcdir}; find src -name '*.[ch]' \
96 ! -name queue.h \
97 -exec grep -n -E '\<(malloc|memory|sys/(errno|fcntl|signal|stropts|termios|unistd))\.h\>' {} +)
98 [ -z "${out}" ]
99 eend $? "Avoid these obsolete functions:"$'\n'"${out}"
100 fail_on_out
101
102 ebegin "Checking for x* func usage"
103 out=$(cd ${top_srcdir}; find src -name '*.[ch]' \
104 ! -name queue.h \
105 -exec grep -n -E '\<(malloc|strdup)[[:space:]]*\(' {} + \
106 | grep -v \
107 -e src/includes/helpers.h \
108 -e src/libeinfo/libeinfo.c)
109 [ -z "${out}" ]
110 eend $? "These need to be using the x* variant:"$'\n'"${out}"
111 fail_on_out
112
113 ebegin "Checking spacing style"
114 out=$(cd ${top_srcdir}; find src -name '*.[ch]' \
115 ! -name queue.h \
116 -exec grep -n -E \
117 -e '\<(for|if|switch|while)\(' \
118 -e '\<(for|if|switch|while) \( ' \
119 -e ' ;' \
120 -e '[[:space:]]$' \
121 -e '\){' \
122 -e '(^|[^:])//' \
123 {} +)
124 [ -z "${out}" ]
125 eend $? "These lines violate style rules:"$'\n'"${out}"
126 fail_on_out
127
128 einfo "Running unit tests"
129 eindent
130 for u in units/*; do
131 [ -x "${u}" -a -f "${u}" ] || continue
132 ebegin "$(basename "${u}")"
133 ./"${u}"
134 eend $?
135 : $(( ret += $? ))
136 done
137
138 exit ${ret}
+0
-83
src/test/units/is_older_than less more
0 #!/bin/sh
1 # unit test for is_older_than code of baselayout (2008/06/19)
2 # Author: Matthias Schwarzott <zzam@gentoo.org>
3
4 TMPDIR=tmp-"$(basename "$0")"
5
6 # Please note that we added this unit test because the function
7 # should really be called is_newer_than as it's what it's really testing.
8 # Or more perversly, returning 0 on failure and 1 and success.
9
10 # bool is_older_than(reference, files/dirs to check)
11 #
12 # return 0 if any of the files/dirs are newer than
13 # the reference file
14 #
15 # EXAMPLE: if is_older_than a.out *.o ; then ...
16 ref_is_older_than()
17 {
18 local x= ref="$1"
19 shift
20
21 for x; do
22 [ "${x}" -nt "${ref}" ] && return 0
23 if [ -d "${x}" ]; then
24 ref_is_older_than "${ref}" "${x}"/* && return 0
25 fi
26 done
27 return 1
28 }
29
30 do_test()
31 {
32 local r1= r2=
33
34 ref_is_older_than "$@"
35 r1=$?
36 is_older_than "$@"
37 r2=$?
38
39 [ -n "${VERBOSE}" ] && echo "reference = $r1 | OpenRC = $r2"
40 [ $r1 = $r2 ]
41 }
42
43 echo_cmd()
44 {
45 [ -n "${VERBOSE}" ] && echo "$@"
46 "$@"
47 }
48
49 test_it()
50 {
51 do_test "${TMPDIR}"/ref "${TMPDIR}"/dir1 "${TMPDIR}"/dir2
52 }
53
54 run_test()
55 {
56 echo_cmd mkdir -p "${TMPDIR}"/dir1 "${TMPDIR}"/dir2
57 echo_cmd touch "${TMPDIR}"/dir1/f1 "${TMPDIR}"/dir1/f2 \
58 "${TMPDIR}"/dir1/f3 "${TMPDIR}"/dir2/f1 \
59 "${TMPDIR}"/dir2/f2 "${TMPDIR}"/dir2/f3
60 echo_cmd sleep 1
61 echo_cmd touch "${TMPDIR}"/ref
62 test_it || return 1
63
64 echo_cmd sleep 1
65 echo_cmd touch "${TMPDIR}"/dir1/f2
66 test_it || return 1
67
68 echo_cmd sleep 1
69 echo_cmd touch "${TMPDIR}"/ref
70 test_it || return 1
71
72 echo_cmd sleep 1
73 echo_cmd touch "${TMPDIR}"/dir2/f2
74 test_it || return 1
75 }
76
77 rm -rf "${TMPDIR}"
78 mkdir "${TMPDIR}"
79 run_test
80 retval=$?
81 rm -rf "${TMPDIR}"
82 exit ${retval}
9191 ```
9292
9393 This is the maximum number of times to respawn a supervised process
94 during the given respawn period. The default is unlimited.
94 during the given respawn period.
95 The default is 10. 0 means unlimited.
9596
9697 ``` sh
9798 respawn_period=seconds
100101 This works in conjunction with respawn_max and respawn_delay above to
101102 decide if a process should not be respawned for some reason.
102103
103 For example, if respawn_period is 60, respawn_max is 2 and respawn_delay
104 is 3 and a process dies more than 4 times, the process will not be
105 respawned and the supervisor will terminate.
104 For example, if respawn period is 10 and respawn_max is 2, the process
105 would need to die 3 times within 10 seconds to no longer be respawned.
106 Note that respawn_delay will delay all of this, so in the above scenario
107 a respawn_delay of greater than 5 will cause infinite respawns.
108
109 By default, this is unset and respawn_max applies to the entire lifetime
110 of the service.
11 include ${MK}/os.mk
22
33 DIR= ${DATADIR}/support/sysvinit
4 INC= inittab README.md
4 INC= halt.sh inittab README.md
55
66
77 include ${MK}/scripts.mk
0 #!/bin/sh
1 if [ "$INIT_HALT" = HALT ]; then
2 exec /sbin/halt -dhn
3 else
4 exec /sbin/poweroff -dhn
5 fi
99 # Further system initialization, brings up the boot runlevel.
1010 rc::bootwait:/sbin/openrc boot
1111
12 l0u:0:wait:/sbin/telinit u
1213 l0:0:wait:/sbin/openrc shutdown
13 l0s:0:wait:/sbin/halt -dhip
14 l0s:0:wait:/sbin/halt.sh
1415 l1:S1:wait:/sbin/openrc single
1516 l2:2:wait:/sbin/openrc nonetwork
1617 l3:3:wait:/sbin/openrc default
1718 l4:4:wait:/sbin/openrc default
1819 l5:5:wait:/sbin/openrc default
20 l6u:6:wait:/sbin/telinit u
1921 l6:6:wait:/sbin/openrc reboot
2022 l6r:6:wait:/sbin/reboot -d
2123 #z6:6:respawn:/sbin/sulogin
3335 c6:2345:respawn:/sbin/agetty 38400 tty6 linux
3436
3537 # SERIAL CONSOLES
36 #s0:12345:respawn:/sbin/agetty 9600 ttyS0 vt100
37 #s1:12345:respawn:/sbin/agetty 9600 ttyS1 vt100
38 #s0:12345:respawn:/sbin/agetty -L 9600 ttyS0 vt100
39 #s1:12345:respawn:/sbin/agetty -L 9600 ttyS1 vt100
3840
3941 # What to do at the "Three Finger Salute".
4042 ca:12345:ctrlaltdel:/sbin/shutdown -r now
0 all:
1
2 install:
3
4 ignore:
5
6 check test::
7 ./runtests.sh
8
9 verbose-test:
10 VERBOSE=yes ./runtests.sh
11
12 clean:
13 rm -rf *.out tmp-*
0 #!/bin/sh
1
2 top_srcdir=${top_srcdir:-..}
3 . ${top_srcdir}/test/setup_env.sh
4
5 libeinfo_srcdir="${srcdir}/../libeinfo"
6 libeinfo_builddir="${builddir}/../libeinfo"
7 librc_srcdir="${srcdir}/../librc"
8 librc_builddir="${builddir}/../librc"
9 rc_srcdir="${srcdir}/../rc"
10 rc_builddir="${builddir}/../rc"
11
12 checkit() {
13 local base=$1; shift
14 echo "$@" | tr ' ' '\n' > ${base}.out
15 diff -u ${base}.list ${base}.out
16 eend $?
17 : $(( ret += $? ))
18 }
19
20 ret=0
21
22 fail_on_out() {
23 if [ -n "${out}" ]; then
24 eerror "Last command failed; failing"
25 exit 1
26 fi
27 }
28
29 ebegin "Checking trailing whitespace in code"
30 # XXX: Should we check man pages too ?
31 out=$(cd ${top_srcdir}; find */ \
32 '(' -name '*.[ch]' -o -name '*.in' -o -name '*.sh' ')' \
33 -exec grep -n -E '[[:space:]]+$' {} +)
34 [ -z "${out}" ]
35 eend $? "Trailing whitespace needs to be deleted:"$'\n'"${out}"
36 fail_on_out
37
38 ebegin "Checking trailing newlines in code"
39 out=$(cd ${top_srcdir};
40 for f in `find */ -name '*.[ch]'` ; do
41 sed -n -e :a -e '/^\n*$/{$q1;N;ba' -e '}' $f || echo $f
42 done)
43 [ -z "${out}" ]
44 eend $? "Trailing newlines need to be deleted:"$'\n'"${out}"
45 fail_on_out
46
47 ebegin "Checking for obsolete functions"
48 out=$(cd ${top_srcdir}; find src -name '*.[ch]' \
49 ! -name queue.h \
50 -exec grep -n -E '\<(malloc|memory|sys/(errno|fcntl|signal|stropts|termios|unistd))\.h\>' {} +)
51 [ -z "${out}" ]
52 eend $? "Avoid these obsolete functions:"$'\n'"${out}"
53 fail_on_out
54
55 ebegin "Checking for x* func usage"
56 out=$(cd ${top_srcdir}; find src -name '*.[ch]' \
57 ! -name queue.h \
58 -exec grep -n -E '\<(malloc|strdup)[[:space:]]*\(' {} + \
59 | grep -v \
60 -e src/includes/helpers.h \
61 -e src/libeinfo/libeinfo.c)
62 [ -z "${out}" ]
63 eend $? "These need to be using the x* variant:"$'\n'"${out}"
64 fail_on_out
65
66 ebegin "Checking spacing style"
67 out=$(cd ${top_srcdir}; find src -name '*.[ch]' \
68 ! -name queue.h \
69 -exec grep -n -E \
70 -e '\<(for|if|switch|while)\(' \
71 -e '\<(for|if|switch|while) \( ' \
72 -e ' ;' \
73 -e '[[:space:]]$' \
74 -e '\){' \
75 -e '(^|[^:])//' \
76 {} +)
77 [ -z "${out}" ]
78 eend $? "These lines violate style rules:"$'\n'"${out}"
79 fail_on_out
80
81 einfo "Running unit tests"
82 eindent
83 for u in units/*; do
84 [ -x "${u}" -a -f "${u}" ] || continue
85 ebegin "$(basename "${u}")"
86 ./"${u}"
87 eend $?
88 : $(( ret += $? ))
89 done
90
91 exit ${ret}
+0
-5
test/skel.runtests.sh less more
0 #!/bin/sh
1
2 # top_srcdir=${top_srcdir:-SET/THIS/PATH/OK!?}
3 . ${top_srcdir}/test/setup_env.sh
4
+0
-23
test/travis.sh less more
0 #!/bin/bash
1 # Copyright (c) 2007-2018 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 set -e
12 set -u
13 set -x
14
15 # These are steps to run on TravisCI under a containerized Ubuntu system.
16 # See $TOP/.travis.yml for more info about the TravisCI setup.
17
18 cpus=$(getconf _NPROCESSORS_CONF || echo 1)
19 # make on TravisCI doesn't support -O yet
20 make -j"${cpus}"
21
22 make test
0 #!/bin/sh
1 # unit test for is_older_than code of baselayout (2008/06/19)
2 # Author: Matthias Schwarzott <zzam@gentoo.org>
3
4 TMPDIR=tmp-"$(basename "$0")"
5
6 # Please note that we added this unit test because the function
7 # should really be called is_newer_than as it's what it's really testing.
8 # Or more perversly, returning 0 on failure and 1 and success.
9
10 # bool is_older_than(reference, files/dirs to check)
11 #
12 # return 0 if any of the files/dirs are newer than
13 # the reference file
14 #
15 # EXAMPLE: if is_older_than a.out *.o ; then ...
16 ref_is_older_than()
17 {
18 local x= ref="$1"
19 shift
20
21 for x; do
22 [ "${x}" -nt "${ref}" ] && return 0
23 if [ -d "${x}" ]; then
24 ref_is_older_than "${ref}" "${x}"/* && return 0
25 fi
26 done
27 return 1
28 }
29
30 do_test()
31 {
32 local r1= r2=
33
34 ref_is_older_than "$@"
35 r1=$?
36 is_older_than "$@"
37 r2=$?
38
39 [ -n "${VERBOSE}" ] && echo "reference = $r1 | OpenRC = $r2"
40 [ $r1 = $r2 ]
41 }
42
43 echo_cmd()
44 {
45 [ -n "${VERBOSE}" ] && echo "$@"
46 "$@"
47 }
48
49 test_it()
50 {
51 do_test "${TMPDIR}"/ref "${TMPDIR}"/dir1 "${TMPDIR}"/dir2
52 }
53
54 run_test()
55 {
56 echo_cmd mkdir -p "${TMPDIR}"/dir1 "${TMPDIR}"/dir2
57 echo_cmd touch "${TMPDIR}"/dir1/f1 "${TMPDIR}"/dir1/f2 \
58 "${TMPDIR}"/dir1/f3 "${TMPDIR}"/dir2/f1 \
59 "${TMPDIR}"/dir2/f2 "${TMPDIR}"/dir2/f3
60 echo_cmd sleep 1
61 echo_cmd touch "${TMPDIR}"/ref
62 test_it || return 1
63
64 echo_cmd sleep 1
65 echo_cmd touch "${TMPDIR}"/dir1/f2
66 test_it || return 1
67
68 echo_cmd sleep 1
69 echo_cmd touch "${TMPDIR}"/ref
70 test_it || return 1
71
72 echo_cmd sleep 1
73 echo_cmd touch "${TMPDIR}"/dir2/f2
74 test_it || return 1
75 }
76
77 rm -rf "${TMPDIR}"
78 mkdir "${TMPDIR}"
79 run_test
80 retval=$?
81 rm -rf "${TMPDIR}"
82 exit ${retval}
0 #!/bin/sh
1 # Copyright (c) 2008-2015 The OpenRC Authors.
2 # See the Authors file at the top-level directory of this distribution and
3 # https://github.com/OpenRC/openrc/blob/master/AUTHORS
4 #
5 # This file is part of OpenRC. It is subject to the license terms in
6 # the LICENSE file found in the top-level directory of this
7 # distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
8 # This file may not be copied, modified, propagated, or distributed
9 # except according to the terms contained in the LICENSE file.
10
11 : ${top_srcdir:=..}
12 . $top_srcdir/test/setup_env.sh
13
14 ret=0
15
16 tret=0
17 for f in yes YES Yes true TRUE True 1 ; do
18 if ! yesno $f; then
19 : $(( tret += 1 ))
20 echo "!$f!"
21 fi
22 done
23 for f in no NO No false FALSE False 0 ; do
24 if yesno $f; then
25 : $(( tret += 1 ))
26 echo "!$f!"
27 fi
28 done
29 : $(( ret += $tret ))
30
31 eend $ret
32 exit $ret
00 #compdef rc-service
11
2 if (( CURRENT == 2 )); then
3 _arguments -s \
4 '(-e --exists)'{-e,--exists}"[tests if the service exists or not]" \
5 '(-l --list)'{-l,--list}'[list all available services]' \
6 '(-r --resolve)'{-r,--resolve}'[resolve the service name to an init script]' \
7 '(-C --nocolor)'{-C,--nocolor}'[Disable color output]' \
8 '(-v --verbose)'{-v,--verbose}'[Run verbosely]' \
9 '(-q --quiet)'{-q,--quiet}'[Run quietly]'
10 _values "service" $(rc-service --list)
11 else
12 case $words[2] in
13 -e|--exists|-r|--resolve)
14 (( CURRENT > 3 )) && return 0
15 _values "service" $(rc-service --list)
16 ;;
17 -*)
18 return 0
19 ;;
20 *)
21 _values "action" stop start restart describe zap
22 ;;
23 esac
24 fi
2 _rc_services() {
3 if [[ -n "${opt_args[(i)-l|--list]}" ]]; then
4 _nothing
5 else
6 _values 'service' $(rc-service -l)
7 fi
8 }
9
10 _rc_actions() {
11 local service="${line[1]}"
12
13 if [[ -n "${opt_args[(i)-e|--exists|-r|--resolve]}" ]] || ! $(rc-service -e $service) ; then
14 _nothing
15 else
16 local -a actions=(${(f)"$(rc-service -C $service describe 2>&1)"})
17 shift actions
18 actions=(${actions# \* })
19 actions=(${actions/:*})
20 actions=(stop start restart describe zap ${actions[@]})
21 _describe -V 'action' actions
22 fi
23
24 }
25
26 _arguments -C -s \
27 '(-e --exists)'{-e,--exists}'[tests if the service exists or not]' \
28 '(-l --list)'{-l,--list}'[list all available services]' \
29 '(-r --resolve)'{-r,--resolve}'[resolve the service name to an init script]' \
30 '(-C --nocolor)'{-C,--nocolor}'[Disable color output]' \
31 '(-v --verbose)'{-v,--verbose}'[Run verbosely]' \
32 '(-q --quiet)'{-q,--quiet}'[Run quietly]' \
33 '1:service:_rc_services' \
34 '2:action:_rc_actions'
2535
2636 # vim: set et sw=2 ts=2 ft=zsh: