diff --git a/man/systemd-validatefs@.service.xml b/man/systemd-validatefs@.service.xml index 397bb0d669..f0c7aabc6e 100644 --- a/man/systemd-validatefs@.service.xml +++ b/man/systemd-validatefs@.service.xml @@ -84,7 +84,7 @@ Takes an absolute path or the special string auto. The specified - path if removed as prefix from the specified mount point argument before the validation. If set to + path is removed as prefix from the specified mount point argument before the validation. If set to auto defaults to unspecified on the host and /sysroot/ when run in initrd context, in order to validate the mount constraint data relative to the future file system root. diff --git a/src/basic/xattr-util.c b/src/basic/xattr-util.c index f958e480ff..deacc1025a 100644 --- a/src/basic/xattr-util.c +++ b/src/basic/xattr-util.c @@ -192,10 +192,11 @@ int getxattr_at_bool(int fd, const char *path, const char *name, int at_flags) { } int getxattr_at_strv(int fd, const char *path, const char *name, int at_flags, char ***ret_strv) { + _cleanup_free_ char *nulstr = NULL; + size_t nulstr_size; int r; - _cleanup_free_ char *nulstr = NULL; - size_t nulstr_size = 0; + assert(ret_strv); r = getxattr_at_malloc(fd, path, name, at_flags, &nulstr, &nulstr_size); if (r < 0) @@ -343,11 +344,13 @@ int xsetxattr_full( return 0; } -int xsetxattr_strv(int fd, const char *path, int at_flags, const char *name, char * const* l) { +int xsetxattr_strv(int fd, const char *path, int at_flags, const char *name, char * const *l) { + _cleanup_free_ char *nulstr = NULL; + size_t size; int r; - _cleanup_free_ char *nulstr = NULL; - size_t size = 0; + assert(name); + r = strv_make_nulstr(l, &nulstr, &size); if (r < 0) return r; diff --git a/src/basic/xattr-util.h b/src/basic/xattr-util.h index 02293e5007..773e736cfb 100644 --- a/src/basic/xattr-util.h +++ b/src/basic/xattr-util.h @@ -50,7 +50,7 @@ static inline int xsetxattr( return xsetxattr_full(fd, path, at_flags, name, value, SIZE_MAX, 0); } -int xsetxattr_strv(int fd, const char *path, int at_flags, const char *name, char *const*l); +int xsetxattr_strv(int fd, const char *path, int at_flags, const char *name, char * const *l); int xremovexattr(int fd, const char *path, int at_flags, const char *name); diff --git a/src/validatefs/validatefs.c b/src/validatefs/validatefs.c index fb516744d3..2499a7e20f 100644 --- a/src/validatefs/validatefs.c +++ b/src/validatefs/validatefs.c @@ -33,7 +33,7 @@ static int help(void) { return log_oom(); printf("%1$s [OPTIONS...] /path/to/mountpoint\n" - "\n%3$sCheck file system validation constraints.%4$s\n" + "\n%3$sCheck file system validation constraints.%4$s\n\n" " -h --help Show this help and exit\n" " --version Print version string and exit\n" " --root=PATH|auto Operate relative to the specified path\n" @@ -136,7 +136,7 @@ static int validate_fields_read(int fd, ValidateFields *ret) { assert(ret); _cleanup_free_ char *t = NULL; - r = getxattr_at_malloc(fd, /* path= */ NULL, "user.validatefs.gpt_type_uuid", AT_EMPTY_PATH, &t, /* ret_size= */ NULL); + r = fgetxattr_malloc(fd, "user.validatefs.gpt_type_uuid", &t, /* ret_size= */ NULL); if (r < 0) { if (r != -ENODATA && !ERRNO_IS_NOT_SUPPORTED(r)) return log_error_errno(r, "Failed to read 'user.validatefs.gpt_type_uuid' xattr: %m"); @@ -146,7 +146,7 @@ static int validate_fields_read(int fd, ValidateFields *ret) { return log_error_errno(r, "Failed to parse 'user.validatefs.gpt_type_uuid' xattr: %s", t); } - r = getxattr_at_malloc(fd, /* path= */ NULL, "user.validatefs.gpt_label", AT_EMPTY_PATH, &f.gpt_label, /* ret_size= */ NULL); + r = fgetxattr_malloc(fd, "user.validatefs.gpt_label", &f.gpt_label, /* ret_size= */ NULL); if (r < 0) { if (r != -ENODATA && !ERRNO_IS_NOT_SUPPORTED(r)) return log_error_errno(r, "Failed to read 'user.validatefs.gpt_label' xattr: %m"); @@ -318,14 +318,10 @@ static int run(int argc, char *argv[]) { return r; if (r == 0) { log_info("File system '%s' has no validation constraints set, not validating.", resolved); - return EXIT_SUCCESS; + return 0; } - r = validate_fields_check(target_fd, resolved, &f); - if (r < 0) - return r; - - return EXIT_SUCCESS; + return validate_fields_check(target_fd, resolved, &f); } DEFINE_MAIN_FUNCTION(run); diff --git a/units/systemd-validatefs@.service.in b/units/systemd-validatefs@.service.in index f94482f982..d0a0f5f9b0 100644 --- a/units/systemd-validatefs@.service.in +++ b/units/systemd-validatefs@.service.in @@ -15,9 +15,9 @@ BindsTo=%i.mount Conflicts=shutdown.target After=%i.mount Before=shutdown.target systemd-pcrfs@%i.service systemd-quotacheck@%i.service systemd-growfs@%i.service +FailureAction=reboot-immediate [Service] Type=oneshot RemainAfterExit=yes ExecStart={{LIBEXECDIR}}/systemd-validatefs --root=auto %f -FailureAction=reboot-immediate