summaryrefslogtreecommitdiff
path: root/utils
AgeCommit message (Collapse)AuthorFilesLines
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-01build: Split libps and libkvm detection into their own macros and variablesGuillem Jover1-1/+3
Do not tie these libraries in a single variable for start-stop-daemon, instead move the usage to the Makefile.am.
2016-04-01build: Remove unused UA_LIBS variableGuillem Jover1-1/+1
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
2016-02-26u-a: Remove useless alternative_has_slave() before alternative_get_slave()Guillem Jover1-4/+6
This gets rid of a warning with gcc-6, that does not understand that we never pass a NULL ‘sl’ pointer as we have checked previously if it has slaves via alternative_has_slave(). And gets rid of unneeded calls to alternative_has_slave(), which internally do alternative_get_slave() anyway.
2016-02-26u-a: Move check for new slave inside alternative_evolve_slave()Guillem Jover1-5/+6
Let's move all the logic concerning checking if the slave link needs to be updated local to the function that was doing so.
2016-02-26u-a: Move alternative temporary extension to the build systemGuillem Jover2-2/+1
This removes another dpkg-specific string from the code to make life easier for downstreams using update-alternatives on non-dpkg based systems.
2016-02-26u-a: Generalize admindir environment variable handlingGuillem Jover2-4/+10
This variable is currently set by dpkg, but other package managers or callers might set it with a different name on other downstream projects. Let's move the variable name to the build system so that third parties do not have to modify the code going on to remove a dpkg-specific name.
2015-12-12u-a: Merge all action handling into a single if-else-if blockGuillem Jover1-17/+28
Introduce two boolean variables to track when to log the command-line arguments when modifying anything on the system, and another one when modifying a single alternative to initialize and update it. This unifies the code, and will make it easier to switch it into a shared library in the future.
2015-12-12u-a: Switch xasprintf() to return an allocated stringGuillem Jover1-32/+27
It should make the code more clear, and in many cases it avoids having to use a temporary variable.
2015-10-18Update Ian Jackson's email addressGuillem Jover1-1/+1
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-17u-a: Do not try to free() a «const char *»Guillem Jover1-4/+4
The returned value is always allocated now, and the call sites are respinsible for its release, so it should not have been a «const char *» pointer, modify the call tree to make it «char *». 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-15u-a: Fix memory leak in alternative_config_all()Guillem Jover1-1/+3
Warned-by: coverity
2015-09-14u-a: Remove subcall and surrounding codeGuillem Jover1-51/+0
This function and macros are unused, now that all commands have been reimplemented fully as built-ins.
2015-09-14u-a: Reimplement --set-selections as a built-in commandGuillem Jover1-10/+12
Do not execute itself with --set or --auto for each alternative to set a selection for, just handle them in-process.
2015-09-14u-a: Reimplement --all as a fully built-in commandGuillem Jover1-14/+25
Do not execute itself with --config for each alternative to configure, just handle them all in-process.
2015-09-14u-a: Move selection functions after alternative_update()Guillem Jover1-123/+123
We will need to use functions defined further down the file, so let's move these ones after alternative_update().
2015-09-14u-a: Refactor config, remove, set_manual and set_auto actionsGuillem Jover1-47/+89
This simplifies the main() function, and will allow reusing some of these new functions to avoid having to call itself.
2015-09-14u-a: Rename alternative_remove to alternative_remove_filesGuillem Jover1-2/+2
We will use this name for the actual alternative remove action.
2015-09-14u-a: Move current best alternative from the trail to the headGuillem Jover1-6/+5
No callers have been found in Debian parsing the best version of an alternative.
2015-09-14u-a: Print master and slave links on --displayGuillem Jover1-0/+3
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>
2015-04-18debian: Update my copyright yearsGuillem Jover1-1/+1
2015-04-10Consistently use proper quotation marks all over the placeGuillem Jover1-6/+6
That is "" or '', and not the unbalanced `' pair.
2015-03-31Use "<enter>" instead of "return" or "enter" in input promptsGuillem Jover1-1/+1
This should make it more clear we are talking about the key and not something else.
2015-01-28test: Move use strict and warnings as the first directivesGuillem Jover1-5/+7
2014-10-23u-a: Inline alternative status description into translatable stringGuillem Jover1-3/+6
This makes it possible to correctly translate the string. Required-by: #766311
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.