Skip Menu |

This queue is for tickets about the Filesys-SmbClient CPAN distribution.

Report information
The Basics
Id: 26368
Status: new
Priority: 0/
Queue: Filesys-SmbClient

People
Owner: Nobody in particular
Requestors: paul+perl [...] aurich.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Wishlist (Patch): Add support for setting smbcctx options
Date: Sat, 14 Apr 2007 16:52:56 -0700
To: bug-Filesys-SmbClient [...] rt.cpan.org
From: Paul Aurich <paul+perl [...] aurich.com>
I have a script where I need to set context->options.one_share_per_server because Windows servers are unhappy with many open connections. I've created a patch against Filesys-Smbclient-3.1 that works for me on Debian Sid with perl 5.8.8. Thanks, Paul Aurich
diff -ur -x configure orig/config.h.in libfilesys-smbclient-perl-3.1/config.h.in --- orig/config.h.in 2006-09-13 07:28:39.000000000 -0700 +++ libfilesys-smbclient-perl-3.1/config.h.in 2007-04-14 15:54:22.000000000 -0700 @@ -24,6 +24,9 @@ /* define if SMBCTXX->flags flag exist. */ #undef HAVE_SMBCTXX_FLAG +/* define if SMBCTXX->options struct exists. */ +#undef HAVE_SMBCTXX_OPTIONS + /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT diff -ur -x configure orig/configure.in libfilesys-smbclient-perl-3.1/configure.in --- orig/configure.in 2006-09-13 05:34:15.000000000 -0700 +++ libfilesys-smbclient-perl-3.1/configure.in 2007-04-14 15:58:58.000000000 -0700 @@ -46,6 +46,18 @@ AC_MSG_RESULT([You don't define SMBCTXX->flags. Samba older than 3.0.11. Filesys::SmbClient::set_flag will not work]) fi +dnl Did we have SMBCTXX->options ? +AC_TRY_COMPILE([#include <libsmbclient.h>], + [SMBCCTX *c; c->options.browse_max_lmb_count=0;], + smbctxOptions_ok=yes, smbctxOptions_ok=no) +if test "$smbctxOptions_ok" = yes; then + AC_DEFINE(HAVE_SMBCTXX_OPTIONS,,[define if SMBCTXX->options struct exists.]) + AC_MSG_RESULT([Good you have SMBCTXX->options ]) + CFLAGS="$CFLAGS -DHAVE_SMBCTXX_OPTIONS" +else + AC_MSG_RESULT([You don't define SMBCTXX->options. Samba older than 3.0.11. Filesys::SmbClient::set_option will not work]) +fi + dnl This is context->close_fn or context close ? AC_TRY_COMPILE([#include <libsmbclient.h>], [SMBCCTX *c; c->close_fn(c,0);], diff -ur -x configure orig/SmbClient.pm libfilesys-smbclient-perl-3.1/SmbClient.pm --- orig/SmbClient.pm 2006-09-13 06:49:32.000000000 -0700 +++ libfilesys-smbclient-perl-3.1/SmbClient.pm 2007-04-14 16:12:30.000000000 -0700 @@ -265,12 +265,27 @@ $self->{context} = _init(@l); $vars{'flags'} && _set_flags($self->{context}, $vars{'flags'}); + if ($vars{'options'}) { + while (my ($name, $val) = each %{$vars{'options'}}) { + _set_option($self->{context}, $name, $val); + } + } die 'You must have a samba configuration file '. '($HOME/.smb/smb.conf , even if it is empty' unless $self->{context}; return $self; } #------------------------------------------------------------------------------ +# set_option +#------------------------------------------------------------------------------ +sub set_option { + my $self = shift; + my $name = shift; + my $val = shift; + return _set_option($self->{context}, $name, $val); +} + +#------------------------------------------------------------------------------ # set_flag #------------------------------------------------------------------------------ sub set_flag { @@ -440,7 +455,7 @@ $Revision: 3.1 $ -=head1 FONCTIONS +=head1 FUNCTIONS =over @@ -471,6 +486,10 @@ flags : See set_flag +=item * + +options : See set_option (pass a hashref) + =back Return instance of Filesys::SmbClient on succes, die with error else. @@ -486,6 +505,7 @@ =item set_flag Set flag for smb connection. See _SMBCCTX->flags in libsmclient.h + Flag can be: =over @@ -498,6 +518,22 @@ =back +=item set_option + +Set options for smb connection. See _SMBCCTX->options in libsmbclient.h + +Options can be: + +=over + +=item browse_max_lbm_count + +=item urlencode_readdir_entries + +=item one_share_per_server + +=back + =back =head2 Tie Filesys::SmbClient filehandle diff -ur -x configure orig/SmbClient.xs libfilesys-smbclient-perl-3.1/SmbClient.xs --- orig/SmbClient.xs 2006-09-13 05:34:19.000000000 -0700 +++ libfilesys-smbclient-perl-3.1/SmbClient.xs 2007-04-14 16:16:15.000000000 -0700 @@ -78,6 +78,35 @@ OUTPUT: RETVAL +int +_set_option(context, name, val) + SMBCCTX *context + char *name + int val +CODE: +#ifdef HAVE_SMBCTXX_OPTIONS + int *opt = NULL; + + if (!strcasecmp(name, "browse_max_lmb_count")) + opt = &(context->options.one_share_per_server); + else if (!strcasecmp(name, "urlencode_readdir_entries")) + opt = &(context->options.urlencode_readdir_entries); + else if (!strcasecmp(name, "one_share_per_server")) + opt = &(context->options.one_share_per_server); + else { +#ifdef VERBOSE + fprintf(stderr, "*** Error Filesys::SmbClient : " + "set_option %s : no such option\n", name); +#endif + } + + if (opt) + *opt = !!val; +#endif + RETVAL = 1; +OUTPUT: + RETVAL + int _mkdir(context, fname, mode) ------------------------------------------------------------- This message has been scanned by Postini anti-virus software.