Patchwork [06/10] mount.cifs: make check_mountpoint a noop for non-legacy builds

login
register
mail settings
Submitter Jeff Layton
Date March 21, 2010, 7:20 p.m.
Message ID <1269199227-21446-7-git-send-email-jlayton@redhat.com>
Download mbox | patch
Permalink /patch/48230/
State New
Headers show

Comments

Jeff Layton - March 21, 2010, 7:20 p.m.
Now that we chdir() to the mountpoint, the checks in that function are
pointless. Just make it a noop for non-legacy setuid builds.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
 mount.cifs.c |   31 ++++++++-----------------------
 1 files changed, 8 insertions(+), 23 deletions(-)

Patch

diff --git a/mount.cifs.c b/mount.cifs.c
index 84167f3..4631310 100644
--- a/mount.cifs.c
+++ b/mount.cifs.c
@@ -115,31 +115,10 @@  char * domain_name = NULL;
 char * prefixpath = NULL;
 const char *cifs_fstype = "cifs";
 
-/*
- * If an unprivileged user is doing the mounting then we need to ensure
- * that the entry is in /etc/fstab.
- */
+#if CIFS_LEGACY_SETUID_CHECK
 static int
 check_mountpoint(const char *progname, char *mountpoint)
 {
-	int err;
-	struct stat statbuf;
-
-	/* does mountpoint exist and is it a directory? */
-	err = stat(".", &statbuf);
-	if (err) {
-		fprintf(stderr, "%s: failed to stat %s: %s\n", progname,
-				mountpoint, strerror(errno));
-		return EX_USAGE;
-	}
-
-	if (!S_ISDIR(statbuf.st_mode)) {
-		fprintf(stderr, "%s: %s is not a directory!", progname,
-				mountpoint);
-		return EX_USAGE;
-	}
-
-#if CIFS_LEGACY_SETUID_CHECK
 	/* do extra checks on mountpoint for legacy setuid behavior */
 	if (!getuid() || geteuid())
 		return 0;
@@ -155,10 +134,16 @@  check_mountpoint(const char *progname, char *mountpoint)
 			mountpoint);
 		return EX_USAGE;
 	}
-#endif /* CIFS_LEGACY_SETUID_CHECK */
 
 	return 0;
 }
+#else /* CIFS_LEGACY_SETUID_CHECK */
+static int
+check_mountpoint(const char *progname, char *mountpoint)
+{
+	return 0;
+}
+#endif /* CIFS_LEGACY_SETUID_CHECK */
 
 #if CIFS_DISABLE_SETUID_CHECK
 static int