smb2www - libsmbclient.so

Alain BARBET alian at alianwebserver.com
Thu Jan 3 03:27:01 GMT 2002


Hi,

I just upload on CPAN version 0.7 of Perl module Filesys-SmbClient.
(It use libsmbclient.so to provide perl method to access smb filesystem).
It comes with a cgi script smb2www-2.cgi
Features for now are:
- browse share, dir
- read file
- upload file
- create dir
- unlink file
Waiting CPAN put file on mirrors, you can found it here:
http://www.alianwebserver.com/tmp/Filesys-SmbClient-0.7.tar.gz

But there is 2 problems with that, pb that I already know:
1/ trivial
Here the code in SmbClient.pm ....

# Here is a temporary hack:
# Actually libsmbclient will segfault if it can't find file
# $ENV{HOME}/.smb/smb.conf so I will test if it exist,
# and create it if no file is found. A empty file is enough ...
# In cgi environnement, $ENV{HOME} can be unset because
# nobody is not a real user. So I will set $ENV{HOME} to dir /tmp
if (!$ENV{HOME}) {$ENV{HOME}="/tmp";}
if (!-e "$ENV{HOME}/.smb/smb.conf")
   {
    print STDERR "you don't have a $ENV{HOME}/.smb/smb.conf, ",
       "I will create it (empty file)\n";
     mkdir "$ENV{HOME}/.smb" unless (-e "$ENV{HOME}/.smb");
     open(F,">$ENV{HOME}/.smb/smb.conf") ||
     die "Can't create $ENV{HOME}/.smb/smb.conf : $!\n";
     close(F);	
   }
# End of temporary hack

Not really beautiful no ? and add a test in libsmbclient.so is not too 
hard no ? I know that there is a lot of job around smb.conf, but if only
a empty file is mandatory, it's not a good reason.

2/ need to add method in libsmbclient ...
Problem with:
CGI persistant (FAST-cgi, mod-perl) / User connection / security
As I can understand, there is a poll of connection in libsmbclient.so
I a user is already connected, password is not checked and open 
connection is given. So in one shot CGI, no problem.
No with persistant:
First a user will successful logged. He do his job and go on. Now a 
second user come. CGI script will not go down on web server and smb 
connection is always open. If second user provide a correct name, he can 
use connection of first user without know the password :-((
A workaround is to provide method that check that a user/password is 
correct on a given server.


I know that I have already asked for this feature on this list, but I 
hope that for a open source project I will receive more result ;-)

Thanks for R.Sharpe and others for job they do on Samba.
Sorry for bad english.
Regards,
--
Alain BARBET










More information about the samba-technical mailing list