From 1a398ab80814546067994ccc58e59a5168f03458 Mon Sep 17 00:00:00 2001 From: short <> Date: Wed, 19 Nov 2003 11:39:46 +0000 Subject: [PATCH] Drop lufsumount(1) in the favor of compatibility with generic umount(8). --- autogen.pl | 1 - debian/lufs.files | 1 - lufs.spec.in | 1 - man/Makefile.am | 4 +- man/lufsmount.1 | 7 ++- man/lufsumount.1 | 28 ------------ util/Makefile.am | 5 +-- util/lufsmnt.c | 18 +++++++- util/lufsumount.c | 128 ------------------------------------------------------ 9 files changed, 23 insertions(+), 170 deletions(-) delete mode 100644 man/lufsumount.1 delete mode 100644 util/lufsumount.c diff --git a/autogen.pl b/autogen.pl index 7556c71..6026723 100755 --- a/autogen.pl +++ b/autogen.pl @@ -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 diff --git a/debian/lufs.files b/debian/lufs.files index b8409bd..99c05c7 100644 --- a/debian/lufs.files +++ b/debian/lufs.files @@ -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 diff --git a/lufs.spec.in b/lufs.spec.in index b6f4336..d0209f1 100644 --- a/lufs.spec.in +++ b/lufs.spec.in @@ -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 diff --git a/man/Makefile.am b/man/Makefile.am index 1f52e24..2741524 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -1,2 +1,2 @@ -man1_MANS=lufsmount.1 lufsumount.1 -EXTRA_DIST=lufsmount.1 lufsumount.1 +man1_MANS=lufsmount.1 +EXTRA_DIST=lufsmount.1 diff --git a/man/lufsmount.1 b/man/lufsmount.1 index 1276f39..c46390d 100644 --- a/man/lufsmount.1 +++ b/man/lufsmount.1 @@ -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 .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 index 17ce9f7..0000000 --- a/man/lufsumount.1 +++ /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 -.SH "SEE ALSO" -.BR lufsmount (1), -.BR mount (8), -.BR umount (8) - diff --git a/util/Makefile.am b/util/Makefile.am index 5d54990..3a7b335 100644 --- a/util/Makefile.am +++ b/util/Makefile.am @@ -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 diff --git a/util/lufsmnt.c b/util/lufsmnt.c index b0b112b..4d27412 100644 --- a/util/lufsmnt.c +++ b/util/lufsmnt.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -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 index 366cba3..0000000 --- a/util/lufsumount.c +++ /dev/null @@ -1,128 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#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; -} - -- 1.8.3.1