X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Ftmpfiles%2Ftmpfiles.c;h=494fd1ac212e4e81e030e0b1b7f41610cfc7508e;hb=8457fea851912fcbc2f9ef3c2730701317bf081c;hp=55a6a7bb54505528744983251d80ae5af7e8f71e;hpb=a4135d32340a5a6cca7a10cc797cafda5451f982;p=elogind.git diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 55a6a7bb5..494fd1ac2 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -174,7 +174,6 @@ static bool takes_ownership(ItemType t) { CREATE_CHAR_DEVICE, CREATE_BLOCK_DEVICE, COPY_FILES, - WRITE_FILE, IGNORE_PATH, IGNORE_DIRECTORY_PATH, @@ -314,16 +313,16 @@ static DIR* xopendirat_nomod(int dirfd, const char *path) { DIR *dir; dir = xopendirat(dirfd, path, O_NOFOLLOW|O_NOATIME); - if (!dir) { - log_debug_errno(errno, "Cannot open %sdirectory \"%s\": %m", - dirfd == AT_FDCWD ? "" : "sub", path); - if (errno == EPERM) { - dir = xopendirat(dirfd, path, O_NOFOLLOW); - if (!dir) - log_debug_errno(errno, "Cannot open %sdirectory \"%s\": %m", - dirfd == AT_FDCWD ? "" : "sub", path); - } - } + if (dir) + return dir; + + log_debug_errno(errno, "Cannot open %sdirectory \"%s\": %m", dirfd == AT_FDCWD ? "" : "sub", path); + if (errno != EPERM) + return NULL; + + dir = xopendirat(dirfd, path, O_NOFOLLOW); + if (!dir) + log_debug_errno(errno, "Cannot open %sdirectory \"%s\": %m", dirfd == AT_FDCWD ? "" : "sub", path); return dir; } @@ -621,7 +620,6 @@ static int path_set_perms(Item *i, const char *path) { } static int get_xattrs_from_arg(Item *i) { - char *xattr; const char *p; int r; @@ -630,35 +628,33 @@ static int get_xattrs_from_arg(Item *i) { p = i->argument; - while ((r = unquote_first_word(&p, &xattr, false)) > 0) { - _cleanup_free_ char *tmp = NULL, *name = NULL, - *value = NULL, *value2 = NULL, *_xattr = xattr; + for (;;) { + _cleanup_free_ char *name = NULL, *value = NULL, *xattr = NULL; + + r = unquote_first_word(&p, &xattr, UNQUOTE_CUNESCAPE); + if (r < 0) + log_warning_errno(r, "Failed to parse extended attribute, ignoring: %s", p); + if (r <= 0) + break; r = split_pair(xattr, "=", &name, &value); if (r < 0) { - log_warning("Illegal xattr found: \"%s\" - ignoring.", xattr); + log_warning_errno(r, "Failed to parse extended attribute, ignoring: %s", xattr); continue; } - if (strempty(name) || strempty(value)) { - log_warning("Malformed xattr found: \"%s\" - ignoring.", xattr); + if (isempty(name) || isempty(value)) { + log_warning("Malformed xattr found, ignoring: %s", xattr); continue; } - tmp = unquote(value, "\""); - if (!tmp) + if (strv_push_pair(&i->xattrs, name, value) < 0) return log_oom(); - value2 = cunescape(tmp); - if (!value2) - return log_oom(); - - if (strv_push_pair(&i->xattrs, name, value2) < 0) - return log_oom(); - name = value2 = NULL; + name = value = NULL; } - return r; + return 0; } static int path_set_xattrs(Item *i, const char *path) { @@ -691,8 +687,7 @@ static int get_acls_from_arg(Item *item) { * afterwards, so the mask can be added now if necessary. */ r = parse_acl(item->argument, &item->acl_access, &item->acl_default, !item->force); if (r < 0) - log_warning_errno(r, "Failed to parse ACL \"%s\": %m. Ignoring", - item->argument); + log_warning_errno(r, "Failed to parse ACL \"%s\": %m. Ignoring", item->argument); #else log_warning_errno(ENOSYS, "ACLs are not supported. Ignoring"); #endif @@ -919,8 +914,7 @@ static int write_one_file(Item *i, const char *path) { if (i->argument) { _cleanup_free_ char *unescaped; - log_debug("%s to \"%s\".", - i->type == CREATE_FILE ? "Appending" : "Writing", path); + log_debug("%s to \"%s\".", i->type == CREATE_FILE ? "Appending" : "Writing", path); unescaped = cunescape(i->argument); if (!unescaped) @@ -1652,15 +1646,16 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) { assert(line >= 1); assert(buffer); - r = unquote_many_words(&buffer, - &action, - &path, - &mode, - &user, - &group, - &age, - &i.argument, - NULL); + r = unquote_many_words( + &buffer, + 0, + &action, + &path, + &mode, + &user, + &group, + &age, + NULL); if (r < 0) return log_error_errno(r, "[%s:%u] Failed to parse line: %m", fname, line); else if (r < 2) { @@ -1668,6 +1663,12 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) { return -EIO; } + if (!isempty(buffer)) { + i.argument = strdup(buffer); + if (!i.argument) + return log_oom(); + } + if (isempty(action)) { log_error("[%s:%u] Command too short '%s'.", fname, line, action); return -EINVAL;