From: Mike Yuan Date: Fri, 14 Feb 2025 22:41:58 +0000 (+0100) Subject: mount-tool: accept fstab-style identifiers for remote what too X-Git-Tag: v258-rc1~1201^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=36d4437c5ba37bcdb9d1bcf5cb36c99bfe7a31a7;p=thirdparty%2Fsystemd.git mount-tool: accept fstab-style identifiers for remote what too fstab-style identifiers have stable translation to absolute paths in the file system, hence it makes no sense to reject them even for remote mounts. --- diff --git a/src/mount/mount-tool.c b/src/mount/mount-tool.c index df3394bb2c3..aa6fd27b03c 100644 --- a/src/mount/mount-tool.c +++ b/src/mount/mount-tool.c @@ -464,27 +464,31 @@ static int parse_argv(int argc, char *argv[]) { arg_mount_what = strdup(argv[optind]); if (!arg_mount_what) return log_oom(); - - } else if (arg_transport == BUS_TRANSPORT_LOCAL && arg_canonicalize) { - _cleanup_free_ char *u = NULL; - - u = fstab_node_to_udev_node(argv[optind]); - if (!u) - return log_oom(); - - r = chase(u, /* root= */ NULL, /* flags= */ 0, &arg_mount_what, /* ret_fd= */ NULL); - if (r < 0) - return log_error_errno(r, "Failed to make path %s absolute: %m", u); - } else { - if (!path_is_absolute(argv[optind])) - return log_error_errno(SYNTHETIC_ERRNO(EINVAL), - "Path must be absolute when operating remotely or when canonicalization is turned off: %s", - argv[optind]); - - r = path_simplify_alloc(argv[optind], &arg_mount_what); - if (r < 0) - return log_error_errno(r, "Failed to simplify path: %m"); + _cleanup_free_ char *u = NULL; + const char *p = argv[optind]; + + if (arg_canonicalize) { + u = fstab_node_to_udev_node(p); + if (!u) + return log_oom(); + p = u; + } + + if (arg_transport == BUS_TRANSPORT_LOCAL && arg_canonicalize) { + r = chase(p, /* root= */ NULL, /* flags= */ 0, &arg_mount_what, /* ret_fd= */ NULL); + if (r < 0) + return log_error_errno(r, "Failed to chase path '%s': %m", p); + } else { + if (!path_is_absolute(p)) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Path must be absolute when operating remotely or when canonicalization is turned off: %s", + p); + + r = path_simplify_alloc(p, &arg_mount_what); + if (r < 0) + return log_oom(); + } } }