fs-util: make CHASE_WARN effective with CHASE_NO_AUTOFS

This has the side effect to upgrade the log level at which the log is emitted
from debug to warning.

This might be better since after all we didn't apply a tmpfiles.d/ rule and
that actually might end up being problematic eventually.
This commit is contained in:
Franck Bui 2018-11-30 15:43:13 +01:00
parent b85ee2ec95
commit 145b8d0f68
2 changed files with 22 additions and 4 deletions

View File

@ -659,6 +659,19 @@ static int log_unsafe_transition(int a, int b, const char *path, unsigned flags)
n1, special_glyph(ARROW), n2, path);
}
static int log_autofs_mount_point(int fd, const char *path, unsigned flags) {
_cleanup_free_ char *n1 = NULL;
if (!FLAGS_SET(flags, CHASE_WARN))
return -EREMOTE;
(void) fd_get_path(fd, &n1);
return log_warning_errno(SYNTHETIC_ERRNO(EREMOTE),
"Detected autofs mount point %s during canonicalization of %s.",
n1, path);
}
int chase_symlinks(const char *path, const char *original_root, unsigned flags, char **ret) {
_cleanup_free_ char *buffer = NULL, *done = NULL, *root = NULL;
_cleanup_close_ int fd = -1;
@ -723,6 +736,10 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags,
* unprivileged to privileged files or directories. In such cases the return value is -ENOLINK. If
* CHASE_WARN is also set a warning describing the unsafe transition is emitted.
*
* 5. With CHASE_NO_AUTOFS: in this case if an autofs mount point is encountered, the path normalization is
* aborted and -EREMOTE is returned. If CHASE_WARN is also set a warning showing the path of the mount point
* is emitted.
*
* */
/* A root directory of "/" or "" is identical to none */
@ -885,7 +902,7 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags,
if ((flags & CHASE_NO_AUTOFS) &&
fd_is_fs_type(child, AUTOFS_SUPER_MAGIC) > 0)
return -EREMOTE;
return log_autofs_mount_point(child, path, flags);
if (S_ISLNK(st.st_mode) && !((flags & CHASE_NOFOLLOW) && isempty(todo))) {
char *joined;

View File

@ -2261,11 +2261,12 @@ static int process_item(Item *i, OperationMask operation) {
i->done |= operation;
r = chase_symlinks(i->path, NULL, CHASE_NO_AUTOFS, NULL);
r = chase_symlinks(i->path, NULL, CHASE_NO_AUTOFS|CHASE_WARN, NULL);
if (r == -EREMOTE) {
log_debug_errno(r, "Item '%s' is below autofs, skipping.", i->path);
log_notice_errno(r, "Skipping %s", i->path);
return 0;
} else if (r < 0)
}
if (r < 0)
log_debug_errno(r, "Failed to determine whether '%s' is below autofs, ignoring: %m", i->path);
r = FLAGS_SET(operation, OPERATION_CREATE) ? create_item(i) : 0;