always canonicalize mount point

This commit is contained in:
wbaumann 2010-11-03 09:11:14 +00:00
parent f8e3e247ad
commit 93a8791136
2 changed files with 19 additions and 15 deletions

View File

@ -1,6 +1,10 @@
ChangeLog for davfs2
--------------------

2010-11-03 Werner Baumann (werner.baumann@onlinehome.de)
* mount_davfs.c, check_mountpoint:
Always canonicalize mount point.

2010-08-07 Werner Baumann (werner.baumann@onlinehome.de)
* webdav.c:
Added missing '\r' in constant none_match_header

View File

@ -758,23 +758,23 @@ check_mountpoint(dav_args *args)
{

struct passwd *pw;
int relative = (*mpoint != '/');

if (*mpoint != '/') {
char *mp = canonicalize_file_name(mpoint);
if (!mp)
char *mp = canonicalize_file_name(mpoint);
if (!mp)
error(EXIT_FAILURE, 0,
_("can't evaluate path of mount point %s"), mpoint);
free(mpoint);
mpoint = mp;

if (relative && getuid() != 0) {
pw = getpwuid(getuid());
if (!pw || !pw->pw_dir)
error(EXIT_FAILURE, 0,
_("can't evaluate path of mount point %s"), mpoint);
if (getuid() != 0) {
pw = getpwuid(getuid());
if (!pw || !pw->pw_dir)
error(EXIT_FAILURE, 0,
_("can't get home directory for uid %i"), getuid());
if (strstr(mp, pw->pw_dir) != mp)
error(EXIT_FAILURE, 0, _("A relative mount point must lie "
"within your home directory"));
}
free(mpoint);
mpoint = mp;
_("can't get home directory for uid %i"), getuid());
if (strstr(mp, pw->pw_dir) != mp)
error(EXIT_FAILURE, 0, _("A relative mount point must lie "
"within your home directory"));
}

if (strcmp(mpoint, "/") == 0 || strlen(mpoint) < 2)