nfudd@mellor.bc.ca
2001-Jan-18 20:26 UTC
Bug? No, feature. A hacked patch for Linux smbmount.
I've solved a problem I had with smbmount. I wanted to put smbmount options into /etc/fstab so I could mount a samba share with just 'mount /ftp' or 'mount -a'. It almost worked, except that I was forced to try and mount a share that had a space in it. There is no way to specify spaces in pathnames in /etc/fstab, neither quotes nor backslashes had any effect. (At least not on this Redhat 6.2 Linux i386 system.) So, I moved /usr/bin/smbmount to /usr/bin/smbmount.real and created this perl script named /usr/bin/smbmount: -------- #!/usr/bin/perl -w use strict; exec "$0.real",map(urlunquote($_),@ARGV); sub urlunquote { my $in=$_[0]; if (!defined $in) {return $in;} $in=~ s/\+/ /gi; $in=~ s/%([0-9a-f]{2})/sprintf("%c",hex($1))/gei; return $in; } -------- Now I can include url-style quoting and get the job done. Here's an example of the /etc/fstab entry that works: ----------- //molly_1/FTP%20Share /ftp smbfs username=ftp,password=mypassword,fmask=2660,dmask=2770,uid=200,gid=1000 0 0 ----------- Also, a cron job that says: ----------- */5 * * * * ls /ftp 2>&1 > /dev/null || (umount /ftp ; mount /ftp; echo remounted /ftp) ----------- since the NT share *sometimes* goes weird. Note, this only does something when 'ls' returns an error. If /ftp is completely mounted or unmounted, there is no error. Oh, and then I "chattr +i"'d it, since the last samba RPM that came along clobbered my changes, and broke things on the next boot. I don't know if you'd want to allow url quoting of command line options by default, or if you'd be leery of breaking sites with percent signs in them. Perhaps an option on the command line that says 'I want to use url escaping' would be the best solution. Doesn't break any existing sites, yet allows this feature to be added. -- Nancy Fudd -- nfudd@mellor.bc.ca
On Thu, 18 Jan 2001 nfudd@mellor.bc.ca wrote:> It almost worked, except that I was forced to try and mount a share that > had a space in it. There is no way to specify spaces in pathnames in > /etc/fstab, neither quotes nor backslashes had any effect.If mount won't allow spaces to be escaped with \ then maybe mount should be fixed?> Also, a cron job that says: > ----------- > */5 * * * * ls /ftp 2>&1 > /dev/null || (umount /ftp ; mount /ftp; echo remounted /ftp) > ----------- > since the NT share *sometimes* goes weird. Note, this only does > something when 'ls' returns an error. If /ftp is completely > mounted or unmounted, there is no error.What kernel are you using? Do you get error messages from the kernel when this happens? Does 2.2.18 work any better for you?> I don't know if you'd want to allow url quoting of command line > options by default, or if you'd be leery of breaking sites with percent > signs in them. Perhaps an option on the command line that sayssmbmount allows "username=user%password", so there would be a conflict there. I know you suggest encoding only parts of the arguments, but a lot of the option may contain space.> 'I want to use url escaping' would be the best solution. Doesn't > break any existing sites, yet allows this feature to be added.An option that enables urldecoding of all parameters might be useful, perhaps urldecode or just url. mount -t smbfs -o username=my%20name,workgroup=silly%20name,urldecode \ //bad%20name/foo ... autofs has the same problem (at least some versions) where it wouldn't allow space and give no way to escape them. If mount and autofs is fixed instead this wouldn't be necessary and that would solve the same problem for other filesystems too. /Urban