aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2009-07-15 14:27:52 +0000
committerMiklos Szeredi <miklos@szeredi.hu>2009-07-15 14:27:52 +0000
commit0eabd863007642ab2e22a7aab72345c32db94822 (patch)
treeee6c35fd1ad8268b31ed46de96cc7ab3158501fe
parentae4614e69045c697b7704b72030dca373b9d0f71 (diff)
downloadsshfs-0eabd863007642ab2e22a7aab72345c32db94822.tar
sshfs-0eabd863007642ab2e22a7aab72345c32db94822.tar.gz
sshfs-0eabd863007642ab2e22a7aab72345c32db94822.tar.bz2
sshfs-0eabd863007642ab2e22a7aab72345c32db94822.zip
Check mountpoint and fuse options before starting an ssh
session (debian bug #535333). This is only supported if compiled against libfuse-2.6 or later. Reported by Greg Kochanski
-rw-r--r--ChangeLog6
-rw-r--r--sshfs.c66
2 files changed, 61 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index d9c45cd..94074c8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-07-15 Miklos Szeredi <miklos@szeredi.hu>
+
+ * Check mountpoint and fuse options before starting an ssh
+ session (debian bug #535333). This is only supported if compiled
+ against libfuse-2.6 or later. Reported by Greg Kochanski
+
2008-07-15 Sebastian Dransfeld <sebastid@tango.flipp.net>
* Add option 'delay_connect': This will always create the sshfs mount,
diff --git a/sshfs.c b/sshfs.c
index 00fb098..cc29799 100644
--- a/sshfs.c
+++ b/sshfs.c
@@ -3156,6 +3156,26 @@ static char *fsname_escape_commas(char *fsnameold)
}
#endif
+static int ssh_connect(void)
+{
+ int res;
+
+ res = processing_init();
+ if (res == -1)
+ return -1;
+
+ if (!sshfs.delay_connect) {
+ if (connect_remote() == -1)
+ return -1;
+
+ if (!sshfs.no_check_root &&
+ sftp_check_root(sshfs.base_path) == -1)
+ return -1;
+
+ }
+ return 0;
+}
+
int main(int argc, char *argv[])
{
int res;
@@ -3240,17 +3260,6 @@ int main(int argc, char *argv[])
ssh_add_arg(sftp_server);
free(sshfs.sftp_server);
- res = processing_init();
- if (res == -1)
- exit(1);
-
- if (!sshfs.delay_connect) {
- if (connect_remote() == -1)
- exit(1);
-
- if (!sshfs.no_check_root && sftp_check_root(sshfs.base_path) == -1)
- exit(1);
- }
res = cache_parse_options(&args);
if (res == -1)
@@ -3267,6 +3276,7 @@ int main(int argc, char *argv[])
fuse_opt_insert_arg(&args, 1, "-oauto_cache,ac_attr_timeout=0");
tmp = g_strdup_printf("-omax_read=%u", sshfs.max_read);
fuse_opt_insert_arg(&args, 1, tmp);
+ g_free(tmp);
tmp = g_strdup_printf("-omax_write=%u", sshfs.max_write);
fuse_opt_insert_arg(&args, 1, tmp);
g_free(tmp);
@@ -3286,7 +3296,41 @@ int main(int argc, char *argv[])
g_free(tmp);
g_free(fsname);
check_large_read(&args);
+
+#if FUSE_VERSION >= 26
+ {
+ struct fuse *fuse;
+ char *mountpoint;
+ int multithreaded;
+
+ fuse = fuse_setup(args.argc, args.argv, cache_init(&sshfs_oper),
+ sizeof(struct fuse_operations), &mountpoint,
+ &multithreaded, NULL);
+ if (fuse == NULL)
+ exit(1);
+
+ res = ssh_connect();
+ if (res == -1)
+ exit(1);
+
+ if (multithreaded)
+ res = fuse_loop_mt(fuse);
+ else
+ res = fuse_loop(fuse);
+
+ fuse_teardown(fuse, mountpoint);
+ if (res == -1)
+ res = 1;
+ else
+ res = 0;
+ }
+#else
+ res = ssh_connect();
+ if (res == -1)
+ exit(1);
+
res = sshfs_fuse_main(&args);
+#endif
if (sshfs.debug) {
unsigned int avg_rtt = 0;