summaryrefslogtreecommitdiff
path: root/testing/kmod/0008-Use-realpath-to-canonicalize-provided-paths.patch
diff options
context:
space:
mode:
Diffstat (limited to 'testing/kmod/0008-Use-realpath-to-canonicalize-provided-paths.patch')
-rw-r--r--testing/kmod/0008-Use-realpath-to-canonicalize-provided-paths.patch163
1 files changed, 0 insertions, 163 deletions
diff --git a/testing/kmod/0008-Use-realpath-to-canonicalize-provided-paths.patch b/testing/kmod/0008-Use-realpath-to-canonicalize-provided-paths.patch
deleted file mode 100644
index 652d2e854..000000000
--- a/testing/kmod/0008-Use-realpath-to-canonicalize-provided-paths.patch
+++ /dev/null
@@ -1,163 +0,0 @@
-From 4148d50c980e20a71b5e284e93863b4f36f4fbe4 Mon Sep 17 00:00:00 2001
-From: Dan McGee <dan@archlinux.org>
-Date: Fri, 3 Feb 2012 15:01:34 -0600
-Subject: [PATCH 8/8] Use realpath() to canonicalize provided paths
-
-The existing function choked in several corner cases:
-* '/tmp/../tmp' was seen as absolute, so not cleaned up.
-* '/tmp/' and '/tmp' were not equal, causing depmod to act differently
- when called with the -b option for the two paths.
-
-Don't reinvent the wheel; just use the standard library function.
-
-Signed-off-by: Dan McGee <dan@archlinux.org>
----
- libkmod/libkmod-module.c | 6 +++---
- libkmod/libkmod-util.c | 36 ------------------------------------
- libkmod/libkmod-util.h | 2 --
- libkmod/libkmod.c | 13 +++++++++----
- tools/kmod-depmod.c | 8 ++++++--
- 5 files changed, 18 insertions(+), 47 deletions(-)
-
-diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
-index 48e4aa1..48e7286 100644
---- a/libkmod/libkmod-module.c
-+++ b/libkmod/libkmod-module.c
-@@ -326,10 +326,10 @@ KMOD_EXPORT int kmod_module_new_from_path(struct kmod_ctx *ctx,
- if (ctx == NULL || path == NULL || mod == NULL)
- return -ENOENT;
-
-- abspath = path_make_absolute_cwd(path);
-+ abspath = canonicalize_file_name(path);
- if (abspath == NULL) {
-- DBG(ctx, "no absolute path for %s\n", path);
-- return -ENOMEM;
-+ DBG(ctx, "no canonical filename returned for %s\n", path);
-+ return -errno;
- }
-
- err = stat(abspath, &st);
-diff --git a/libkmod/libkmod-util.c b/libkmod/libkmod-util.c
-index 6a9f697..02b7f63 100644
---- a/libkmod/libkmod-util.c
-+++ b/libkmod/libkmod-util.c
-@@ -301,42 +301,6 @@ char *strchr_replace(char *s, int c, char r)
- return s;
- }
-
--bool path_is_absolute(const char *p)
--{
-- assert(p != NULL);
--
-- return p[0] == '/';
--}
--
--char *path_make_absolute_cwd(const char *p)
--{
-- char *cwd, *r;
-- size_t plen;
-- size_t cwdlen;
--
-- if (path_is_absolute(p))
-- return strdup(p);
--
-- cwd = get_current_dir_name();
-- if (cwd == NULL)
-- return NULL;
--
-- plen = strlen(p);
-- cwdlen = strlen(cwd);
--
-- /* cwd + '/' + p + '\0' */
-- r = realloc(cwd, cwdlen + 1 + plen + 1);
-- if (r == NULL) {
-- free(cwd);
-- return NULL;
-- }
--
-- r[cwdlen] = '/';
-- memcpy(&r[cwdlen + 1], p, plen + 1);
--
-- return r;
--}
--
- #define USEC_PER_SEC 1000000ULL
- #define NSEC_PER_USEC 1000ULL
- unsigned long long ts_usec(const struct timespec *ts)
-diff --git a/libkmod/libkmod-util.h b/libkmod/libkmod-util.h
-index c9a1a21..63c348f 100644
---- a/libkmod/libkmod-util.h
-+++ b/libkmod/libkmod-util.h
-@@ -19,8 +19,6 @@ ssize_t write_str_safe(int fd, const char *buf, size_t buflen) __attribute__((no
- int read_str_long(int fd, long *value, int base) __must_check __attribute__((nonnull(2)));
- int read_str_ulong(int fd, unsigned long *value, int base) __must_check __attribute__((nonnull(2)));
- char *strchr_replace(char *s, int c, char r);
--bool path_is_absolute(const char *p) __must_check __attribute__((nonnull(1)));
--char *path_make_absolute_cwd(const char *p) __must_check __attribute__((nonnull(1)));
- int alias_normalize(const char *alias, char buf[PATH_MAX], size_t *len) __must_check __attribute__((nonnull(1,2)));
- char *modname_normalize(const char *modname, char buf[PATH_MAX], size_t *len) __attribute__((nonnull(1, 2)));
- char *path_to_modname(const char *path, char buf[PATH_MAX], size_t *len) __attribute__((nonnull(2)));
-diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c
-index 800a178..c578afb 100644
---- a/libkmod/libkmod.c
-+++ b/libkmod/libkmod.c
-@@ -160,13 +160,18 @@ static int log_priority(const char *priority)
-
- static const char *dirname_default_prefix = ROOTPREFIX "/lib/modules";
-
--static char *get_kernel_release(const char *dirname)
-+static char *get_kernel_release(struct kmod_ctx *ctx, const char *dirname)
- {
- struct utsname u;
- char *p;
-
-- if (dirname != NULL)
-- return path_make_absolute_cwd(dirname);
-+ if (dirname != NULL) {
-+ p = canonicalize_file_name(dirname);
-+ if (p)
-+ return p;
-+ INFO(ctx, "could not canonicalize directory %s: %m\n", dirname);
-+ return strdup(dirname);
-+ }
-
- if (uname(&u) < 0)
- return NULL;
-@@ -215,7 +220,7 @@ KMOD_EXPORT struct kmod_ctx *kmod_new(const char *dirname,
- ctx->log_data = stderr;
- ctx->log_priority = LOG_ERR;
-
-- ctx->dirname = get_kernel_release(dirname);
-+ ctx->dirname = get_kernel_release(ctx, dirname);
-
- /* environment overwrites config */
- env = getenv("KMOD_LOG");
-diff --git a/tools/kmod-depmod.c b/tools/kmod-depmod.c
-index 0cf28f6..72180ef 100644
---- a/tools/kmod-depmod.c
-+++ b/tools/kmod-depmod.c
-@@ -1160,7 +1160,7 @@ static int depmod_module_add(struct depmod *depmod, struct kmod_module *kmod)
- }
- }
-
-- DBG("add %p kmod=%p, path=%s\n", mod, kmod, mod->path);
-+ DBG("add %p kmod=%p, path=%s, relpath=%s\n", mod, kmod, mod->path, mod->relpath);
-
- return 0;
- }
-@@ -2547,7 +2547,11 @@ static int do_depmod(int argc, char *argv[])
- maybe_all = 1;
- break;
- case 'b':
-- root = path_make_absolute_cwd(optarg);
-+ root = canonicalize_file_name(optarg);
-+ if (!root) {
-+ CRIT("could not resolve path %s\n", optarg);
-+ goto cmdline_failed;
-+ }
- break;
- case 'C': {
- size_t bytes = sizeof(char *) * (n_config_paths + 2);
---
-1.7.9
-