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)
202202bool
203203logsrvd_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