2017-11-18 17:09:20 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
2012-07-18 19:07:51 +02:00
|
|
|
#pragma once
|
2010-08-20 03:26:37 +02:00
|
|
|
|
2011-01-20 18:22:03 +01:00
|
|
|
#include <stdbool.h>
|
2014-03-03 21:23:12 +01:00
|
|
|
|
2015-11-30 21:43:37 +01:00
|
|
|
#include "hashmap.h"
|
|
|
|
#include "macro.h"
|
2015-12-01 23:22:03 +01:00
|
|
|
#include "set.h"
|
2014-03-03 21:23:12 +01:00
|
|
|
|
2019-07-28 10:13:21 +02:00
|
|
|
/* This defines pretty names for the LSB 'start' verb exit codes. Note that they shouldn't be confused with
|
|
|
|
* the LSB 'status' verb exit codes which are defined very differently. For details see:
|
2016-06-02 17:56:59 +02:00
|
|
|
*
|
|
|
|
* https://refspecs.linuxbase.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
|
|
|
|
*/
|
|
|
|
|
2016-10-10 20:08:41 +02:00
|
|
|
enum {
|
2010-08-20 03:26:37 +02:00
|
|
|
/* EXIT_SUCCESS defined by libc */
|
|
|
|
/* EXIT_FAILURE defined by libc */
|
|
|
|
EXIT_INVALIDARGUMENT = 2,
|
|
|
|
EXIT_NOTIMPLEMENTED = 3,
|
|
|
|
EXIT_NOPERMISSION = 4,
|
|
|
|
EXIT_NOTINSTALLED = 5,
|
|
|
|
EXIT_NOTCONFIGURED = 6,
|
|
|
|
EXIT_NOTRUNNING = 7,
|
|
|
|
|
exit-status: list BSD exit codes too
Let's optionally translate BSD exit codes to error strings too.
My first approach on adding this was to turn ExitStatusLevel into a
bitmask rather than a linear level, with one bit for the various feature
bits. However, the exit code ranges are generally not defined
independently from each other, i.e. our own ones are defined with the
LSB ones in mind, and most sets are defined with the ISO C ones.
Hence, instead I changed the existing hierarchy of MINIMAL, SYSTEMD, LSB
with an alias of FULL == LSB, only slightly by seperating FULL and LSB
into two separate levels, so that there's now:
1. MINIMAL (only EXIT_SUCCESS/EXIT_FAILURE)
2. SYSTEMD (incorporating our own exit codes)
3. LSB (like SYSTEMD but adding in LSB service exit codes)
4. FULL (like FULL but adding BSD exit codes)
Note that across the codebase only FULL, SYSTEMD, and MINIMAL are used,
depending on context, how much we know about the process and whether we
are logging for debugging purposes or not. This means the LSB level
wouldn't really have to be separate, but it appeared careless to me to
fold it into FULL along with the BSD exit codes.
Note that this commit doesn't change much for regular codepaths: the
FULL exit status level is only used during debug logging, as a helper to
the user reading the debug logs.
2018-04-23 19:26:25 +02:00
|
|
|
/* BSD's sysexits.h defines a couple EX_xyz exit codes in the range 64 … 78 */
|
2010-08-20 03:26:37 +02:00
|
|
|
|
2019-07-28 10:13:21 +02:00
|
|
|
/* The LSB suggests that error codes >= 200 are "reserved". We use them here under the assumption
|
|
|
|
* that they hence are unused by init scripts. */
|
2010-08-20 03:26:37 +02:00
|
|
|
EXIT_CHDIR = 200,
|
|
|
|
EXIT_NICE,
|
|
|
|
EXIT_FDS,
|
|
|
|
EXIT_EXEC,
|
|
|
|
EXIT_MEMORY,
|
|
|
|
EXIT_LIMITS,
|
|
|
|
EXIT_OOM_ADJUST,
|
|
|
|
EXIT_SIGNAL_MASK,
|
|
|
|
EXIT_STDIN,
|
|
|
|
EXIT_STDOUT,
|
|
|
|
EXIT_CHROOT, /* 210 */
|
|
|
|
EXIT_IOPRIO,
|
|
|
|
EXIT_TIMERSLACK,
|
|
|
|
EXIT_SECUREBITS,
|
|
|
|
EXIT_SETSCHEDULER,
|
|
|
|
EXIT_CPUAFFINITY,
|
|
|
|
EXIT_GROUP,
|
|
|
|
EXIT_USER,
|
|
|
|
EXIT_CAPABILITIES,
|
|
|
|
EXIT_CGROUP,
|
|
|
|
EXIT_SETSID, /* 220 */
|
|
|
|
EXIT_CONFIRM,
|
|
|
|
EXIT_STDERR,
|
2014-03-24 20:07:42 +01:00
|
|
|
_EXIT_RESERVED, /* used to be tcpwrap, don't reuse! */
|
2011-08-02 05:24:58 +02:00
|
|
|
EXIT_PAM,
|
2011-11-17 00:21:16 +01:00
|
|
|
EXIT_NETWORK,
|
2012-07-17 04:17:53 +02:00
|
|
|
EXIT_NAMESPACE,
|
|
|
|
EXIT_NO_NEW_PRIVILEGES,
|
2014-02-06 10:05:16 +01:00
|
|
|
EXIT_SECCOMP,
|
2014-02-19 02:15:24 +01:00
|
|
|
EXIT_SELINUX_CONTEXT,
|
2014-02-20 16:19:44 +01:00
|
|
|
EXIT_PERSONALITY, /* 230 */
|
2014-02-25 20:37:03 +01:00
|
|
|
EXIT_APPARMOR_PROFILE,
|
|
|
|
EXIT_ADDRESS_FAMILIES,
|
2014-06-05 09:55:53 +02:00
|
|
|
EXIT_RUNTIME_DIRECTORY,
|
2017-09-15 16:41:19 +02:00
|
|
|
_EXIT_RESERVED2, /* used to be used by kdbus, don't reuse */
|
2014-06-05 09:55:53 +02:00
|
|
|
EXIT_CHOWN,
|
2014-11-24 12:46:20 +01:00
|
|
|
EXIT_SMACK_PROCESS_LABEL,
|
2016-12-02 01:54:41 +01:00
|
|
|
EXIT_KEYRING,
|
core: add {State,Cache,Log,Configuration}Directory= (#6384)
This introduces {State,Cache,Log,Configuration}Directory= those are
similar to RuntimeDirectory=. They create the directories under
/var/lib, /var/cache/, /var/log, or /etc, respectively, with the mode
specified in {State,Cache,Log,Configuration}DirectoryMode=.
This also fixes #6391.
2017-07-18 14:34:52 +02:00
|
|
|
EXIT_STATE_DIRECTORY,
|
|
|
|
EXIT_CACHE_DIRECTORY,
|
|
|
|
EXIT_LOGS_DIRECTORY, /* 240 */
|
|
|
|
EXIT_CONFIGURATION_DIRECTORY,
|
2019-03-12 18:58:26 +01:00
|
|
|
EXIT_NUMA_POLICY,
|
2018-11-20 16:55:51 +01:00
|
|
|
|
|
|
|
EXIT_EXCEPTION = 255, /* Whenever we want to propagate an abnormal/signal exit, in line with bash */
|
2016-10-10 20:08:41 +02:00
|
|
|
};
|
2010-08-20 03:26:37 +02:00
|
|
|
|
2019-07-28 10:13:21 +02:00
|
|
|
typedef enum ExitStatusClass {
|
|
|
|
EXIT_STATUS_GLIBC = 1 << 0, /* libc EXIT_STATUS/EXIT_FAILURE */
|
|
|
|
EXIT_STATUS_SYSTEMD = 1 << 1, /* systemd's own exit codes */
|
|
|
|
EXIT_STATUS_LSB = 1 << 2, /* LSB exit codes */
|
|
|
|
EXIT_STATUS_BSD = 1 << 3, /* BSD (EX_xyz) exit codes */
|
|
|
|
EXIT_STATUS_FULL = EXIT_STATUS_GLIBC | EXIT_STATUS_SYSTEMD | EXIT_STATUS_LSB | EXIT_STATUS_BSD,
|
|
|
|
} ExitStatusClass;
|
2010-08-20 03:26:37 +02:00
|
|
|
|
2012-08-13 13:58:01 +02:00
|
|
|
typedef struct ExitStatusSet {
|
2014-07-03 15:36:50 +02:00
|
|
|
Set *status;
|
2012-08-13 13:58:01 +02:00
|
|
|
Set *signal;
|
|
|
|
} ExitStatusSet;
|
|
|
|
|
2019-07-28 10:13:21 +02:00
|
|
|
const char* exit_status_to_string(int code, ExitStatusClass class) _const_;
|
|
|
|
const char* exit_status_class(int code) _const_;
|
|
|
|
|
|
|
|
typedef struct ExitStatusMapping {
|
|
|
|
const char *name;
|
|
|
|
ExitStatusClass class;
|
|
|
|
} ExitStatusMapping;
|
|
|
|
|
|
|
|
extern const ExitStatusMapping exit_status_mappings[256];
|
2010-08-20 03:26:37 +02:00
|
|
|
|
2016-10-10 22:07:30 +02:00
|
|
|
typedef enum ExitClean {
|
|
|
|
EXIT_CLEAN_DAEMON,
|
|
|
|
EXIT_CLEAN_COMMAND,
|
|
|
|
} ExitClean;
|
|
|
|
|
|
|
|
bool is_clean_exit(int code, int status, ExitClean clean, ExitStatusSet *success_status);
|
2014-07-03 12:47:40 +02:00
|
|
|
|
|
|
|
void exit_status_set_free(ExitStatusSet *x);
|
2014-07-03 15:50:31 +02:00
|
|
|
bool exit_status_set_is_empty(ExitStatusSet *x);
|
2015-04-28 18:24:20 +02:00
|
|
|
bool exit_status_set_test(ExitStatusSet *x, int code, int status);
|