./util/auto.sshfs
./util/lufsmnt-bin
./util/lufsmount
- ./util/lufsumount
./kernel/Linux/prepmod
./kernel/Linux/modbin/*.o
./kernel/Linux/modbin/prepmod-tmp-dir
/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
# These are SUID root...
%defattr(4755,root,root)
%{_bindir}/lufsmnt
-%{_bindir}/lufsumount
%changelog
* Wed Aug 20 2003 Jan Kratochvil <project-captive@jankratochvil.net>
-man1_MANS=lufsmount.1 lufsumount.1
-EXTRA_DIST=lufsmount.1 lufsumount.1
+man1_MANS=lufsmount.1
+EXTRA_DIST=lufsmount.1
.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
.SH AUTHOR
Florin Malita <mali at go dot ro>
.SH "SEE ALSO"
-.BR lufsumount (1),
.BR mount (8),
.BR umount (8)
+++ /dev/null
-.\" 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)
-
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
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
#include <paths.h>
#include <fcntl.h>
#include <string.h>
+#include <pwd.h>
#include <sys/types.h>
#include <sys/mount.h>
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];
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);
+++ /dev/null
-#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;
-}
-