findsmb patch

Jeff schaller at southwind.net
Sun Jan 16 18:53:59 GMT 2000


Hello Herb, all.  I recently played a bit harder with Samba, as I'm
working on getting it set up for my sister (remotely). I came across
Herb's old 'findsmb' perl script which got me a lot further along than
I had been.  I wanted to note a small patch I made in order for the
script to deal with 'bad' characters in the machine names:

--- /usr/bin/findsmb    Mon Oct 12 20:03:10 1998
+++ findsmb     Sun Jan 16 10:30:11 2000
@@ -79,7 +79,8 @@

 # do an smbclient command on the netbios name.

-    open(SMB,"$SAMBABIN/smbclient -N -L $name -I $ip -U% |") ||
+    ($ename = $name) =~ s/"/\\"/g;
+    open(SMB,"$SAMBABIN/smbclient -N -L \"$ename\" -I $ip -U% |") ||
        die("Can't do smbclient command.\n");
     @smb = <SMB>;
     close SMB;


==> end diff

The patch just changes findsmb so that it changes any double-quote
marks in the name into escaped double-quote marks, then protects the
name from the shell with double-quote marks.  Otherwise, machines like
"Lauren's box" gave errors.  There may be a better way to do it, but
this fixed the error I saw, so :)

-jeff
-- 
According to a recent Justice Department report, the number of jailed
Americans more than doubled over the past 12 years. What do you think
about America's soaring prison population? "I have only one question: How
will this affect the Internet?"  Dennis Herndon, Magazine Editor
http://www.theonion.com/onion3511/wdyt_3511.html



More information about the samba mailing list