diff options
author | Drew DeVault <sir@cmpwn.com> | 2017-03-10 23:41:24 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2017-03-10 23:41:24 -0500 |
commit | 9aed9d93596cdc72e305338d82ccc0dcaf85c6e2 (patch) | |
tree | b5a3db4994970b2d0033e717771b24a92503ddac /sway/config.c | |
parent | 74d4f1bec9a70bc800ecd7b15c9c6c0d7a5ce918 (diff) |
UnGNUify the codebase
Diffstat (limited to 'sway/config.c')
-rw-r--r-- | sway/config.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/sway/config.c b/sway/config.c index 98351b1e..f46ce882 100644 --- a/sway/config.c +++ b/sway/config.c @@ -1,3 +1,5 @@ +#define _POSIX_C_SOURCE 200809L +#define _XOPEN_SOURCE 500 #include <stdio.h> #include <stdbool.h> #include <stdlib.h> @@ -12,6 +14,7 @@ #include <limits.h> #include <float.h> #include <dirent.h> +#include <strings.h> #include "wayland-desktop-shell-server-protocol.h" #include "sway/commands.h" #include "sway/config.h" @@ -528,11 +531,13 @@ bool load_main_config(const char *file, bool is_active) { list_t *secconfigs = create_list(); char *base = SYSCONFDIR "/sway/security.d/"; struct dirent *ent = readdir(dir); + struct stat s; while (ent != NULL) { - if (ent->d_type == DT_REG) { - char *_path = malloc(strlen(ent->d_name) + strlen(base) + 1); - strcpy(_path, base); - strcat(_path, ent->d_name); + char *_path = malloc(strlen(ent->d_name) + strlen(base) + 1); + strcpy(_path, base); + strcat(_path, ent->d_name); + lstat(_path, &s); + if (S_ISREG(s.st_mode)) { list_add(secconfigs, _path); } ent = readdir(dir); @@ -542,7 +547,6 @@ bool load_main_config(const char *file, bool is_active) { list_qsort(secconfigs, qstrcmp); for (int i = 0; i < secconfigs->length; ++i) { char *_path = secconfigs->items[i]; - struct stat s; if (stat(_path, &s) || s.st_uid != 0 || s.st_gid != 0 || (s.st_mode & 0777) != 0644) { sway_log(L_ERROR, "Refusing to load %s - it must be owned by root and mode 644", _path); success = false; |