Commit [8cffdb] Maximize Restore History

preparing for release

Miklos Szeredi Miklos Szeredi 2001-11-09

added patch/.cvsignore
added patch/Makefile.am
changed example/Makefile.am
changed example/fusexmp.c
changed include/linux/fuse.h
changed include/fuse.h
changed kernel/dev.c
changed kernel/dir.c
changed kernel/fuse_i.h
changed kernel/inode.c
changed lib/Makefile.am
changed lib/fuse.c
changed lib/fuse_i.h
changed util/Makefile.am
changed util/fusermount.c
changed AUTHORS
changed ChangeLog
changed Makefile.am
changed NEWS
changed README
changed configure.in
copied lib/mount.c -> patch/ms_permission.patch
patch/.cvsignore Diff Switch to side-by-side view
Loading...
patch/Makefile.am Diff Switch to side-by-side view
Loading...
example/Makefile.am Diff Switch to side-by-side view
Loading...
example/fusexmp.c Diff Switch to side-by-side view
Loading...
include/linux/fuse.h Diff Switch to side-by-side view
Loading...
include/fuse.h Diff Switch to side-by-side view
Loading...
kernel/dev.c Diff Switch to side-by-side view
Loading...
kernel/dir.c Diff Switch to side-by-side view
Loading...
kernel/fuse_i.h Diff Switch to side-by-side view
Loading...
kernel/inode.c Diff Switch to side-by-side view
Loading...
lib/Makefile.am Diff Switch to side-by-side view
Loading...
lib/fuse.c Diff Switch to side-by-side view
Loading...
lib/fuse_i.h Diff Switch to side-by-side view
Loading...
util/Makefile.am Diff Switch to side-by-side view
Loading...
util/fusermount.c Diff Switch to side-by-side view
Loading...
AUTHORS Diff Switch to side-by-side view
Loading...
ChangeLog Diff Switch to side-by-side view
Loading...
Makefile.am Diff Switch to side-by-side view
Loading...
NEWS Diff Switch to side-by-side view
Loading...
README Diff Switch to side-by-side view
Loading...
configure.in Diff Switch to side-by-side view
Loading...
lib/mount.c to patch/ms_permission.patch
--- a/lib/mount.c
+++ b/patch/ms_permission.patch
@@ -1,145 +1,62 @@
-/*
-    FUSE: Filesystem in Userspace
-    Copyright (C) 2001  Miklos Szeredi (mszeredi@inf.bme.hu)
-
-    This program can be distributed under the terms of the GNU GPL.
-    See the file COPYING.
-*/
-
-#include "fuse_i.h"
-#include <linux/fuse.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <fcntl.h>
-#include <sys/mount.h>
-#include <mntent.h>
-
-static int do_mount(const char *dev, const char *dir, const char *type,
-                    mode_t rootmode, int fd)
-{
-    int res;
-    struct fuse_mount_data data;
-    
-    data.version = FUSE_KERNEL_VERSION;
-    data.fd = fd;
-    data.rootmode = rootmode;
-
-    res = mount(dev, dir, type, MS_MGC_VAL | MS_NOSUID | MS_NODEV, &data);
-    if(res == -1) {
-        perror("mount failed");
-	return -1;
-    }
-    
-    return 0;
-}
-
-static void add_mntent(const char *dev, const char *dir, const char *type)
-{
-    int res;
-    FILE *fp;
-    struct mntent ent;
-    
-    fp = setmntent("/etc/mtab", "a");
-    if(fp == NULL) {
-        perror("setmntent");
-	return;
-    }
-    
-    ent.mnt_fsname = (char *) dev;
-    ent.mnt_dir = (char *) dir;
-    ent.mnt_type = (char *) type;
-    ent.mnt_opts = "rw,nosuid,nodev";
-    ent.mnt_freq = 0;
-    ent.mnt_passno = 0;
-    res = addmntent(fp, & ent);
-    if(res != 0)
-	perror("addmntent");
-    
-    endmntent(fp);
-
-}
-
-static void remove_mntent(const char *dir)
-{
-    int res;
-    FILE *fdold, *fdnew;
-    struct mntent *entp;
-        
-    fdold = setmntent("/etc/mtab", "r");
-    if(fdold == NULL) {
-        perror("/etc/mtab");
-	return;
-    }
-
-    fdnew = setmntent("/etc/mtab~", "w");
-    if(fdnew == NULL) {
-        perror("/etc/mtab~");
-	return;
-    }
-
-    do {
-	entp = getmntent(fdold);
-	if(entp != NULL && strcmp(entp->mnt_dir, dir) != 0) {
-            res = addmntent(fdnew, entp);
-            if(res != 0)
-                perror("addmntent");
-        }
-    } while(entp != NULL);
-
-    endmntent(fdold);
-    endmntent(fdnew);
-
-    res = rename("/etc/mtab~", "/etc/mtab");
-    if(res == -1)
-        perror("renameing /etc/mtab~ to /etc/mtab");
-}
-
-int fuse_mount(struct fuse *f, const char *dir)
-{
-    int res;
-    const char *dev = FUSE_DEV;
-    const char *type = "fuse";
-
-    if(f->mnt != NULL)
-        return 0;
-
-    f->fd = open(dev, O_RDWR);
-    if(f->fd == -1) {
-        perror(dev);
-        return -1;
-    }
-    
-    res = do_mount(dev, dir, type, f->rootmode, f->fd);
-    if(res == -1)
-        return -1;
-
-    add_mntent(dev, dir, type);
-    f->mnt = strdup(dir);
-    
-    return 0;
-}
-
-int fuse_unmount(struct fuse *f)
-{
-    int res;
-
-    if(f->mnt == NULL)
-        return 0;
-
-    close(f->fd);
-    f->fd = -1;
-
-    res = umount(f->mnt);
-    if(res == -1)
-        perror("umount failed");
-    else
-        remove_mntent(f->mnt);
-
-    free(f->mnt);
-    f->mnt = NULL;
-
-    return res;
-}
+--- /store/linux/linux-2.4.14.tar.gz#/linux/fs/namespace.c	Fri Nov  9 08:58:10 2001
++++ linux/fs/namespace.c	Fri Nov  9 09:31:04 2001
+@@ -478,20 +478,15 @@
+ 
+ static int mount_is_safe(struct nameidata *nd)
+ {
+-	if (capable(CAP_SYS_ADMIN))
+-		return 0;
+-	return -EPERM;
+-#ifdef notyet
+ 	if (S_ISLNK(nd->dentry->d_inode->i_mode))
+ 		return -EPERM;
+ 	if (nd->dentry->d_inode->i_mode & S_ISVTX) {
+-		if (current->uid != nd->dentry->d_inode->i_uid)
++		if (current->fsuid != nd->dentry->d_inode->i_uid)
+ 			return -EPERM;
+ 	}
+ 	if (permission(nd->dentry->d_inode, MAY_WRITE))
+ 		return -EPERM;
+ 	return 0;
+-#endif
+ }
+ 
+ static struct vfsmount *copy_tree(struct vfsmount *mnt, struct dentry *dentry)
+@@ -570,9 +565,10 @@
+ {
+ 	struct nameidata old_nd;
+ 	struct vfsmount *mnt = NULL;
+-	int err = mount_is_safe(nd);
+-	if (err)
+-		return err;
++	int err = 0;
++
++	if (!capable(CAP_SYS_ADMIN))
++		return -EPERM;
+ 	if (!old_name || !*old_name)
+ 		return -EINVAL;
+ 	if (path_init(old_name, LOOKUP_POSITIVE|LOOKUP_FOLLOW, &old_nd))
+@@ -741,6 +737,13 @@
+ 		retval = path_walk(dir_name, &nd);
+ 	if (retval)
+ 		return retval;
++
++	if (flags & MS_PERMISSION) {
++		retval = mount_is_safe(&nd);
++		if(retval)
++			return retval;
++	}
++	flags &= ~MS_PERMISSION;
+ 
+ 	if (flags & MS_REMOUNT)
+ 		retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
+--- /store/linux/linux-2.4.14.tar.gz#/linux/include/linux/fs.h	Fri Nov  9 08:58:51 2001
++++ linux/include/linux/fs.h	Fri Nov  9 09:24:21 2001
+@@ -105,6 +105,7 @@
+ #define MS_SYNCHRONOUS	16	/* Writes are synced at once */
+ #define MS_REMOUNT	32	/* Alter flags of a mounted FS */
+ #define MS_MANDLOCK	64	/* Allow mandatory locks on an FS */
++#define MS_PERMISSION	128	/* Check write permission on mount target */
+ #define MS_NOATIME	1024	/* Do not update access times. */
+ #define MS_NODIRATIME	2048	/* Do not update directory access times */
+ #define MS_BIND		4096