]> err.no Git - systemd/commitdiff
tmpfiles: ensure we do no follow symlinks when cleaning up dirs
authorLennart Poettering <lennart@poettering.net>
Tue, 28 Dec 2010 13:20:21 +0000 (14:20 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 28 Dec 2010 13:21:28 +0000 (14:21 +0100)
Patch suggested by Miloslav Trmac.

src/tmpfiles.c
src/util.c
src/util.h

index 120236c5cc07490f03724b694e77e831f9987f92..1234cbf3480c9c1bc190dfdfe3c3a768cba0e66f 100644 (file)
@@ -149,7 +149,7 @@ static int dir_cleanup(
                                 DIR *sub_dir;
                                 int q;
 
-                                sub_dir = xopendirat(dirfd(d), dent->d_name);
+                                sub_dir = xopendirat(dirfd(d), dent->d_name, O_NOFOLLOW);
                                 if (sub_dir == NULL) {
                                         if (errno != ENOENT) {
                                                 log_error("opendir(%s/%s) failed: %m", p, dent->d_name);
index d769d60986f136d628d0eb0cfac21c3f9c478a35..60af4fe60d4dfce08e66a92632e30dbada029d3f 100644 (file)
@@ -3402,8 +3402,8 @@ bool null_or_empty(struct stat *st) {
         return false;
 }
 
-DIR *xopendirat(int fd, const char *name) {
-        return fdopendir(openat(fd, name, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC));
+DIR *xopendirat(int fd, const char *name, int flags) {
+        return fdopendir(openat(fd, name, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|flags));
 }
 
 int signal_from_string_try_harder(const char *s) {
index 7e1eacc6878a342aa984941304c4e7919becd2be..1e4eedfbce54ffc269f62fb9283cbeadd2553a94 100644 (file)
@@ -363,7 +363,7 @@ _noreturn_ void freeze(void);
 
 bool null_or_empty(struct stat *st);
 
-DIR *xopendirat(int dirfd, const char *name);
+DIR *xopendirat(int dirfd, const char *name, int flags);
 
 void dual_timestamp_serialize(FILE *f, const char *name, dual_timestamp *t);
 void dual_timestamp_deserialize(const char *value, dual_timestamp *t);