mirror of
https://github.com/systemd/systemd.git
synced 2025-03-11 20:58:27 +03:00
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.
This commit is contained in:
parent
70b1f3e0a2
commit
36d4437c5b
@ -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]);
|
||||
_cleanup_free_ char *u = NULL;
|
||||
const char *p = argv[optind];
|
||||
|
||||
r = path_simplify_alloc(argv[optind], &arg_mount_what);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to simplify path: %m");
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user