diff options
author | Miklos Szeredi <miklos@szeredi.hu> | 2008-10-08 11:07:48 +0000 |
---|---|---|
committer | Miklos Szeredi <miklos@szeredi.hu> | 2008-10-08 11:07:48 +0000 |
commit | 8a4015a3b6bba62e320994f7c1bf23e4014683a4 (patch) | |
tree | 1e3f495f6cdb9c9024137658d84aa70f0fad0b66 /sshfs.c | |
parent | fd52ef3e51efe674386c2b62fead27128da37179 (diff) | |
download | sshfs-8a4015a3b6bba62e320994f7c1bf23e4014683a4.tar sshfs-8a4015a3b6bba62e320994f7c1bf23e4014683a4.tar.gz sshfs-8a4015a3b6bba62e320994f7c1bf23e4014683a4.tar.bz2 sshfs-8a4015a3b6bba62e320994f7c1bf23e4014683a4.zip |
* Handle numerical IPv6 addresses enclosed in square brackets. Reported by Andre-John Mas * Fix error if username contains a comma character. Reported by Yang Zhang
Diffstat (limited to 'sshfs.c')
-rw-r--r-- | sshfs.c | 49 |
1 files changed, 47 insertions, 2 deletions
@@ -3091,6 +3091,36 @@ static void set_ssh_command(void) } } +static char *find_base_path(void) +{ + char *s = sshfs.host; + char *d = s; + + for (; *s && *s != ':'; s++) { + if (*s == '[') { + /* + * Handle IPv6 numerical address enclosed in square + * brackets + */ + s++; + for (; *s != ']'; s++) { + if (!*s) { + fprintf(stderr, "missing ']' in hostname\n"); + exit(1); + } + *d++ = *s; + } + } else { + *d++ = *s; + } + + } + *d++ = '\0'; + s++; + + return s; +} + int main(int argc, char *argv[]) { int res; @@ -3148,8 +3178,7 @@ int main(int argc, char *argv[]) } fsname = g_strdup(sshfs.host); - base_path = strchr(sshfs.host, ':'); - *base_path++ = '\0'; + base_path = find_base_path(); if (base_path[0] && base_path[strlen(base_path)-1] != '/') sshfs.base_path = g_strdup_printf("%s/", base_path); else @@ -3208,6 +3237,22 @@ int main(int argc, char *argv[]) tmp = g_strdup_printf("-omax_write=%u", sshfs.max_write); fuse_opt_insert_arg(&args, 1, tmp); g_free(tmp); + /* + * Remove commas from fsname, as it confuses the fuse option + * parser. + * + * FIXME: escape commas instead. Needs support in libfuse. + */ + if (strchr(fsname, ',') != NULL) { + char *s = fsname; + char *d = s; + + for (; *s; s++) { + if (*s != ',') + *d++ = *s; + } + *d = *s; + } #if FUSE_VERSION >= 27 libver = fuse_version(); assert(libver >= 27); |