summaryrefslogtreecommitdiff
path: root/utils/start-stop-daemon.c
AgeCommit message (Collapse)AuthorFilesLines
2017-07-04s-s-d: Parse usernames and groupnames starting with digits correctlyGuillem Jover1-3/+3
We should not consider a username or groupname that starts with digits as a valid uid or gid. When parsing integers we should parse the strings fully and not consider any partial parsing to be correct. Reported-by: Bodo Eggert <7eggert@online.de>
2017-02-26s-s-d: Define _KMEMUSER for NetBSDGuillem Jover1-0/+3
We need to define this macro to be able to get the declarations for the struct proc and other struct kproc_info members.
2017-02-26s-s-d: Use correct struct kinfo_proc ruid submember on NetBSDGuillem Jover1-0/+2
2017-02-26s-s-d: Use 5-argument kvm_getprocs() call form on OpenBSDGuillem Jover1-0/+4
2017-02-26s-s-d: Rename err to ret as the former is a function on BSDsGuillem Jover1-3/+3
Do not shadow the global err() with a local variable.
2017-01-22s-s-d: Use the new process executable support in GNU/HurdGuillem Jover1-0/+12
This gives the actual executable name instead of having to look into argv[0], which is not really correct, as the program doing execve() can set that to anything it likes. We have to check for the name being NULL or empty due to an initial implementation bug.
2017-01-22s-s-d: Use proc_stat_pid() instead of accessing the member directlyGuillem Jover1-1/+1
2016-10-30s-s-d: Port process handling to AIXGuillem Jover1-3/+74
2016-10-30s-s-d: Cleanup OS* macrosGuillem Jover1-64/+64
When setting them sort them on by relative importance/relevance/freeness. Separate the name with an underscore and use proper case for the kernel names. Update the name of several OSes/kernels.
2016-10-30s-s-d: Port process handling to Mac OS XGuillem Jover1-0/+87
Based-on-a-patch-by: Mo McRoberts <mo@nevali.net> Signed-off-by: Guillem Jover <guillem@debian.org>
2016-10-30s-s-d: On FreeBSD return STATUS_UNKNOWN instead of false in do_procinit()Guillem Jover1-4/+4
The function returns an enum status_code, not a bool.
2016-10-30s-s-d: Handle _POSIX_PRIORITY_SCHEDULING being defined to -1 or 0Guillem Jover1-3/+3
POSIX states that these can be defined as -1 (unavailable), or 0 (available at build-time, but might or might not be available at run-time). Handles these, which happens to be the case in Mac OS X.
2016-10-30s-s-d: Use reserved system preprocessor symbolsGuillem Jover1-3/+3
Use underscore-prefixed symbols to distinguish the system we are building for.
2016-07-03s-s-d: Simplify action dispatching in main()Guillem Jover1-12/+4
Avoid useless intermediate variables, and use if else to select the actions.
2016-07-03s-s-d: Switch do_start() to return a value instead of exit()ing directlyGuillem Jover1-4/+4
2016-07-03s-s-d: Set return buffer length for sysctl(2) calls on */kFreeBSDGuillem Jover1-3/+6
2016-07-03s-s-d: Fix number of entries computation returned by sysctl() on */kFreeBSDGuillem Jover1-1/+1
2016-05-09s-s-d: Use a heap allocated formatted string for what to stopGuillem Jover1-11/+18
2016-05-03s-s-d: Initialize nentries from sysctl(2) on */kFreeBSDGuillem Jover1-0/+1
2016-05-03s-s-d: Rename sysctl() name variables to mibGuillem Jover1-30/+30
This is the common name used for the first argument, and avoids the variable name clash with the function argument with the same name. This fixes a build failure on */kFreeBSD systems.
2016-04-01s-s-d: Switch kFreeBSD to use sysctl(3)Guillem Jover1-0/+102
Avoid libkvm-dev to make sure we always use the low-level sysctl(3) interface.
2016-04-01s-s-d: Unify --help output with the rest of the toolsGuillem Jover1-38/+52
2015-09-21s-s-d: Do not set changegroup unconditionallySven Joachim1-4/+5
Commit 3db7a6eb4fd16b4cea475009bd80be3a41ada014 would always set changegroup in the --chuid option, even if no colon is given on the commandline. [guillem@debian.org: - Avoid an else from a fatal if. ] Signed-off-by: Guillem Jover <guillem@debian.org>
2015-09-17s-s-d: Remove now unused xstrdup() functionGuillem Jover1-11/+0
Warned-by: gcc
2015-09-15s-s-d: Fix short-lived memory leak when parsing --chuidGuillem Jover1-1/+1
Introduced in commit 3db7a6eb4fd16b4cea475009bd80be3a41ada014. Warned-by: coverity
2015-09-14s-s-d: Fix short-lived memory leaksGuillem Jover1-13/+30
As a side effect now a missing group after ‘:’ on --chuid is a fatal error. Warned-by: coverity
2015-05-09s-s-d: Cleanup timespec_mul()Guillem Jover1-3/+4
2015-05-09s-s-d: Switch to use a monotonic clock if availableGuillem Jover1-0/+7
Use clock_gettime(CLOCK_MONOTONIC) if available instead of gettimeofday() which gets affected by abrupt system clock changes, and might mess with the timeout calculations. Closes: #783014 Suggested-by: Jose M Calhariz <jose.calhariz@hds.com>
2015-05-09s-s-d: Switch to use timespec instead of timevalGuillem Jover1-23/+53
Switch to use pselect() instead of select().
2015-05-09s-s-d: Do not leak kvm descriptorsGuillem Jover1-10/+34
Cherry picked from commit eaa073bc37901a6d8c46abc9fa5e7ec5551df04b. We should close the kvm instances after every operation, so not to leak them, as they might exhaust the file descriptor pool, or leak into the started process. Closes: #779467 Based-on-patch-by: Jeff Epler <jepler@unpythonic.net>
2014-10-20s-s-d: Add a new --remove-pidfile optionGuillem Jover1-0/+19
This is the counter-option to --make-pidfile, so that programs that need their pidfile created can use an option to remove them without needing to do that manually.
2014-10-16s-s-d: Create a pidfile even when not backgrounding ourselvesGuillem Jover1-0/+3
Regression introduced in commit 29778da537e2ff1a0f032db33dde43413b7345ef. When the user asked us to create the pidfile, but _not_ to background ourselves, we should still create the pidfile. This usage is somewhat dubious, as s-s-d has an option to background, which is better in any way, as it will make sure to return error codes in case the program cannot be started for whatever reason. But it's still a regression. Closes: #765110
2014-10-06s-s-d: Do not fail when kvm_getprocs() cannot find any processGuillem Jover1-1/+9
Return NULL, and let the call sites return false themselves. This fixes the code failing on retries when the process has disappeared.
2014-10-06s-s-d: On kFreeBSD do not make kvm_openfiles() open /dev/memGuillem Jover1-1/+6
We do not need that file, as we are not using any kvm_read(3) call, either explicitly or implicitly. Everything is retrieved through sysctl(2). libkvm from FreeBSD allows to pass /dev/null as the memory file to denote that we do not need it. This will make s-s-d work again on jails which do not usually have /dev/mem available. Reported-by: Steven Chamberlain <steven@pyro.eu.org>
2014-10-06s-s-d: Refactor KVM codeGuillem Jover1-39/+44
Create two new functions, ssd_kvm_open() and ssd_kvm_get_procs().
2014-10-06s-s-d: Do not abort on --stop when only pid or ppid options are specifiedChristos Trochalakis1-0/+4
When running with «--stop» and only pid or ppid as matching options, start-stop-daemon aborts with a "no match option" error. «pid» and «ppid» are proper matching options, so they should be enough to proceed. Missed in commits 80de58344cb38ab085ca2c7808f4f7b3be1d2422 and 3fabf94e0b5fe1bcdea26fecee1c87e74fab98b2. Closes: #763767 Signed-off-by: Guillem Jover <guillem@debian.org>
2014-10-06s-s-d: Make sure the pidfile is always created with a 022 umaskGuillem Jover1-4/+5
Although this got partially corrected with the fix for the background and pidfile creation bug, it still migth happen that the parent had a too restrictive umask. Closes: #760222 Reported-by: Will Conley <willconley3@gmail.com>
2014-10-06s-s-d: Do not exit from first parent before the pidfile has been createdGuillem Jover1-5/+53
When using the --background option combined with --make-pidfile, the parent process might end up exiting before the child's pidfile has been created, which might confuse service supervising programs. Fix the race condition by making the first parent wait for the second one, so that it can safely create the pidfile if required. Closes: #686420 Based-on-patch-by: Nir Soffer <nirs@hyperms.com>
2014-10-06s-s-d: Move write_pidfile() before daemonize()Guillem Jover1-21/+21
We'll be needing to call the former in the latter.
2014-10-06s-s-d: Abort if the system or compatibility setsid() failsGuillem Jover1-2/+5
This requires to check the setpgid() return value in the setsid() compatibility function.
2014-08-19s-s-d: Switch GNU/kFreeBSD systems to use libkvmGuillem Jover1-2/+2
Use libkvm instead of relying on linprocfs, which is not the native procfs on kFreeBSD, and it is usually not mounted as FreeBSD programs do not expect it to be present. This stops making the code handle GNU/kFreeBSD as if it was a Linux-based system.
2014-08-15s-s-d: Remove wasteful strlen() comparison before strcmp()Guillem Jover1-2/+0
2014-06-05s-s-d: Add DragonFlyBSD supportGuillem Jover1-0/+13
Closes: #734452 Based-on-patch-by: Hleb Valoshka <375gnu@gmail.com>
2014-05-28s-s-d: Uppercase status_code enum valuesGuillem Jover1-22/+22
2014-05-28s-s-d: Uppercase action_code enum valuesGuillem Jover1-17/+17
2014-05-17s-s-d: Cope with bogus OpenVZ kernels that prepend the " (deleted)" markerGuillem Jover1-4/+12
There are OpenVZ Linux kernels that instead of appending, prepend the deleted marker, making the exec check fail to match. Add a workaround so that those systems do not get affected. This will still be affecting any other userland tool that checks the /proc/PID/exe symlink, and might end up helping this behaviour to get entrenched, but better this than the getting strange system failures. Closes: #731530
2014-04-30s-s-d: Fix off-by-one stack buffer overrun on GNU/Linux and GNU/kFreeBSDGuillem Jover1-2/+2
This might happen if the executable pathname is longer than _POSIX_PATH_MAX. Although this should not have security implications as the buffer is surrounded by two arrays (so those catch accesses even if the stack grows up or down), and we are compiling with -fstack-protector anyway. We just need to always leave room for the final NUL character. Warned-by: coverity
2014-04-21s-s-d: Add a new --ppid matching optionGuillem Jover1-2/+91
This allows to check for processes with a specific parent PID. Suggested-by: Alex Mestiashvili <mailatgoogl@gmail.com>
2014-04-21s-s-d: Detect system specific headers at configure timeGuillem Jover1-15/+16
Instead of hardcoding their usage depending on system macros.
2014-04-21s-s-d: Move Hurd specific headers after all standard headersGuillem Jover1-5/+5