tree-wide: always drop unnecessary dot in path
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -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);
|
||||
|
||||
+1
-1
@@ -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 */
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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); \
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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("-");
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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",
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
+2
-2
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
+1
-1
@@ -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. */
|
||||
|
||||
+1
-1
@@ -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)
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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/")) {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
+12
-19
@@ -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"));
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user