The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=5f5a1657a921c3f7a84ef326c2116d986409e161
commit 5f5a1657a921c3f7a84ef326c2116d986409e161 Author: Baptiste Daroussin <[email protected]> AuthorDate: 2026-09-04 11:43:22 +0000 Commit: Baptiste Daroussin <[email protected]> CommitDate: 2026-09-04 14:28:46 +0000 pw: cleanup No functional change intended. MFC After: 1 week --- usr.sbin/pw/pw_user.c | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c index e2b84b2a83d3..269344232912 100644 --- a/usr.sbin/pw/pw_user.c +++ b/usr.sbin/pw/pw_user.c @@ -681,33 +681,32 @@ static void rmat(uid_t uid) { DIR *d = opendir("/var/at/jobs"); + struct dirent *e; + const char *argv[] = { "/usr/sbin/atrm", NULL, NULL }; - if (d != NULL) { - struct dirent *e; - - while ((e = readdir(d)) != NULL) { - struct stat st; - pid_t pid; - - if (strncmp(e->d_name, ".lock", 5) != 0 && - stat(e->d_name, &st) == 0 && - !S_ISDIR(st.st_mode) && - st.st_uid == uid) { - const char *argv[] = { - "/usr/sbin/atrm", - e->d_name, - NULL - }; - if (posix_spawn(&pid, argv[0], NULL, NULL, - (char *const *) argv, environ)) { - warn("Failed to execute '%s %s'", - argv[0], argv[1]); - } else - (void) waitpid(pid, NULL, 0); - } + if (d == NULL) + return; + + while ((e = readdir(d)) != NULL) { + struct stat st; + pid_t pid; + + if (strncmp(e->d_name, ".lock", 5) == 0) + continue; + if (stat(e->d_name, &st) != 0) + continue; + if (S_ISDIR(st.st_mode) || st.st_uid != uid) + continue; + argv[1] = e->d_name; + if (posix_spawn(&pid, argv[0], NULL, NULL, + (char *const *) argv, environ)) { + warn("Failed to execute '%s %s'", + argv[0], argv[1]); + } else + (void) waitpid(pid, NULL, 0); } - closedir(d); } + closedir(d); } int
