Skip to content

Commit 65a0ede

Browse files
committed
conf-parser: add specific parser for PID values
1 parent a99a852 commit 65a0ede

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/shared/conf-parser.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,7 @@ DEFINE_PARSER(nsec, nsec_t, parse_nsec);
642642
DEFINE_PARSER(sec, usec_t, parse_sec);
643643
DEFINE_PARSER(sec_def_infinity, usec_t, parse_sec_def_infinity);
644644
DEFINE_PARSER(mode, mode_t, parse_mode);
645+
DEFINE_PARSER(pid, pid_t, parse_pid);
645646

646647
int config_parse_iec_size(
647648
const char* unit,

src/shared/conf-parser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ CONFIG_PARSER_PROTOTYPE(config_parse_ether_addrs);
195195
CONFIG_PARSER_PROTOTYPE(config_parse_in_addr_non_null);
196196
CONFIG_PARSER_PROTOTYPE(config_parse_percent);
197197
CONFIG_PARSER_PROTOTYPE(config_parse_permyriad);
198+
CONFIG_PARSER_PROTOTYPE(config_parse_pid);
198199

199200
typedef enum Disabled {
200201
DISABLED_CONFIGURATION,

src/tty-ask-password-agent/tty-ask-password-agent.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,13 @@ static int process_one_password_file(const char *filename) {
174174
_cleanup_free_ char *socket_name = NULL, *message = NULL;
175175
bool accept_cached = false, echo = false, silent = false;
176176
uint64_t not_after = 0;
177-
unsigned pid = 0;
177+
pid_t pid = 0;
178178

179179
const ConfigTableItem items[] = {
180180
{ "Ask", "Socket", config_parse_safe_string, 0, &socket_name },
181181
{ "Ask", "NotAfter", config_parse_uint64, 0, &not_after },
182182
{ "Ask", "Message", config_parse_string, 0, &message },
183-
{ "Ask", "PID", config_parse_unsigned, 0, &pid },
183+
{ "Ask", "PID", config_parse_pid, 0, &pid },
184184
{ "Ask", "AcceptCached", config_parse_bool, 0, &accept_cached },
185185
{ "Ask", "Echo", config_parse_bool, 0, &echo },
186186
{ "Ask", "Silent", config_parse_bool, 0, &silent },
@@ -212,14 +212,14 @@ static int process_one_password_file(const char *filename) {
212212

213213
switch (arg_action) {
214214
case ACTION_LIST:
215-
printf("'%s' (PID %u)\n", strna(message), pid);
215+
printf("'%s' (PID " PID_FMT ")\n", strna(message), pid);
216216
return 0;
217217

218218
case ACTION_WALL: {
219219
_cleanup_free_ char *wall = NULL;
220220

221221
if (asprintf(&wall,
222-
"Password entry required for \'%s\' (PID %u).\r\n"
222+
"Password entry required for \'%s\' (PID " PID_FMT ").\r\n"
223223
"Please enter password with the systemd-tty-ask-password-agent tool.",
224224
strna(message),
225225
pid) < 0)
@@ -235,7 +235,7 @@ static int process_one_password_file(const char *filename) {
235235

236236
if (access(socket_name, W_OK) < 0) {
237237
if (arg_action == ACTION_QUERY)
238-
log_info("Not querying '%s' (PID %u), lacking privileges.", strna(message), pid);
238+
log_info("Not querying '%s' (PID " PID_FMT "), lacking privileges.", strna(message), pid);
239239

240240
return 0;
241241
}

0 commit comments

Comments
 (0)