Bug? No, feature. A hacked patch for Linux smbmount.

nfudd at mellor.bc.ca nfudd at mellor.bc.ca
Thu Jan 18 20:26:18 GMT 2001

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($_), at 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 at mellor.bc.ca

More information about the samba mailing list