X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=udev_utils_file.c;h=19668b936f7cface508af6dd9f4825240f8bddd3;hb=4278ab015d76876f61821b293df07e0c3746bfd5;hp=0ceefe17200c68bab8e08a20b0d3be2dc60834ee;hpb=254d6d3ca2188a396706b363d0840431d360fbd9;p=elogind.git diff --git a/udev_utils_file.c b/udev_utils_file.c index 0ceefe172..19668b936 100644 --- a/udev_utils_file.c +++ b/udev_utils_file.c @@ -29,12 +29,14 @@ #include #include "udev.h" +#include "udev_selinux.h" int create_path(const char *path) { char p[PATH_SIZE]; char *pos; struct stat stats; + int ret; strlcpy(p, path, sizeof(p)); pos = strrchr(p, '/'); @@ -53,8 +55,12 @@ int create_path(const char *path) return -1; dbg("mkdir '%s'", p); - if (mkdir(p, 0755) == 0) + selinux_setfscreatecon(p, NULL, S_IFDIR|0755); + ret = mkdir(p, 0755); + selinux_resetfscreatecon(); + if (ret == 0) return 0; + if (errno == EEXIST) if (stat(p, &stats) == 0 && (stats.st_mode & S_IFMT) == S_IFDIR) return 0;