} else
t = *s;
- r = chase_symlinks(t, root, &u);
+ r = chase_symlinks(t, root, 0, &u);
if (r == -ENOENT) {
if (root) {
u = orig;
return path_equal(a, b) || files_same(a, b) > 0;
}
-#if 0 /// UNNEEDED by elogind
char* path_join(const char *root, const char *path, const char *rest) {
assert(path);
return last_error;
}
+#if 0 /// UNNEEDED by elogind
bool paths_check_timestamp(const char* const* paths, usec_t *timestamp, bool update) {
bool changed = false;
const char* const* i;
mkfs = strjoina("mkfs.", fstype);
return binary_is_good(mkfs);
}
+#endif // 0
char *prefix_root(const char *root, const char *path) {
char *n, *p;
return n;
}
+#if 0 /// UNNEEDED by elogind
int parse_path_argument_and_warn(const char *path, bool suppress_root, char **arg) {
char *p;
int r;
if (isempty(p))
return false;
- if (streq(p, "."))
- return false;
-
- if (streq(p, ".."))
+ if (dot_or_dot_dot(p))
return false;
e = strchrnul(p, '/');
if (isempty(p))
return false;
- if (streq(p, "..") || startswith(p, "../") || endswith(p, "/..") || strstr(p, "/../"))
+ if (dot_or_dot_dot(p))
+ return false;
+
+ if (startswith(p, "../") || endswith(p, "/..") || strstr(p, "/../"))
return false;
if (strlen(p)+1 > PATH_MAX)
return false;
/* The following two checks are not really dangerous, but hey, they still are confusing */
- if (streq(p, ".") || startswith(p, "./") || endswith(p, "/.") || strstr(p, "/./"))
+ if (startswith(p, "./") || endswith(p, "/.") || strstr(p, "/./"))
return false;
if (strstr(p, "//"))
return false;
}
#endif // 0
+
+bool dot_or_dot_dot(const char *path) {
+ if (!path)
+ return false;
+ if (path[0] != '.')
+ return false;
+ if (path[1] == 0)
+ return true;
+ if (path[1] != '.')
+ return false;
+
+ return path[2] == 0;
+}