Drop lufsumount(1) in the favor of compatibility with generic umount(8).
authorshort <>
Wed, 19 Nov 2003 11:39:46 +0000 (11:39 +0000)
committershort <>
Wed, 19 Nov 2003 11:39:46 +0000 (11:39 +0000)
autogen.pl
debian/lufs.files
lufs.spec.in
man/Makefile.am
man/lufsmount.1
man/lufsumount.1 [deleted file]
util/Makefile.am
util/lufsmnt.c
util/lufsumount.c [deleted file]

index 7556c71..6026723 100755 (executable)
@@ -46,7 +46,6 @@ AutoGen->run(
                                ./util/auto.sshfs
                                ./util/lufsmnt-bin
                                ./util/lufsmount
-                               ./util/lufsumount
                                ./kernel/Linux/prepmod
                                ./kernel/Linux/modbin/*.o
                                ./kernel/Linux/modbin/prepmod-tmp-dir
index b8409bd..99c05c7 100644 (file)
@@ -12,7 +12,6 @@
 /usr/lib/lib*.so*
 /usr/man/man*/lufs*
 /usr/bin/lufsmnt-bin
-/usr/bin/lufsumount
 /usr/include/lufs
 /usr/lib/lib*.la
 /etc/auto.sshfs
index b6f4336..d0209f1 100644 (file)
@@ -95,7 +95,6 @@ depmod -aq
 # These are SUID root...
 %defattr(4755,root,root)
 %{_bindir}/lufsmnt
-%{_bindir}/lufsumount
 
 %changelog
 * Wed Aug 20 2003 Jan Kratochvil <project-captive@jankratochvil.net>
index 1f52e24..2741524 100644 (file)
@@ -1,2 +1,2 @@
-man1_MANS=lufsmount.1 lufsumount.1
-EXTRA_DIST=lufsmount.1 lufsumount.1
+man1_MANS=lufsmount.1
+EXTRA_DIST=lufsmount.1
index 1276f39..c46390d 100644 (file)
@@ -11,9 +11,9 @@ The
 .B lufsmount
 command is a convenience wrapper for mounting LUFS filesystems. 
 It provides a more natural syntax and allows regular users to take 
-advantage of it, provided that the LUFS mount/umount utilities 
-(lufsmnt & lufsumount) have been installed suid root. Conversely, the
-.BR lufsumount (1)
+advantage of it, provided that the LUFS mount utility
+(lufsmnt) have been installed suid root. Conversely, the
+.BR umount (8)
 command will detach the mounted file system.
 .SH OPTIONS
 Options available for the 
@@ -83,7 +83,6 @@ URL syntax.
 .SH AUTHOR
 Florin Malita <mali at go dot ro>
 .SH "SEE ALSO"
-.BR lufsumount (1),
 .BR mount (8),
 .BR umount (8)
 
diff --git a/man/lufsumount.1 b/man/lufsumount.1
deleted file mode 100644 (file)
index 17ce9f7..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-.\" Process this file with
-.\" groff -man -Tascii foo.1
-.\"
-.TH LUFSUMOUNT "1" "January 2003" LUFS "User Commands"
-.SH NAME
-lufsumount \- unmount an LUFS file system
-.SH SYNOPSIS
-.BI "lufsumount " dir
-.SH DESCRIPTION
-The 
-.B lufsumount
-command detaches an LUFS file system mounted in the given dir from the
-file hierachy. It will only work for file systems mounted via
-.B lufsmount
-(1). If installed as suid root, will enable regular users to operate LUFS
-file systems.
-.SH FILES
-.I /etc/mtab
-.RS
-Table of mounted file systems
-.RE
-.SH AUTHOR
-Florin Malita <mali at go dot ro>
-.SH "SEE ALSO"
-.BR lufsmount (1),
-.BR mount (8),
-.BR umount (8)
-
index 5d54990..3a7b335 100644 (file)
@@ -1,10 +1,9 @@
 INCLUDES=-I../
 LSUID:= @LUFS_SUID@
 
-bin_PROGRAMS=lufsmount lufsumount lufsmnt auto.sshfs auto.ftpfs
+bin_PROGRAMS=lufsmount lufsmnt auto.sshfs auto.ftpfs
 
 lufsmount_SOURCES=lufsmount.c
-lufsumount_SOURCES=lufsumount.c
 lufsmnt_SOURCES=lufsmnt.c
 auto_sshfs_SOURCES=auto.sshfs.c
 auto_ftpfs_SOURCES=auto.ftpfs.c
@@ -16,6 +15,6 @@ install-exec-hook:
        ln -fs $(bindir)/auto.sshfs $(DESTDIR)/etc/auto.sshfs
        rm -f $(DESTDIR)/etc/auto.ftpfs
        ln -fs $(bindir)/auto.ftpfs $(DESTDIR)/etc/auto.ftpfs
-       if [ "$(LSUID)" -a -z "$(DESTDIR)" ]; then chmod a+s $(DESTDIR)$(bindir)/lufsmnt $(DESTDIR)$(bindir)/lufsumount; fi
+       if [ "$(LSUID)" -a -z "$(DESTDIR)" ]; then chmod a+s $(DESTDIR)$(bindir)/lufsmnt; fi
        if [ -f /etc/auto.master -a "$(AUTOFS_INSTALL)" -a ! "`cat $(DESTDIR)/etc/auto.master | grep \"auto.ftpfs\"`" ]; then mkdir -p $(DESTDIR)/mnt/net/ssh $(DESTDIR)/mnt/net/ftp; echo -e "/mnt/net/ssh\t/etc/auto.sshfs\t--timeout=60\n/mnt/net/ftp\t/etc/auto.ftpfs\t--timeout=60\n" >> $(DESTDIR)/etc/auto.master; $(DESTDIR)/etc/init.d/autofs restart; fi
        
index b0b112b..4d27412 100644 (file)
@@ -8,6 +8,7 @@
 #include <paths.h>
 #include <fcntl.h>
 #include <string.h>
+#include <pwd.h>
 
 #include <sys/types.h>
 #include <sys/mount.h>
@@ -99,9 +100,20 @@ get_opt(char *opts, const char *optname, char *buf, int buflen){
     return 0;
 }
 
+/* From util-linux/mount/getusername.c */
+const char *
+getusername() {
+    const char *user = 0;
+    struct passwd *pw = getpwuid(getuid());
+
+    if (pw)
+       user = pw->pw_name;
+    return user;
+}
+
 int
 main(int argc, char **argv){
-    char *mountpoint, *opts;
+    char *mountpoint, *opts, *s;
     static char fpath[PATH_MAX];
     static char mfs[PATH_MAX];
     static char mopts[PATH_MAX];
@@ -139,10 +151,12 @@ main(int argc, char **argv){
        return errno;
     }
 
-    sprintf(mopts, "owner=%d,", getuid());
+    snprintf(mopts, sizeof(mopts), "user=%s,", getusername());
     hide_pass(opts);
     if(strlen(mopts) + strlen(opts) < PATH_MAX)
        strcat(mopts, opts);
+    while ((s = strstr(mopts, ",user")) && (s[strlen(",user")]==0 || s[strlen(",user")]==','))
+       memmove(s, s+strlen(",user"), strlen(s+strlen(",user"))+1);
     mfs[0] = 0;
     get_opt(opts, "fs", mfs, PATH_MAX);
     get_opt(opts, "mntent.mnt_fsname", mfs, PATH_MAX);
diff --git a/util/lufsumount.c b/util/lufsumount.c
deleted file mode 100644 (file)
index 366cba3..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <limits.h>
-#include <errno.h>
-#include <mntent.h>
-#include <paths.h>
-#include <fcntl.h>
-#include <string.h>
-
-#include <sys/types.h>
-#include <sys/mount.h>
-#include <sys/stat.h>
-
-#define MTAB_TMP _PATH_MOUNTED".tmp"
-
-static void
-help(){
-    printf("\n");
-    printf("Usage: lufsumount mount-point\n");
-
-}
-
-static int
-fullpath(char *path, char *full){
-    
-    full[0] = 0;
-    
-    if(strlen(path) >= PATH_MAX - 1)
-       return -1;
-
-    if(!realpath(path, full))
-       return -1;
-    else 
-       return 0;
-}
-
-int
-main(int argc, char **argv){
-    char *mountpoint;
-    static char fpath[PATH_MAX];
-    struct mntent *ment;
-    int fd, muid = -1;
-    FILE *mtab, *new_mtab;
-    
-    if(argc != 2){
-       help();
-       return 1;
-    }
-    
-    if(geteuid()){
-       fprintf(stderr, "lufsumount should be installed suid root\n");
-       return 1;
-    }
-        
-    mountpoint = argv[1];
-
-    fullpath(mountpoint, fpath);
-    
-    if((fd = open(_PATH_MOUNTED"~", O_RDWR|O_CREAT|O_EXCL, 0600)) < 0){
-       fprintf(stderr, "can't get "_PATH_MOUNTED"~ lock file");
-       return 1;
-    }
-    
-    close(fd);
-    
-    if((mtab = setmntent(_PATH_MOUNTED, "r")) == NULL){
-       fprintf(stderr, "can't open "_PATH_MOUNTED ":%s\n", strerror(errno));
-       goto err;
-    }
-
-    if((new_mtab = setmntent(MTAB_TMP, "w")) == NULL){
-       fprintf(stderr, "can't open "MTAB_TMP": %s\n", strerror(errno));
-       endmntent(mtab);
-       goto err;
-    }
-    
-    while((ment = getmntent(mtab))){
-       if(!strcmp(ment->mnt_dir, fpath)){
-           sscanf(ment->mnt_opts, "owner=%u,", &muid);
-       }else
-           addmntent(new_mtab, ment);
-    }
-
-    endmntent(mtab);
-
-    if(fchmod(fileno(new_mtab), 0644) < 0){
-       fprintf(stderr, "can't change mode for "MTAB_TMP"\n");
-       goto err;
-    }
-
-    endmntent(new_mtab);
-    
-    if(muid == -1){
-       fprintf(stderr, "mtab entry for %s not found\n", fpath);
-       goto err_mtab;
-    }
-
-    if((getuid()) && (getuid() != muid)){
-       fprintf(stderr, "you are not allowed to umount this filesystem.\n");
-       goto err_mtab;
-    }
-
-    if(umount(fpath)){
-       fprintf(stderr, "could not umount %s: %s\n", fpath, strerror(errno));
-       goto err_mtab;
-    }
-
-    if(rename(MTAB_TMP, _PATH_MOUNTED) < 0){
-       fprintf(stderr, "can't rename %s to %s: %s\n", MTAB_TMP, _PATH_MOUNTED, strerror(errno));
-       goto err_mtab;
-    }
-
-    if(unlink(_PATH_MOUNTED"~") < 0){
-       fprintf(stderr, "can't remove "_PATH_MOUNTED"~\n");
-       return 1;
-    }
-    
-    return 0;
-
-err_mtab:
-    unlink(MTAB_TMP);
-err:
-    unlink(_PATH_MOUNTED"~");
-    return 1;
-}
-