Skip to content

Commit 8d22406

Browse files
committed
error out if no matching configuration files are found in the configuration directory
1 parent cac56ea commit 8d22406

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

doas.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ static void
210210
parseconfdir(const char *dirpath, int checkperms)
211211
{
212212
struct dirent **dirent_table;
213-
int i, dirent_count;
213+
int i, m, dirent_count;
214214
char pathbuf[PATH_MAX];
215215

216216
if (!isconfdir(dirpath))
@@ -222,7 +222,7 @@ parseconfdir(const char *dirpath, int checkperms)
222222
err(1, checkperms ? "doas is not enabled, %s" :
223223
"could not open config directory %s", dirpath);
224224

225-
for (i = 0; i < dirent_count; i++)
225+
for (i = 0, m = 0; i < dirent_count; i++)
226226
{
227227
struct stat sb;
228228
size_t pathlen;
@@ -244,9 +244,16 @@ parseconfdir(const char *dirpath, int checkperms)
244244
continue;
245245

246246
parseconfig(pathbuf, checkperms);
247+
m++;
247248
}
248249

249250
free(dirent_table);
251+
252+
if (!m) {
253+
fprintf(stderr, "doas is not enabled, %s: no matching configuration files found\n",
254+
dirpath);
255+
exit(1);
256+
}
250257
}
251258
#endif
252259

0 commit comments

Comments
 (0)