Skip to content

Commit cdc42d8

Browse files
committed
logsrvd_queue_scan: outgoing files are now stored by uuid
1 parent 8320381 commit cdc42d8

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

logsrvd/logsrvd.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@
4646
/* Shutdown timeout (in seconds) in case client connections time out. */
4747
#define SHUTDOWN_TIMEO 10
4848

49-
/* Template for mkstemp(3) when creating temporary files. */
50-
#define RELAY_TEMPLATE "relay.XXXXXXXX"
51-
5249
/*
5350
* Connection status.
5451
* In the RUNNING state we expect I/O log buffers.

logsrvd/logsrvd_queue.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* SPDX-License-Identifier: ISC
33
*
4-
* Copyright (c) 2021 Todd C. Miller <[email protected]>
4+
* Copyright (c) 2021-2025 Todd C. Miller <[email protected]>
55
*
66
* Permission to use, copy, modify, and distribute this software for any
77
* purpose with or without fee is hereby granted, provided that the above
@@ -202,9 +202,9 @@ logsrvd_queue_insert(struct connection_closure *closure)
202202
bool
203203
logsrvd_queue_scan(struct sudo_event_base *evbase)
204204
{
205+
const char uuid_template[] = "123e4567-e89b-12d3-a456-426655440000";
205206
char path[PATH_MAX];
206207
struct dirent *dent;
207-
size_t prefix_len;
208208
int dirlen;
209209
DIR *dirp;
210210
debug_decl(logsrvd_queue_scan, SUDO_DEBUG_UTIL);
@@ -214,28 +214,26 @@ logsrvd_queue_scan(struct sudo_event_base *evbase)
214214
debug_return_bool(true);
215215

216216
dirlen = snprintf(path, sizeof(path), "%s/outgoing/%s",
217-
logsrvd_conf_relay_dir(), RELAY_TEMPLATE);
217+
logsrvd_conf_relay_dir(), uuid_template);
218218
if (dirlen >= ssizeof(path)) {
219219
errno = ENAMETOOLONG;
220-
sudo_warn("%s/outgoing/%s", logsrvd_conf_relay_dir(), RELAY_TEMPLATE);
220+
sudo_warn("%s/outgoing/%s", logsrvd_conf_relay_dir(), uuid_template);
221221
debug_return_bool(false);
222222
}
223-
dirlen -= (int)sizeof(RELAY_TEMPLATE) - 1;
223+
dirlen -= (int)sizeof(uuid_template) - 1;
224224
path[dirlen] = '\0';
225225

226226
dirp = opendir(path);
227227
if (dirp == NULL) {
228228
sudo_warn("opendir %s", path);
229229
debug_return_bool(false);
230230
}
231-
prefix_len = strcspn(RELAY_TEMPLATE, "X");
232231
while ((dent = readdir(dirp)) != NULL) {
232+
unsigned char uuid[16];
233233
struct outgoing_journal *oj;
234234

235-
/* Skip anything that is not a relay temp file. */
236-
if (NAMLEN(dent) != sizeof(RELAY_TEMPLATE) - 1)
237-
continue;
238-
if (strncmp(dent->d_name, RELAY_TEMPLATE, prefix_len) != 0)
235+
/* Skip anything that is not a uuid. */
236+
if (sudo_uuid_from_string(dent->d_name, uuid) != 0)
239237
continue;
240238

241239
/* Add to queue. */

0 commit comments

Comments
 (0)