From: Lennart Poettering Date: Wed, 9 Feb 2022 09:13:59 +0000 (+0100) Subject: conf-parser: add specific parser for PID values X-Git-Tag: v251-rc1~319^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=65a0ede2ed931a42f0906bb241ffe5634f510e91;p=thirdparty%2Fsystemd.git conf-parser: add specific parser for PID values --- diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index ef2aeaf79d7..853f60f5173 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -642,6 +642,7 @@ DEFINE_PARSER(nsec, nsec_t, parse_nsec); DEFINE_PARSER(sec, usec_t, parse_sec); DEFINE_PARSER(sec_def_infinity, usec_t, parse_sec_def_infinity); DEFINE_PARSER(mode, mode_t, parse_mode); +DEFINE_PARSER(pid, pid_t, parse_pid); int config_parse_iec_size( const char* unit, diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h index fd1781774fc..7badb4b12b1 100644 --- a/src/shared/conf-parser.h +++ b/src/shared/conf-parser.h @@ -195,6 +195,7 @@ CONFIG_PARSER_PROTOTYPE(config_parse_ether_addrs); CONFIG_PARSER_PROTOTYPE(config_parse_in_addr_non_null); CONFIG_PARSER_PROTOTYPE(config_parse_percent); CONFIG_PARSER_PROTOTYPE(config_parse_permyriad); +CONFIG_PARSER_PROTOTYPE(config_parse_pid); typedef enum Disabled { DISABLED_CONFIGURATION, diff --git a/src/tty-ask-password-agent/tty-ask-password-agent.c b/src/tty-ask-password-agent/tty-ask-password-agent.c index c7105cde573..72559e11a96 100644 --- a/src/tty-ask-password-agent/tty-ask-password-agent.c +++ b/src/tty-ask-password-agent/tty-ask-password-agent.c @@ -174,13 +174,13 @@ static int process_one_password_file(const char *filename) { _cleanup_free_ char *socket_name = NULL, *message = NULL; bool accept_cached = false, echo = false, silent = false; uint64_t not_after = 0; - unsigned pid = 0; + pid_t pid = 0; const ConfigTableItem items[] = { { "Ask", "Socket", config_parse_safe_string, 0, &socket_name }, { "Ask", "NotAfter", config_parse_uint64, 0, ¬_after }, { "Ask", "Message", config_parse_string, 0, &message }, - { "Ask", "PID", config_parse_unsigned, 0, &pid }, + { "Ask", "PID", config_parse_pid, 0, &pid }, { "Ask", "AcceptCached", config_parse_bool, 0, &accept_cached }, { "Ask", "Echo", config_parse_bool, 0, &echo }, { "Ask", "Silent", config_parse_bool, 0, &silent }, @@ -212,14 +212,14 @@ static int process_one_password_file(const char *filename) { switch (arg_action) { case ACTION_LIST: - printf("'%s' (PID %u)\n", strna(message), pid); + printf("'%s' (PID " PID_FMT ")\n", strna(message), pid); return 0; case ACTION_WALL: { _cleanup_free_ char *wall = NULL; if (asprintf(&wall, - "Password entry required for \'%s\' (PID %u).\r\n" + "Password entry required for \'%s\' (PID " PID_FMT ").\r\n" "Please enter password with the systemd-tty-ask-password-agent tool.", strna(message), pid) < 0) @@ -235,7 +235,7 @@ static int process_one_password_file(const char *filename) { if (access(socket_name, W_OK) < 0) { if (arg_action == ACTION_QUERY) - log_info("Not querying '%s' (PID %u), lacking privileges.", strna(message), pid); + log_info("Not querying '%s' (PID " PID_FMT "), lacking privileges.", strna(message), pid); return 0; }