UnGNUify the codebase

This commit is contained in:
Drew DeVault 2017-03-10 23:41:24 -05:00
parent 74d4f1bec9
commit 9aed9d9359
84 changed files with 123 additions and 33 deletions

View file

@ -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;