From 0d5eee462676ad7925bfbdb792d3f58d73e1c277 Mon Sep 17 00:00:00 2001 From: wbaumann Date: Wed, 29 Jun 2011 18:48:26 +0000 Subject: [PATCH] Check for relative mount point --- ChangeLog | 4 ++++ src/mount_davfs.c | 7 +++++-- src/mount_davfs.h | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3afd66a..c2670e1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,10 @@ ChangeLog for davfs2 -------------------- +2011-06-29 Werner Baumann (werner.baumann@onlinehome.de) + * mount_davfs.c, mount_davfs.h: + Check for relative mount point. + 2011-06-25 Werner Baumann (werner.baumann@onlinehome.de) * umount_davfs.c: Quote mpoint in umount_command. diff --git a/src/mount_davfs.c b/src/mount_davfs.c index 43cfa8e..92a18ad 100644 --- a/src/mount_davfs.c +++ b/src/mount_davfs.c @@ -756,9 +756,8 @@ check_mountpoint(dav_args *args) { struct passwd *pw; - int relative = (*mpoint != '/'); - if (relative && getuid() != 0) { + if (args->relative_mpoint && getuid() != 0) { pw = getpwuid(getuid()); if (!pw || !pw->pw_dir) error(EXIT_FAILURE, 0, @@ -967,6 +966,7 @@ parse_commandline(int argc, char *argv[]) if (!mpoint) error(EXIT_FAILURE, 0, _("can't evaluate path of mount point %s"), mpoint); + args->relative_mpoint = (*argv[i] != '/'); break; default: error(0, 0, _("too many arguments")); @@ -1692,6 +1692,7 @@ new_args(void) dav_args *args = ne_malloc(sizeof(*args)); args->cmdline = NULL; + args->relative_mpoint = 0; args->dav_user = ne_strdup(DAV_USER); args->dav_group = ne_strdup(DAV_GROUP); @@ -1793,6 +1794,8 @@ log_dbg_config(char *argv[], dav_args *args) " url: %s", url); syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " mount point: %s", mpoint); + syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), + " relative_mpoint: %i", args->relative_mpoint); syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), " dav_user: %s", args->dav_user); syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), diff --git a/src/mount_davfs.h b/src/mount_davfs.h index 168dc66..5448454 100644 --- a/src/mount_davfs.h +++ b/src/mount_davfs.h @@ -32,6 +32,7 @@ daemon mode. The rest will be freed when forking into daemon mode. */ typedef struct { char *cmdline; + int relative_mpoint; char *dav_user; /* System config file */ char *dav_group; /* System config file */ char *conf; /* Command line */