chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
timesysnc: reword network watching messages, and move resolver errors to debug
[elogind.git]
/
src
/
shared
/
mkdir.c
diff --git
a/src/shared/mkdir.c
b/src/shared/mkdir.c
index 43c6ea6d4a1616bc85775fb48418be8c52fbc6e8..ba083d6d673a58e2b1cb422651026bd6735f176f 100644
(file)
--- a/
src/shared/mkdir.c
+++ b/
src/shared/mkdir.c
@@
-41,9
+41,11
@@
int mkdir_safe_internal(const char *path, mode_t mode, uid_t uid, gid_t gid, mkd
if (lstat(path, &st) < 0)
return -errno;
if (lstat(path, &st) < 0)
return -errno;
- if ((st.st_mode & 0777) != mode ||
- st.st_uid != uid ||
- st.st_gid != gid ||
+ if ((st.st_mode & 0007) > (mode & 0007) ||
+ (st.st_mode & 0070) > (mode & 0070) ||
+ (st.st_mode & 0700) > (mode & 0700) ||
+ (uid != (uid_t) -1 && st.st_uid != uid) ||
+ (gid != (gid_t) -1 && st.st_gid != gid) ||
!S_ISDIR(st.st_mode)) {
errno = EEXIST;
return -errno;
!S_ISDIR(st.st_mode)) {
errno = EEXIST;
return -errno;
@@
-56,7
+58,7
@@
int mkdir_safe(const char *path, mode_t mode, uid_t uid, gid_t gid) {
return mkdir_safe_internal(path, mode, uid, gid, mkdir);
}
return mkdir_safe_internal(path, mode, uid, gid, mkdir);
}
-
static
int is_dir(const char* path) {
+int is_dir(const char* path) {
struct stat st;
if (stat(path, &st) < 0)
struct stat st;
if (stat(path, &st) < 0)