chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
selinux: set context for real file name not the temp name
[elogind.git]
/
udev_utils_file.c
diff --git
a/udev_utils_file.c
b/udev_utils_file.c
index 9bf60696d94ed74d9ddd79d5b854e918154dc1c2..0ceefe17200c68bab8e08a20b0d3be2dc60834ee 100644
(file)
--- a/
udev_utils_file.c
+++ b/
udev_utils_file.c
@@
-36,25
+36,29
@@
int create_path(const char *path)
char *pos;
struct stat stats;
char *pos;
struct stat stats;
- str
cpy (p, path
);
+ str
lcpy(p, path, sizeof(p)
);
pos = strrchr(p, '/');
if (pos == p || pos == NULL)
return 0;
while (pos[-1] == '/')
pos--;
pos = strrchr(p, '/');
if (pos == p || pos == NULL)
return 0;
while (pos[-1] == '/')
pos--;
-
pos[0] = '\0';
pos[0] = '\0';
- dbg("stat '%s'
\n
", p);
+ dbg("stat '%s'", p);
if (stat(p, &stats) == 0 && (stats.st_mode & S_IFMT) == S_IFDIR)
return 0;
if (stat(p, &stats) == 0 && (stats.st_mode & S_IFMT) == S_IFDIR)
return 0;
- if (create_path
(p) != 0)
+ if (create_path(p) != 0)
return -1;
return -1;
- dbg("mkdir '%s'\n", p);
- return mkdir(p, 0755);
+ dbg("mkdir '%s'", p);
+ if (mkdir(p, 0755) == 0)
+ return 0;
+ if (errno == EEXIST)
+ if (stat(p, &stats) == 0 && (stats.st_mode & S_IFMT) == S_IFDIR)
+ return 0;
+ return -1;
}
int delete_path(const char *path)
}
int delete_path(const char *path)
@@
-65,6
+69,9
@@
int delete_path(const char *path)
strcpy (p, path);
pos = strrchr(p, '/');
strcpy (p, path);
pos = strrchr(p, '/');
+ if (pos == p || pos == NULL)
+ return 0;
+
while (1) {
*pos = '\0';
pos = strrchr(p, '/');
while (1) {
*pos = '\0';
pos = strrchr(p, '/');