aboutsummaryrefslogtreecommitdiffstats
path: root/sway/config.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2017-03-10 23:41:24 -0500
committerLibravatar Drew DeVault <sir@cmpwn.com>2017-03-10 23:41:24 -0500
commit9aed9d93596cdc72e305338d82ccc0dcaf85c6e2 (patch)
treeb5a3db4994970b2d0033e717771b24a92503ddac /sway/config.c
parentFurther indentation corrections (diff)
downloadsway-9aed9d93596cdc72e305338d82ccc0dcaf85c6e2.tar.gz
sway-9aed9d93596cdc72e305338d82ccc0dcaf85c6e2.tar.zst
sway-9aed9d93596cdc72e305338d82ccc0dcaf85c6e2.zip
UnGNUify the codebase
Diffstat (limited to 'sway/config.c')
-rw-r--r--sway/config.c14
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 @@
1#define _POSIX_C_SOURCE 200809L
2#define _XOPEN_SOURCE 500
1#include <stdio.h> 3#include <stdio.h>
2#include <stdbool.h> 4#include <stdbool.h>
3#include <stdlib.h> 5#include <stdlib.h>
@@ -12,6 +14,7 @@
12#include <limits.h> 14#include <limits.h>
13#include <float.h> 15#include <float.h>
14#include <dirent.h> 16#include <dirent.h>
17#include <strings.h>
15#include "wayland-desktop-shell-server-protocol.h" 18#include "wayland-desktop-shell-server-protocol.h"
16#include "sway/commands.h" 19#include "sway/commands.h"
17#include "sway/config.h" 20#include "sway/config.h"
@@ -528,11 +531,13 @@ bool load_main_config(const char *file, bool is_active) {
528 list_t *secconfigs = create_list(); 531 list_t *secconfigs = create_list();
529 char *base = SYSCONFDIR "/sway/security.d/"; 532 char *base = SYSCONFDIR "/sway/security.d/";
530 struct dirent *ent = readdir(dir); 533 struct dirent *ent = readdir(dir);
534 struct stat s;
531 while (ent != NULL) { 535 while (ent != NULL) {
532 if (ent->d_type == DT_REG) { 536 char *_path = malloc(strlen(ent->d_name) + strlen(base) + 1);
533 char *_path = malloc(strlen(ent->d_name) + strlen(base) + 1); 537 strcpy(_path, base);
534 strcpy(_path, base); 538 strcat(_path, ent->d_name);
535 strcat(_path, ent->d_name); 539 lstat(_path, &s);
540 if (S_ISREG(s.st_mode)) {
536 list_add(secconfigs, _path); 541 list_add(secconfigs, _path);
537 } 542 }
538 ent = readdir(dir); 543 ent = readdir(dir);
@@ -542,7 +547,6 @@ bool load_main_config(const char *file, bool is_active) {
542 list_qsort(secconfigs, qstrcmp); 547 list_qsort(secconfigs, qstrcmp);
543 for (int i = 0; i < secconfigs->length; ++i) { 548 for (int i = 0; i < secconfigs->length; ++i) {
544 char *_path = secconfigs->items[i]; 549 char *_path = secconfigs->items[i];
545 struct stat s;
546 if (stat(_path, &s) || s.st_uid != 0 || s.st_gid != 0 || (s.st_mode & 0777) != 0644) { 550 if (stat(_path, &s) || s.st_uid != 0 || s.st_gid != 0 || (s.st_mode & 0777) != 0644) {
547 sway_log(L_ERROR, "Refusing to load %s - it must be owned by root and mode 644", _path); 551 sway_log(L_ERROR, "Refusing to load %s - it must be owned by root and mode 644", _path);
548 success = false; 552 success = false;