From 4ff361cc8611459388d7f75955bfe645f894f065 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sat, 8 May 2021 17:43:49 +0900 Subject: [PATCH] tree-wide: always drop unnecessary dot in path --- src/basic/cgroup-util.c | 10 ++++----- src/basic/fileio.c | 6 +++--- src/basic/fs-util.c | 2 +- src/basic/path-util.c | 18 ++++++++-------- src/basic/path-util.h | 6 +++--- src/basic/sysctl-util.c | 2 +- src/basic/tmpfile-util.c | 6 +++--- src/basic/unit-name.c | 2 +- src/basic/user-util.c | 8 +++---- src/cgls/cgls.c | 2 +- src/cgtop/cgtop.c | 2 +- src/core/automount.c | 2 +- src/core/cgroup.c | 2 +- src/core/dbus-execute.c | 4 ++-- src/core/dbus-path.c | 2 +- src/core/dbus-service.c | 2 +- src/core/dbus-socket.c | 2 +- src/core/dbus-unit.c | 2 +- src/core/execute.c | 4 ++-- src/core/load-fragment.c | 2 +- src/core/manager.c | 2 +- src/core/mount.c | 2 +- src/core/service.c | 2 +- src/core/socket.c | 2 +- src/core/swap.c | 2 +- src/core/unit.c | 2 +- src/delta/delta.c | 2 +- src/fstab-generator/fstab-generator.c | 2 +- src/libsystemd/sd-device/sd-device.c | 2 +- src/mount/mount-tool.c | 6 +++--- src/portable/portable.c | 4 ++-- src/shared/discover-image.c | 2 +- src/shared/install.c | 8 +++---- src/shared/mount-setup.c | 2 +- src/shared/parse-argument.c | 2 +- src/sysusers/sysusers.c | 4 ++-- src/test/test-path-util.c | 31 +++++++++++---------------- src/test/test-tmpfile-util.c | 16 +++++++------- src/test/test-unit-name.c | 2 +- src/tmpfiles/tmpfiles.c | 6 +++--- src/udev/test-udev-event.c | 2 +- 41 files changed, 91 insertions(+), 98 deletions(-) diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c index e39bfd9bc74..1ff6160dc88 100644 --- a/src/basic/cgroup-util.c +++ b/src/basic/cgroup-util.c @@ -506,7 +506,7 @@ int cg_get_path(const char *controller, const char *path, const char *suffix, ch if (!t) return -ENOMEM; - *fs = path_simplify(t, false); + *fs = path_simplify(t); return 0; } @@ -523,7 +523,7 @@ int cg_get_path(const char *controller, const char *path, const char *suffix, ch if (r < 0) return r; - path_simplify(*fs, false); + path_simplify(*fs); return 0; } @@ -919,7 +919,7 @@ int cg_split_spec(const char *spec, char **ret_controller, char **ret_path) { if (!path) return -ENOMEM; - path_simplify(path, false); + path_simplify(path); } } else { @@ -942,7 +942,7 @@ int cg_split_spec(const char *spec, char **ret_controller, char **ret_path) { !path_is_absolute(path)) return -EINVAL; - path_simplify(path, false); + path_simplify(path); } } else { @@ -979,7 +979,7 @@ int cg_mangle_path(const char *path, char **result) { if (!t) return -ENOMEM; - *result = path_simplify(t, false); + *result = path_simplify(t); return 0; } diff --git a/src/basic/fileio.c b/src/basic/fileio.c index 16f36359ebc..213f9cef7b6 100644 --- a/src/basic/fileio.c +++ b/src/basic/fileio.c @@ -972,7 +972,7 @@ static int search_and_fopen_internal( f = fopen(p, mode); if (f) { if (ret_path) - *ret_path = path_simplify(TAKE_PTR(p), true); + *ret_path = path_simplify(TAKE_PTR(p)); *ret = f; return 0; @@ -1013,7 +1013,7 @@ int search_and_fopen( if (!p) return -ENOMEM; - *ret_path = path_simplify(p, true); + *ret_path = path_simplify(p); } *ret = TAKE_PTR(f); @@ -1051,7 +1051,7 @@ int search_and_fopen_nulstr( if (!p) return -ENOMEM; - *ret_path = path_simplify(p, true); + *ret_path = path_simplify(p); } *ret = TAKE_PTR(f); diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c index e9fdb75a232..f2999ba077f 100644 --- a/src/basic/fs-util.c +++ b/src/basic/fs-util.c @@ -866,7 +866,7 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags, * anyway. Moreover at the end of this function after processing everything we'll always turn * the empty string back to "/". */ delete_trailing_chars(root, "/"); - path_simplify(root, true); + path_simplify(root); if (flags & CHASE_PREFIX_ROOT) { /* We don't support relative paths in combination with a root directory */ diff --git a/src/basic/path-util.c b/src/basic/path-util.c index 0be5af8da15..82d6a28257a 100644 --- a/src/basic/path-util.c +++ b/src/basic/path-util.c @@ -145,7 +145,7 @@ int path_make_relative(const char *from, const char *to, char **ret) { if (!result) return -ENOMEM; - path_simplify(result, true); + path_simplify(result); if (!path_is_valid(result)) return -EINVAL; @@ -191,7 +191,7 @@ int path_make_relative(const char *from, const char *to, char **ret) { strcpy(p, t); - path_simplify(result, true); + path_simplify(result); if (!path_is_valid(result)) return -EINVAL; @@ -227,7 +227,7 @@ int path_strv_make_absolute_cwd(char **l) { if (r < 0) return r; - path_simplify(t, false); + path_simplify(t); free_and_replace(*s, t); } @@ -327,7 +327,7 @@ char **path_strv_resolve_uniq(char **l, const char *root) { return strv_uniq(l); } -char *path_simplify(char *path, bool kill_dots) { +char *path_simplify(char *path) { char *f, *t; bool slash = false, ignore_slash = false, absolute; @@ -348,7 +348,7 @@ char *path_simplify(char *path, bool kill_dots) { absolute = path_is_absolute(path); f = path; - if (kill_dots && *f == '.' && IN_SET(f[1], 0, '/')) { + if (*f == '.' && IN_SET(f[1], 0, '/')) { ignore_slash = true; f++; } @@ -361,7 +361,7 @@ char *path_simplify(char *path, bool kill_dots) { } if (slash) { - if (kill_dots && *f == '.' && IN_SET(f[1], 0, '/')) + if (*f == '.' && IN_SET(f[1], 0, '/')) continue; slash = false; @@ -418,7 +418,7 @@ int path_simplify_and_warn( lvalue, fatal ? "" : ", ignoring", path); } - path_simplify(path, true); + path_simplify(path); if (!path_is_valid(path)) return log_syntax(unit, LOG_ERR, filename, line, SYNTHETIC_ERRNO(EINVAL), @@ -711,7 +711,7 @@ int find_executable_full(const char *name, bool use_path_envvar, char **ret_file /* Found it! */ if (ret_filename) - *ret_filename = path_simplify(TAKE_PTR(element), false); + *ret_filename = path_simplify(TAKE_PTR(element)); if (ret_fd) *ret_fd = TAKE_FD(fd); @@ -1116,7 +1116,7 @@ int path_extract_directory(const char *path, char **ret) { if (!a) return -ENOMEM; - path_simplify(a, true); + path_simplify(a); if (!path_is_valid(a)) return -EINVAL; diff --git a/src/basic/path-util.h b/src/basic/path-util.h index e447608d40b..c6d4668794b 100644 --- a/src/basic/path-util.h +++ b/src/basic/path-util.h @@ -71,7 +71,7 @@ char* path_extend_internal(char **x, ...); #define path_extend(x, ...) path_extend_internal(x, __VA_ARGS__, POINTER_MAX) #define path_join(...) path_extend_internal(NULL, __VA_ARGS__, POINTER_MAX) -char* path_simplify(char *path, bool kill_dots); +char* path_simplify(char *path); enum { PATH_CHECK_FATAL = 1 << 0, /* If not set, then error message is appended with 'ignoring'. */ @@ -109,7 +109,7 @@ int fsck_exists(const char *fstype); * directory. Excludes the specified directory itself */ #define PATH_FOREACH_PREFIX(prefix, path) \ for (char *_slash = ({ \ - path_simplify(strcpy(prefix, path), false); \ + path_simplify(strcpy(prefix, path)); \ streq(prefix, "/") ? NULL : strrchr(prefix, '/'); \ }); \ _slash && ((*_slash = 0), true); \ @@ -118,7 +118,7 @@ int fsck_exists(const char *fstype); /* Same as PATH_FOREACH_PREFIX but also includes the specified path itself */ #define PATH_FOREACH_PREFIX_MORE(prefix, path) \ for (char *_slash = ({ \ - path_simplify(strcpy(prefix, path), false); \ + path_simplify(strcpy(prefix, path)); \ if (streq(prefix, "/")) \ prefix[0] = 0; \ strrchr(prefix, 0); \ diff --git a/src/basic/sysctl-util.c b/src/basic/sysctl-util.c index c96b5cd77f0..8913e6ff85b 100644 --- a/src/basic/sysctl-util.c +++ b/src/basic/sysctl-util.c @@ -33,7 +33,7 @@ char *sysctl_normalize(char *s) { n = strpbrk(n + 1, "/."); } while (n); - path_simplify(s, true); + path_simplify(s); /* Kill the leading slash, but keep the first character of the string in the same place. */ if (*s == '/' && *(s+1)) diff --git a/src/basic/tmpfile-util.c b/src/basic/tmpfile-util.c index 9eb654c1407..91c8ff17254 100644 --- a/src/basic/tmpfile-util.c +++ b/src/basic/tmpfile-util.c @@ -126,7 +126,7 @@ int tempfn_xxxxxx(const char *p, const char *extra, char **ret) { if (!path_extend(&d, nf)) return -ENOMEM; - *ret = path_simplify(TAKE_PTR(d), false); + *ret = path_simplify(TAKE_PTR(d)); } else *ret = TAKE_PTR(nf); @@ -168,7 +168,7 @@ int tempfn_random(const char *p, const char *extra, char **ret) { if (!path_extend(&d, nf)) return -ENOMEM; - *ret = path_simplify(TAKE_PTR(d), false); + *ret = path_simplify(TAKE_PTR(d)); } else *ret = TAKE_PTR(nf); @@ -213,7 +213,7 @@ int tempfn_random_child(const char *p, const char *extra, char **ret) { *x = 0; - *ret = path_simplify(t, false); + *ret = path_simplify(t); return 0; } diff --git a/src/basic/unit-name.c b/src/basic/unit-name.c index dbc9f5baa26..29ffd81ea9a 100644 --- a/src/basic/unit-name.c +++ b/src/basic/unit-name.c @@ -387,7 +387,7 @@ int unit_name_path_escape(const char *f, char **ret) { if (!p) return -ENOMEM; - path_simplify(p, false); + path_simplify(p); if (empty_or_root(p)) s = strdup("-"); diff --git a/src/basic/user-util.c b/src/basic/user-util.c index 3756e80c30d..385ec514b41 100644 --- a/src/basic/user-util.c +++ b/src/basic/user-util.c @@ -571,7 +571,7 @@ int get_home_dir(char **_h) { if (!h) return -ENOMEM; - *_h = path_simplify(h, true); + *_h = path_simplify(h); return 0; } @@ -609,7 +609,7 @@ int get_home_dir(char **_h) { if (!h) return -ENOMEM; - *_h = path_simplify(h, true); + *_h = path_simplify(h); return 0; } @@ -628,7 +628,7 @@ int get_shell(char **_s) { if (!s) return -ENOMEM; - *_s = path_simplify(s, true); + *_s = path_simplify(s); return 0; } @@ -666,7 +666,7 @@ int get_shell(char **_s) { if (!s) return -ENOMEM; - *_s = path_simplify(s, true); + *_s = path_simplify(s); return 0; } diff --git a/src/cgls/cgls.c b/src/cgls/cgls.c index 6868049c18f..f39aa53da0b 100644 --- a/src/cgls/cgls.c +++ b/src/cgls/cgls.c @@ -243,7 +243,7 @@ static int run(int argc, char *argv[]) { if (!j) return log_oom(); - path_simplify(j, false); + path_simplify(j); path = j; } else path = root; diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c index 5424f2c90f7..9cc2f275918 100644 --- a/src/cgtop/cgtop.c +++ b/src/cgtop/cgtop.c @@ -472,7 +472,7 @@ static int refresh_one( if (!p) return -ENOMEM; - path_simplify(p, false); + path_simplify(p); r = refresh_one(controller, p, a, b, iteration, depth + 1, &child); if (r < 0) diff --git a/src/core/automount.c b/src/core/automount.c index dc92f9c0e44..8d75346d97c 100644 --- a/src/core/automount.c +++ b/src/core/automount.c @@ -199,7 +199,7 @@ static int automount_set_where(Automount *a) { if (r < 0) return r; - path_simplify(a->where, false); + path_simplify(a->where); return 1; } diff --git a/src/core/cgroup.c b/src/core/cgroup.c index 5b00faa6f62..6a46e14556d 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -2113,7 +2113,7 @@ static int unit_attach_pid_to_cgroup_via_bus(Unit *u, pid_t pid, const char *suf return -EINVAL; pp = strjoina("/", pp, suffix_path); - path_simplify(pp, false); + path_simplify(pp); r = sd_bus_call_method(u->manager->system_bus, "org.freedesktop.systemd1", diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c index 9c141d73b10..50daef67021 100644 --- a/src/core/dbus-execute.c +++ b/src/core/dbus-execute.c @@ -1451,7 +1451,7 @@ int bus_set_transient_exec_command( } else c->flags = b ? EXEC_COMMAND_IGNORE_FAILURE : 0; - path_simplify(c->path, false); + path_simplify(c->path); exec_command_append_list(exec_command, c); } @@ -3062,7 +3062,7 @@ int bus_exec_context_set_transient_property( if (!path_is_absolute(i + offset)) return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid %s", name); - path_simplify(i + offset, false); + path_simplify(i + offset); } if (!UNIT_WRITE_FLAGS_NOOP(flags)) { diff --git a/src/core/dbus-path.c b/src/core/dbus-path.c index e132cd2b3cf..e025c31532c 100644 --- a/src/core/dbus-path.c +++ b/src/core/dbus-path.c @@ -103,7 +103,7 @@ static int bus_path_set_transient_property( if (!k) return -ENOMEM; - path_simplify(k, false); + path_simplify(k); s = new0(PathSpec, 1); if (!s) diff --git a/src/core/dbus-service.c b/src/core/dbus-service.c index 4dea8d5aec1..13d555041e5 100644 --- a/src/core/dbus-service.c +++ b/src/core/dbus-service.c @@ -475,7 +475,7 @@ static int bus_service_set_transient_property( if (!n) return -ENOMEM; - path_simplify(n, true); + path_simplify(n); if (!path_is_normalized(n)) return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "PIDFile= path '%s' is not valid", n); diff --git a/src/core/dbus-socket.c b/src/core/dbus-socket.c index 2c9da7412a1..61c2f1a1993 100644 --- a/src/core/dbus-socket.c +++ b/src/core/dbus-socket.c @@ -390,7 +390,7 @@ static int bus_socket_set_transient_property( if (!p->path) return log_oom(); - path_simplify(p->path, false); + path_simplify(p->path); } else if (streq(t, "Netlink")) { r = socket_address_parse_netlink(&p->address, a); diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c index 8875ba082d1..6c04c6e5db8 100644 --- a/src/core/dbus-unit.c +++ b/src/core/dbus-unit.c @@ -2265,7 +2265,7 @@ static int bus_unit_set_transient_property( return r; STRV_FOREACH(p, l) { - path_simplify(*p, true); + path_simplify(*p); if (!path_is_absolute(*p)) return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Path specified in %s is not absolute: %s", name, *p); diff --git a/src/core/execute.c b/src/core/execute.c index f577b790e6a..3d750ee06ea 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -1846,7 +1846,7 @@ static int build_environment( if (!x) return -ENOMEM; - path_simplify(x + 5, true); + path_simplify(x + 5); our_env[n_env++] = x; } @@ -1867,7 +1867,7 @@ static int build_environment( if (!x) return -ENOMEM; - path_simplify(x + 6, true); + path_simplify(x + 6); our_env[n_env++] = x; } diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index d31d6420170..c6fca7135cc 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -810,7 +810,7 @@ int config_parse_exec( n[nlen] = NULL; } - path_simplify(path, false); + path_simplify(path); while (!isempty(p)) { _cleanup_free_ char *word = NULL, *resolved = NULL; diff --git a/src/core/manager.c b/src/core/manager.c index 419bab5b9d7..d96280667a6 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -4589,7 +4589,7 @@ Set *manager_get_units_requiring_mounts_for(Manager *m, const char *path) { assert(path); strcpy(p, path); - path_simplify(p, false); + path_simplify(p); return hashmap_get(m->units_requiring_mounts_for, streq(p, "/") ? "" : p); } diff --git a/src/core/mount.c b/src/core/mount.c index b4962681645..07d8e7b9857 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -634,7 +634,7 @@ static int mount_add_extras(Mount *m) { return r; } - path_simplify(m->where, false); + path_simplify(m->where); if (!u->description) { r = unit_set_description(u, m->where); diff --git a/src/core/service.c b/src/core/service.c index f11b8f55579..792ec99a00b 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -3148,7 +3148,7 @@ static int service_demand_pid_file(Service *s) { return -ENOMEM; } - path_simplify(ps->path, false); + path_simplify(ps->path); /* PATH_CHANGED would not be enough. There are daemons (sendmail) that * keep their PID file open all the time. */ diff --git a/src/core/socket.c b/src/core/socket.c index 8be01aa8e18..10777e4e808 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -1347,7 +1347,7 @@ static int usbffs_dispatch_eps(SocketPort *p) { goto fail; } - path_simplify(ep, false); + path_simplify(ep); r = usbffs_address_create(ep); if (r < 0) diff --git a/src/core/swap.c b/src/core/swap.c index a81b1928b89..74da2428c29 100644 --- a/src/core/swap.c +++ b/src/core/swap.c @@ -342,7 +342,7 @@ static int swap_add_extras(Swap *s) { return -ENOMEM; } - path_simplify(s->what, false); + path_simplify(s->what); if (!UNIT(s)->description) { r = unit_set_description(UNIT(s), s->what); diff --git a/src/core/unit.c b/src/core/unit.c index 9c97a927463..e48e7602c27 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -4601,7 +4601,7 @@ int unit_require_mounts_for(Unit *u, const char *path, UnitDependencyMask mask) if (!p) return -ENOMEM; - path = path_simplify(p, true); + path = path_simplify(p); if (!path_is_normalized(path)) return -EPERM; diff --git a/src/delta/delta.c b/src/delta/delta.c index 8c702459c1e..9ebe435a498 100644 --- a/src/delta/delta.c +++ b/src/delta/delta.c @@ -656,7 +656,7 @@ static int run(int argc, char *argv[]) { int i; for (i = optind; i < argc; i++) { - path_simplify(argv[i], false); + path_simplify(argv[i]); k = process_suffix_chop(argv[i]); if (k < 0) diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index 1d8ee93013a..a4e3ea53110 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -610,7 +610,7 @@ static int parse_fstab(bool initrd) { return log_oom(); if (is_path(where)) { - path_simplify(where, false); + path_simplify(where); /* Follow symlinks here; see 5261ba901845c084de5a8fd06500ed09bfb0bd80 which makes sense for * mount units, but causes problems since it historically worked to have symlinks in e.g. diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index a5bd7d8d84d..de0798f4d82 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -171,7 +171,7 @@ int device_set_syspath(sd_device *device, const char *_syspath, bool verify) { return -ENOMEM; free_and_replace(syspath, new_syspath); - path_simplify(syspath, false); + path_simplify(syspath); } if (path_startswith(syspath, "/sys/devices/")) { diff --git a/src/mount/mount-tool.c b/src/mount/mount-tool.c index 2e69a99bc6f..1d78ff28c8a 100644 --- a/src/mount/mount-tool.c +++ b/src/mount/mount-tool.c @@ -386,7 +386,7 @@ static int parse_argv(int argc, char *argv[]) { if (!arg_mount_what) return log_oom(); - path_simplify(arg_mount_what, false); + path_simplify(arg_mount_what); if (!path_is_absolute(arg_mount_what)) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), @@ -403,7 +403,7 @@ static int parse_argv(int argc, char *argv[]) { if (!arg_mount_where) return log_oom(); - path_simplify(arg_mount_where, false); + path_simplify(arg_mount_where); if (!path_is_absolute(arg_mount_where)) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), @@ -985,7 +985,7 @@ static int action_umount( if (!p) return log_oom(); - path_simplify(p, false); + path_simplify(p); r = stop_mounts(bus, p); if (r < 0) diff --git a/src/portable/portable.c b/src/portable/portable.c index 2eebdc08aec..9e33299ed51 100644 --- a/src/portable/portable.c +++ b/src/portable/portable.c @@ -688,14 +688,14 @@ static int portable_changes_add( if (!p) return -ENOMEM; - path_simplify(p, false); + path_simplify(p); if (source) { s = strdup(source); if (!s) return -ENOMEM; - path_simplify(s, false); + path_simplify(s); } c[(*n_changes)++] = (PortableChange) { diff --git a/src/shared/discover-image.c b/src/shared/discover-image.c index 8d04ba04fc3..c572e8dae81 100644 --- a/src/shared/discover-image.c +++ b/src/shared/discover-image.c @@ -160,7 +160,7 @@ static int image_new( if (!i->path) return -ENOMEM; - path_simplify(i->path, false); + path_simplify(i->path); *ret = TAKE_PTR(i); diff --git a/src/shared/install.c b/src/shared/install.c index 3723ec031c1..48e632f4dfe 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -289,14 +289,14 @@ int unit_file_changes_add( if (!p) return -ENOMEM; - path_simplify(p, false); + path_simplify(p); if (source) { s = strdup(source); if (!s) return -ENOMEM; - path_simplify(s, false); + path_simplify(s); } c[(*n_changes)++] = (UnitFileChange) { @@ -515,7 +515,7 @@ static int mark_symlink_for_removal( if (!n) return -ENOMEM; - path_simplify(n, false); + path_simplify(n); r = set_consume(*remove_symlinks_to, n); if (r == -EEXIST) @@ -597,7 +597,7 @@ static int remove_marked_symlinks_fd( p = path_make_absolute(de->d_name, path); if (!p) return -ENOMEM; - path_simplify(p, false); + path_simplify(p); q = chase_symlinks(p, NULL, CHASE_NONEXISTENT, &dest, NULL); if (q == -ENOENT) diff --git a/src/shared/mount-setup.c b/src/shared/mount-setup.c index 1e4bbfb1ab0..ef3527e9a7f 100644 --- a/src/shared/mount-setup.c +++ b/src/shared/mount-setup.c @@ -454,7 +454,7 @@ static int relabel_extra(void) { if (r == 0) /* EOF */ break; - path_simplify(line, true); + path_simplify(line); if (!path_is_normalized(line)) { log_warning("Path to relabel is not normalized, ignoring: %s", line); diff --git a/src/shared/parse-argument.c b/src/shared/parse-argument.c index 68c55a54c9e..145bd119ac7 100644 --- a/src/shared/parse-argument.c +++ b/src/shared/parse-argument.c @@ -73,7 +73,7 @@ int parse_path_argument(const char *path, bool suppress_root, char **arg) { if (r < 0) return log_error_errno(r, "Failed to parse path \"%s\" and make it absolute: %m", path); - path_simplify(p, false); + path_simplify(p); if (suppress_root && empty_or_root(p)) p = mfree(p); diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c index c9eda29b49f..d76556e75d3 100644 --- a/src/sysusers/sysusers.c +++ b/src/sysusers/sysusers.c @@ -1651,7 +1651,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) { if (resolved_id) { if (path_is_absolute(resolved_id)) { i->uid_path = TAKE_PTR(resolved_id); - path_simplify(i->uid_path, false); + path_simplify(i->uid_path); } else { _cleanup_free_ char *uid = NULL, *gid = NULL; if (split_pair(resolved_id, ":", &uid, &gid) == 0) { @@ -1706,7 +1706,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) { if (resolved_id) { if (path_is_absolute(resolved_id)) { i->gid_path = TAKE_PTR(resolved_id); - path_simplify(i->gid_path, false); + path_simplify(i->gid_path); } else { r = parse_gid(resolved_id, &i->gid); if (r < 0) diff --git a/src/test/test-path-util.c b/src/test/test-path-util.c index c07c22a4072..8e8802b72f5 100644 --- a/src/test/test-path-util.c +++ b/src/test/test-path-util.c @@ -21,16 +21,13 @@ static void test_print_paths(void) { log_info("DEFAULT_USER_PATH=%s", DEFAULT_USER_PATH); } -static void test_path_simplify(const char *in, const char *out, const char *out_dot) { +static void test_path_simplify(const char *in, const char *out) { char *p; log_info("/* %s */", __func__); p = strdupa(in); - assert_se(streq(path_simplify(p, false), out)); - - p = strdupa(in); - assert_se(streq(path_simplify(p, true), out_dot)); + assert_se(streq(path_simplify(p), out)); } static void test_path(void) { @@ -48,27 +45,23 @@ static void test_path(void) { assert_se(streq(basename("/aa///file..."), "file...")); assert_se(streq(basename("file.../"), "")); - test_path_simplify("aaa/bbb////ccc", "aaa/bbb/ccc", "aaa/bbb/ccc"); - test_path_simplify("//aaa/.////ccc", "/aaa/./ccc", "/aaa/ccc"); - test_path_simplify("///", "/", "/"); - test_path_simplify("///.//", "/.", "/"); - test_path_simplify("///.//.///", "/./.", "/"); - test_path_simplify("////.././///../.", "/.././../.", "/../.."); - test_path_simplify(".", ".", "."); - test_path_simplify("./", ".", "."); - test_path_simplify(".///.//./.", "./././.", "."); - test_path_simplify(".///.//././/", "./././.", "."); + test_path_simplify("aaa/bbb////ccc", "aaa/bbb/ccc"); + test_path_simplify("//aaa/.////ccc", "/aaa/ccc"); + test_path_simplify("///", "/"); + test_path_simplify("///.//", "/"); + test_path_simplify("///.//.///", "/"); + test_path_simplify("////.././///../.", "/../.."); + test_path_simplify(".", "."); + test_path_simplify("./", "."); + test_path_simplify(".///.//./.", "."); + test_path_simplify(".///.//././/", "."); test_path_simplify("//./aaa///.//./.bbb/..///c.//d.dd///..eeee/.", - "/./aaa/././.bbb/../c./d.dd/..eeee/.", "/aaa/.bbb/../c./d.dd/..eeee"); test_path_simplify("//./aaa///.//./.bbb/..///c.//d.dd///..eeee/..", - "/./aaa/././.bbb/../c./d.dd/..eeee/..", "/aaa/.bbb/../c./d.dd/..eeee/.."); test_path_simplify(".//./aaa///.//./.bbb/..///c.//d.dd///..eeee/..", - "././aaa/././.bbb/../c./d.dd/..eeee/..", "aaa/.bbb/../c./d.dd/..eeee/.."); test_path_simplify("..//./aaa///.//./.bbb/..///c.//d.dd///..eeee/..", - ".././aaa/././.bbb/../c./d.dd/..eeee/..", "../aaa/.bbb/../c./d.dd/..eeee/.."); assert_se(PATH_IN_SET("/bin", "/", "/bin", "/foo")); diff --git a/src/test/test-tmpfile-util.c b/src/test/test-tmpfile-util.c index af18df1bd57..9f2e6158674 100644 --- a/src/test/test-tmpfile-util.c +++ b/src/test/test-tmpfile-util.c @@ -37,8 +37,8 @@ static void test_tempfn_random(void) { test_tempfn_random_one("foo", "bar", ".#barfoo", 0); test_tempfn_random_one("/tmp/foo", NULL, "/tmp/.#foo", 0); test_tempfn_random_one("/tmp/foo", "bar", "/tmp/.#barfoo", 0); - test_tempfn_random_one("./foo", NULL, "./.#foo", 0); - test_tempfn_random_one("./foo", "bar", "./.#barfoo", 0); + test_tempfn_random_one("./foo", NULL, ".#foo", 0); + test_tempfn_random_one("./foo", "bar", ".#barfoo", 0); test_tempfn_random_one("../foo", NULL, "../.#foo", 0); test_tempfn_random_one("../foo", "bar", "../.#barfoo", 0); @@ -46,8 +46,8 @@ static void test_tempfn_random(void) { test_tempfn_random_one("foo/", "bar", ".#barfoo", 0); test_tempfn_random_one("/tmp/foo/", NULL, "/tmp/.#foo", 0); test_tempfn_random_one("/tmp/foo/", "bar", "/tmp/.#barfoo", 0); - test_tempfn_random_one("./foo/", NULL, "./.#foo", 0); - test_tempfn_random_one("./foo/", "bar", "./.#barfoo", 0); + test_tempfn_random_one("./foo/", NULL, ".#foo", 0); + test_tempfn_random_one("./foo/", "bar", ".#barfoo", 0); test_tempfn_random_one("../foo/", NULL, "../.#foo", 0); test_tempfn_random_one("../foo/", "bar", "../.#barfoo", 0); } @@ -81,8 +81,8 @@ static void test_tempfn_xxxxxx(void) { test_tempfn_xxxxxx_one("foo", "bar", ".#barfoo", 0); test_tempfn_xxxxxx_one("/tmp/foo", NULL, "/tmp/.#foo", 0); test_tempfn_xxxxxx_one("/tmp/foo", "bar", "/tmp/.#barfoo", 0); - test_tempfn_xxxxxx_one("./foo", NULL, "./.#foo", 0); - test_tempfn_xxxxxx_one("./foo", "bar", "./.#barfoo", 0); + test_tempfn_xxxxxx_one("./foo", NULL, ".#foo", 0); + test_tempfn_xxxxxx_one("./foo", "bar", ".#barfoo", 0); test_tempfn_xxxxxx_one("../foo", NULL, "../.#foo", 0); test_tempfn_xxxxxx_one("../foo", "bar", "../.#barfoo", 0); @@ -90,8 +90,8 @@ static void test_tempfn_xxxxxx(void) { test_tempfn_xxxxxx_one("foo/", "bar", ".#barfoo", 0); test_tempfn_xxxxxx_one("/tmp/foo/", NULL, "/tmp/.#foo", 0); test_tempfn_xxxxxx_one("/tmp/foo/", "bar", "/tmp/.#barfoo", 0); - test_tempfn_xxxxxx_one("./foo/", NULL, "./.#foo", 0); - test_tempfn_xxxxxx_one("./foo/", "bar", "./.#barfoo", 0); + test_tempfn_xxxxxx_one("./foo/", NULL, ".#foo", 0); + test_tempfn_xxxxxx_one("./foo/", "bar", ".#barfoo", 0); test_tempfn_xxxxxx_one("../foo/", NULL, "../.#foo", 0); test_tempfn_xxxxxx_one("../foo/", "bar", "../.#barfoo", 0); } diff --git a/src/test/test-unit-name.c b/src/test/test-unit-name.c index dc4dc7529d3..0bce571fedd 100644 --- a/src/test/test-unit-name.c +++ b/src/test/test-unit-name.c @@ -129,7 +129,7 @@ static void test_unit_name_from_path(void) { test_unit_name_from_path_one("/", ".mount", "-.mount", 0); test_unit_name_from_path_one("///", ".mount", "-.mount", 0); test_unit_name_from_path_one("/foo/../bar", ".mount", NULL, -EINVAL); - test_unit_name_from_path_one("/foo/./bar", ".mount", NULL, -EINVAL); + test_unit_name_from_path_one("/foo/./bar", ".mount", "foo-bar.mount", 0); test_unit_name_from_path_one("/waldoaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", ".mount", NULL, -EINVAL); } diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 3eac712b0bf..071070e9f6a 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -445,7 +445,7 @@ static int load_unix_sockets(void) { if (!s) return log_oom(); - path_simplify(s, false); + path_simplify(s); r = set_consume(sockets, s); if (r == -EEXIST) @@ -2779,7 +2779,7 @@ static int parse_line( free_and_replace(i.argument, p); } - path_simplify(i.argument, false); + path_simplify(i.argument); break; case CREATE_CHAR_DEVICE: @@ -2847,7 +2847,7 @@ static int parse_line( "Path '%s' not absolute.", i.path); } - path_simplify(i.path, false); + path_simplify(i.path); if (!should_include_path(i.path)) return 0; diff --git a/src/udev/test-udev-event.c b/src/udev/test-udev-event.c index 584e5c27ed8..fd1752c65fd 100644 --- a/src/udev/test-udev-event.c +++ b/src/udev/test-udev-event.c @@ -96,7 +96,7 @@ int main(int argc, char *argv[]) { test_event_spawn_cat(false); assert_se(path_make_absolute_cwd(argv[0], &self) >= 0); - path_simplify(self, true); + path_simplify(self); test_event_spawn_self(self, "test1", true); test_event_spawn_self(self, "test1", false); -- 2.39.5