From 9aed9d93596cdc72e305338d82ccc0dcaf85c6e2 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 10 Mar 2017 23:41:24 -0500 Subject: UnGNUify the codebase --- sway/config.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'sway/config.c') 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 #include #include @@ -12,6 +14,7 @@ #include #include #include +#include #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; -- cgit v1.2.3-54-g00ecf