[Samba] libsmbclient problem

Philipp Janda siffiejoe at gmx.net
Fri Nov 29 15:52:01 GMT 2002


Hi *,

I have a problem (configuration problem probably) using the libsmbclient 
library (samba 2.2.6/7).

I use a small c program to open directories (workgroups and servers) and 
list the contents of these dirs.
I have two samba servers int the network. The first is everything-master 
and wins server, the second is nothing like that. The program works fine 
if I run it on the first server (using the /etc/smb.conf) but it doesn't 
work on the second samba server (using its /etc/smb.conf).

errors:
1) list all workgroups
$ ./list smb://
smbc_opendir: Invalid argument

# means: A NULL file/URL was passed, or the URL would not parse, or was 
of incorrect form or smbc_init not called.
# lists the available workgroups when called on first server

2) list servers in workgroup RATNET
$ ./list smb://RATNET/
smbc_opendir: No such device

# means: the workgroup or server could not be found.
# lists servers when called on first server



Listing dirctories and shares works with both samba servers.

My question is: which options in the smb.conf file are used by 
libsmbclient (and which options could be wrong in my case)?

I've listed the (in my eyes) important options below...

<first server (works)>
workgroup = RATNET
security = user
interfaces = 172.17.10.3/255.255.255.0 127.0.0.1
bind interfaces only = yes
domain master = yes
local master = yes
preferred master = yes
os level = 65
name resolve order = lmhosts wins bcast
wins support = yes
wins proxy = yes
</first server>

<second server (doesn't work)>
workgroup = RATNET
security = share
domain master = no
local master = no
preferred master = no
os level = 0
name resolve order = lmhosts wins bcast
wins support = no
wins server = 172.17.10.3
</second server>


I've appended my test program at the end of this mail.
$ smbclient -L 172.17.10.3
# works and lists all information I need (on both samba servers)


Thanks for any help,
Philipp



-------------- next part --------------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

#include "libsmbclient.h"


static void auth_func( char const* server,
                       char const* share,
                       char* workgroup, int wglen,
                       char* username,  int unlen,
                       char* password,  int pwlen ) {
#if 1 
  printf( "need authentication: smb://%s/%s\n", server, share );
#endif
  if ( workgroup[0] != '\0' ) {
    memset( workgroup, '\0', wglen );
    snprintf( workgroup, wglen-1, "%s", "RATNET" );
  }
}

/* main function */
int main( int argc, char** argv ) {
  char const* smburl = argc > 1 ? argv[1] : "smb://RATNET/";
  struct smbc_dirent* dirp;
  int handle;

  /* open libsmbclient library... */
  if( smbc_init( auth_func, 10 ) < 0 ) {
    perror( "smbc_init" );
    return 1;
  }

  /* open directory */
  handle = smbc_opendir( smburl );
  if( handle < 0 ) {
    perror( "smbc_opendir" );
    return 1;
  }

  /* read dir contents */
  errno = 0;
  while( (dirp=smbc_readdir( handle )) != NULL ) {
    printf( "%s\n", dirp->name );
  }
  if( errno != 0 ) {
    perror( "smbc_readdir" );
    smbc_closedir( handle );
    return 1;
  }
  printf( "Done.\n" );

  /* close dir */
  smbc_closedir( handle );
  return 0;
}



More information about the samba mailing list