From patchwork Sun Mar 21 19:20:23 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [06/10] mount.cifs: make check_mountpoint a noop for non-legacy builds Date: Sun, 21 Mar 2010 09:20:23 -0000 From: Jeff Layton X-Patchwork-Id: 48230 Message-Id: <1269199227-21446-7-git-send-email-jlayton@redhat.com> To: linux-cifs-client@lists.samba.org 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 --- mount.cifs.c | 31 ++++++++----------------------- 1 files changed, 8 insertions(+), 23 deletions(-) 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