summaryrefslogtreecommitdiff
path: root/src/tmpfiles/tmpfiles.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-06-10 22:48:56 +0200
committerLennart Poettering <lennart@poettering.net>2014-06-10 22:48:56 +0200
commit874f1947e33922f08c578696af5b628a0f67fec2 (patch)
tree9ce50f3d1106be80214fe4bce3199da1ebf0fbf7 /src/tmpfiles/tmpfiles.c
parent62be1c9aab241b5eeabe1503a75ff5779bfb6d5b (diff)
label: when clearing selinux context, don't mangle errno
Diffstat (limited to 'src/tmpfiles/tmpfiles.c')
-rw-r--r--src/tmpfiles/tmpfiles.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index 04b472da97..68f0a5cf78 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -462,20 +462,21 @@ static int item_set_perms(Item *i, const char *path) {
}
static int write_one_file(Item *i, const char *path) {
- int e, flags;
+ int flags;
int fd = -1;
struct stat st;
int r = 0;
+ assert(i);
+ assert(path);
+
flags = i->type == CREATE_FILE ? O_CREAT|O_APPEND :
i->type == TRUNCATE_FILE ? O_CREAT|O_TRUNC : 0;
RUN_WITH_UMASK(0) {
label_context_set(path, S_IFREG);
fd = open(path, flags|O_NDELAY|O_CLOEXEC|O_WRONLY|O_NOCTTY|O_NOFOLLOW, i->mode);
- e = errno;
label_context_clear();
- errno = e;
}
if (fd < 0) {
@@ -636,7 +637,6 @@ static int glob_item(Item *i, int (*action)(Item *, const char *)) {
}
static int create_item(Item *i) {
- int e;
struct stat st;
int r = 0;
@@ -732,9 +732,7 @@ static int create_item(Item *i) {
label_context_set(i->path, S_IFLNK);
r = symlink(i->argument, i->path);
- e = errno;
label_context_clear();
- errno = e;
if (r < 0 && errno != EEXIST) {
log_error("symlink(%s, %s) failed: %m", i->argument, i->path);
@@ -774,9 +772,7 @@ static int create_item(Item *i) {
RUN_WITH_UMASK(0000) {
label_context_set(i->path, file_type);
r = mknod(i->path, i->mode | file_type, i->major_minor);
- e = errno;
label_context_clear();
- errno = e;
}
if (r < 0 && errno != EEXIST) {