]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
conf-parser: add specific parser for PID values 22458/head
authorLennart Poettering <lennart@poettering.net>
Wed, 9 Feb 2022 09:13:59 +0000 (10:13 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 9 Feb 2022 09:17:37 +0000 (10:17 +0100)
src/shared/conf-parser.c
src/shared/conf-parser.h
src/tty-ask-password-agent/tty-ask-password-agent.c

index ef2aeaf79d79979568b4ffe8fc2d17597611aaeb..853f60f517375ca0f17e8675ab9f832d9c4dd2aa 100644 (file)
@@ -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,
index fd1781774fcf06fb279fdd70bab65fe8b8e52998..7badb4b12b12df9c6a36ad1c8d1f6fc06f2133d7 100644 (file)
@@ -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,
index c7105cde573b50fe7184f240c48578a591cd4d3e..72559e11a960c00c8f88a861668ded735b7a161d 100644 (file)
@@ -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, &not_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;
                 }