On Sat, Sep 22, 2007 at 03:44:37PM -0700, [EMAIL PROTECTED] wrote:
> so, because ltspfs mounts in /tmp/.ltspfs-username/* and then bind
> mounts into /media/username/*, gnome-vfs sees this as two different
> devices. apparently this does not happen in ubuntu. no idea for KDE or
> other systems.
> 
> i think it would be possible, if not desireable, to reconfigure the
> mount to happen directly into /media/username. this would require
> patches to lbmount and ltspfsmounter, at least.

managed to put together a couple proof of concept patches that mount
directly into /media/username that also simplify the code (especially
the code run as root).

basically, just switched the order of the ltspfs mount and the
/media/username directory creation, and dropped the bind mount from
lbmount. in order to do this, /media/username/* needs to be made
writeable by the user's group (the patch does this in lbmount).

works from the commandline, haven't tested with gnome or kde or anything
with a desktop, really.

patches attached.

live well,
  vagrant
=== modified file 'scripts/ltspfsmounter'
--- scripts/ltspfsmounter	2006-09-16 23:44:02 +0000
+++ scripts/ltspfsmounter	2007-11-24 07:55:35 +0000
@@ -8,57 +8,44 @@
     return os.environ.get(name)
 
 def add_ltspfsmount(conn, path, root, dev):
-    hidden_mount = '%s/%s' % (root, dev)
     lbmount_command = ['lbmount', dev]
     ltspfs_mount = ['ltspfs', conn+':'+path, root+'/'+dev]
 
-    if not os.access(root, 0):
-        os.mkdir(root)
-    if not os.access(hidden_mount, 0):
-        os.mkdir(hidden_mount)
-
     env = os.environ.copy()
-    env['DISPLAY'] = 'localhost:10.0'
 
     try:
+        call(lbmount_command)
+    except OSError, e:
+        print >>sys.stderr, "suid mount failed:", e
+    try:
 		call(ltspfs_mount, env=env)
     except OSError, e:
         print >>sys.stderr, "mount failed:", e
-    try:
-        call(lbmount_command)
-    except OSError, e:
-        print >>sys.stderr, "suid mount failed:", e
 
 def remove_ltspfsmount(root, dev):
-    hidden_mount = "%s/%s" % (root, dev)
     lbumount_command=['lbmount', '--umount', dev]
     ltspfs_umount=['fusermount', '-uzq', root+'/'+dev]
 
     try:
+        call(ltspfs_umount)
+    except OSError, e:
+        print >>sys.stderr, "umount failed:", e
+
+    try:
         call(lbumount_command)
     except OSError, e:
         print >>sys.stderr, "suid umount failed:", e
-    try:
-        call(ltspfs_umount)
-    except OSError, e:
-        print >>sys.stderr, "umount failed:", e
-
-    if os.access(hidden_mount, 0):
-        os.rmdir(hidden_mount)
 
 def cleanup(user):
     known_mounts = open( '/proc/mounts', 'r' ).readlines()
-    for dir in ['/media', '/tmp']:
+    for dir in ['/media']:
         for mount in known_mounts:
             if mount.startswith('ltspfs') and user in mount:
                 mountpoint=mount.split()[1]
                 device=mountpoint.split('/')[-1]
                 if dir=='/media' and mountpoint.startswith(dir):
+                    call(['fusermount', '-uzq', mountpoint])
                     call(['lbmount', '--umount', device])
-                elif dir=='/tmp' and mountpoint.startswith(dir):
-                    call(['fusermount', '-uzq', mountpoint])
-                    if os.access(mountpoint, 0):
-                        os.rmdir(mountpoint)
     sys.exit(0)
 
 def main():
@@ -68,7 +55,7 @@
 
     path = sys.argv[1]
     command = sys.argv[2]
-    root = "/tmp/.%s-ltspfs" % get_var('USER')
+    root = "/media/%s" % get_var('USER')
     conn = get_var('SSH_CONNECTION').split()[0]
     dev = path.split('/')[-1]
 

=== modified file 'src/lbmount.c'
--- src/lbmount.c	2007-08-21 20:01:32 +0000
+++ src/lbmount.c	2007-11-24 08:41:13 +0000
@@ -115,53 +115,8 @@
             exit(1);
         }
     }
-}
-
-/*
- * domount: actually bindmounts path1 onto path2.
- */
-
-int root_mounter(const char *path1, const char *path2)
-{
-    int status;
-    pid_t child;
-    char *program;
-    char *null_env[] = { NULL };
-
-    child = fork();
-
-    if (child == 0) {
-        if (setreuid(0, -1)) {
-            /* Couldn't become root */
-            perror("Couldn't obtain root privs");
-            exit(1);
-        }
-        /* Statically build command line to prevent monkey business */
-        if (path2)
-            execle(mountprog, mountprog, "--bind", path1, path2, NULL,
-                   null_env);
-        else
-            execle(umountprog, umountprog, path1, NULL, null_env);
-        perror("Error: execl() returned");
-        exit(1);                                 /* exec should never return */
-    } else if (child > 0) {
-        if (waitpid(child, &status, 0) < 0) {
-            perror("Error: wait() call failed");
-            exit(1);
-        }
-    } else if (child < 0) {
-        perror("Error: fork() failed");
-        exit(1);
-    }
-
-    if (!WIFEXITED(status)) {
-        fprintf(stderr, "Error: execle() returned no status");
-        exit(1);
-    }
-
-    return WEXITSTATUS(status);
-}
-
+    chmod(dir, 0775);
+}
 
 /*
  * mainline
@@ -240,16 +195,6 @@
         exit(1);
     }
 
-    /*
-     * Build our ltspfs mountpoint string, and check and see if it exists.
-     */
-
-    snprintf(ltspfsmount, sizeof(ltspfsmount), "%s%s%s%s",
-             ltspfsdir1, pwent->pw_name, ltspfsdir2, mountpoint);
-
-    if (!is_mounted(ltspfsmount))
-        exit(1);
-
     if (!umount) {
         /* OK, name's a normal size, and looks valid. Begin creating the media
          * mount point. First, we need to create /media/uid */
@@ -266,16 +211,13 @@
 
         mkdir_safe(mediamount);
 
-        return root_mounter(ltspfsmount, mediamount);
     } else {
         /* umount */
 
         snprintf(mediamount, sizeof(mediamount), "%s/%s/%s", mediadir,
                  pwent->pw_name, mountpoint);
 
-        if (is_mounted(mediamount))
-            root_mounter(mediamount, NULL);
-        else {
+        if (is_mounted(mediamount)) {
             fprintf(stderr, "Error: %s unmountable", mediamount);
             exit(1);
         }

Reply via email to