libsmbclient - 2.2 and HEAD
Ben Menking
coder at menking.net
Tue Oct 2 09:25:04 GMT 2001
Please see the code below (it should remind you of libsmbclient.c -
smbc_server()). I've written some comments into the code that explain the
problem. Is this a known problem between 2.2.1a and HEAD?
<code>
/*
* Authenticates a user (user) with password (pass) in domain (dom)
* to Windows Domain server (s1)
* Mercilessly torn from libsmb/libsmbclient.c
*/
#include <includes.h>
#include "auth.h"
int auth_user(char *user, char *pass, char *dom, char *s1)
{
struct cli_state c;
struct nmb_name calling, called;
pstring ipenv;
struct in_addr ip;
extern struct in_addr ipzero;
ip = ipzero;
ZERO_STRUCT(c);
make_nmb_name(&calling, "", 0x0);
make_nmb_name(&called , s1, 0x20);
again:
slprintf(ipenv,sizeof(ipenv)-1,"HOST_%s", s1);
ip = ipzero;
if (!cli_initialise(&c) || !cli_connect(&c, s1, &ip))
{
return AUTH_FAILED;
}
if (!cli_session_request(&c, &calling, &called))
{
cli_shutdown(&c);
/*
Here's where the problem exists. When I compile and link this with the
HEAD samba code the auth_user() function returns AUTH_FAILED or AUTH_OK
as e xpected.
BUT when I compile and link this code with the 2.2.1a samba code the
var called.name _always_ equals "*SMBSERVER" and the code infinitely
loops. Has anyone seen this or know how to fix?
*/
if (strcmp(called.name, "*SMBSERVER"))
{
make_nmb_name(&called , "*SMBSERVER", 0x20);
printf("auth_user: make_nmb_name\n");
goto again;
}
return AUTH_FAILED;
}
if (!cli_negprot(&c))
{
cli_shutdown(&c);
return AUTH_FAILED;
}
if (!cli_session_setup(&c, user, pass, strlen(pass), pass,
strlen(pass), dom))
{
cli_shutdown(&c);
return AUTH_FAILED;
}
else
{
return AUTH_OK;
}
}
</code>
--
Ben Menking
<coder at menking.net>
http://www.menking.net/
More information about the samba-technical
mailing list