util: introduce PERSONALITY_INVALID as macro for 0xffffffffLU

This commit is contained in:
Lennart Poettering 2015-05-21 19:48:49 +02:00
parent 481a0aa2c9
commit 050f727728
5 changed files with 15 additions and 11 deletions

View File

@ -1491,7 +1491,7 @@ static int exec_child(
return -errno;
}
if (context->personality != 0xffffffffUL)
if (context->personality != PERSONALITY_INVALID)
if (personality(context->personality) < 0) {
*exit_status = EXIT_PERSONALITY;
return -errno;
@ -1946,7 +1946,7 @@ void exec_context_init(ExecContext *c) {
c->syslog_level_prefix = true;
c->ignore_sigpipe = true;
c->timer_slack_nsec = NSEC_INFINITY;
c->personality = 0xffffffffUL;
c->personality = PERSONALITY_INVALID;
c->runtime_directory_mode = 0755;
}
@ -2427,7 +2427,7 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) {
"%sSELinuxContext: %s%s\n",
prefix, c->selinux_context_ignore ? "-" : "", c->selinux_context);
if (c->personality != 0xffffffffUL)
if (c->personality != PERSONALITY_INVALID)
fprintf(f,
"%sPersonality: %s\n",
prefix, strna(personality_to_string(c->personality)));

View File

@ -3046,7 +3046,7 @@ int config_parse_personality(
assert(personality);
p = personality_from_string(rvalue);
if (p == 0xffffffffUL) {
if (p == PERSONALITY_INVALID) {
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
"Failed to parse personality, ignoring: %s", rvalue);
return 0;

View File

@ -195,7 +195,7 @@ static char **arg_network_macvlan = NULL;
static char **arg_network_ipvlan = NULL;
static bool arg_network_veth = false;
static const char *arg_network_bridge = NULL;
static unsigned long arg_personality = 0xffffffffLU;
static unsigned long arg_personality = PERSONALITY_INVALID;
static char *arg_image = NULL;
static Volatile arg_volatile = VOLATILE_NO;
static ExposePort *arg_expose_ports = NULL;
@ -823,7 +823,7 @@ static int parse_argv(int argc, char *argv[]) {
case ARG_PERSONALITY:
arg_personality = personality_from_string(optarg);
if (arg_personality == 0xffffffffLU) {
if (arg_personality == PERSONALITY_INVALID) {
log_error("Unknown or unsupported personality '%s'.", optarg);
return -EINVAL;
}
@ -4128,7 +4128,7 @@ static int inner_child(
setup_hostname();
if (arg_personality != 0xffffffffLU) {
if (arg_personality != PERSONALITY_INVALID) {
if (personality(arg_personality) < 0)
return log_error_errno(errno, "personality() failed: %m");
} else if (secondary) {

View File

@ -4837,10 +4837,7 @@ unsigned long personality_from_string(const char *p) {
return PER_LINUX;
#endif
/* personality(7) documents that 0xffffffffUL is used for
* querying the current personality, hence let's use that here
* as error indicator. */
return 0xffffffffUL;
return PERSONALITY_INVALID;
}
const char* personality_to_string(unsigned long p) {

View File

@ -816,6 +816,13 @@ int open_tmpfile(const char *path, int flags);
int fd_warn_permissions(const char *path, int fd);
#ifndef PERSONALITY_INVALID
/* personality(7) documents that 0xffffffffUL is used for querying the
* current personality, hence let's use that here as error
* indicator. */
#define PERSONALITY_INVALID 0xffffffffLU
#endif
unsigned long personality_from_string(const char *p);
const char *personality_to_string(unsigned long);