All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steve Dickson <SteveD@redhat.com>
To: nfs@lists.sourceforge.net
Subject: [PATCH 10/11] nfs-utils: mount: Stop v4 umounts from ping remote mountds
Date: Mon, 26 Feb 2007 06:19:06 -0500	[thread overview]
Message-ID: <45E2C22A.6090706@RedHat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #2: patch-10.dif --]
[-- Type: text/x-patch, Size: 2626 bytes --]

commit 7f9cc56de079b1c53f912fc2abe31203e79782f4
Author: Steve Dickson <steved@redhat.com>
Date:   Sat Feb 24 16:18:22 2007 -0500

    Stop v4 umounts from ping remote mountds
    
    Signed-off-by: Steve Dickson <steved@redhat.com>

diff --git a/utils/mount/nfsumount.c b/utils/mount/nfsumount.c
index 5894e3a..bb06341 100644
--- a/utils/mount/nfsumount.c
+++ b/utils/mount/nfsumount.c
@@ -19,6 +19,7 @@
 
 #include <stdio.h>
 #include <errno.h>
+#include <unistd.h>
 #include <getopt.h>
 #include <mntent.h>
 #include <sys/mount.h>
@@ -333,7 +334,7 @@ void umount_usage()
 
 int nfsumount(int argc, char *argv[])
 {
-	int c, ret;
+	int c, ret, v4=0;
 	char *spec;
 	struct mntentchn *mc;
 
@@ -371,39 +372,33 @@ int nfsumount(int argc, char *argv[])
 	mc = getmntdirbackward(spec, NULL);
 	if (!mc)
 		mc = getmntdevbackward(spec, NULL);
-	if (!mc && verbose)
-		printf(_("Could not find %s in mtab\n"), spec);
-
-	if(mc) {
-		if(contains(mc->m.mnt_opts, "user") && getuid() != 0) {
-			struct passwd *pw = getpwuid(getuid());
-			if(!pw || strcmp(pw->pw_name, get_value(mc->m.mnt_opts, "user="))) {
-				fprintf(stderr, "%s: permission denied to unmount %s\n",
-						progname, spec);
-				exit(1);
-			}
-		} else {
-			if(!contains(mc->m.mnt_opts, "users") && getuid() != 0) {
-				fprintf(stderr, "%s: only root can unmount %s from %s\n",
-						progname, mc->m.mnt_fsname, mc->m.mnt_dir);
-				exit(1);
-			}
-		}
-
-		ret = 0;
-		if(!force && !lazy)
-			ret = _nfsumount(mc->m.mnt_fsname, mc->m.mnt_opts);
-		if(!ret)
-			ret = add_mtab2(mc->m.mnt_fsname, mc->m.mnt_dir,
-				mc->m.mnt_type, mc->m.mnt_opts, mc);
+	if (mc == NULL) {
+		fprintf(stderr, "%s: Unable to find '%s' in mount table\n",
+				progname, spec);
+		exit(1);
 	}
-	else {
-		ret = 0;
-		if(!force && !lazy)
-			ret = _nfsumount(spec, NULL);
-		if(!ret)
-			ret = add_mtab2(spec, spec, spec, spec, NULL);
+	if(contains(mc->m.mnt_opts, "user") && getuid() != 0) {
+		struct passwd *pw = getpwuid(getuid());
+		if(!pw || strcmp(pw->pw_name, get_value(mc->m.mnt_opts, "user="))) {
+			fprintf(stderr, "%s: permission denied to unmount %s\n",
+					progname, spec);
+			exit(1);
+		}
+	} else {
+		if(!contains(mc->m.mnt_opts, "users") && getuid() != 0) {
+			fprintf(stderr, "%s: only root can unmount %s from %s\n",
+					progname, mc->m.mnt_fsname, mc->m.mnt_dir);
+			exit(1);
+		}
 	}
+	v4 = contains(mc->m.mnt_type, "nfs4");
+
+	ret = 0;
+	if(!force && !lazy && !v4)
+		ret = _nfsumount(mc->m.mnt_fsname, mc->m.mnt_opts);
+	if(!ret)
+		ret = add_mtab2(mc->m.mnt_fsname, mc->m.mnt_dir,
+			mc->m.mnt_type, mc->m.mnt_opts, mc);
 
 	return(ret);
 }

[-- Attachment #3: Type: text/plain, Size: 345 bytes --]

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

[-- Attachment #4: Type: text/plain, Size: 140 bytes --]

_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

                 reply	other threads:[~2007-02-26 11:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45E2C22A.6090706@RedHat.com \
    --to=steved@redhat.com \
    --cc=nfs@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.