1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-31 10:50:24 +03:00

Merge branch 'master' of ssh://git.samba.org/data/git/samba

This commit is contained in:
Jelmer Vernooij 2008-12-16 15:36:53 +01:00
commit a7109b183b
83 changed files with 2185 additions and 4601 deletions

2
.gitignore vendored

@ -51,6 +51,8 @@ examples/VFS/skel_transparent.so
*.po
*.pyc
semantic.cache
nsswitch/libnss_winbind.so
nsswitch/libnss_wins.so
source3/bin/*
source3/config.cache
source3/config.log

@ -23,8 +23,8 @@
extensions. This module implements only the "idmap"
API, and is READONLY. Mappings must be provided in advance
by the administrator by adding the posixAccount/posixGroup
classess and relative attribute/value pairs to the users and
groups objects in AD</para>
classes and relative attribute/value pairs to the user and
group objects in the AD.</para>
</refsynopsisdiv>
<refsect1>
@ -34,7 +34,7 @@
<varlistentry>
<term>range = low - high</term>
<listitem><para>
Defines the available matching uid and gid range for which the
Defines the available matching UID and GID range for which the
backend is authoritative. Note that the range acts as a filter.
If specified any UID or GID stored in AD that fall outside the
range is ignored and the corresponding map is discarded.
@ -47,7 +47,7 @@
<listitem><para>
Defines the schema that idmap_ad should use when querying
Active Directory regarding user and group information.
This can either the RFC2307 schema support included
This can be either the RFC2307 schema support included
in Windows 2003 R2 or the Service for Unix (SFU) schema.
</para></listitem>
</varlistentry>
@ -58,8 +58,8 @@
<title>EXAMPLES</title>
<para>
The following example shows how to retrieve idmappings from our principal and
and trusted AD domains. All is needed is to set default to yes. If trusted
domains are present id conflicts must be resolved beforehand, there is no
and trusted AD domains. If trusted domains are present id conflicts must be
resolved beforehand, there is no
guarantee on the order conflicting mappings would be resolved at this point.
This example also shows how to leave a small non conflicting range for local

@ -191,6 +191,14 @@
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>check</option>
</term>
<listitem><para>Check the integrity of the current database.
</para></listitem>
</varlistentry>
<varlistentry>
<term>
<option>quit</option>

@ -1,5 +1,5 @@
<samba:parameter name="acl compatibility"
context="S"
context="G"
type="enum"
advanced="1" developer="1"
xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">

@ -800,3 +800,92 @@ failed:
tdb_unlockall(tdb);
return -1;
}
struct traverse_state {
bool error;
struct tdb_context *dest_db;
};
/*
traverse function for repacking
*/
static int repack_traverse(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *private)
{
struct traverse_state *state = (struct traverse_state *)private;
if (tdb_store(state->dest_db, key, data, TDB_INSERT) != 0) {
state->error = true;
return -1;
}
return 0;
}
/*
repack a tdb
*/
int tdb_repack(struct tdb_context *tdb)
{
struct tdb_context *tmp_db;
struct traverse_state state;
if (tdb_transaction_start(tdb) != 0) {
TDB_LOG((tdb, TDB_DEBUG_FATAL, __location__ " Failed to start transaction\n"));
return -1;
}
tmp_db = tdb_open("tmpdb", tdb_hash_size(tdb), TDB_INTERNAL, O_RDWR|O_CREAT, 0);
if (tmp_db == NULL) {
TDB_LOG((tdb, TDB_DEBUG_FATAL, __location__ " Failed to create tmp_db\n"));
tdb_transaction_cancel(tdb);
return -1;
}
state.error = false;
state.dest_db = tmp_db;
if (tdb_traverse_read(tdb, repack_traverse, &state) == -1) {
TDB_LOG((tdb, TDB_DEBUG_FATAL, __location__ " Failed to traverse copying out\n"));
tdb_transaction_cancel(tdb);
tdb_close(tmp_db);
return -1;
}
if (state.error) {
TDB_LOG((tdb, TDB_DEBUG_FATAL, __location__ " Error during traversal\n"));
tdb_transaction_cancel(tdb);
tdb_close(tmp_db);
return -1;
}
if (tdb_wipe_all(tdb) != 0) {
TDB_LOG((tdb, TDB_DEBUG_FATAL, __location__ " Failed to wipe database\n"));
tdb_transaction_cancel(tdb);
tdb_close(tmp_db);
return -1;
}
state.error = false;
state.dest_db = tdb;
if (tdb_traverse_read(tmp_db, repack_traverse, &state) == -1) {
TDB_LOG((tdb, TDB_DEBUG_FATAL, __location__ " Failed to traverse copying back\n"));
tdb_transaction_cancel(tdb);
tdb_close(tmp_db);
return -1;
}
if (state.error) {
TDB_LOG((tdb, TDB_DEBUG_FATAL, __location__ " Error during second traversal\n"));
tdb_transaction_cancel(tdb);
tdb_close(tmp_db);
return -1;
}
tdb_close(tmp_db);
if (tdb_transaction_commit(tdb) != 0) {
TDB_LOG((tdb, TDB_DEBUG_FATAL, __location__ " Failed to commit\n"));
return -1;
}
return 0;
}

@ -152,11 +152,14 @@ int tdb_chainlock_unmark(struct tdb_context *tdb, TDB_DATA key);
void tdb_setalarm_sigptr(struct tdb_context *tdb, volatile sig_atomic_t *sigptr);
/* wipe and repack */
int tdb_wipe_all(struct tdb_context *tdb);
int tdb_repack(struct tdb_context *tdb);
/* Debug functions. Not used in production. */
void tdb_dump_all(struct tdb_context *tdb);
int tdb_printfreelist(struct tdb_context *tdb);
int tdb_validate_freelist(struct tdb_context *tdb, int *pnum_entries);
int tdb_wipe_all(struct tdb_context *tdb);
int tdb_freelist_size(struct tdb_context *tdb);
extern TDB_DATA tdb_null;

@ -126,9 +126,17 @@ static int backup_tdb(const char *old_name, const char *new_name, int hash_size)
return 1;
}
/* lock the old tdb */
if (tdb_lockall(tdb) != 0) {
fprintf(stderr,"Failed to lock %s\n", old_name);
if (tdb_transaction_start(tdb) != 0) {
printf("Failed to start transaction on old tdb\n");
tdb_close(tdb);
tdb_close(tdb_new);
unlink(tmp_name);
free(tmp_name);
return 1;
}
if (tdb_transaction_start(tdb_new) != 0) {
printf("Failed to start transaction on new tdb\n");
tdb_close(tdb);
tdb_close(tdb_new);
unlink(tmp_name);
@ -152,6 +160,14 @@ static int backup_tdb(const char *old_name, const char *new_name, int hash_size)
/* close the old tdb */
tdb_close(tdb);
if (tdb_transaction_commit(tdb_new) != 0) {
fprintf(stderr, "Failed to commit new tdb\n");
tdb_close(tdb_new);
unlink(tmp_name);
free(tmp_name);
return 1;
}
/* close the new tdb and re-open read-only */
tdb_close(tdb_new);
tdb_new = tdb_open(tmp_name, 0, TDB_DEFAULT, O_RDONLY, 0);
@ -173,9 +189,6 @@ static int backup_tdb(const char *old_name, const char *new_name, int hash_size)
return 1;
}
/* make sure the new tdb has reached stable storage */
fsync(tdb_fd(tdb_new));
/* close the new tdb and rename it to .bak */
tdb_close(tdb_new);
if (rename(tmp_name, new_name) != 0) {

@ -57,6 +57,7 @@ enum commands {
CMD_FIRST,
CMD_NEXT,
CMD_SYSTEM,
CMD_CHECK,
CMD_QUIT,
CMD_HELP
};
@ -87,6 +88,7 @@ COMMAND_TABLE cmd_table[] = {
{"1", CMD_FIRST},
{"next", CMD_NEXT},
{"n", CMD_NEXT},
{"check", CMD_CHECK},
{"quit", CMD_QUIT},
{"q", CMD_QUIT},
{"!", CMD_SYSTEM},
@ -179,7 +181,8 @@ static void help(void)
" delete key : delete a record by key\n"
" list : print the database hash table and freelist\n"
" free : print the database freelist\n"
" ! command : execute system command\n"
" check : check the integrity of an opened database\n"
" ! command : execute system command\n"
" 1 | first : print the first record\n"
" n | next : print the next record\n"
" q | quit : terminate\n"
@ -452,6 +455,27 @@ static void next_record(TDB_CONTEXT *the_tdb, TDB_DATA *pkey)
print_rec(the_tdb, *pkey, dbuf, NULL);
}
static int test_fn(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, void *state)
{
return 0;
}
static void check_db(TDB_CONTEXT *the_tdb)
{
int tdbcount=-1;
if (the_tdb) {
tdbcount = tdb_traverse(the_tdb, test_fn, NULL);
} else {
printf("Error: No database opened!\n");
}
if (tdbcount<0) {
printf("Integrity check for the opened database failed.\n");
} else {
printf("Database integrity is OK and has %d records.\n", tdbcount);
}
}
static int do_command(void)
{
COMMAND_TABLE *ctp = cmd_table;
@ -552,6 +576,9 @@ static int do_command(void)
if (bIterate)
next_record(tdb, &iterate_kbuf);
return 0;
case CMD_CHECK:
check_db(tdb);
return 0;
case CMD_HELP:
help();
return 0;

@ -3,10 +3,9 @@ AC_CHECK_HEADERS(nss.h nss_common.h ns_api.h )
case "$host_os" in
*linux*)
SMB_LIBRARY(nss_winbind,
[nsswitch/winbind_nss_linux.o],
[../nsswitch/winbind_nss_linux.o],
[LIBWINBIND-CLIENT])
;;
*)
;;
esac

@ -31,4 +31,4 @@ PRIVATE_DEPENDENCIES = \
#################################
wbinfo_OBJ_FILES = \
$(nsswitchsrcdir)/wbinfo.o
$(nsswitchsrcdir)/wbinfo4.o

@ -299,7 +299,7 @@ static wbcErr process_domain_info_string(TALLOC_CTX *ctx,
wbc_status = wbcStringToSid(r, &info->sid);
BAIL_ON_WBC_ERROR(wbc_status);
/* Trust type */
r = s;
if ((s = strchr(r, '\\')) == NULL) {
@ -332,9 +332,9 @@ static wbcErr process_domain_info_string(TALLOC_CTX *ctx,
s++;
if (strcmp(r, "Yes") == 0) {
info->trust_flags |= WBC_DOMINFO_TRUST_TRANSITIVE;
info->trust_flags |= WBC_DOMINFO_TRUST_TRANSITIVE;
}
/* Incoming */
r = s;
if ((s = strchr(r, '\\')) == NULL) {
@ -345,7 +345,7 @@ static wbcErr process_domain_info_string(TALLOC_CTX *ctx,
s++;
if (strcmp(r, "Yes") == 0) {
info->trust_flags |= WBC_DOMINFO_TRUST_INCOMING;
info->trust_flags |= WBC_DOMINFO_TRUST_INCOMING;
}
/* Outgoing */
@ -358,7 +358,7 @@ static wbcErr process_domain_info_string(TALLOC_CTX *ctx,
s++;
if (strcmp(r, "Yes") == 0) {
info->trust_flags |= WBC_DOMINFO_TRUST_OUTGOING;
info->trust_flags |= WBC_DOMINFO_TRUST_OUTGOING;
}
/* Online/Offline status */
@ -385,14 +385,14 @@ wbcErr wbcListTrusts(struct wbcDomainInfo **domains, size_t *num_domains)
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
char *p = NULL;
char *q = NULL;
char *extra_data = NULL;
int count = 0;
char *extra_data = NULL;
int count = 0;
struct wbcDomainInfo *d_list = NULL;
int i = 0;
*domains = NULL;
*num_domains = 0;
ZERO_STRUCT(response);
/* Send request */
@ -409,20 +409,20 @@ wbcErr wbcListTrusts(struct wbcDomainInfo **domains, size_t *num_domains)
if (strlen(p) == 0) {
/* We should always at least get back our
own SAM domain */
wbc_status = WBC_ERR_DOMAIN_NOT_FOUND;
BAIL_ON_WBC_ERROR(wbc_status);
}
/* Count number of domains */
count = 0;
count = 0;
while (p) {
count++;
if ((q = strchr(p, '\n')) != NULL)
q++;
p = q;
p = q;
}
d_list = talloc_array(NULL, struct wbcDomainInfo, count);
@ -431,13 +431,13 @@ wbcErr wbcListTrusts(struct wbcDomainInfo **domains, size_t *num_domains)
extra_data = strdup((char*)response.extra_data.data);
BAIL_ON_PTR_ERROR(extra_data, wbc_status);
p = extra_data;
p = extra_data;
/* Outer loop processes the list of domain information */
for (i=0; i<count && p; i++) {
char *next = strchr(p, '\n');
if (next) {
*next = '\0';
next++;
@ -449,9 +449,9 @@ wbcErr wbcListTrusts(struct wbcDomainInfo **domains, size_t *num_domains)
p = next;
}
*domains = d_list;
*num_domains = i;
*domains = d_list;
*num_domains = i;
done:
if (!WBC_ERROR_IS_OK(wbc_status)) {
if (d_list)

@ -155,5 +155,3 @@ done:
talloc_free(info);
return wbc_status;
}

@ -952,7 +952,7 @@ wbcErr wbcDomainInfo(const char *domain,
*
* @return #wbcErr
**/
wbcErr wbcListTrusts(struct wbcDomainInfo **domains,
wbcErr wbcListTrusts(struct wbcDomainInfo **domains,
size_t *num_domains);
/* Flags for wbcLookupDomainController */

@ -1,18 +1,18 @@
/*
/*
Unix SMB/CIFS implementation.
nss tester for winbindd
Copyright (C) Andrew Tridgell 2001
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@ -54,13 +54,13 @@ static void report_nss_error(const char *who, NSS_STATUS status)
{
last_error = status;
total_errors++;
printf("ERROR %s: NSS_STATUS=%d %d (nss_errno=%d)\n",
printf("ERROR %s: NSS_STATUS=%d %d (nss_errno=%d)\n",
who, status, NSS_STATUS_SUCCESS, nss_errno);
}
static struct passwd *nss_getpwent(void)
{
NSS_STATUS (*_nss_getpwent_r)(struct passwd *, char *,
NSS_STATUS (*_nss_getpwent_r)(struct passwd *, char *,
size_t , int *) = find_fn("getpwent_r");
static struct passwd pwd;
static char buf[1000];
@ -79,12 +79,12 @@ static struct passwd *nss_getpwent(void)
static struct passwd *nss_getpwnam(const char *name)
{
NSS_STATUS (*_nss_getpwnam_r)(const char *, struct passwd *, char *,
NSS_STATUS (*_nss_getpwnam_r)(const char *, struct passwd *, char *,
size_t , int *) = find_fn("getpwnam_r");
static struct passwd pwd;
static char buf[1000];
NSS_STATUS status;
status = _nss_getpwnam_r(name, &pwd, buf, sizeof(buf), &nss_errno);
if (status == NSS_STATUS_NOTFOUND) {
return NULL;
@ -98,12 +98,12 @@ static struct passwd *nss_getpwnam(const char *name)
static struct passwd *nss_getpwuid(uid_t uid)
{
NSS_STATUS (*_nss_getpwuid_r)(uid_t , struct passwd *, char *,
NSS_STATUS (*_nss_getpwuid_r)(uid_t , struct passwd *, char *,
size_t , int *) = find_fn("getpwuid_r");
static struct passwd pwd;
static char buf[1000];
NSS_STATUS status;
status = _nss_getpwuid_r(uid, &pwd, buf, sizeof(buf), &nss_errno);
if (status == NSS_STATUS_NOTFOUND) {
return NULL;
@ -138,7 +138,7 @@ static void nss_endpwent(void)
static struct group *nss_getgrent(void)
{
NSS_STATUS (*_nss_getgrent_r)(struct group *, char *,
NSS_STATUS (*_nss_getgrent_r)(struct group *, char *,
size_t , int *) = find_fn("getgrent_r");
static struct group grp;
static char *buf;
@ -147,7 +147,7 @@ static struct group *nss_getgrent(void)
if (!buf) buf = malloc_array_p(char, buflen);
again:
again:
status = _nss_getgrent_r(&grp, buf, buflen, &nss_errno);
if (status == NSS_STATUS_TRYAGAIN) {
buflen *= 2;
@ -166,7 +166,7 @@ again:
static struct group *nss_getgrnam(const char *name)
{
NSS_STATUS (*_nss_getgrnam_r)(const char *, struct group *, char *,
NSS_STATUS (*_nss_getgrnam_r)(const char *, struct group *, char *,
size_t , int *) = find_fn("getgrnam_r");
static struct group grp;
static char *buf;
@ -174,7 +174,7 @@ static struct group *nss_getgrnam(const char *name)
NSS_STATUS status;
if (!buf) buf = malloc_array_p(char, buflen);
again:
again:
status = _nss_getgrnam_r(name, &grp, buf, buflen, &nss_errno);
if (status == NSS_STATUS_TRYAGAIN) {
buflen *= 2;
@ -193,15 +193,15 @@ again:
static struct group *nss_getgrgid(gid_t gid)
{
NSS_STATUS (*_nss_getgrgid_r)(gid_t , struct group *, char *,
NSS_STATUS (*_nss_getgrgid_r)(gid_t , struct group *, char *,
size_t , int *) = find_fn("getgrgid_r");
static struct group grp;
static char *buf;
static int buflen = 1000;
NSS_STATUS status;
if (!buf) buf = malloc_array_p(char, buflen);
again:
again:
status = _nss_getgrgid_r(gid, &grp, buf, buflen, &nss_errno);
if (status == NSS_STATUS_TRYAGAIN) {
buflen *= 2;
@ -241,7 +241,7 @@ static void nss_endgrent(void)
static int nss_initgroups(char *user, gid_t group, gid_t **groups, long int *start, long int *size)
{
NSS_STATUS (*_nss_initgroups)(char *, gid_t , long int *,
long int *, gid_t **, long int , int *) =
long int *, gid_t **, long int , int *) =
find_fn("initgroups_dyn");
NSS_STATUS status;
@ -256,7 +256,7 @@ static int nss_initgroups(char *user, gid_t group, gid_t **groups, long int *sta
static void print_passwd(struct passwd *pwd)
{
printf("%s:%s:%d:%d:%s:%s:%s\n",
printf("%s:%s:%d:%d:%s:%s:%s\n",
pwd->pw_name,
pwd->pw_passwd,
pwd->pw_uid,
@ -269,16 +269,16 @@ static void print_passwd(struct passwd *pwd)
static void print_group(struct group *grp)
{
int i;
printf("%s:%s:%d: ",
printf("%s:%s:%d: ",
grp->gr_name,
grp->gr_passwd,
grp->gr_gid);
if (!grp->gr_mem[0]) {
printf("\n");
return;
}
for (i=0; grp->gr_mem[i+1]; i++) {
printf("%s, ", grp->gr_mem[i]);
}
@ -397,7 +397,7 @@ static void nss_test_errors(void)
}
int main(int argc, char *argv[])
{
{
if (argc > 1) so_path = argv[1];
if (argc > 2) nss_name = argv[2];

@ -1,18 +1,18 @@
/*
/*
Unix SMB/CIFS implementation.
nss includes for the nss tester
Copyright (C) Kai Blin 2007
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@ -25,7 +25,7 @@
#ifdef HAVE_NSS_COMMON_H
/*
/*
* Sun Solaris
*/

@ -1,9 +1,8 @@
case "$host_os" in
*linux*)
*linux*)
SMB_ENABLE(nsstest,YES)
;;
*)
SMB_ENABLE(nsstest,NO)
;;
esac

@ -1,4 +1,4 @@
/* pam_winbind header file
/* pam_winbind header file
(Solaris needs some macros from Linux for common PAM code)
Shirish Kalele 2000
@ -32,7 +32,7 @@
/* Solaris always uses dynamic pam modules */
#define PAM_EXTERN extern
#if defined(HAVE_SECURITY_PAM_APPL_H)
#include <security/pam_appl.h>
#include <security/pam_appl.h>
#elif defined(HAVE_PAM_PAM_APPL_H)
#include <pam/pam_appl.h>
#endif
@ -83,7 +83,7 @@ do { \
#define _pam_drop(X) SAFE_FREE(X)
#define x_strdup(s) ( (s) ? strdup(s):NULL )
#define x_strdup(s) ( (s) ? strdup(s):NULL )
#endif /* HAVE_SECURITY__PAM_MACROS_H */
#ifdef HAVE_SECURITY_PAM_EXT_H
@ -167,4 +167,3 @@ struct pwb_context {
#define TALLOC_FREE(ctx) do { if ((ctx) != NULL) {talloc_free(ctx); ctx=NULL;} } while(0)
#define TALLOC_ZERO_P(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type)
#define TALLOC_P(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type)

@ -184,4 +184,3 @@ testit "wbinfo -K against $TARGET with domain creds" $wbinfo -K "$DOMAIN/$USERNA
testit "wbinfo --separator against $TARGET" $wbinfo --separator || failed=`expr $failed + 1`
exit $failed

@ -1,4 +1,4 @@
/*
/*
Unix SMB/CIFS implementation.
winbind client common code
@ -6,18 +6,18 @@
Copyright (C) Tim Potter 2000
Copyright (C) Andrew Tridgell 2000
Copyright (C) Andrew Bartlett 2002
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@ -74,11 +74,11 @@ void winbind_close_sock(void)
/* Make sure socket handle isn't stdin, stdout or stderr */
#define RECURSION_LIMIT 3
static int make_nonstd_fd_internals(int fd, int limit /* Recursion limiter */)
static int make_nonstd_fd_internals(int fd, int limit /* Recursion limiter */)
{
int new_fd;
if (fd >= 0 && fd <= 2) {
#ifdef F_DUPFD
#ifdef F_DUPFD
if ((new_fd = fcntl(fd, F_DUPFD, 3)) == -1) {
return -1;
}
@ -92,9 +92,9 @@ static int make_nonstd_fd_internals(int fd, int limit /* Recursion limiter */)
#else
if (limit <= 0)
return -1;
new_fd = dup(fd);
if (new_fd == -1)
if (new_fd == -1)
return -1;
/* use the program stack to hold our list of FDs to close */
@ -114,7 +114,7 @@ static int make_nonstd_fd_internals(int fd, int limit /* Recursion limiter */)
Set close on exec also.
****************************************************************************/
static int make_safe_fd(int fd)
static int make_safe_fd(int fd)
{
int result, flags;
int new_fd = make_nonstd_fd_internals(fd, RECURSION_LIMIT);
@ -366,65 +366,65 @@ static int winbind_open_pipe_sock(int recursing, int need_priv)
int winbind_write_sock(void *buffer, int count, int recursing, int need_priv)
{
int result, nwritten;
/* Open connection to winbind daemon */
restart:
if (winbind_open_pipe_sock(recursing, need_priv) == -1) {
errno = ENOENT;
return -1;
}
/* Write data to socket */
nwritten = 0;
while(nwritten < count) {
struct timeval tv;
fd_set r_fds;
/* Catch pipe close on other end by checking if a read()
call would not block by calling select(). */
FD_ZERO(&r_fds);
FD_SET(winbindd_fd, &r_fds);
ZERO_STRUCT(tv);
if (select(winbindd_fd + 1, &r_fds, NULL, NULL, &tv) == -1) {
winbind_close_sock();
return -1; /* Select error */
}
/* Write should be OK if fd not available for reading */
if (!FD_ISSET(winbindd_fd, &r_fds)) {
/* Do the write */
result = write(winbindd_fd,
(char *)buffer + nwritten,
(char *)buffer + nwritten,
count - nwritten);
if ((result == -1) || (result == 0)) {
/* Write failed */
winbind_close_sock();
return -1;
}
nwritten += result;
} else {
/* Pipe has closed on remote end */
winbind_close_sock();
goto restart;
}
}
return nwritten;
}
@ -443,7 +443,7 @@ int winbind_read_sock(void *buffer, int count)
while(nread < count) {
struct timeval tv;
fd_set r_fds;
/* Catch pipe close on other end by checking if a read()
call would not block by calling select(). */
@ -457,7 +457,7 @@ int winbind_read_sock(void *buffer, int count)
winbind_close_sock();
return -1; /* Select error */
}
if (selret == 0) {
/* Not ready for read yet... */
if (total_time >= 30) {
@ -470,27 +470,27 @@ int winbind_read_sock(void *buffer, int count)
}
if (FD_ISSET(winbindd_fd, &r_fds)) {
/* Do the Read */
int result = read(winbindd_fd, (char *)buffer + nread,
int result = read(winbindd_fd, (char *)buffer + nread,
count - nread);
if ((result == -1) || (result == 0)) {
/* Read failed. I think the only useful thing we
can do here is just return -1 and fail since the
transaction has failed half way through. */
winbind_close_sock();
return -1;
}
nread += result;
}
}
return nread;
}
@ -503,15 +503,15 @@ int winbindd_read_reply(struct winbindd_response *response)
if (!response) {
return -1;
}
/* Read fixed length response */
result1 = winbind_read_sock(response,
sizeof(struct winbindd_response));
if (result1 == -1) {
return -1;
}
/* We actually send the pointer value of the extra_data field from
the server. This has no meaning in the client's address space
so we clear it out. */
@ -519,17 +519,17 @@ int winbindd_read_reply(struct winbindd_response *response)
response->extra_data.data = NULL;
/* Read variable length response */
if (response->length > sizeof(struct winbindd_response)) {
int extra_data_len = response->length -
int extra_data_len = response->length -
sizeof(struct winbindd_response);
/* Mallocate memory for extra data */
if (!(response->extra_data.data = malloc(extra_data_len))) {
return -1;
}
result2 = winbind_read_sock(response->extra_data.data,
extra_data_len);
if (result2 == -1) {
@ -537,14 +537,14 @@ int winbindd_read_reply(struct winbindd_response *response)
return -1;
}
}
/* Return total amount of data read */
return result1 + result2;
}
/*
* send simple types of requests
/*
* send simple types of requests
*/
NSS_STATUS winbindd_send_request(int req_type, int need_priv,
@ -562,33 +562,33 @@ NSS_STATUS winbindd_send_request(int req_type, int need_priv,
ZERO_STRUCT(lrequest);
request = &lrequest;
}
/* Fill in request and send down pipe */
winbindd_init_request(request, req_type);
if (winbind_write_sock(request, sizeof(*request),
request->wb_flags & WBFLAG_RECURSE,
need_priv) == -1)
need_priv) == -1)
{
/* Set ENOENT for consistency. Required by some apps */
errno = ENOENT;
return NSS_STATUS_UNAVAIL;
}
if ((request->extra_len != 0) &&
(winbind_write_sock(request->extra_data.data,
request->extra_len,
request->extra_len,
request->wb_flags & WBFLAG_RECURSE,
need_priv) == -1))
need_priv) == -1))
{
/* Set ENOENT for consistency. Required by some apps */
errno = ENOENT;
return NSS_STATUS_UNAVAIL;
}
return NSS_STATUS_SUCCESS;
}
@ -624,13 +624,13 @@ NSS_STATUS winbindd_get_response(struct winbindd_response *response)
if (response->result != WINBINDD_OK) {
return NSS_STATUS_NOTFOUND;
}
return NSS_STATUS_SUCCESS;
}
/* Handle simple types of requests */
NSS_STATUS winbindd_request_response(int req_type,
NSS_STATUS winbindd_request_response(int req_type,
struct winbindd_request *request,
struct winbindd_response *response)
{
@ -639,7 +639,7 @@ NSS_STATUS winbindd_request_response(int req_type,
while ((status == NSS_STATUS_UNAVAIL) && (count < 10)) {
status = winbindd_send_request(req_type, 0, request);
if (status != NSS_STATUS_SUCCESS)
if (status != NSS_STATUS_SUCCESS)
return(status);
status = winbindd_get_response(response);
count += 1;
@ -648,7 +648,7 @@ NSS_STATUS winbindd_request_response(int req_type,
return status;
}
NSS_STATUS winbindd_priv_request_response(int req_type,
NSS_STATUS winbindd_priv_request_response(int req_type,
struct winbindd_request *request,
struct winbindd_response *response)
{
@ -657,7 +657,7 @@ NSS_STATUS winbindd_priv_request_response(int req_type,
while ((status == NSS_STATUS_UNAVAIL) && (count < 10)) {
status = winbindd_send_request(req_type, 1, request);
if (status != NSS_STATUS_SUCCESS)
if (status != NSS_STATUS_SUCCESS)
return(status);
status = winbindd_get_response(response);
count += 1;

@ -1,21 +1,21 @@
/*
/*
Unix SMB/CIFS implementation.
Winbind status program.
Copyright (C) Tim Potter 2000-2003
Copyright (C) Andrew Bartlett 2002
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@ -378,8 +378,8 @@ static bool wbinfo_list_domains(bool list_all_domains, bool verbose)
}
if (print_all) {
d_printf("%-16s%-24s%-12s%-12s%-5s%-5s\n",
"Domain Name", "DNS Domain", "Trust Type",
d_printf("%-16s%-24s%-12s%-12s%-5s%-5s\n",
"Domain Name", "DNS Domain", "Trust Type",
"Transitive", "In", "Out");
}
@ -398,10 +398,10 @@ static bool wbinfo_list_domains(bool list_all_domains, bool verbose)
case WBC_DOMINFO_TRUSTTYPE_NONE:
d_printf("None ");
break;
case WBC_DOMINFO_TRUSTTYPE_FOREST:
case WBC_DOMINFO_TRUSTTYPE_FOREST:
d_printf("Forest ");
break;
case WBC_DOMINFO_TRUSTTYPE_EXTERNAL:
case WBC_DOMINFO_TRUSTTYPE_EXTERNAL:
d_printf("External ");
break;
case WBC_DOMINFO_TRUSTTYPE_IN_FOREST:
@ -472,8 +472,8 @@ static bool wbinfo_show_onlinestatus(const char *domain)
}
is_offline = (domain_list[i].domain_flags & WBC_DOMINFO_DOMAIN_OFFLINE);
d_printf("%s : %s\n",
d_printf("%s : %s\n",
domain_list[i].short_name,
is_offline ? "offline" : "online" );
}
@ -1104,12 +1104,12 @@ static bool wbinfo_auth_krb5(char *username, const char *cctype, uint32 flags)
/* Display response */
d_printf("plaintext kerberos password authentication for [%s] %s (requesting cctype: %s)\n",
d_printf("plaintext kerberos password authentication for [%s] %s (requesting cctype: %s)\n",
username, (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed", cctype);
if (response.data.auth.nt_status)
d_fprintf(stderr, "error code was %s (0x%x)\nerror messsage was: %s\n",
response.data.auth.nt_status_string,
d_fprintf(stderr, "error code was %s (0x%x)\nerror messsage was: %s\n",
response.data.auth.nt_status_string,
response.data.auth.nt_status,
response.data.auth.error_string);
@ -1162,7 +1162,7 @@ static bool wbinfo_auth(char *username)
#if 0
if (response.data.auth.nt_status)
d_fprintf(stderr, "error code was %s (0x%x)\nerror messsage was: %s\n",
d_fprintf(stderr, "error code was %s (0x%x)\nerror messsage was: %s\n",
response.data.auth.nt_status_string,
response.data.auth.nt_status,
response.data.auth.error_string);
@ -1260,7 +1260,7 @@ static bool wbinfo_auth_crap(char *username)
WBC_ERROR_IS_OK(wbc_status) ? "succeeded" : "failed");
if (wbc_status == WBC_ERR_AUTH_ERROR) {
d_fprintf(stderr, "error code was %s (0x%x)\nerror messsage was: %s\n",
d_fprintf(stderr, "error code was %s (0x%x)\nerror messsage was: %s\n",
err->nt_string,
err->nt_status,
err->display_string);
@ -1312,7 +1312,7 @@ static bool wbinfo_klog(char *username)
(result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed");
if (response.data.auth.nt_status)
d_fprintf(stderr, "error code was %s (0x%x)\nerror messsage was: %s\n",
d_fprintf(stderr, "error code was %s (0x%x)\nerror messsage was: %s\n",
response.data.auth.nt_status_string,
response.data.auth.nt_status,
response.data.auth.error_string);
@ -1853,14 +1853,14 @@ int main(int argc, char **argv, char **envp)
break;
case 'r':
if (!wbinfo_get_usergroups(string_arg)) {
d_fprintf(stderr, "Could not get groups for user %s\n",
d_fprintf(stderr, "Could not get groups for user %s\n",
string_arg);
goto done;
}
break;
case OPT_USERSIDS:
if (!wbinfo_get_usersids(string_arg)) {
d_fprintf(stderr, "Could not get group SIDs for user SID %s\n",
d_fprintf(stderr, "Could not get group SIDs for user SID %s\n",
string_arg);
goto done;
}

@ -1,21 +1,21 @@
/*
/*
Unix SMB/CIFS implementation.
Winbind status program.
Copyright (C) Tim Potter 2000-2003
Copyright (C) Andrew Bartlett 2002-2007
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@ -29,6 +29,10 @@
#include "dynconfig/dynconfig.h"
#include "param/param.h"
#ifndef fstrcpy
#define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1)
#endif
extern int winbindd_fd;
static char winbind_separator_int(bool strict)
@ -65,7 +69,7 @@ static char winbind_separator_int(bool strict)
/* HACK: (this module should not call lp_ funtions) */
sep = *lp_winbind_separator(cmdline_lp_ctx);
}
return sep;
}
@ -86,7 +90,7 @@ static const char *get_winbind_domain(void)
if (winbindd_request_response(WINBINDD_DOMAIN_NAME, NULL, &response) !=
NSS_STATUS_SUCCESS) {
d_fprintf(stderr, "could not obtain winbind domain name!\n");
/* HACK: (this module should not call lp_ funtions) */
return lp_workgroup(cmdline_lp_ctx);
}
@ -100,7 +104,7 @@ static const char *get_winbind_domain(void)
/* Copy of parse_domain_user from winbindd_util.c. Parse a string of the
form DOMAIN/user into a domain and a user */
static bool parse_wbinfo_domain_user(const char *domuser, fstring domain,
static bool parse_wbinfo_domain_user(const char *domuser, fstring domain,
fstring user)
{
@ -111,7 +115,7 @@ static bool parse_wbinfo_domain_user(const char *domuser, fstring domain,
fstrcpy(domain, get_winbind_domain());
return true;
}
fstrcpy(user, p+1);
fstrcpy(domain, domuser);
domain[PTR_DIFF(p, domuser)] = 0;
@ -127,19 +131,19 @@ static bool wbinfo_get_userinfo(char *user)
struct winbindd_request request;
struct winbindd_response response;
NSS_STATUS result;
ZERO_STRUCT(request);
ZERO_STRUCT(response);
/* Send request */
fstrcpy(request.data.username, user);
result = winbindd_request_response(WINBINDD_GETPWNAM, &request, &response);
if (result != NSS_STATUS_SUCCESS)
return false;
d_printf( "%s:%s:%d:%d:%s:%s:%s\n",
response.data.pw.pw_name,
response.data.pw.pw_passwd,
@ -148,7 +152,7 @@ static bool wbinfo_get_userinfo(char *user)
response.data.pw.pw_gecos,
response.data.pw.pw_dir,
response.data.pw.pw_shell );
return true;
}
@ -201,11 +205,11 @@ static bool wbinfo_get_groupinfo(char *group)
if ( result != NSS_STATUS_SUCCESS)
return false;
d_printf( "%s:%s:%d\n",
d_printf( "%s:%s:%d\n",
response.data.gr.gr_name,
response.data.gr.gr_passwd,
response.data.gr.gr_gid );
return true;
}
@ -217,7 +221,7 @@ static bool wbinfo_get_usergroups(char *user)
struct winbindd_response response;
NSS_STATUS result;
int i;
ZERO_STRUCT(request);
ZERO_STRUCT(response);
@ -290,7 +294,7 @@ static bool wbinfo_get_userdomgroups(const char *user_sid)
if (response.data.num_entries != 0)
printf("%s", (char *)response.extra_data.data);
SAFE_FREE(response.extra_data.data);
return true;
@ -503,16 +507,16 @@ static bool wbinfo_check_secret(void)
ZERO_STRUCT(response);
result = winbindd_request_response(WINBINDD_CHECK_MACHACC, NULL, &response);
d_printf("checking the trust secret via RPC calls %s\n",
d_printf("checking the trust secret via RPC calls %s\n",
(result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed");
if (result != NSS_STATUS_SUCCESS)
d_fprintf(stderr, "error code was %s (0x%x)\n",
response.data.auth.nt_status_string,
response.data.auth.nt_status);
return result == NSS_STATUS_SUCCESS;
if (result != NSS_STATUS_SUCCESS)
d_fprintf(stderr, "error code was %s (0x%x)\n",
response.data.auth.nt_status_string,
response.data.auth.nt_status);
return result == NSS_STATUS_SUCCESS;
}
/* Convert uid to sid */
@ -669,7 +673,7 @@ static bool wbinfo_lookupname(char *name)
ZERO_STRUCT(request);
ZERO_STRUCT(response);
parse_wbinfo_domain_user(name, request.data.name.dom_name,
parse_wbinfo_domain_user(name, request.data.name.dom_name,
request.data.name.name);
if (winbindd_request_response(WINBINDD_LOOKUPNAME, &request, &response) !=
@ -717,12 +721,12 @@ static bool wbinfo_auth_krb5(char *username, const char *cctype, uint32_t flags)
/* Display response */
d_printf("plaintext kerberos password authentication for [%s] %s (requesting cctype: %s)\n",
d_printf("plaintext kerberos password authentication for [%s] %s (requesting cctype: %s)\n",
username, (result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed", cctype);
if (response.data.auth.nt_status)
d_fprintf(stderr, "error code was %s (0x%x)\nerror messsage was: %s\n",
response.data.auth.nt_status_string,
d_fprintf(stderr, "error code was %s (0x%x)\nerror messsage was: %s\n",
response.data.auth.nt_status_string,
response.data.auth.nt_status,
response.data.auth.error_string);
@ -772,12 +776,12 @@ static bool wbinfo_auth(char *username)
/* Display response */
d_printf("plaintext password authentication %s\n",
d_printf("plaintext password authentication %s\n",
(result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed");
if (response.data.auth.nt_status)
d_fprintf(stderr, "error code was %s (0x%x)\nerror messsage was: %s\n",
response.data.auth.nt_status_string,
d_fprintf(stderr, "error code was %s (0x%x)\nerror messsage was: %s\n",
response.data.auth.nt_status_string,
response.data.auth.nt_status,
response.data.auth.error_string);
@ -807,21 +811,21 @@ static bool wbinfo_auth_crap(struct loadparm_context *lp_ctx, char *username)
*p = 0;
fstrcpy(pass, p + 1);
}
parse_wbinfo_domain_user(username, name_domain, name_user);
request.data.auth_crap.logon_parameters = MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT | MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT;
fstrcpy(request.data.auth_crap.user, name_user);
fstrcpy(request.data.auth_crap.domain,
fstrcpy(request.data.auth_crap.domain,
name_domain);
generate_random_buffer(request.data.auth_crap.chal, 8);
if (lp_client_ntlmv2_auth(lp_ctx)) {
DATA_BLOB server_chal;
DATA_BLOB names_blob;
DATA_BLOB names_blob;
DATA_BLOB lm_response;
DATA_BLOB nt_response;
@ -833,12 +837,12 @@ static bool wbinfo_auth_crap(struct loadparm_context *lp_ctx, char *username)
return false;
}
server_chal = data_blob(request.data.auth_crap.chal, 8);
server_chal = data_blob(request.data.auth_crap.chal, 8);
/* Pretend this is a login to 'us', for blob purposes */
names_blob = NTLMv2_generate_names_blob(mem_ctx, lp_netbios_name(lp_ctx), lp_workgroup(lp_ctx));
if (!SMBNTLMv2encrypt(mem_ctx, name_user, name_domain, pass, &server_chal,
if (!SMBNTLMv2encrypt(mem_ctx, name_user, name_domain, pass, &server_chal,
&names_blob,
&lm_response, &nt_response, NULL, NULL)) {
data_blob_free(&names_blob);
@ -848,22 +852,22 @@ static bool wbinfo_auth_crap(struct loadparm_context *lp_ctx, char *username)
data_blob_free(&names_blob);
data_blob_free(&server_chal);
memcpy(request.data.auth_crap.nt_resp, nt_response.data,
MIN(nt_response.length,
memcpy(request.data.auth_crap.nt_resp, nt_response.data,
MIN(nt_response.length,
sizeof(request.data.auth_crap.nt_resp)));
request.data.auth_crap.nt_resp_len = nt_response.length;
memcpy(request.data.auth_crap.lm_resp, lm_response.data,
MIN(lm_response.length,
memcpy(request.data.auth_crap.lm_resp, lm_response.data,
MIN(lm_response.length,
sizeof(request.data.auth_crap.lm_resp)));
request.data.auth_crap.lm_resp_len = lm_response.length;
data_blob_free(&nt_response);
data_blob_free(&lm_response);
} else {
if (lp_client_lanman_auth(lp_ctx)
&& SMBencrypt(pass, request.data.auth_crap.chal,
if (lp_client_lanman_auth(lp_ctx)
&& SMBencrypt(pass, request.data.auth_crap.chal,
(unsigned char *)request.data.auth_crap.lm_resp)) {
request.data.auth_crap.lm_resp_len = 24;
} else {
@ -879,12 +883,12 @@ static bool wbinfo_auth_crap(struct loadparm_context *lp_ctx, char *username)
/* Display response */
d_printf("challenge/response password authentication %s\n",
d_printf("challenge/response password authentication %s\n",
(result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed");
if (response.data.auth.nt_status)
d_fprintf(stderr, "error code was %s (0x%x)\nerror messsage was: %s\n",
response.data.auth.nt_status_string,
d_fprintf(stderr, "error code was %s (0x%x)\nerror messsage was: %s\n",
response.data.auth.nt_status_string,
response.data.auth.nt_status,
response.data.auth.error_string);
@ -904,7 +908,7 @@ static bool print_domain_users(const char *domain)
ZERO_STRUCT(request);
ZERO_STRUCT(response);
if (domain) {
/* '.' is the special sign for our own domain */
if ( strequal(domain, ".") )
@ -926,7 +930,7 @@ static bool print_domain_users(const char *domain)
while(next_token(&extra_data, name, ",", sizeof(fstring)))
d_printf("%s\n", name);
SAFE_FREE(response.extra_data.data);
return true;
@ -966,7 +970,7 @@ static bool print_domain_groups(const char *domain)
d_printf("%s\n", name);
SAFE_FREE(response.extra_data.data);
return true;
}
@ -978,7 +982,7 @@ static bool wbinfo_ping(void)
/* Display response */
d_printf("Ping to winbindd %s on fd %d\n",
d_printf("Ping to winbindd %s on fd %d\n",
(result == NSS_STATUS_SUCCESS) ? "succeeded" : "failed", winbindd_fd);
return result == NSS_STATUS_SUCCESS;
@ -1016,7 +1020,7 @@ int main(int argc, char **argv, char **envp)
struct poptOption long_options[] = {
POPT_AUTOHELP
/* longName, shortName, argInfo, argPtr, value, descrip,
/* longName, shortName, argInfo, argPtr, value, descrip,
argDesc */
{ "domain-users", 'u', POPT_ARG_NONE, 0, 'u', "Lists all domain users", "domain"},
@ -1042,7 +1046,7 @@ int main(int argc, char **argv, char **envp)
{ "user-domgroups", 0, POPT_ARG_STRING, &string_arg,
OPT_USERDOMGROUPS, "Get user domain groups", "SID" },
{ "user-sids", 0, POPT_ARG_STRING, &string_arg, OPT_USERSIDS, "Get user group sids for user SID", "SID" },
{ "authenticate", 'a', POPT_ARG_STRING, &string_arg, 'a', "authenticate user", "user%password" },
{ "authenticate", 'a', POPT_ARG_STRING, &string_arg, 'a', "authenticate user", "user%password" },
{ "getdcname", 0, POPT_ARG_STRING, &string_arg, OPT_GETDCNAME,
"Get a DC name for a foreign domain", "domainname" },
{ "ping", 'p', POPT_ARG_NONE, 0, 'p', "Ping winbindd to see if it is alive" },
@ -1075,7 +1079,7 @@ int main(int argc, char **argv, char **envp)
poptFreeContext(pc);
pc = poptGetContext(NULL, argc, (const char **)argv, long_options,
pc = poptGetContext(NULL, argc, (const char **)argv, long_options,
POPT_CONTEXT_KEEP_FIRST);
while((opt = poptGetNextOpt(pc)) != -1) {
@ -1190,14 +1194,14 @@ int main(int argc, char **argv, char **envp)
break;
case 'r':
if (!wbinfo_get_usergroups(string_arg)) {
d_fprintf(stderr, "Could not get groups for user %s\n",
d_fprintf(stderr, "Could not get groups for user %s\n",
string_arg);
goto done;
}
break;
case OPT_USERSIDS:
if (!wbinfo_get_usersids(string_arg)) {
d_fprintf(stderr, "Could not get group SIDs for user SID %s\n",
d_fprintf(stderr, "Could not get group SIDs for user SID %s\n",
string_arg);
goto done;
}

@ -6,10 +6,10 @@ void winbindd_free_response(struct winbindd_response *response);
NSS_STATUS winbindd_send_request(int req_type, int need_priv,
struct winbindd_request *request);
NSS_STATUS winbindd_get_response(struct winbindd_response *response);
NSS_STATUS winbindd_request_response(int req_type,
NSS_STATUS winbindd_request_response(int req_type,
struct winbindd_request *request,
struct winbindd_response *response);
NSS_STATUS winbindd_priv_request_response(int req_type,
NSS_STATUS winbindd_priv_request_response(int req_type,
struct winbindd_request *request,
struct winbindd_response *response);
int winbindd_read_reply(struct winbindd_response *response);

@ -1,21 +1,21 @@
/*
/*
Unix SMB/CIFS implementation.
A common place to work out how to define NSS_STATUS on various
platforms.
Copyright (C) Tim Potter 2000
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@ -25,8 +25,8 @@
#ifdef HAVE_NSS_COMMON_H
/*
* Sun Solaris
/*
* Sun Solaris
*/
#include "nsswitch/winbind_nss_solaris.h"
@ -42,7 +42,7 @@
#elif HAVE_NS_API_H
/*
* SGI IRIX
* SGI IRIX
*/
#include "nsswitch/winbind_nss_irix.h"

@ -1,4 +1,4 @@
/*
/*
Unix SMB/CIFS implementation.
AIX loadable authentication module, providing identification and
@ -7,17 +7,17 @@
Copyright (C) Tim Potter 2003
Copyright (C) Steve Roylance 2003
Copyright (C) Andrew Tridgell 2003-2004
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@ -31,7 +31,7 @@
changing routines, so you do not need to install the winbind PAM
module.
see
see
http://publib16.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/kernextc/sec_load_mod.htm
for some information in the interface that this module implements
@ -113,12 +113,12 @@ static void free_grp(struct group *grp)
free(grp->gr_name);
free(grp->gr_passwd);
if (!grp->gr_mem) {
free(grp);
return;
}
for (i=0; grp->gr_mem[i]; i++) {
free(grp->gr_mem[i]);
}
@ -200,7 +200,7 @@ static struct passwd *fill_pwent(struct winbindd_pw *pw)
result->pw_gecos = strdup(pw->pw_gecos);
result->pw_dir = strdup(pw->pw_dir);
result->pw_shell = strdup(pw->pw_shell);
return result;
}
@ -229,12 +229,12 @@ static struct group *fill_grent(struct winbindd_gr *gr, char *gr_mem)
if ((gr->num_gr_mem < 0) || !gr_mem) {
gr->num_gr_mem = 0;
}
if (gr->num_gr_mem == 0) {
/* Group is empty */
/* Group is empty */
return result;
}
result->gr_mem = (char **)malloc(sizeof(char *) * (gr->num_gr_mem+1));
if (!result->gr_mem) {
errno = ENOMEM;
@ -243,8 +243,8 @@ static struct group *fill_grent(struct winbindd_gr *gr, char *gr_mem)
/* Start looking at extra data */
i=0;
for (name = strtok_r(gr_mem, ",", &p);
name;
for (name = strtok_r(gr_mem, ",", &p);
name;
name = strtok_r(NULL, ",", &p)) {
if (i == gr->num_gr_mem) {
break;
@ -261,7 +261,7 @@ static struct group *fill_grent(struct winbindd_gr *gr, char *gr_mem)
/* take a group id and return a filled struct group */
/* take a group id and return a filled struct group */
static struct group *wb_aix_getgrgid(gid_t gid)
{
struct winbindd_response response;
@ -273,7 +273,7 @@ static struct group *wb_aix_getgrgid(gid_t gid)
ZERO_STRUCT(response);
ZERO_STRUCT(request);
request.data.gid = gid;
ret = winbindd_request_response(WINBINDD_GETGRGID, &request, &response);
@ -309,7 +309,7 @@ static struct group *wb_aix_getgrnam(const char *name)
STRCPY_RETNULL(request.data.groupname, name);
ret = winbindd_request_response(WINBINDD_GETGRNAM, &request, &response);
HANDLE_ERRORS(ret);
grp = fill_grent(&response.data.gr, response.extra_data.data);
@ -373,7 +373,7 @@ static char *wb_aix_getgrset(char *user)
num_gids = response.data.num_entries;
gid_list = (gid_t *)response.extra_data.data;
/* allocate a space large enough to contruct the string */
tmpbuf = malloc(num_gids*12);
if (!tmpbuf) {
@ -381,9 +381,9 @@ static char *wb_aix_getgrset(char *user)
}
for (idx=i=0; i < num_gids-1; i++) {
idx += sprintf(tmpbuf+idx, "%u,", gid_list[i]);
idx += sprintf(tmpbuf+idx, "%u,", gid_list[i]);
}
idx += sprintf(tmpbuf+idx, "%u", gid_list[i]);
idx += sprintf(tmpbuf+idx, "%u", gid_list[i]);
winbindd_free_response(&response);
@ -391,7 +391,7 @@ static char *wb_aix_getgrset(char *user)
}
/* take a uid and return a filled struct passwd */
/* take a uid and return a filled struct passwd */
static struct passwd *wb_aix_getpwuid(uid_t uid)
{
struct winbindd_response response;
@ -403,9 +403,9 @@ static struct passwd *wb_aix_getpwuid(uid_t uid)
ZERO_STRUCT(response);
ZERO_STRUCT(request);
request.data.uid = uid;
ret = winbindd_request_response(WINBINDD_GETPWUID, &request, &response);
HANDLE_ERRORS(ret);
@ -442,7 +442,7 @@ static struct passwd *wb_aix_getpwnam(const char *name)
ret = winbindd_request_response(WINBINDD_GETPWNAM, &request, &response);
HANDLE_ERRORS(ret);
pwd = fill_pwent(&response.data.pw);
winbindd_free_response(&response);
@ -471,7 +471,7 @@ static int wb_aix_lsuser(char *attributes[], attrval_t results[], int size)
ZERO_STRUCT(request);
ZERO_STRUCT(response);
ret = winbindd_request_response(WINBINDD_LIST_USERS, &request, &response);
if (ret != 0) {
errno = EINVAL;
@ -486,7 +486,7 @@ static int wb_aix_lsuser(char *attributes[], attrval_t results[], int size)
errno = ENOMEM;
return -1;
}
memcpy(s, response.extra_data.data, len+1);
replace_commas(s);
@ -495,7 +495,7 @@ static int wb_aix_lsuser(char *attributes[], attrval_t results[], int size)
results[0].attr_flag = 0;
winbindd_free_response(&response);
return 0;
}
@ -519,7 +519,7 @@ static int wb_aix_lsgroup(char *attributes[], attrval_t results[], int size)
ZERO_STRUCT(request);
ZERO_STRUCT(response);
ret = winbindd_request_response(WINBINDD_LIST_GROUPS, &request, &response);
if (ret != 0) {
errno = EINVAL;
@ -534,7 +534,7 @@ static int wb_aix_lsgroup(char *attributes[], attrval_t results[], int size)
errno = ENOMEM;
return -1;
}
memcpy(s, response.extra_data.data, len+1);
replace_commas(s);
@ -543,7 +543,7 @@ static int wb_aix_lsgroup(char *attributes[], attrval_t results[], int size)
results[0].attr_flag = 0;
winbindd_free_response(&response);
return 0;
}
@ -552,9 +552,9 @@ static attrval_t pwd_to_group(struct passwd *pwd)
{
attrval_t r;
struct group *grp = wb_aix_getgrgid(pwd->pw_gid);
if (!grp) {
r.attr_flag = EINVAL;
r.attr_flag = EINVAL;
} else {
r.attr_flag = 0;
r.attr_un.au_char = strdup(grp->gr_name);
@ -692,18 +692,18 @@ static int wb_aix_group_attrib(const char *key, char *attributes[],
/*
called for user/group enumerations
*/
static int wb_aix_getentry(char *key, char *table, char *attributes[],
static int wb_aix_getentry(char *key, char *table, char *attributes[],
attrval_t results[], int size)
{
logit("Got getentry with key='%s' table='%s' size=%d attributes[0]='%s'\n",
logit("Got getentry with key='%s' table='%s' size=%d attributes[0]='%s'\n",
key, table, size, attributes[0]);
if (strcmp(key, "ALL") == 0 &&
if (strcmp(key, "ALL") == 0 &&
strcmp(table, "user") == 0) {
return wb_aix_lsuser(attributes, results, size);
}
if (strcmp(key, "ALL") == 0 &&
if (strcmp(key, "ALL") == 0 &&
strcmp(table, "group") == 0) {
return wb_aix_lsgroup(attributes, results, size);
}
@ -732,7 +732,7 @@ static void *wb_aix_open(const char *name, const char *domain, int mode, char *o
if (strstr(options, "debug")) {
debug_enabled = 1;
}
logit("open name='%s' mode=%d domain='%s' options='%s'\n", name, domain,
logit("open name='%s' mode=%d domain='%s' options='%s'\n", name, domain,
mode, options);
return NULL;
}
@ -744,14 +744,14 @@ static void wb_aix_close(void *token)
}
#ifdef HAVE_STRUCT_SECMETHOD_TABLE_METHOD_ATTRLIST
/*
return a list of additional attributes supported by the backend
/*
return a list of additional attributes supported by the backend
*/
static attrlist_t **wb_aix_attrlist(void)
{
/* pretty confusing but we are allocating the array of pointers
and the structures we'll be pointing to all at once. So
you need N+1 pointers and N structures. */
you need N+1 pointers and N structures. */
attrlist_t **ret = NULL;
attrlist_t *offset = NULL;
@ -821,7 +821,7 @@ static attrlist_t **wb_aix_attrlist(void)
/*
turn a long username into a short one. Needed to cope with the 8 char
turn a long username into a short one. Needed to cope with the 8 char
username limit in AIX 5.2 and below
*/
static int wb_aix_normalize(char *longname, char *shortname)
@ -854,7 +854,7 @@ static int wb_aix_normalize(char *longname, char *shortname)
/*
authenticate a user
*/
static int wb_aix_authenticate(char *user, char *pass,
static int wb_aix_authenticate(char *user, char *pass,
int *reenter, char **message)
{
struct winbindd_request request;
@ -950,7 +950,7 @@ static int wb_aix_chpass(char *user, char *oldpass, char *newpass, char **messag
/*
don't do any password strength testing for now
*/
static int wb_aix_passwdrestrictions(char *user, char *newpass, char *oldpass,
static int wb_aix_passwdrestrictions(char *user, char *newpass, char *oldpass,
char **message)
{
logit("passwdresrictions called for '%s'\n", user);
@ -977,13 +977,13 @@ static char *wb_aix_getpasswd(char *user)
}
/*
this is called to update things like the last login time. We don't
this is called to update things like the last login time. We don't
currently pass this onto the DC
*/
static int wb_aix_putentry(char *key, char *table, char *attributes[],
static int wb_aix_putentry(char *key, char *table, char *attributes[],
attrval_t values[], int size)
{
logit("putentry key='%s' table='%s' attrib='%s'\n",
logit("putentry key='%s' table='%s' attrib='%s'\n",
key, table, size>=1?attributes[0]:"<null>");
errno = ENOSYS;
return -1;
@ -1047,7 +1047,7 @@ int wb_aix_init(struct secmethod_table *methods)
methods->method_passwdexpired = wb_aix_passwdexpired;
methods->method_putentry = wb_aix_putentry;
methods->method_getpasswd = wb_aix_getpasswd;
methods->method_authenticate = wb_aix_authenticate;
methods->method_authenticate = wb_aix_authenticate;
methods->method_commit = wb_aix_commit;
methods->method_chpass = wb_aix_chpass;
methods->method_passwdrestrictions = wb_aix_passwdrestrictions;
@ -1074,4 +1074,3 @@ int wb_aix_init(struct secmethod_table *methods)
return AUTH_SUCCESS;
}

@ -1,20 +1,20 @@
/*
/*
Unix SMB/CIFS implementation.
Winbind daemon for ntdom nss module
Copyright (C) Tim Potter 2000
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@ -54,6 +54,7 @@
#ifndef FSTRING_LEN
#define FSTRING_LEN 256
typedef char fstring[FSTRING_LEN];
#define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1)
#endif
/* Some systems (SCO) treat UNIX domain sockets as FIFOs */

@ -1,21 +1,21 @@
/*
/*
Unix SMB/CIFS implementation.
AIX loadable authentication module, providing identification
AIX loadable authentication module, providing identification
routines against Samba winbind/Windows NT Domain
Copyright (C) Aaron Collins 2003
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

@ -1,19 +1,19 @@
/*
Unix SMB/CIFS implementation.
Donated by HP to enable Winbindd to build on HPUX 11.x.
Copyright (C) Jeremy Allison 2002.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
@ -34,20 +34,20 @@
#ifdef HAVE_PTHREAD_H
#include <pthread.h>
#endif
typedef enum {
NSS_SUCCESS,
NSS_NOTFOUND,
NSS_UNAVAIL,
NSS_TRYAGAIN
} nss_status_t;
typedef nss_status_t NSS_STATUS;
struct nss_backend;
typedef nss_status_t (*nss_backend_op_t)(struct nss_backend *, void *args);
struct nss_backend {
nss_backend_op_t *ops;
int n_ops;
@ -58,41 +58,41 @@ typedef int nss_dbop_t;
#include <errno.h>
#include <netdb.h>
#include <limits.h>
#ifndef NSS_INCLUDE_UNSAFE
#define NSS_INCLUDE_UNSAFE 1 /* Build old, MT-unsafe interfaces, */
#endif /* NSS_INCLUDE_UNSAFE */
enum nss_netgr_argn {
NSS_NETGR_MACHINE,
NSS_NETGR_USER,
NSS_NETGR_DOMAIN,
NSS_NETGR_N
};
enum nss_netgr_status {
NSS_NETGR_FOUND,
NSS_NETGR_NO,
NSS_NETGR_NOMEM
};
typedef unsigned nss_innetgr_argc;
typedef char **nss_innetgr_argv;
struct nss_innetgr_1arg {
nss_innetgr_argc argc;
nss_innetgr_argv argv;
};
typedef struct {
void *result; /* "result" parameter to getXbyY_r() */
char *buffer; /* "buffer" " " */
int buflen; /* "buflen" " " */
} nss_XbyY_buf_t;
extern nss_XbyY_buf_t *_nss_XbyY_buf_alloc(int struct_size, int buffer_size);
extern void _nss_XbyY_buf_free(nss_XbyY_buf_t *);
union nss_XbyY_key {
uid_t uid;
gid_t gid;
@ -116,7 +116,7 @@ union nss_XbyY_key {
} serv;
void *ether;
};
typedef struct nss_XbyY_args {
nss_XbyY_buf_t buf;
int stayopen;
@ -127,11 +127,11 @@ typedef struct nss_XbyY_args {
*/
int (*str2ent)(const char *instr, int instr_len, void *ent, char *buffer, int buflen);
union nss_XbyY_key key;
void *returnval;
int erange;
int h_errno;
nss_status_t status;
} nss_XbyY_args_t;
#endif /* _WINBIND_NSS_HPUX_H */

@ -1,21 +1,21 @@
/*
/*
Unix SMB/CIFS implementation.
Windows NT Domain nsswitch module
Copyright (C) Tim Potter 2000
Copyright (C) James Peach 2006
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@ -38,7 +38,7 @@ int asprintf(char **,const char *, ...) PRINTF_ATTRIBUTE(2,3);
#endif
/* Maximum number of users to pass back over the unix domain socket
per call. This is not a static limit on the total number of users
per call. This is not a static limit on the total number of users
or groups returned in total. */
#define MAX_GETPWENT_USERS 250
@ -170,7 +170,7 @@ do_request(nsd_file_t *rq, struct winbindd_request *request)
}
}
static int
static int
winbind_callback(nsd_file_t **rqp, int fd)
{
struct winbindd_response response;
@ -195,7 +195,7 @@ winbind_callback(nsd_file_t **rqp, int fd)
if (status != NSS_STATUS_SUCCESS) {
/* free any extra data area in response structure */
winbindd_free_response(&response);
nsd_logprintf(NSD_LOG_MIN,
nsd_logprintf(NSD_LOG_MIN,
"callback (winbind) returning not found, status = %d\n",
status);
@ -225,9 +225,9 @@ winbind_callback(nsd_file_t **rqp, int fd)
if (rlen == 0 || result == NULL) {
return NSD_ERROR;
}
winbindd_free_response(&response);
nsd_logprintf(NSD_LOG_MIN, " %s\n", result);
nsd_set_result(rq, NS_SUCCESS, result, rlen, DYNAMIC);
return NSD_OK;
@ -236,7 +236,7 @@ winbind_callback(nsd_file_t **rqp, int fd)
case WINBINDD_GETPWNAM:
{
struct winbindd_pw *pw = &response.data.pw;
nsd_logprintf(NSD_LOG_MIN,
"callback (winbind) GETPWUID | GETPWUID\n");
@ -250,9 +250,9 @@ winbind_callback(nsd_file_t **rqp, int fd)
pw->pw_shell);
if (rlen == 0 || result == NULL)
return NSD_ERROR;
winbindd_free_response(&response);
nsd_logprintf(NSD_LOG_MIN, " %s\n", result);
nsd_set_result(rq, NS_SUCCESS, result, rlen, DYNAMIC);
return NSD_OK;
@ -263,7 +263,7 @@ winbind_callback(nsd_file_t **rqp, int fd)
{
const struct winbindd_gr *gr = &response.data.gr;
const char * members;
nsd_logprintf(NSD_LOG_MIN,
"callback (winbind) GETGRNAM | GETGRGID\n");
@ -272,14 +272,14 @@ winbind_callback(nsd_file_t **rqp, int fd)
} else {
members = "";
}
rlen = asprintf(&result, "%s:%s:%d:%s\n",
gr->gr_name, gr->gr_passwd, gr->gr_gid, members);
if (rlen == 0 || result == NULL)
return NSD_ERROR;
winbindd_free_response(&response);
nsd_logprintf(NSD_LOG_MIN, " %s\n", result);
nsd_set_result(rq, NS_SUCCESS, result, rlen, DYNAMIC);
return NSD_OK;
@ -296,46 +296,46 @@ winbind_callback(nsd_file_t **rqp, int fd)
case WINBINDD_GETGRLST:
{
int entries;
nsd_logprintf(NSD_LOG_MIN,
"callback (winbind) GETGRENT | GETGRLIST %d responses\n",
response.data.num_entries);
if (response.data.num_entries) {
const struct winbindd_gr *gr = &response.data.gr;
const char * members;
fstring grp_name;
int i;
gr = (struct winbindd_gr *)response.extra_data.data;
if (! gr ) {
nsd_logprintf(NSD_LOG_MIN, " no extra_data\n");
winbindd_free_response(&response);
return NSD_ERROR;
}
members = (char *)response.extra_data.data +
(response.data.num_entries * sizeof(struct winbindd_gr));
for (i = 0; i < response.data.num_entries; i++) {
snprintf(grp_name, sizeof(grp_name) - 1, "%s:%s:%d:",
gr->gr_name, gr->gr_passwd, gr->gr_gid);
nsd_append_element(rq, NS_SUCCESS, result, rlen);
nsd_append_result(rq, NS_SUCCESS,
&members[gr->gr_mem_ofs],
strlen(&members[gr->gr_mem_ofs]));
/* Don't log the whole list, because it might be
* _really_ long and we probably don't want to clobber
* the log with it.
*/
nsd_logprintf(NSD_LOG_MIN, " %s (...)\n", grp_name);
gr++;
}
}
entries = response.data.num_entries;
winbindd_free_response(&response);
if (entries < MAX_GETPWENT_USERS)
@ -405,7 +405,7 @@ winbind_callback(nsd_file_t **rqp, int fd)
}
}
static int
static int
winbind_timeout(nsd_file_t **rqp, nsd_times_t *to)
{
nsd_file_t *rq;
@ -455,7 +455,7 @@ send_next_request(nsd_file_t *rq, struct winbindd_request *request)
SAFE_FREE(request);
if (status != NSS_STATUS_SUCCESS) {
nsd_logprintf(NSD_LOG_MIN,
nsd_logprintf(NSD_LOG_MIN,
"send_next_request (winbind) error status = %d\n",
status);
rq->f_status = status;
@ -512,15 +512,15 @@ int lookup(nsd_file_t *rq)
request->data.uid = atoi(key);
rq->f_cmd_data = (void *)WINBINDD_GETPWUID;
} else if (strcasecmp(map,"passwd.byname") == 0) {
strncpy(request->data.username, key,
strncpy(request->data.username, key,
sizeof(request->data.username) - 1);
request->data.username[sizeof(request->data.username) - 1] = '\0';
rq->f_cmd_data = (void *)WINBINDD_GETPWNAM;
rq->f_cmd_data = (void *)WINBINDD_GETPWNAM;
} else if (strcasecmp(map,"group.byname") == 0) {
strncpy(request->data.groupname, key,
strncpy(request->data.groupname, key,
sizeof(request->data.groupname) - 1);
request->data.groupname[sizeof(request->data.groupname) - 1] = '\0';
rq->f_cmd_data = (void *)WINBINDD_GETGRNAM;
rq->f_cmd_data = (void *)WINBINDD_GETGRNAM;
} else if (strcasecmp(map,"group.bygid") == 0) {
request->data.gid = atoi(key);
rq->f_cmd_data = (void *)WINBINDD_GETGRGID;

@ -1,20 +1,20 @@
/*
/*
Unix SMB/CIFS implementation.
Winbind daemon for ntdom nss module
Copyright (C) Tim Potter 2000
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

@ -1,20 +1,20 @@
/*
/*
Unix SMB/CIFS implementation.
Windows NT Domain nsswitch module
Copyright (C) Tim Potter 2000
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@ -30,7 +30,7 @@ static pthread_mutex_t winbind_nss_mutex = PTHREAD_MUTEX_INITIALIZER;
#endif
/* Maximum number of users to pass back over the unix domain socket
per call. This is not a static limit on the total number of users
per call. This is not a static limit on the total number of users
or groups returned in total. */
#define MAX_GETPWENT_USERS 250
@ -38,37 +38,37 @@ static pthread_mutex_t winbind_nss_mutex = PTHREAD_MUTEX_INITIALIZER;
NSS_STATUS _nss_winbind_setpwent(void);
NSS_STATUS _nss_winbind_endpwent(void);
NSS_STATUS _nss_winbind_getpwent_r(struct passwd *result, char *buffer,
NSS_STATUS _nss_winbind_getpwent_r(struct passwd *result, char *buffer,
size_t buflen, int *errnop);
NSS_STATUS _nss_winbind_getpwuid_r(uid_t uid, struct passwd *result,
NSS_STATUS _nss_winbind_getpwuid_r(uid_t uid, struct passwd *result,
char *buffer, size_t buflen, int *errnop);
NSS_STATUS _nss_winbind_getpwnam_r(const char *name, struct passwd *result,
NSS_STATUS _nss_winbind_getpwnam_r(const char *name, struct passwd *result,
char *buffer, size_t buflen, int *errnop);
NSS_STATUS _nss_winbind_setgrent(void);
NSS_STATUS _nss_winbind_endgrent(void);
NSS_STATUS _nss_winbind_getgrent_r(struct group *result, char *buffer,
NSS_STATUS _nss_winbind_getgrent_r(struct group *result, char *buffer,
size_t buflen, int *errnop);
NSS_STATUS _nss_winbind_getgrlst_r(struct group *result, char *buffer,
NSS_STATUS _nss_winbind_getgrlst_r(struct group *result, char *buffer,
size_t buflen, int *errnop);
NSS_STATUS _nss_winbind_getgrnam_r(const char *name, struct group *result,
NSS_STATUS _nss_winbind_getgrnam_r(const char *name, struct group *result,
char *buffer, size_t buflen, int *errnop);
NSS_STATUS _nss_winbind_getgrgid_r(gid_t gid, struct group *result, char *buffer,
NSS_STATUS _nss_winbind_getgrgid_r(gid_t gid, struct group *result, char *buffer,
size_t buflen, int *errnop);
NSS_STATUS _nss_winbind_initgroups_dyn(char *user, gid_t group, long int *start,
long int *size, gid_t **groups,
NSS_STATUS _nss_winbind_initgroups_dyn(char *user, gid_t group, long int *start,
long int *size, gid_t **groups,
long int limit, int *errnop);
NSS_STATUS _nss_winbind_getusersids(const char *user_sid, char **group_sids,
int *num_groups, char *buffer, size_t buf_size,
NSS_STATUS _nss_winbind_getusersids(const char *user_sid, char **group_sids,
int *num_groups, char *buffer, size_t buf_size,
int *errnop);
NSS_STATUS _nss_winbind_nametosid(const char *name, char **sid, char *buffer,
size_t buflen, int *errnop);
NSS_STATUS _nss_winbind_sidtoname(const char *sid, char **name, char *buffer,
NSS_STATUS _nss_winbind_sidtoname(const char *sid, char **name, char *buffer,
size_t buflen, int *errnop);
NSS_STATUS _nss_winbind_sidtouid(const char *sid, uid_t *uid, int *errnop);
NSS_STATUS _nss_winbind_sidtogid(const char *sid, gid_t *gid, int *errnop);
NSS_STATUS _nss_winbind_uidtosid(uid_t uid, char **sid, char *buffer,
NSS_STATUS _nss_winbind_uidtosid(uid_t uid, char **sid, char *buffer,
size_t buflen, int *errnop);
NSS_STATUS _nss_winbind_gidtosid(gid_t gid, char **sid, char *buffer,
NSS_STATUS _nss_winbind_gidtosid(gid_t gid, char **sid, char *buffer,
size_t buflen, int *errnop);
/* Prototypes from wb_common.c */
@ -180,7 +180,7 @@ static NSS_STATUS fill_pwent(struct passwd *result,
{
/* User name */
if ((result->pw_name =
if ((result->pw_name =
get_static(buffer, buflen, strlen(pw->pw_name) + 1)) == NULL) {
/* Out of memory */
@ -192,7 +192,7 @@ static NSS_STATUS fill_pwent(struct passwd *result,
/* Password */
if ((result->pw_passwd =
if ((result->pw_passwd =
get_static(buffer, buflen, strlen(pw->pw_passwd) + 1)) == NULL) {
/* Out of memory */
@ -201,7 +201,7 @@ static NSS_STATUS fill_pwent(struct passwd *result,
}
strcpy(result->pw_passwd, pw->pw_passwd);
/* [ug]id */
result->pw_uid = pw->pw_uid;
@ -209,7 +209,7 @@ static NSS_STATUS fill_pwent(struct passwd *result,
/* GECOS */
if ((result->pw_gecos =
if ((result->pw_gecos =
get_static(buffer, buflen, strlen(pw->pw_gecos) + 1)) == NULL) {
/* Out of memory */
@ -218,10 +218,10 @@ static NSS_STATUS fill_pwent(struct passwd *result,
}
strcpy(result->pw_gecos, pw->pw_gecos);
/* Home directory */
if ((result->pw_dir =
if ((result->pw_dir =
get_static(buffer, buflen, strlen(pw->pw_dir) + 1)) == NULL) {
/* Out of memory */
@ -232,10 +232,10 @@ static NSS_STATUS fill_pwent(struct passwd *result,
strcpy(result->pw_dir, pw->pw_dir);
/* Logon shell */
if ((result->pw_shell =
if ((result->pw_shell =
get_static(buffer, buflen, strlen(pw->pw_shell) + 1)) == NULL) {
/* Out of memory */
return NSS_STATUS_TRYAGAIN;
@ -423,7 +423,7 @@ _nss_winbind_endpwent(void)
/* Fetch the next password entry from ntdom password database */
NSS_STATUS
_nss_winbind_getpwent_r(struct passwd *result, char *buffer,
_nss_winbind_getpwent_r(struct passwd *result, char *buffer,
size_t buflen, int *errnop)
{
NSS_STATUS ret;
@ -446,7 +446,7 @@ _nss_winbind_getpwent_r(struct passwd *result, char *buffer,
}
/* Else call winbindd to get a bunch of entries */
if (num_pw_cache > 0) {
winbindd_free_response(&getpwent_response);
}
@ -456,7 +456,7 @@ _nss_winbind_getpwent_r(struct passwd *result, char *buffer,
request.data.num_entries = MAX_GETPWENT_USERS;
ret = winbindd_request_response(WINBINDD_GETPWENT, &request,
ret = winbindd_request_response(WINBINDD_GETPWENT, &request,
&getpwent_response);
if (ret == NSS_STATUS_SUCCESS) {
@ -483,7 +483,7 @@ _nss_winbind_getpwent_r(struct passwd *result, char *buffer,
ret = fill_pwent(result, &pw_cache[ndx_pw_cache],
&buffer, &buflen);
/* Out of memory - try again */
if (ret == NSS_STATUS_TRYAGAIN) {
@ -547,7 +547,7 @@ _nss_winbind_getpwuid_r(uid_t uid, struct passwd *result, char *buffer,
ret = winbindd_request_response(WINBINDD_GETPWUID, &request, &response);
if (ret == NSS_STATUS_SUCCESS) {
ret = fill_pwent(result, &response.data.pw,
ret = fill_pwent(result, &response.data.pw,
&buffer, &buflen);
if (ret == NSS_STATUS_TRYAGAIN) {
@ -615,7 +615,7 @@ _nss_winbind_getpwnam_r(const char *name, struct passwd *result, char *buffer,
ZERO_STRUCT(response);
ZERO_STRUCT(request);
strncpy(request.data.username, name,
strncpy(request.data.username, name,
sizeof(request.data.username) - 1);
request.data.username
[sizeof(request.data.username) - 1] = '\0';
@ -746,7 +746,7 @@ winbind_getgrent(enum winbindd_cmd cmd,
NSS_STATUS ret;
static struct winbindd_request request;
static int called_again;
#ifdef DEBUG_NSS
fprintf(stderr, "[%5d]: getgrent\n", getpid());
@ -764,7 +764,7 @@ winbind_getgrent(enum winbindd_cmd cmd,
}
/* Else call winbindd to get a bunch of entries */
if (num_gr_cache > 0) {
winbindd_free_response(&getgrent_response);
}
@ -774,7 +774,7 @@ winbind_getgrent(enum winbindd_cmd cmd,
request.data.num_entries = MAX_GETGRENT_USERS;
ret = winbindd_request_response(cmd, &request,
ret = winbindd_request_response(cmd, &request,
&getgrent_response);
if (ret == NSS_STATUS_SUCCESS) {
@ -810,7 +810,7 @@ winbind_getgrent(enum winbindd_cmd cmd,
ret = fill_grent(result, &gr_cache[ndx_gr_cache],
((char *)getgrent_response.extra_data.data)+mem_ofs,
&buffer, &buflen);
/* Out of memory - try again */
if (ret == NSS_STATUS_TRYAGAIN) {
@ -869,7 +869,7 @@ _nss_winbind_getgrnam_r(const char *name,
static struct winbindd_response response;
struct winbindd_request request;
static int keep_response;
#ifdef DEBUG_NSS
fprintf(stderr, "[%5d]: getgrnam %s\n", getpid(), name);
#endif
@ -888,7 +888,7 @@ _nss_winbind_getgrnam_r(const char *name,
ZERO_STRUCT(request);
ZERO_STRUCT(response);
strncpy(request.data.groupname, name,
strncpy(request.data.groupname, name,
sizeof(request.data.groupname));
request.data.groupname
[sizeof(request.data.groupname) - 1] = '\0';
@ -896,7 +896,7 @@ _nss_winbind_getgrnam_r(const char *name,
ret = winbindd_request_response(WINBINDD_GETGRNAM, &request, &response);
if (ret == NSS_STATUS_SUCCESS) {
ret = fill_grent(result, &response.data.gr,
ret = fill_grent(result, &response.data.gr,
(char *)response.extra_data.data,
&buffer, &buflen);
@ -911,7 +911,7 @@ _nss_winbind_getgrnam_r(const char *name,
/* We've been called again */
ret = fill_grent(result, &response.data.gr,
ret = fill_grent(result, &response.data.gr,
(char *)response.extra_data.data, &buffer,
&buflen);
@ -975,8 +975,8 @@ _nss_winbind_getgrgid_r(gid_t gid,
if (ret == NSS_STATUS_SUCCESS) {
ret = fill_grent(result, &response.data.gr,
(char *)response.extra_data.data,
ret = fill_grent(result, &response.data.gr,
(char *)response.extra_data.data,
&buffer, &buflen);
if (ret == NSS_STATUS_TRYAGAIN) {
@ -990,7 +990,7 @@ _nss_winbind_getgrgid_r(gid_t gid,
/* We've been called again */
ret = fill_grent(result, &response.data.gr,
ret = fill_grent(result, &response.data.gr,
(char *)response.extra_data.data, &buffer,
&buflen);
@ -1110,7 +1110,7 @@ _nss_winbind_initgroups_dyn(char *user, gid_t group, long int *start,
*start += 1;
}
}
/* Back to your regularly scheduled programming */
done:
@ -1167,7 +1167,7 @@ _nss_winbind_getusersids(const char *user_sid, char **group_sids,
*group_sids = buffer;
memcpy(buffer, response.extra_data.data, response.length - sizeof(response));
errno = *errnop = 0;
done:
winbindd_free_response(&response);
@ -1199,7 +1199,7 @@ _nss_winbind_nametosid(const char *name, char **sid, char *buffer,
ZERO_STRUCT(response);
ZERO_STRUCT(request);
strncpy(request.data.name.name, name,
strncpy(request.data.name.name, name,
sizeof(request.data.name.name) - 1);
request.data.name.name[sizeof(request.data.name.name) - 1] = '\0';
@ -1264,7 +1264,7 @@ _nss_winbind_sidtoname(const char *sid, char **name, char *buffer,
}
strncpy(request.data.sid, sid,
strncpy(request.data.sid, sid,
sizeof(request.data.sid) - 1);
request.data.sid[sizeof(request.data.sid) - 1] = '\0';
@ -1274,7 +1274,7 @@ _nss_winbind_sidtoname(const char *sid, char **name, char *buffer,
goto failed;
}
needed =
needed =
strlen(response.data.name.dom_name) +
strlen(response.data.name.name) + 2;
@ -1284,7 +1284,7 @@ _nss_winbind_sidtoname(const char *sid, char **name, char *buffer,
goto failed;
}
snprintf(buffer, needed, "%s%c%s",
snprintf(buffer, needed, "%s%c%s",
response.data.name.dom_name,
sep_char,
response.data.name.name);

@ -1,20 +1,20 @@
/*
/*
Unix SMB/CIFS implementation.
Winbind daemon for ntdom nss module
Copyright (C) Tim Potter 2000
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

@ -1,21 +1,21 @@
/*
/*
Unix SMB/CIFS implementation.
NetBSD loadable authentication module, providing identification
NetBSD loadable authentication module, providing identification
routines against Samba winbind/Windows NT Domain
Copyright (C) Luke Mewburn 2004-2005
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

@ -1,8 +1,8 @@
/*
Solaris NSS wrapper for winbind
Solaris NSS wrapper for winbind
- Shirish Kalele 2000
Based on Luke Howard's ldap_nss module for Solaris
Based on Luke Howard's ldap_nss module for Solaris
*/
/*
@ -38,7 +38,7 @@
#include <sys/syslog.h>
#endif /*hpux*/
#if defined(HAVE_NSS_COMMON_H) || defined(HPUX)
#if defined(HAVE_NSS_COMMON_H) || defined(HPUX)
#undef NSS_DEBUG
@ -63,9 +63,9 @@ struct nss_groupsbymem {
gid_t *gid_array;
int maxgids;
int force_slow_way;
int (*str2ent)(const char *instr, int instr_len, void *ent,
int (*str2ent)(const char *instr, int instr_len, void *ent,
char *buffer, int buflen);
nss_status_t (*process_cstr)(const char *instr, int instr_len,
nss_status_t (*process_cstr)(const char *instr, int instr_len,
struct nss_groupsbymem *);
int numgids;
};
@ -106,7 +106,7 @@ _nss_winbind_getpwent_solwrap (nss_backend_t* be, void *args)
int* errnop = &NSS_ARGS(args)->erange;
char logmsg[80];
ret = _nss_winbind_getpwent_r(result, buffer,
ret = _nss_winbind_getpwent_r(result, buffer,
buflen, errnop);
if(ret == NSS_STATUS_SUCCESS)
@ -119,7 +119,7 @@ _nss_winbind_getpwent_solwrap (nss_backend_t* be, void *args)
snprintf(logmsg, 79, "_nss_winbind_getpwent_solwrap: Returning error: %d.\n",ret);
NSS_DEBUG(logmsg);
}
return ret;
}
@ -138,7 +138,7 @@ _nss_winbind_getpwnam_solwrap (nss_backend_t* be, void* args)
&NSS_ARGS(args)->erange);
if(ret == NSS_STATUS_SUCCESS)
NSS_ARGS(args)->returnval = (void*) result;
return ret;
}
@ -147,7 +147,7 @@ _nss_winbind_getpwuid_solwrap(nss_backend_t* be, void* args)
{
NSS_STATUS ret;
struct passwd* result = (struct passwd*) NSS_ARGS(args)->buf.result;
NSS_DEBUG("_nss_winbind_getpwuid_solwrap");
ret = _nss_winbind_getpwuid_r (NSS_ARGS(args)->key.uid,
result,
@ -156,7 +156,7 @@ _nss_winbind_getpwuid_solwrap(nss_backend_t* be, void* args)
&NSS_ARGS(args)->erange);
if(ret == NSS_STATUS_SUCCESS)
NSS_ARGS(args)->returnval = (void*) result;
return ret;
}
@ -183,7 +183,7 @@ _nss_winbind_passwd_constr (const char* db_name,
const char* cfg_args)
{
nss_backend_t *be;
if(!(be = SMB_MALLOC_P(nss_backend_t)) )
return NULL;
@ -221,7 +221,7 @@ _nss_winbind_getgrent_solwrap(nss_backend_t* be, void* args)
int* errnop = &NSS_ARGS(args)->erange;
char logmsg[80];
ret = _nss_winbind_getgrent_r(result, buffer,
ret = _nss_winbind_getgrent_r(result, buffer,
buflen, errnop);
if(ret == NSS_STATUS_SUCCESS)
@ -235,7 +235,7 @@ _nss_winbind_getgrent_solwrap(nss_backend_t* be, void* args)
}
return ret;
}
static NSS_STATUS
@ -253,10 +253,10 @@ _nss_winbind_getgrnam_solwrap(nss_backend_t* be, void* args)
if(ret == NSS_STATUS_SUCCESS)
NSS_ARGS(args)->returnval = (void*) result;
return ret;
}
static NSS_STATUS
_nss_winbind_getgrgid_solwrap(nss_backend_t* be, void* args)
{
@ -310,7 +310,7 @@ _nss_winbind_group_destr (nss_backend_t* be, void* args)
return NSS_STATUS_SUCCESS;
}
static nss_backend_op_t group_ops[] =
static nss_backend_op_t group_ops[] =
{
_nss_winbind_group_destr,
_nss_winbind_endgrent_solwrap,
@ -319,7 +319,7 @@ static nss_backend_op_t group_ops[] =
_nss_winbind_getgrnam_solwrap,
_nss_winbind_getgrgid_solwrap,
_nss_winbind_getgroupsbymember_solwrap
};
};
nss_backend_t*
_nss_winbind_group_constr (const char* db_name,
@ -333,7 +333,7 @@ _nss_winbind_group_constr (const char* db_name,
be->ops = group_ops;
be->n_ops = sizeof(group_ops) / sizeof(nss_backend_op_t);
NSS_DEBUG("Initialized nss_winbind group backend");
return be;
}
@ -410,7 +410,7 @@ parse_response(int af, nss_XbyY_args_t* argp, struct winbindd_response *response
argp->erange = 1;
return NSS_STR_PARSE_ERANGE;
}
data = response->data.winsresp;
for( i = 0; i < addrcount; i++) {
p = strchr(data, '\t');
@ -524,7 +524,7 @@ _nss_winbind_hosts_getbyname(nss_backend_t* be, void *args)
ZERO_STRUCT(response);
ZERO_STRUCT(request);
strncpy(request.data.winsreq, argp->key.name, sizeof(request.data.winsreq) - 1);
request.data.winsreq[sizeof(request.data.winsreq) - 1] = '\0';
@ -560,7 +560,7 @@ _nss_winbind_hosts_getbyaddr(nss_backend_t* be, void *args)
request.data.winsreq, sizeof request.data.winsreq);
#else
snprintf(request.data.winsreq, sizeof request.data.winsreq,
"%u.%u.%u.%u",
"%u.%u.%u.%u",
((unsigned char *)argp->key.hostaddr.addr)[0],
((unsigned char *)argp->key.hostaddr.addr)[1],
((unsigned char *)argp->key.hostaddr.addr)[2],

@ -1,20 +1,20 @@
/*
/*
Unix SMB/CIFS implementation.
Winbind daemon for ntdom nss module
Copyright (C) Tim Potter 2000
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

@ -1,14 +1,14 @@
/*
/*
Unix SMB/CIFS implementation.
Winbind daemon for ntdom nss module
Copyright (C) Tim Potter 2000
Copyright (C) Gerald Carter 2006
You are free to use this interface definition in any way you see
fit, including without restriction, using this header in your own
products. You do not need to give any attribution.
products. You do not need to give any attribution.
*/
#ifndef SAFE_FREE
@ -41,8 +41,6 @@
/* Update this when you change the interface. */
/* Version 20: added WINBINDD_REMOVE_MAPPING command */
#define WINBIND_INTERFACE_VERSION 20
/* Have to deal with time_t being 4 or 8 bytes due to structure alignment.
@ -217,7 +215,7 @@ typedef struct winbindd_gr {
/*******************************************************************************
* This structure MUST be the same size in the 32bit and 64bit builds
* for compatibility between /lib64/libnss_winbind.so and /lib/libnss_winbind.so
*
*
* DO NOT CHANGE THIS STRUCTURE WITHOUT TESTING THE 32BIT NSS LIB AGAINST
* A 64BIT WINBINDD --jerry
******************************************************************************/
@ -327,7 +325,7 @@ struct winbindd_request {
} dsgetdcname;
/* padding -- needed to fix alignment between 32bit and 64bit libs.
The size is the sizeof the union without the padding aligned on
The size is the sizeof the union without the padding aligned on
an 8 byte boundary. --jerry */
char padding[1800];
@ -353,27 +351,27 @@ enum winbindd_result {
/*******************************************************************************
* This structure MUST be the same size in the 32bit and 64bit builds
* for compatibility between /lib64/libnss_winbind.so and /lib/libnss_winbind.so
*
*
* DO NOT CHANGE THIS STRUCTURE WITHOUT TESTING THE 32BIT NSS LIB AGAINST
* A 64BIT WINBINDD --jerry
******************************************************************************/
struct winbindd_response {
/* Header information */
uint32_t length; /* Length of response */
enum winbindd_result result; /* Result code */
/* Fixed length return data */
union {
int interface_version; /* Try to ensure this is always in the same spot... */
fstring winsresp; /* WINS response */
/* getpwnam, getpwuid */
struct winbindd_pw pw;
/* getgrnam, getgrgid */
@ -387,7 +385,7 @@ struct winbindd_response {
} sid;
struct winbindd_name {
fstring dom_name; /* lookupsid */
fstring name;
fstring name;
int type;
} name;
uid_t uid; /* sid_to_uid */

@ -1,21 +1,21 @@
/*
/*
Unix SMB/CIFS implementation.
a WINS nsswitch module
a WINS nsswitch module
Copyright (C) Andrew Tridgell 1999
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
@ -207,7 +207,7 @@ int lookup(nsd_file_t *rq)
bool found = False;
nsd_logprintf(NSD_LOG_MIN, "entering lookup (wins)\n");
if (! rq)
if (! rq)
return NSD_ERROR;
map = nsd_attr_fetch_string(rq->f_attrs, "table", (char*)0);
@ -225,7 +225,7 @@ int lookup(nsd_file_t *rq)
response[0] = '\0';
len = sizeof(response) - 2;
/*
/*
* response needs to be a string of the following format
* ip_address[ ip_address]*\tname[ alias]*
*/
@ -276,7 +276,7 @@ int lookup(nsd_file_t *rq)
if (size > len) {
free(ip_list);
return NSD_ERROR;
}
}
strncat(response,key,size);
strncat(response,"\n",1);
found = True;
@ -306,7 +306,7 @@ static char *get_static(char **buffer, size_t *buflen, int len)
/* Error check. We return false if things aren't set up right, or
there isn't enough buffer space left. */
if ((buffer == NULL) || (buflen == NULL) || (*buflen < len)) {
return NULL;
}
@ -333,7 +333,7 @@ _nss_wins_gethostbyname_r(const char *hostname, struct hostent *he,
int i, count;
fstring name;
size_t namelen;
#if HAVE_PTHREAD
pthread_mutex_lock(&wins_nss_mutex);
#endif

@ -28,4 +28,7 @@ $(pidldir)/lib/Parse/Pidl/Expr.pm: $(pidldir)/idl.yp
testcov-html:: pidl-testcov
pidl-clean:
/bin/rm -f $(pidldir)/Makefile
clean:: pidl-clean

@ -244,7 +244,7 @@ SMBLDAP_OBJ = @SMBLDAP@ @SMBLDAPUTIL@
VERSION_OBJ = lib/version.o
WBCOMMON_OBJ = nsswitch/wb_common.o
WBCOMMON_OBJ = ../nsswitch/wb_common.o
AFS_OBJ = lib/afs.o
@ -809,7 +809,7 @@ RPCCLIENT_OBJ = $(RPCCLIENT_OBJ1) \
$(LIBADS_OBJ) $(POPT_LIB_OBJ) \
$(SMBLDAP_OBJ) $(DCUTIL_OBJ) $(LDB_OBJ)
PAM_WINBIND_OBJ = nsswitch/pam_winbind.o localedir.o $(WBCOMMON_OBJ) \
PAM_WINBIND_OBJ = ../nsswitch/pam_winbind.o localedir.o $(WBCOMMON_OBJ) \
$(LIBREPLACE_OBJ) @BUILD_INIPARSER@
LIBSMBCLIENT_OBJ0 = \
@ -1009,7 +1009,7 @@ SMBFILTER_OBJ = utils/smbfilter.o $(PARAM_OBJ) $(LIBSMB_OBJ) \
$(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) \
$(LIBNDR_GEN_OBJ0)
WINBIND_WINS_NSS_OBJ = nsswitch/wins.o $(PARAM_OBJ) \
WINBIND_WINS_NSS_OBJ = ../nsswitch/wins.o $(PARAM_OBJ) \
$(LIBSMB_OBJ) $(LIB_NONSMBD_OBJ) $(NSSWINS_OBJ) $(KRBCLIENT_OBJ) \
$(LIBNDR_GEN_OBJ0)
@ -1073,7 +1073,7 @@ WINBINDD_OBJ = \
$(AFS_OBJ) $(AFS_SETTOKEN_OBJ) \
$(LIBADS_SERVER_OBJ) $(SERVER_MUTEX_OBJ) $(LDB_OBJ)
WBINFO_OBJ = nsswitch/wbinfo.o $(LIBSAMBA_OBJ) $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \
WBINFO_OBJ = ../nsswitch/wbinfo.o $(LIBSAMBA_OBJ) $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) \
$(POPT_LIB_OBJ) $(AFS_SETTOKEN_OBJ) \
lib/winbind_util.o $(WBCOMMON_OBJ) @LIBWBCLIENT_STATIC@
@ -1110,7 +1110,7 @@ LDBADD_OBJ = $(LDB_CMDLINE_OBJ) lib/ldb/tools/ldbadd.o
LDBDEL_OBJ = $(LDB_CMDLINE_OBJ) lib/ldb/tools/ldbdel.o
LDBMODIFY_OBJ = $(LDB_CMDLINE_OBJ) lib/ldb/tools/ldbmodify.o
WINBIND_KRB5_LOCATOR_OBJ1 = nsswitch/winbind_krb5_locator.o
WINBIND_KRB5_LOCATOR_OBJ1 = ../nsswitch/winbind_krb5_locator.o
WINBIND_KRB5_LOCATOR_OBJ = $(WINBIND_KRB5_LOCATOR_OBJ1) $(LIBREPLACE_OBJ)
POPT_OBJ=../lib/popt/findme.o ../lib/popt/popt.o ../lib/popt/poptconfig.o \
@ -1767,13 +1767,13 @@ shlibs test_shlibs: @LIBTDB_SHARED@
#
#-------------------------------------------------------------------
LIBWBCLIENT_OBJ0 = nsswitch/libwbclient/wbclient.o \
nsswitch/libwbclient/wbc_util.o \
nsswitch/libwbclient/wbc_pwd.o \
nsswitch/libwbclient/wbc_idmap.o \
nsswitch/libwbclient/wbc_sid.o \
nsswitch/libwbclient/wbc_guid.o \
nsswitch/libwbclient/wbc_pam.o
LIBWBCLIENT_OBJ0 = ../nsswitch/libwbclient/wbclient.o \
../nsswitch/libwbclient/wbc_util.o \
../nsswitch/libwbclient/wbc_pwd.o \
../nsswitch/libwbclient/wbc_idmap.o \
../nsswitch/libwbclient/wbc_sid.o \
../nsswitch/libwbclient/wbc_guid.o \
../nsswitch/libwbclient/wbc_pam.o
LIBWBCLIENT_OBJ = $(LIBWBCLIENT_OBJ0) \
$(WBCOMMON_OBJ) \
@LIBTALLOC_STATIC@ $(LIBREPLACE_OBJ)
@ -1784,7 +1784,7 @@ LIBWBCLIENT_SHARED_TARGET_SONAME=$(LIBWBCLIENT_SHARED_TARGET).$(LIBWBCLIENT_SOVE
LIBWBCLIENT_STATIC_TARGET=@LIBWBCLIENT_STATIC_TARGET@
LIBWBCLIENT=@LIBWBCLIENT_STATIC@ @LIBWBCLIENT_SHARED@
LIBWBCLIENT_SYMS=$(srcdir)/exports/libwbclient.@SYMSEXT@
LIBWBCLIENT_HEADERS=$(srcdir)/nsswitch/libwbclient/wbclient.h
LIBWBCLIENT_HEADERS=$(srcdir)/../nsswitch/libwbclient/wbclient.h
$(LIBWBCLIENT_SYMS): $(LIBWBCLIENT_HEADERS)
@$(MKSYMS_SH) $(AWK) $@ $(LIBWBCLIENT_HEADERS)
@ -2776,7 +2776,7 @@ etags::
etags --append `find $(srcdir)/../source4/ldap_server -name "*.[ch]"`
etags --append `find $(srcdir)/../source4/smb_server -name "*.[ch]"`
etags --append `find $(srcdir)/../source4/include -name "*.[ch]"`
etags --append `find $(srcdir)/../source4/nsswitch -name "*.[ch]"`
etags --append `find $(srcdir)/../nsswitch -name "*.[ch]"`
etags --append `find $(srcdir)/../source4/cldap_server -name "*.[ch]"`
etags --append `find $(srcdir)/../source4/utils -name "*.[ch]"`
etags --append `find $(srcdir)/../source4/librpc -name "*.[ch]"`

@ -5699,8 +5699,8 @@ HAVE_WINBIND=yes
# Define the winbind shared library name and any specific linker flags
# it needs to be built with.
WINBIND_NSS="nsswitch/libnss_winbind.$SHLIBEXT"
WINBIND_WINS_NSS="nsswitch/libnss_wins.$SHLIBEXT"
WINBIND_NSS="../nsswitch/libnss_winbind.$SHLIBEXT"
WINBIND_WINS_NSS="../nsswitch/libnss_wins.$SHLIBEXT"
WINBIND_NSS_LDSHFLAGS=$LDSHFLAGS
NSSSONAMEVERSIONSUFFIX=""
WINBIND_NSS_PTHREAD=""
@ -5708,16 +5708,16 @@ WINBIND_NSS_PTHREAD=""
case "$host_os" in
*linux*)
NSSSONAMEVERSIONSUFFIX=".2"
WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_linux.o"
WINBIND_NSS_EXTRA_OBJS="../nsswitch/winbind_nss_linux.o"
;;
*freebsd[[5-9]]*)
# FreeBSD winbind client is implemented as a wrapper around
# the Linux version.
NSSSONAMEVERSIONSUFFIX=".1"
WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_freebsd.o \
nsswitch/winbind_nss_linux.o"
WINBIND_NSS="nsswitch/nss_winbind.$SHLIBEXT"
WINBIND_WINS_NSS="nsswitch/nss_wins.$SHLIBEXT"
WINBIND_NSS_EXTRA_OBJS="../nsswitch/winbind_nss_freebsd.o \
../nsswitch/winbind_nss_linux.o"
WINBIND_NSS="../nsswitch/nss_winbind.$SHLIBEXT"
WINBIND_WINS_NSS="../nsswitch/nss_wins.$SHLIBEXT"
;;
*netbsd*[[3-9]]*)
@ -5727,10 +5727,10 @@ case "$host_os" in
#
if test x"$ac_cv_func_getpwent_r" = x"yes"; then
WINBIND_NSS_EXTRA_OBJS="\
nsswitch/winbind_nss_netbsd.o \
nsswitch/winbind_nss_linux.o"
WINBIND_NSS="nsswitch/nss_winbind.$SHLIBEXT"
WINBIND_WINS_NSS="nsswitch/nss_wins.$SHLIBEXT"
../nsswitch/winbind_nss_netbsd.o \
../nsswitch/winbind_nss_linux.o"
WINBIND_NSS="../nsswitch/nss_winbind.$SHLIBEXT"
WINBIND_WINS_NSS="../nsswitch/nss_wins.$SHLIBEXT"
else
HAVE_WINBIND=no
winbind_no_reason=", getpwent_r is missing on $host_os so winbind is unsupported"
@ -5738,28 +5738,28 @@ case "$host_os" in
;;
*irix*)
# IRIX has differently named shared libraries
WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_irix.o"
WINBIND_NSS="nsswitch/libns_winbind.$SHLIBEXT"
WINBIND_WINS_NSS="nsswitch/libns_wins.$SHLIBEXT"
WINBIND_NSS_EXTRA_OBJS="../nsswitch/winbind_nss_irix.o"
WINBIND_NSS="../nsswitch/libns_winbind.$SHLIBEXT"
WINBIND_WINS_NSS="../nsswitch/libns_wins.$SHLIBEXT"
;;
*solaris*)
# Solaris winbind client is implemented as a wrapper around
# the Linux version.
NSSSONAMEVERSIONSUFFIX=".1"
WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o \
nsswitch/winbind_nss_linux.o"
WINBIND_NSS_EXTRA_OBJS="../nsswitch/winbind_nss_solaris.o \
../nsswitch/winbind_nss_linux.o"
WINBIND_NSS_EXTRA_LIBS="${LIBREPLACE_NETWORK_LIBS}"
PAM_WINBIND_EXTRA_LIBS="${LIBREPLACE_NETWORK_LIBS}"
;;
*hpux11*)
WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o"
WINBIND_NSS_EXTRA_OBJS="../nsswitch/winbind_nss_solaris.o"
;;
*aix*)
# AIX has even differently named shared libraries. No
# WINS support has been implemented yet.
WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_aix.o"
WINBIND_NSS_EXTRA_OBJS="../nsswitch/winbind_nss_aix.o"
WINBIND_NSS_LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-ewb_aix_init"
WINBIND_NSS="nsswitch/WINBIND"
WINBIND_NSS="../nsswitch/WINBIND"
WINBIND_WINS_NSS=""
;;
*)

@ -368,13 +368,14 @@ static void print_socket_options(int s)
* leak in SCO Openserver 5.0 */
/* reported on samba-technical --jerry */
if ( DEBUGLEVEL >= 5 ) {
DEBUG(5,("Socket options:\n"));
for (; p->name != NULL; p++) {
if (getsockopt(s, p->level, p->option,
(void *)&value, &vlen) == -1) {
DEBUG(5,("Could not test socket option %s.\n",
DEBUGADD(5,("\tCould not test socket option %s.\n",
p->name));
} else {
DEBUG(5,("socket option %s = %d\n",
DEBUGADD(5,("\t%s = %d\n",
p->name,value));
}
}

File diff suppressed because it is too large Load Diff

@ -157,9 +157,6 @@ typedef struct
#define YYLEX_PARAM parm
#define YYPARSE_PARAM parm
static int yyerror ();
static int yylex ();
%}
/* We want a reentrant parser. */
@ -174,6 +171,13 @@ static int yylex ();
textint textintval;
}
%{
static int yyerror(const char *);
static int yylex(YYSTYPE *, parser_control *);
%}
%token tAGO tDST
%token <intval> tDAY tDAY_UNIT tDAYZONE tHOUR_UNIT tLOCAL_ZONE tMERIDIAN
@ -449,13 +453,13 @@ o_merid:
#include "modules/getdate.h"
#ifndef gmtime
struct tm *gmtime ();
struct tm *gmtime (const time_t *);
#endif
#ifndef localtime
struct tm *localtime ();
struct tm *localtime (const time_t *);
#endif
#ifndef mktime
time_t mktime ();
time_t mktime (struct tm *);
#endif
static table const meridian_table[] =
@ -863,7 +867,7 @@ yylex (YYSTYPE *lvalp, parser_control *pc)
/* Do nothing if the parser reports an error. */
static int
yyerror (char *s ATTRIBUTE_UNUSED)
yyerror (const char *s ATTRIBUTE_UNUSED)
{
return 0;
}

@ -1,76 +0,0 @@
/*
Unix SMB/CIFS implementation.
A common place to work out how to define NSS_STATUS on various
platforms.
Copyright (C) Tim Potter 2000
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _NSSWITCH_NSS_H
#define _NSSWITCH_NSS_H
#ifdef HAVE_NSS_COMMON_H
/*
* Sun Solaris
*/
#include "nsswitch/winbind_nss_solaris.h"
#elif HAVE_NSS_H
/*
* Linux (glibc)
*/
#include "nsswitch/winbind_nss_linux.h"
#elif HAVE_NS_API_H
/*
* SGI IRIX
*/
#include "nsswitch/winbind_nss_irix.h"
#elif defined(HPUX) && defined(HAVE_NSSWITCH_H)
/* HP-UX 11 */
#include "nsswitch/winbind_nss_hpux.h"
#elif defined(__NetBSD__) && defined(HAVE_GETPWENT_R)
/*
* NetBSD 3 and newer
*/
#include "nsswitch/winbind_nss_netbsd.h"
#else /* Nothing's defined. Neither gnu nor netbsd nor sun nor hp */
typedef enum
{
NSS_STATUS_SUCCESS=0,
NSS_STATUS_NOTFOUND=1,
NSS_STATUS_UNAVAIL=2,
NSS_STATUS_TRYAGAIN=3
} NSS_STATUS;
#endif
#endif /* _NSSWITCH_NSS_H */

@ -1,42 +0,0 @@
/*
Unix SMB/CIFS implementation.
Winbind daemon for ntdom nss module
Copyright (C) Tim Potter 2000
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _WINBIND_NSS_IRIX_H
#define _WINBIND_NSS_IRIX_H
/* following required to prevent warnings of double definition
* of datum from ns_api.h
*/
#ifdef DATUM
#define _DATUM_DEFINED
#endif
#include <ns_api.h>
typedef enum
{
NSS_STATUS_SUCCESS=NS_SUCCESS,
NSS_STATUS_NOTFOUND=NS_NOTFOUND,
NSS_STATUS_UNAVAIL=NS_UNAVAIL,
NSS_STATUS_TRYAGAIN=NS_TRYAGAIN
} NSS_STATUS;
#endif /* _WINBIND_NSS_IRIX_H */

@ -152,7 +152,7 @@ bool smb_io_dom_sid(const char *desc, DOM_SID *sid, prs_struct *ps, int depth)
if(!prs_uint8 ("sid_rev_num", ps, depth, &sid->sid_rev_num))
return False;
if(!prs_uint8 ("num_auths ", ps, depth, &sid->num_auths))
if(!prs_uint8 ("num_auths ", ps, depth, (uint8 *)&sid->num_auths))
return False;
for (i = 0; i < 6; i++)

@ -629,7 +629,7 @@ bool prs_uint8(const char *name, prs_struct *ps, int depth, uint8 *data8)
else
SCVAL(q,0,*data8);
DEBUG(5,("%s%04x %s: %02x\n", tab_depth(5,depth), ps->data_offset, name, *data8));
DEBUGADD(5,("%s%04x %s: %02x\n", tab_depth(5,depth), ps->data_offset, name, *data8));
ps->data_offset += 1;
@ -694,7 +694,7 @@ bool prs_uint16(const char *name, prs_struct *ps, int depth, uint16 *data16)
SSVAL(q,0,*data16);
}
DEBUG(5,("%s%04x %s: %04x\n", tab_depth(5,depth), ps->data_offset, name, *data16));
DEBUGADD(5,("%s%04x %s: %04x\n", tab_depth(5,depth), ps->data_offset, name, *data16));
ps->data_offset += sizeof(uint16);
@ -723,7 +723,7 @@ bool prs_uint32(const char *name, prs_struct *ps, int depth, uint32 *data32)
SIVAL(q,0,*data32);
}
DEBUG(5,("%s%04x %s: %08x\n", tab_depth(5,depth), ps->data_offset, name, *data32));
DEBUGADD(5,("%s%04x %s: %08x\n", tab_depth(5,depth), ps->data_offset, name, *data32));
ps->data_offset += sizeof(uint32);
@ -752,7 +752,7 @@ bool prs_int32(const char *name, prs_struct *ps, int depth, int32 *data32)
SIVALS(q,0,*data32);
}
DEBUG(5,("%s%04x %s: %08x\n", tab_depth(5,depth), ps->data_offset, name, *data32));
DEBUGADD(5,("%s%04x %s: %08x\n", tab_depth(5,depth), ps->data_offset, name, *data32));
ps->data_offset += sizeof(int32);
@ -781,7 +781,7 @@ bool prs_ntstatus(const char *name, prs_struct *ps, int depth, NTSTATUS *status)
SIVAL(q,0,NT_STATUS_V(*status));
}
DEBUG(5,("%s%04x %s: %s\n", tab_depth(5,depth), ps->data_offset, name,
DEBUGADD(5,("%s%04x %s: %s\n", tab_depth(5,depth), ps->data_offset, name,
nt_errstr(*status)));
ps->data_offset += sizeof(uint32);
@ -811,7 +811,7 @@ bool prs_dcerpc_status(const char *name, prs_struct *ps, int depth, NTSTATUS *st
SIVAL(q,0,NT_STATUS_V(*status));
}
DEBUG(5,("%s%04x %s: %s\n", tab_depth(5,depth), ps->data_offset, name,
DEBUGADD(5,("%s%04x %s: %s\n", tab_depth(5,depth), ps->data_offset, name,
dcerpc_errstr(debug_ctx(), NT_STATUS_V(*status))));
ps->data_offset += sizeof(uint32);
@ -842,7 +842,7 @@ bool prs_werror(const char *name, prs_struct *ps, int depth, WERROR *status)
SIVAL(q,0,W_ERROR_V(*status));
}
DEBUG(5,("%s%04x %s: %s\n", tab_depth(5,depth), ps->data_offset, name,
DEBUGADD(5,("%s%04x %s: %s\n", tab_depth(5,depth), ps->data_offset, name,
win_errstr(*status)));
ps->data_offset += sizeof(uint32);
@ -870,14 +870,14 @@ bool prs_uint8s(bool charmode, const char *name, prs_struct *ps, int depth, uint
SCVAL(q, i, data8s[i]);
}
DEBUG(5,("%s%04x %s: ", tab_depth(5,depth), ps->data_offset ,name));
DEBUGADD(5,("%s%04x %s: ", tab_depth(5,depth), ps->data_offset ,name));
if (charmode)
print_asc(5, (unsigned char*)data8s, len);
else {
for (i = 0; i < len; i++)
DEBUG(5,("%02x ", data8s[i]));
DEBUGADD(5,("%02x ", data8s[i]));
}
DEBUG(5,("\n"));
DEBUGADD(5,("\n"));
ps->data_offset += len;
@ -913,14 +913,14 @@ bool prs_uint16s(bool charmode, const char *name, prs_struct *ps, int depth, uin
}
}
DEBUG(5,("%s%04x %s: ", tab_depth(5,depth), ps->data_offset, name));
DEBUGADD(5,("%s%04x %s: ", tab_depth(5,depth), ps->data_offset, name));
if (charmode)
print_asc(5, (unsigned char*)data16s, 2*len);
else {
for (i = 0; i < len; i++)
DEBUG(5,("%04x ", data16s[i]));
DEBUGADD(5,("%04x ", data16s[i]));
}
DEBUG(5,("\n"));
DEBUGADD(5,("\n"));
ps->data_offset += (len * sizeof(uint16));
@ -955,14 +955,14 @@ static void dbg_rw_punival(bool charmode, const char *name, int depth, prs_struc
}
}
DEBUG(5,("%s%04x %s: ", tab_depth(5,depth), ps->data_offset, name));
DEBUGADD(5,("%s%04x %s: ", tab_depth(5,depth), ps->data_offset, name));
if (charmode)
print_asc(5, (unsigned char*)out_buf, 2*len);
else {
for (i = 0; i < len; i++)
DEBUG(5,("%04x ", out_buf[i]));
DEBUGADD(5,("%04x ", out_buf[i]));
}
DEBUG(5,("\n"));
DEBUGADD(5,("\n"));
}
/******************************************************************
@ -1010,14 +1010,14 @@ bool prs_uint32s(bool charmode, const char *name, prs_struct *ps, int depth, uin
}
}
DEBUG(5,("%s%04x %s: ", tab_depth(5,depth), ps->data_offset, name));
DEBUGADD(5,("%s%04x %s: ", tab_depth(5,depth), ps->data_offset, name));
if (charmode)
print_asc(5, (unsigned char*)data32s, 4*len);
else {
for (i = 0; i < len; i++)
DEBUG(5,("%08x ", data32s[i]));
DEBUGADD(5,("%08x ", data32s[i]));
}
DEBUG(5,("\n"));
DEBUGADD(5,("\n"));
ps->data_offset += (len * sizeof(uint32));
@ -1078,7 +1078,7 @@ bool prs_string2(bool charmode, const char *name, prs_struct *ps, int depth, STR
} else {
str->buffer = NULL;
/* Return early to ensure Coverity isn't confused. */
DEBUG(5,("%s%04x %s: \n", tab_depth(5,depth), ps->data_offset, name));
DEBUGADD(5,("%s%04x %s: \n", tab_depth(5,depth), ps->data_offset, name));
return True;
}
}
@ -1091,14 +1091,14 @@ bool prs_string2(bool charmode, const char *name, prs_struct *ps, int depth, STR
SCVAL(q, i, str->buffer[i]);
}
DEBUG(5,("%s%04x %s: ", tab_depth(5,depth), ps->data_offset, name));
DEBUGADD(5,("%s%04x %s: ", tab_depth(5,depth), ps->data_offset, name));
if (charmode)
print_asc(5, (unsigned char*)str->buffer, str->str_str_len);
else {
for (i = 0; i < str->str_str_len; i++)
DEBUG(5,("%02x ", str->buffer[i]));
}
DEBUG(5,("\n"));
DEBUGADD(5,("\n"));
ps->data_offset += str->str_str_len;
@ -1227,9 +1227,9 @@ bool prs_unistr(const char *name, prs_struct *ps, int depth, UNISTR *str)
len++;
DEBUG(5,("%s%04x %s: ", tab_depth(5,depth), ps->data_offset, name));
DEBUGADD(5,("%s%04x %s: ", tab_depth(5,depth), ps->data_offset, name));
print_asc(5, (unsigned char*)start, 2*len);
DEBUG(5, ("\n"));
DEBUGADD(5, ("\n"));
}
else { /* unmarshalling */
@ -1284,9 +1284,9 @@ bool prs_unistr(const char *name, prs_struct *ps, int depth, UNISTR *str)
str->buffer[len++] = '\0';
}
DEBUG(5,("%s%04x %s: ", tab_depth(5,depth), ps->data_offset, name));
DEBUGADD(5,("%s%04x %s: ", tab_depth(5,depth), ps->data_offset, name));
print_asc(5, (unsigned char*)str->buffer, 2*len);
DEBUG(5, ("\n"));
DEBUGADD(5, ("\n"));
}
/* set the offset in the prs_struct; 'len' points to the

@ -35,7 +35,7 @@ m4_include(../lib/util/time.m4)
m4_include(../lib/popt/samba.m4)
m4_include(../lib/util/charset/config.m4)
m4_include(lib/socket/config.m4)
m4_include(nsswitch/nsstest.m4)
m4_include(../nsswitch/nsstest.m4)
m4_include(../pidl/config.m4)
AC_ZLIB([
SMB_EXT_LIB(ZLIB, [${ZLIB_LIBS}])
@ -119,7 +119,7 @@ m4_include(ntvfs/unixuid/config.m4)
m4_include(auth/config.m4)
m4_include(kdc/config.m4)
m4_include(ntvfs/sysdep/config.m4)
m4_include(nsswitch/config.m4)
m4_include(../nsswitch/config.m4)
dnl Samba 4 files
AC_SUBST(LD)

@ -70,7 +70,7 @@ smbdsrcdir := $(samba4srcdir)/smbd
clustersrcdir := $(samba4srcdir)/cluster
libnetsrcdir := $(samba4srcdir)/libnet
authsrcdir := $(samba4srcdir)/auth
nsswitchsrcdir := $(samba4srcdir)/nsswitch
nsswitchsrcdir := $(samba4srcdir)/../nsswitch
libsrcdir := $(samba4srcdir)/lib
libsocketsrcdir := $(samba4srcdir)/lib/socket
libcharsetsrcdir := $(samba4srcdir)/../lib/util/charset
@ -161,7 +161,7 @@ modules:: $(PLUGINS)
pythonmods:: $(PYTHON_PYS) $(PYTHON_SO)
all:: bin/samba4 bin/regpatch4 bin/regdiff4 bin/regshell4 bin/regtree4 bin/smbclient4 pythonmods setup
all:: bin/samba4 bin/regpatch4 bin/regdiff4 bin/regshell4 bin/regtree4 bin/smbclient4 bin/wbinfo4 pythonmods setup
torture:: bin/smbtorture4
everything:: $(patsubst %,%4,$(BINARIES))
setup:

@ -28,16 +28,15 @@ int net_status_usage(struct net_context *c, int argc, const char **argv)
return -1;
}
static int show_session(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf,
void *state)
static int show_session(struct db_record *rec, void *private_data)
{
bool *parseable = (bool *)state;
bool *parseable = (bool *)private_data;
struct sessionid sessionid;
if (dbuf.dsize != sizeof(sessionid))
if (rec->value.dsize != sizeof(sessionid))
return 0;
memcpy(&sessionid, dbuf.dptr, sizeof(sessionid));
memcpy(&sessionid, rec->value.dptr, sizeof(sessionid));
if (!process_exists(sessionid.pid)) {
return 0;
@ -60,7 +59,7 @@ static int show_session(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf,
static int net_status_sessions(struct net_context *c, int argc, const char **argv)
{
TDB_CONTEXT *tdb;
struct db_context *db;
bool parseable;
if (c->display_usage) {
@ -87,16 +86,15 @@ static int net_status_sessions(struct net_context *c, int argc, const char **arg
"------------------------\n");
}
tdb = tdb_open_log(lock_path("sessionid.tdb"), 0,
TDB_DEFAULT, O_RDONLY, 0);
if (tdb == NULL) {
db = db_open(NULL, lock_path("sessionid.tdb"), 0,
TDB_CLEAR_IF_FIRST, O_RDONLY, 0644);
if (db == NULL) {
d_fprintf(stderr, "%s not initialised\n", lock_path("sessionid.tdb"));
return -1;
}
tdb_traverse(tdb, show_session, &parseable);
tdb_close(tdb);
db->traverse_read(db, show_session, &parseable);
TALLOC_FREE(db);
return 0;
}
@ -126,16 +124,15 @@ struct sessionids {
struct sessionid *entries;
};
static int collect_pid(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf,
void *state)
static int collect_pid(struct db_record *rec, void *private_data)
{
struct sessionids *ids = (struct sessionids *)state;
struct sessionids *ids = (struct sessionids *)private_data;
struct sessionid sessionid;
if (dbuf.dsize != sizeof(sessionid))
if (rec->value.dsize != sizeof(sessionid))
return 0;
memcpy(&sessionid, dbuf.dptr, sizeof(sessionid));
memcpy(&sessionid, rec->value.dptr, sizeof(sessionid));
if (!process_exists(sessionid.pid))
return 0;
@ -189,21 +186,20 @@ static int show_share_parseable(struct db_record *rec,
static int net_status_shares_parseable(struct net_context *c, int argc, const char **argv)
{
struct sessionids ids;
TDB_CONTEXT *tdb;
struct db_context *db;
ids.num_entries = 0;
ids.entries = NULL;
tdb = tdb_open_log(lock_path("sessionid.tdb"), 0,
TDB_DEFAULT, O_RDONLY, 0);
if (tdb == NULL) {
db = db_open(NULL, lock_path("sessionid.tdb"), 0,
TDB_CLEAR_IF_FIRST, O_RDONLY, 0644);
if (db == NULL) {
d_fprintf(stderr, "%s not initialised\n", lock_path("sessionid.tdb"));
return -1;
}
tdb_traverse(tdb, collect_pid, &ids);
tdb_close(tdb);
db->traverse_read(db, collect_pid, &ids);
TALLOC_FREE(db);
connections_forall(show_share_parseable, &ids);

@ -56,7 +56,7 @@ smbdsrcdir := smbd
clustersrcdir := cluster
libnetsrcdir := libnet
authsrcdir := auth
nsswitchsrcdir := nsswitch
nsswitchsrcdir := ../nsswitch
libsrcdir := lib
libsocketsrcdir := lib/socket
libcharsetsrcdir := ../lib/util/charset

@ -30,7 +30,7 @@ SMB_EXT_LIB(ZLIB, [${ZLIB_LIBS}])
],[
SMB_INCLUDE_MK(lib/zlib.mk)
])
m4_include(nsswitch/nsstest.m4)
m4_include(../nsswitch/nsstest.m4)
m4_include(../pidl/config.m4)
AC_CONFIG_FILES(lib/registry/registry.pc)
@ -108,7 +108,7 @@ m4_include(../lib/nss_wrapper/config.m4)
m4_include(auth/config.m4)
m4_include(kdc/config.m4)
m4_include(ntvfs/sysdep/config.m4)
m4_include(nsswitch/config.m4)
m4_include(../nsswitch/config.m4)
#################################################
# add *_CFLAGS only for the real build

@ -40,6 +40,9 @@
#define LDB_MODULE_PREFIX "modules:"
#define LDB_MODULE_PREFIX_LEN 8
static void *ldb_dso_load_symbol(struct ldb_context *ldb, const char *name,
const char *symbol);
void ldb_set_modules_dir(struct ldb_context *ldb, const char *path)
{
talloc_free(ldb->modules_dir);
@ -291,8 +294,8 @@ int ldb_register_module(const struct ldb_module_ops *ops)
return 0;
}
void *ldb_dso_load_symbol(struct ldb_context *ldb, const char *name,
const char *symbol)
static void *ldb_dso_load_symbol(struct ldb_context *ldb, const char *name,
const char *symbol)
{
char *path;
void *handle;
@ -334,6 +337,10 @@ int ldb_load_modules_list(struct ldb_context *ldb, const char **module_list, str
for (i = 0; module_list[i] != NULL; i++) {
struct ldb_module *current;
const struct ldb_module_ops *ops;
if (strcmp(module_list[i], "") == 0) {
continue;
}
ops = ldb_find_module_ops(module_list[i]);
if (ops == NULL) {

@ -259,9 +259,6 @@ const char *ldb_default_modules_dir(void);
int ldb_register_backend(const char *url_prefix, ldb_connect_fn);
void *ldb_dso_load_symbol(struct ldb_context *ldb, const char *name,
const char *symbol);
struct ldb_handle *ldb_handle_new(TALLOC_CTX *mem_ctx, struct ldb_context *ldb);
int ldb_module_send_entry(struct ldb_request *req,

@ -190,6 +190,7 @@ PyObject *ldb_val_to_py_object(struct ldb_context *ldb_ctx,
}
%apply const char * const *NULL_STR_LIST { const char * const *attrs }
%apply const char * const *NULL_STR_LIST { const char * const *options }
%apply const char * const *NULL_STR_LIST { const char * const *control_strings }
#endif
@ -711,9 +712,10 @@ typedef struct ldb_context {
%feature("docstring") connect "S.connect(url,flags=0,options=None) -> None\n" \
"Connect to a LDB URL.";
ldb_error connect(const char *url, unsigned int flags = 0,
const char *options[] = NULL);
const char *const *options = NULL);
~ldb() { talloc_free($self); }
ldb_error search_ex(TALLOC_CTX *mem_ctx,
ldb_dn *base = NULL,
enum ldb_scope scope = LDB_SCOPE_DEFAULT,

@ -1250,5 +1250,9 @@ int ltdb_reindex(struct ldb_module *module)
return LDB_ERR_OPERATIONS_ERROR;
}
if (tdb_repack(ltdb->tdb) != 0) {
return LDB_ERR_OPERATIONS_ERROR;
}
return LDB_SUCCESS;
}

@ -4822,7 +4822,7 @@ SWIGINTERN PyObject *_wrap_Ldb_connect(PyObject *SWIGUNUSEDPARM(self), PyObject
ldb *arg1 = (ldb *) 0 ;
char *arg2 = (char *) 0 ;
unsigned int arg3 = (unsigned int) 0 ;
char **arg4 = (char **) (char **)NULL ;
char **arg4 = (char **) NULL ;
void *argp1 = 0 ;
int res1 = 0 ;
int res2 ;
@ -4830,8 +4830,6 @@ SWIGINTERN PyObject *_wrap_Ldb_connect(PyObject *SWIGUNUSEDPARM(self), PyObject
int alloc2 = 0 ;
unsigned int val3 ;
int ecode3 = 0 ;
void *argp4 = 0 ;
int res4 = 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
@ -4860,25 +4858,33 @@ SWIGINTERN PyObject *_wrap_Ldb_connect(PyObject *SWIGUNUSEDPARM(self), PyObject
arg3 = (unsigned int)(val3);
}
if (obj3) {
res4 = SWIG_ConvertPtr(obj3, &argp4,SWIGTYPE_p_p_char, 0 | 0 );
if (!SWIG_IsOK(res4)) {
SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "Ldb_connect" "', argument " "4"" of type '" "char const *[]""'");
}
arg4 = (char **)(argp4);
if (obj3 == Py_None) {
arg4 = NULL;
} else if (PySequence_Check(obj3)) {
int i;
arg4 = talloc_array(NULL, char *, PySequence_Size(obj3)+1);
for(i = 0; i < PySequence_Size(obj3); i++)
arg4[i] = PyString_AsString(PySequence_GetItem(obj3, i));
arg4[i] = NULL;
} else {
SWIG_exception(SWIG_TypeError, "expected sequence");
}
}
if (arg1 == NULL)
SWIG_exception(SWIG_ValueError,
"ldb context must be non-NULL");
result = ldb_connect(arg1,(char const *)arg2,arg3,(char const *(*))arg4);
result = ldb_connect(arg1,(char const *)arg2,arg3,(char const *const *)arg4);
if (result != 0) {
PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_errstring(arg1)));
SWIG_fail;
}
resultobj = Py_None;
if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
talloc_free(arg4);
return resultobj;
fail:
if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
talloc_free(arg4);
return NULL;
}

@ -92,6 +92,11 @@ int main(int argc, const char **argv)
options = ldb_cmdline_process(ldb, argc, argv, usage);
if (ldb_transaction_start(ldb) != 0) {
printf("Failed to start transaction\n");
exit(1);
}
if (options->argc == 0) {
ret = process_file(ldb, stdin, &count);
} else {
@ -108,6 +113,11 @@ int main(int argc, const char **argv)
}
}
if (count != 0 && ldb_transaction_commit(ldb) != 0) {
printf("Failed to commit transaction\n");
exit(1);
}
talloc_free(ldb);
printf("Added %d records with %d failures\n", count, failures);

@ -112,6 +112,11 @@ static int merge_edits(struct ldb_context *ldb,
int ret = 0;
int adds=0, modifies=0, deletes=0;
if (ldb_transaction_start(ldb) != 0) {
fprintf(stderr, "Failed to start transaction\n");
return -1;
}
/* do the adds and modifies */
for (i=0;i<count2;i++) {
msg = msg_find(ldb, msgs1, count1, msgs2[i]->dn);
@ -150,6 +155,11 @@ static int merge_edits(struct ldb_context *ldb,
}
}
if (ldb_transaction_commit(ldb) != 0) {
fprintf(stderr, "Failed to commit transaction\n");
return -1;
}
printf("# %d adds %d modifies %d deletes\n", adds, modifies, deletes);
return ret;

@ -91,6 +91,11 @@ int main(int argc, const char **argv)
ldb = ldb_init(NULL, NULL);
if (ldb_transaction_start(ldb) != 0) {
printf("Failed to start transaction\n");
exit(1);
}
options = ldb_cmdline_process(ldb, argc, argv, usage);
if (options->argc == 0) {
@ -108,6 +113,11 @@ int main(int argc, const char **argv)
}
}
if (count != 0 && ldb_transaction_commit(ldb) != 0) {
printf("Failed to commit transaction\n");
exit(1);
}
talloc_free(ldb);
printf("Modified %d records with %d failures\n", count, failures);

@ -6,7 +6,7 @@ mkinclude cluster/config.mk
mkinclude smbd/process_model.mk
mkinclude libnet/config.mk
mkinclude auth/config.mk
mkinclude nsswitch/config.mk
mkinclude ../nsswitch/config.mk
mkinclude lib/samba3/config.mk
mkinclude lib/socket/config.mk
mkinclude ../lib/util/charset/config.mk

@ -1,698 +0,0 @@
/*
Unix SMB/CIFS implementation.
winbind client common code
Copyright (C) Tim Potter 2000
Copyright (C) Andrew Tridgell 2000
Copyright (C) Andrew Bartlett 2002
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "winbind_client.h"
/* Global variables. These are effectively the client state information */
int winbindd_fd = -1; /* fd for winbindd socket */
static int is_privileged = 0;
/* Free a response structure */
void winbindd_free_response(struct winbindd_response *response)
{
/* Free any allocated extra_data */
if (response)
SAFE_FREE(response->extra_data.data);
}
/* Initialise a request structure */
void winbindd_init_request(struct winbindd_request *request, int request_type)
{
request->length = sizeof(struct winbindd_request);
request->cmd = (enum winbindd_cmd)request_type;
request->pid = getpid();
}
/* Initialise a response structure */
static void init_response(struct winbindd_response *response)
{
/* Initialise return value */
response->result = WINBINDD_ERROR;
}
/* Close established socket */
void winbind_close_sock(void)
{
if (winbindd_fd != -1) {
close(winbindd_fd);
winbindd_fd = -1;
}
}
#define CONNECT_TIMEOUT 30
/* Make sure socket handle isn't stdin, stdout or stderr */
#define RECURSION_LIMIT 3
static int make_nonstd_fd_internals(int fd, int limit /* Recursion limiter */)
{
int new_fd;
if (fd >= 0 && fd <= 2) {
#ifdef F_DUPFD
if ((new_fd = fcntl(fd, F_DUPFD, 3)) == -1) {
return -1;
}
/* Paranoia */
if (new_fd < 3) {
close(new_fd);
return -1;
}
close(fd);
return new_fd;
#else
if (limit <= 0)
return -1;
new_fd = dup(fd);
if (new_fd == -1)
return -1;
/* use the program stack to hold our list of FDs to close */
new_fd = make_nonstd_fd_internals(new_fd, limit - 1);
close(fd);
return new_fd;
#endif
}
return fd;
}
/****************************************************************************
Set a fd into blocking/nonblocking mode. Uses POSIX O_NONBLOCK if available,
else
if SYSV use O_NDELAY
if BSD use FNDELAY
Set close on exec also.
****************************************************************************/
static int make_safe_fd(int fd)
{
int result, flags;
int new_fd = make_nonstd_fd_internals(fd, RECURSION_LIMIT);
if (new_fd == -1) {
close(fd);
return -1;
}
/* Socket should be nonblocking. */
#ifdef O_NONBLOCK
#define FLAG_TO_SET O_NONBLOCK
#else
#ifdef SYSV
#define FLAG_TO_SET O_NDELAY
#else /* BSD */
#define FLAG_TO_SET FNDELAY
#endif
#endif
if ((flags = fcntl(new_fd, F_GETFL)) == -1) {
close(new_fd);
return -1;
}
flags |= FLAG_TO_SET;
if (fcntl(new_fd, F_SETFL, flags) == -1) {
close(new_fd);
return -1;
}
#undef FLAG_TO_SET
/* Socket should be closed on exec() */
#ifdef FD_CLOEXEC
result = flags = fcntl(new_fd, F_GETFD, 0);
if (flags >= 0) {
flags |= FD_CLOEXEC;
result = fcntl( new_fd, F_SETFD, flags );
}
if (result < 0) {
close(new_fd);
return -1;
}
#endif
return new_fd;
}
/* Connect to winbindd socket */
static int winbind_named_pipe_sock(const char *dir)
{
struct sockaddr_un sunaddr;
struct stat st;
char *path;
int fd;
int wait_time;
int slept;
/* Check permissions on unix socket directory */
if (lstat(dir, &st) == -1) {
return -1;
}
if (!S_ISDIR(st.st_mode) ||
(st.st_uid != 0 && st.st_uid != geteuid())) {
return -1;
}
/* Connect to socket */
asprintf(&path, "%s/%s", dir, WINBINDD_SOCKET_NAME);
ZERO_STRUCT(sunaddr);
sunaddr.sun_family = AF_UNIX;
strncpy(sunaddr.sun_path, path, sizeof(sunaddr.sun_path) - 1);
SAFE_FREE(path);
/* If socket file doesn't exist, don't bother trying to connect
with retry. This is an attempt to make the system usable when
the winbindd daemon is not running. */
if (lstat(sunaddr.sun_path, &st) == -1) {
return -1;
}
/* Check permissions on unix socket file */
if (!S_ISSOCK(st.st_mode) ||
(st.st_uid != 0 && st.st_uid != geteuid())) {
return -1;
}
/* Connect to socket */
if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
return -1;
}
/* Set socket non-blocking and close on exec. */
if ((fd = make_safe_fd( fd)) == -1) {
return fd;
}
for (wait_time = 0; connect(fd, (struct sockaddr *)&sunaddr, sizeof(sunaddr)) == -1;
wait_time += slept) {
struct timeval tv;
fd_set w_fds;
int ret;
int connect_errno = 0;
socklen_t errnosize;
if (wait_time >= CONNECT_TIMEOUT)
goto error_out;
switch (errno) {
case EINPROGRESS:
FD_ZERO(&w_fds);
FD_SET(fd, &w_fds);
tv.tv_sec = CONNECT_TIMEOUT - wait_time;
tv.tv_usec = 0;
ret = select(fd + 1, NULL, &w_fds, NULL, &tv);
if (ret > 0) {
errnosize = sizeof(connect_errno);
ret = getsockopt(fd, SOL_SOCKET,
SO_ERROR, &connect_errno, &errnosize);
if (ret >= 0 && connect_errno == 0) {
/* Connect succeed */
goto out;
}
}
slept = CONNECT_TIMEOUT;
break;
case EAGAIN:
slept = rand() % 3 + 1;
sleep(slept);
break;
default:
goto error_out;
}
}
out:
return fd;
error_out:
close(fd);
return -1;
}
static const char *winbindd_socket_dir(void)
{
#ifdef SOCKET_WRAPPER
const char *env_dir;
env_dir = getenv(WINBINDD_SOCKET_DIR_ENVVAR);
if (env_dir) {
return env_dir;
}
#endif
return WINBINDD_SOCKET_DIR;
}
/* Connect to winbindd socket */
static int winbind_open_pipe_sock(int recursing, int need_priv)
{
#ifdef HAVE_UNIXSOCKET
static pid_t our_pid;
struct winbindd_request request;
struct winbindd_response response;
ZERO_STRUCT(request);
ZERO_STRUCT(response);
if (our_pid != getpid()) {
winbind_close_sock();
our_pid = getpid();
}
if ((need_priv != 0) && (is_privileged == 0)) {
winbind_close_sock();
}
if (winbindd_fd != -1) {
return winbindd_fd;
}
if (recursing) {
return -1;
}
if ((winbindd_fd = winbind_named_pipe_sock(winbindd_socket_dir())) == -1) {
return -1;
}
is_privileged = 0;
/* version-check the socket */
request.wb_flags = WBFLAG_RECURSE;
if ((winbindd_request_response(WINBINDD_INTERFACE_VERSION, &request, &response) != NSS_STATUS_SUCCESS) || (response.data.interface_version != WINBIND_INTERFACE_VERSION)) {
winbind_close_sock();
return -1;
}
/* try and get priv pipe */
request.wb_flags = WBFLAG_RECURSE;
if (winbindd_request_response(WINBINDD_PRIV_PIPE_DIR, &request, &response) == NSS_STATUS_SUCCESS) {
int fd;
if ((fd = winbind_named_pipe_sock((char *)response.extra_data.data)) != -1) {
close(winbindd_fd);
winbindd_fd = fd;
is_privileged = 1;
}
}
if ((need_priv != 0) && (is_privileged == 0)) {
return -1;
}
SAFE_FREE(response.extra_data.data);
return winbindd_fd;
#else
return -1;
#endif /* HAVE_UNIXSOCKET */
}
/* Write data to winbindd socket */
int winbind_write_sock(void *buffer, int count, int recursing, int need_priv)
{
int result, nwritten;
/* Open connection to winbind daemon */
restart:
if (winbind_open_pipe_sock(recursing, need_priv) == -1) {
return -1;
}
/* Write data to socket */
nwritten = 0;
while(nwritten < count) {
struct timeval tv;
fd_set r_fds;
/* Catch pipe close on other end by checking if a read()
call would not block by calling select(). */
FD_ZERO(&r_fds);
FD_SET(winbindd_fd, &r_fds);
ZERO_STRUCT(tv);
if (select(winbindd_fd + 1, &r_fds, NULL, NULL, &tv) == -1) {
winbind_close_sock();
return -1; /* Select error */
}
/* Write should be OK if fd not available for reading */
if (!FD_ISSET(winbindd_fd, &r_fds)) {
/* Do the write */
result = write(winbindd_fd,
(char *)buffer + nwritten,
count - nwritten);
if ((result == -1) || (result == 0)) {
/* Write failed */
winbind_close_sock();
return -1;
}
nwritten += result;
} else {
/* Pipe has closed on remote end */
winbind_close_sock();
goto restart;
}
}
return nwritten;
}
/* Read data from winbindd socket */
int winbind_read_sock(void *buffer, int count)
{
int nread = 0;
int total_time = 0, selret;
if (winbindd_fd == -1) {
return -1;
}
/* Read data from socket */
while(nread < count) {
struct timeval tv;
fd_set r_fds;
/* Catch pipe close on other end by checking if a read()
call would not block by calling select(). */
FD_ZERO(&r_fds);
FD_SET(winbindd_fd, &r_fds);
ZERO_STRUCT(tv);
/* Wait for 5 seconds for a reply. May need to parameterise this... */
tv.tv_sec = 5;
if ((selret = select(winbindd_fd + 1, &r_fds, NULL, NULL, &tv)) == -1) {
winbind_close_sock();
return -1; /* Select error */
}
if (selret == 0) {
/* Not ready for read yet... */
if (total_time >= 30) {
/* Timeout */
winbind_close_sock();
return -1;
}
total_time += 5;
continue;
}
if (FD_ISSET(winbindd_fd, &r_fds)) {
/* Do the Read */
int result = read(winbindd_fd, (char *)buffer + nread,
count - nread);
if ((result == -1) || (result == 0)) {
/* Read failed. I think the only useful thing we
can do here is just return -1 and fail since the
transaction has failed half way through. */
winbind_close_sock();
return -1;
}
nread += result;
}
}
return nread;
}
/* Read reply */
int winbindd_read_reply(struct winbindd_response *response)
{
int result1, result2 = 0;
if (!response) {
return -1;
}
/* Read fixed length response */
result1 = winbind_read_sock(response,
sizeof(struct winbindd_response));
if (result1 == -1) {
return -1;
}
/* We actually send the pointer value of the extra_data field from
the server. This has no meaning in the client's address space
so we clear it out. */
response->extra_data.data = NULL;
/* Read variable length response */
if (response->length > sizeof(struct winbindd_response)) {
int extra_data_len = response->length -
sizeof(struct winbindd_response);
/* Mallocate memory for extra data */
if (!(response->extra_data.data = malloc(extra_data_len))) {
return -1;
}
result2 = winbind_read_sock(response->extra_data.data,
extra_data_len);
if (result2 == -1) {
winbindd_free_response(response);
return -1;
}
}
/* Return total amount of data read */
return result1 + result2;
}
bool winbind_env_set(void)
{
char *env;
if ((env=getenv(WINBINDD_DONT_ENV)) != NULL) {
if(strcmp(env, "1") == 0) {
return true;
}
}
return false;
}
/*
* send simple types of requests
*/
NSS_STATUS winbindd_send_request(int req_type, int need_priv,
struct winbindd_request *request)
{
struct winbindd_request lrequest;
/* Check for our tricky environment variable */
if (winbind_env_set()) {
return NSS_STATUS_NOTFOUND;
}
if (!request) {
ZERO_STRUCT(lrequest);
request = &lrequest;
}
/* Fill in request and send down pipe */
winbindd_init_request(request, req_type);
if (winbind_write_sock(request, sizeof(*request),
request->wb_flags & WBFLAG_RECURSE,
need_priv) == -1) {
return NSS_STATUS_UNAVAIL;
}
if ((request->extra_len != 0) &&
(winbind_write_sock(request->extra_data.data,
request->extra_len,
request->wb_flags & WBFLAG_RECURSE,
need_priv) == -1)) {
return NSS_STATUS_UNAVAIL;
}
return NSS_STATUS_SUCCESS;
}
/*
* Get results from winbindd request
*/
NSS_STATUS winbindd_get_response(struct winbindd_response *response)
{
struct winbindd_response lresponse;
if (!response) {
ZERO_STRUCT(lresponse);
response = &lresponse;
}
init_response(response);
/* Wait for reply */
if (winbindd_read_reply(response) == -1) {
return NSS_STATUS_UNAVAIL;
}
/* Throw away extra data if client didn't request it */
if (response == &lresponse) {
winbindd_free_response(response);
}
/* Copy reply data from socket */
if (response->result != WINBINDD_OK) {
return NSS_STATUS_NOTFOUND;
}
return NSS_STATUS_SUCCESS;
}
/* Handle simple types of requests */
NSS_STATUS winbindd_request_response(int req_type,
struct winbindd_request *request,
struct winbindd_response *response)
{
NSS_STATUS status = NSS_STATUS_UNAVAIL;
int count = 0;
while ((status == NSS_STATUS_UNAVAIL) && (count < 10)) {
status = winbindd_send_request(req_type, 0, request);
if (status != NSS_STATUS_SUCCESS)
return(status);
status = winbindd_get_response(response);
count += 1;
}
return status;
}
NSS_STATUS winbindd_priv_request_response(int req_type,
struct winbindd_request *request,
struct winbindd_response *response)
{
NSS_STATUS status = NSS_STATUS_UNAVAIL;
int count = 0;
while ((status == NSS_STATUS_UNAVAIL) && (count < 10)) {
status = winbindd_send_request(req_type, 1, request);
if (status != NSS_STATUS_SUCCESS)
return(status);
status = winbindd_get_response(response);
count += 1;
}
return status;
}
/*************************************************************************
A couple of simple functions to disable winbindd lookups and re-
enable them
************************************************************************/
bool winbind_off(void)
{
return setenv(WINBINDD_DONT_ENV, "1", 1) != -1;
}
bool winbind_on(void)
{
return setenv(WINBINDD_DONT_ENV, "0", 1) != -1;
}
/*************************************************************************
************************************************************************/
const char *nss_err_str(NSS_STATUS ret)
{
switch (ret) {
case NSS_STATUS_TRYAGAIN:
return "NSS_STATUS_TRYAGAIN";
case NSS_STATUS_SUCCESS:
return "NSS_STATUS_SUCCESS";
case NSS_STATUS_NOTFOUND:
return "NSS_STATUS_NOTFOUND";
case NSS_STATUS_UNAVAIL:
return "NSS_STATUS_UNAVAIL";
#ifdef NSS_STATUS_RETURN
case NSS_STATUS_RETURN:
return "NSS_STATUS_RETURN";
#endif
default:
return "UNKNOWN RETURN CODE!!!!!!!";
}
}

@ -1,25 +0,0 @@
#include "winbind_nss_config.h"
#include "winbind_struct_protocol.h"
void winbindd_init_request(struct winbindd_request *req,int rq_type);
void winbindd_free_response(struct winbindd_response *response);
NSS_STATUS winbindd_send_request(int req_type, int need_priv,
struct winbindd_request *request);
NSS_STATUS winbindd_get_response(struct winbindd_response *response);
NSS_STATUS winbindd_request_response(int req_type,
struct winbindd_request *request,
struct winbindd_response *response);
NSS_STATUS winbindd_priv_request_response(int req_type,
struct winbindd_request *request,
struct winbindd_response *response);
int winbindd_read_reply(struct winbindd_response *response);
bool winbind_env_set(void);
bool winbind_off(void);
bool winbind_on(void);
int winbind_write_sock(void *buffer, int count, int recursing, int need_priv);
int winbind_read_sock(void *buffer, int count);
void winbind_close_sock(void);
const char *nss_err_str(NSS_STATUS ret);

@ -1,53 +0,0 @@
/*
Unix SMB/CIFS implementation.
Winbind daemon for ntdom nss module
Copyright (C) Tim Potter 2000
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _WINBIND_NSS_CONFIG_H
#define _WINBIND_NSS_CONFIG_H
/* shutup the compiler warnings due to krb5.h on 64-bit sles9 */
#ifdef SIZEOF_LONG
#undef SIZEOF_LONG
#endif
/* Include header files from data in config.h file */
#ifndef NO_CONFIG_H
#include "../replace/replace.h"
#endif
#include "system/passwd.h"
#include "system/filesys.h"
#include "system/network.h"
#include "nsswitch/winbind_nss.h"
/* Some systems (SCO) treat UNIX domain sockets as FIFOs */
#ifndef S_IFSOCK
#define S_IFSOCK S_IFIFO
#endif
#ifndef S_ISSOCK
#define S_ISSOCK(mode) ((mode & S_IFSOCK) == S_IFSOCK)
#endif
#endif

@ -1,137 +0,0 @@
/*
Unix SMB/CIFS implementation.
Donated by HP to enable Winbindd to build on HPUX 11.x.
Copyright (C) Jeremy Allison 2002.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _WINBIND_NSS_HPUX_H
#define _WINBIND_NSS_HPUX_H
#include <nsswitch.h>
#define NSS_STATUS_SUCCESS NSS_SUCCESS
#define NSS_STATUS_NOTFOUND NSS_NOTFOUND
#define NSS_STATUS_UNAVAIL NSS_UNAVAIL
#define NSS_STATUS_TRYAGAIN NSS_TRYAGAIN
#ifdef HAVE_SYNCH_H
#include <synch.h>
#endif
#ifdef HAVE_PTHREAD_H
#include <pthread.h>
#endif
typedef enum {
NSS_SUCCESS,
NSS_NOTFOUND,
NSS_UNAVAIL,
NSS_TRYAGAIN
} nss_status_t;
typedef nss_status_t NSS_STATUS;
struct nss_backend;
typedef nss_status_t (*nss_backend_op_t)(struct nss_backend *, void *args);
struct nss_backend {
nss_backend_op_t *ops;
int n_ops;
};
typedef struct nss_backend nss_backend_t;
typedef int nss_dbop_t;
#include <errno.h>
#include <netdb.h>
#include <limits.h>
#ifndef NSS_INCLUDE_UNSAFE
#define NSS_INCLUDE_UNSAFE 1 /* Build old, MT-unsafe interfaces, */
#endif /* NSS_INCLUDE_UNSAFE */
enum nss_netgr_argn {
NSS_NETGR_MACHINE,
NSS_NETGR_USER,
NSS_NETGR_DOMAIN,
NSS_NETGR_N
};
enum nss_netgr_status {
NSS_NETGR_FOUND,
NSS_NETGR_NO,
NSS_NETGR_NOMEM
};
typedef unsigned nss_innetgr_argc;
typedef char **nss_innetgr_argv;
struct nss_innetgr_1arg {
nss_innetgr_argc argc;
nss_innetgr_argv argv;
};
typedef struct {
void *result; /* "result" parameter to getXbyY_r() */
char *buffer; /* "buffer" " " */
int buflen; /* "buflen" " " */
} nss_XbyY_buf_t;
extern nss_XbyY_buf_t *_nss_XbyY_buf_alloc(int struct_size, int buffer_size);
extern void _nss_XbyY_buf_free(nss_XbyY_buf_t *);
union nss_XbyY_key {
uid_t uid;
gid_t gid;
const char *name;
int number;
struct {
long net;
int type;
} netaddr;
struct {
const char *addr;
int len;
int type;
} hostaddr;
struct {
union {
const char *name;
int port;
} serv;
const char *proto;
} serv;
void *ether;
};
typedef struct nss_XbyY_args {
nss_XbyY_buf_t buf;
int stayopen;
/*
* Support for setXXXent(stayopen)
* Used only in hosts, protocols,
* networks, rpc, and services.
*/
int (*str2ent)(const char *instr, int instr_len, void *ent, char *buffer, int buflen);
union nss_XbyY_key key;
void *returnval;
int erange;
int h_errno;
nss_status_t status;
} nss_XbyY_args_t;
#endif /* _WINBIND_NSS_HPUX_H */

File diff suppressed because it is too large Load Diff

@ -1,29 +0,0 @@
/*
Unix SMB/CIFS implementation.
Winbind daemon for ntdom nss module
Copyright (C) Tim Potter 2000
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _WINBIND_NSS_LINUX_H
#define _WINBIND_NSS_LINUX_H
#include <nss.h>
typedef enum nss_status NSS_STATUS;
#endif /* _WINBIND_NSS_LINUX_H */

@ -1,40 +0,0 @@
/*
Unix SMB/CIFS implementation.
NetBSD loadable authentication module, providing identification
routines against Samba winbind/Windows NT Domain
Copyright (C) Luke Mewburn 2004-2005
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _WINBIND_NSS_NETBSD_H
#define _WINBIND_NSS_NETBSD_H
#include <nsswitch.h>
/* dynamic nsswitch with "new" getpw* nsdispatch API available */
#if defined(NSS_MODULE_INTERFACE_VERSION) && defined(HAVE_GETPWENT_R)
typedef int NSS_STATUS;
#define NSS_STATUS_SUCCESS NS_SUCCESS
#define NSS_STATUS_NOTFOUND NS_NOTFOUND
#define NSS_STATUS_UNAVAIL NS_UNAVAIL
#define NSS_STATUS_TRYAGAIN NS_TRYAGAIN
#endif /* NSS_MODULE_INTERFACE_VERSION && HAVE_GETPWENT_R */
#endif /* _WINBIND_NSS_NETBSD_H */

@ -1,89 +0,0 @@
/*
Unix SMB/CIFS implementation.
Winbind daemon for ntdom nss module
Copyright (C) Tim Potter 2000
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _WINBIND_NSS_SOLARIS_H
#define _WINBIND_NSS_SOLARIS_H
/* Solaris has a broken nss_common header file containing C++ reserved names. */
#ifndef __cplusplus
#undef class
#undef private
#undef public
#undef protected
#undef template
#undef this
#undef new
#undef delete
#undef friend
#endif
#include <nss_common.h>
/*
TODO: we need to cleanup samba4's headers..
#ifndef __cplusplus
#define class #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
#define private #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
#define public #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
#define protected #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
#define template #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
#define this #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
#define new #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
#define delete #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
#define friend #error DONT_USE_CPLUSPLUS_RESERVED_NAMES
#endif
*/
#include <nss_dbdefs.h>
#include <nsswitch.h>
typedef nss_status_t NSS_STATUS;
#define NSS_STATUS_SUCCESS NSS_SUCCESS
#define NSS_STATUS_NOTFOUND NSS_NOTFOUND
#define NSS_STATUS_UNAVAIL NSS_UNAVAIL
#define NSS_STATUS_TRYAGAIN NSS_TRYAGAIN
/* The solaris winbind is implemented as a wrapper around the linux
version. */
NSS_STATUS _nss_winbind_setpwent(void);
NSS_STATUS _nss_winbind_endpwent(void);
NSS_STATUS _nss_winbind_getpwent_r(struct passwd* result, char* buffer,
size_t buflen, int* errnop);
NSS_STATUS _nss_winbind_getpwuid_r(uid_t, struct passwd*, char* buffer,
size_t buflen, int* errnop);
NSS_STATUS _nss_winbind_getpwnam_r(const char* name, struct passwd* result,
char* buffer, size_t buflen, int* errnop);
NSS_STATUS _nss_winbind_setgrent(void);
NSS_STATUS _nss_winbind_endgrent(void);
NSS_STATUS _nss_winbind_getgrent_r(struct group* result, char* buffer,
size_t buflen, int* errnop);
NSS_STATUS _nss_winbind_getgrnam_r(const char *name,
struct group *result, char *buffer,
size_t buflen, int *errnop);
NSS_STATUS _nss_winbind_getgrgid_r(gid_t gid,
struct group *result, char *buffer,
size_t buflen, int *errnop);
#endif /* _WINBIND_NSS_SOLARIS_H */

@ -1,507 +0,0 @@
/*
Unix SMB/CIFS implementation.
Winbind daemon for ntdom nss module
Copyright (C) Tim Potter 2000
Copyright (C) Gerald Carter 2006
You are free to use this interface definition in any way you see
fit, including without restriction, using this header in your own
products. You do not need to give any attribution.
*/
#ifndef SAFE_FREE
#define SAFE_FREE(x) do { if(x) {free(x); x=NULL;} } while(0)
#endif
#ifndef _WINBINDD_NTDOM_H
#define _WINBINDD_NTDOM_H
#define _PSTRING
#define FSTRING_LEN 256
typedef char fstring[FSTRING_LEN];
#define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1)
#define fstrcat(d,s) safe_strcat((d),(s),sizeof(fstring)-1)
#define WINBINDD_SOCKET_NAME "pipe" /* Name of PF_UNIX socket */
/* Let the build environment override the public winbindd socket location. This
* is needed for launchd support -- jpeach.
*/
#ifndef WINBINDD_SOCKET_DIR
#define WINBINDD_SOCKET_DIR "/tmp/.winbindd" /* Name of PF_UNIX dir */
#endif
/*
* when compiled with socket_wrapper support
* the location of the WINBINDD_SOCKET_DIR
* can be overwritten via an environment variable
*/
#define WINBINDD_SOCKET_DIR_ENVVAR "WINBINDD_SOCKET_DIR"
#define WINBINDD_DOMAIN_ENV "WINBINDD_DOMAIN" /* Environment variables */
#define WINBINDD_DONT_ENV "_NO_WINBINDD"
#define WINBINDD_LOCATOR_KDC_ADDRESS "WINBINDD_LOCATOR_KDC_ADDRESS"
/* Update this when you change the interface. */
#define WINBIND_INTERFACE_VERSION 19
/* Have to deal with time_t being 4 or 8 bytes due to structure alignment.
On a 64bit Linux box, we have to support a constant structure size
between /lib/libnss_winbind.so.2 and /li64/libnss_winbind.so.2.
The easiest way to do this is to always use 8byte values for time_t. */
#define SMB_TIME_T int64_t
/* Socket commands */
enum winbindd_cmd {
WINBINDD_INTERFACE_VERSION, /* Always a well known value */
/* Get users and groups */
WINBINDD_GETPWNAM,
WINBINDD_GETPWUID,
WINBINDD_GETGRNAM,
WINBINDD_GETGRGID,
WINBINDD_GETGROUPS,
/* Enumerate users and groups */
WINBINDD_SETPWENT,
WINBINDD_ENDPWENT,
WINBINDD_GETPWENT,
WINBINDD_SETGRENT,
WINBINDD_ENDGRENT,
WINBINDD_GETGRENT,
/* PAM authenticate and password change */
WINBINDD_PAM_AUTH,
WINBINDD_PAM_AUTH_CRAP,
WINBINDD_PAM_CHAUTHTOK,
WINBINDD_PAM_LOGOFF,
WINBINDD_PAM_CHNG_PSWD_AUTH_CRAP,
/* List various things */
WINBINDD_LIST_USERS, /* List w/o rid->id mapping */
WINBINDD_LIST_GROUPS, /* Ditto */
WINBINDD_LIST_TRUSTDOM,
/* SID conversion */
WINBINDD_LOOKUPSID,
WINBINDD_LOOKUPNAME,
WINBINDD_LOOKUPRIDS,
/* Lookup functions */
WINBINDD_SID_TO_UID,
WINBINDD_SID_TO_GID,
WINBINDD_SIDS_TO_XIDS,
WINBINDD_UID_TO_SID,
WINBINDD_GID_TO_SID,
WINBINDD_ALLOCATE_UID,
WINBINDD_ALLOCATE_GID,
WINBINDD_SET_MAPPING,
WINBINDD_SET_HWM,
/* Miscellaneous other stuff */
WINBINDD_DUMP_MAPS,
WINBINDD_CHECK_MACHACC, /* Check machine account pw works */
WINBINDD_PING, /* Just tell me winbind is running */
WINBINDD_INFO, /* Various bit of info. Currently just tidbits */
WINBINDD_DOMAIN_NAME, /* The domain this winbind server is a member of (lp_workgroup()) */
WINBINDD_DOMAIN_INFO, /* Most of what we know from
struct winbindd_domain */
WINBINDD_GETDCNAME, /* Issue a GetDCName Request */
WINBINDD_DSGETDCNAME, /* Issue a DsGetDCName Request */
WINBINDD_SHOW_SEQUENCE, /* display sequence numbers of domains */
/* WINS commands */
WINBINDD_WINS_BYIP,
WINBINDD_WINS_BYNAME,
/* this is like GETGRENT but gives an empty group list */
WINBINDD_GETGRLST,
WINBINDD_NETBIOS_NAME, /* The netbios name of the server */
/* find the location of our privileged pipe */
WINBINDD_PRIV_PIPE_DIR,
/* return a list of group sids for a user sid */
WINBINDD_GETUSERSIDS,
/* Various group queries */
WINBINDD_GETUSERDOMGROUPS,
/* Initialize connection in a child */
WINBINDD_INIT_CONNECTION,
/* Blocking calls that are not allowed on the main winbind pipe, only
* between parent and children */
WINBINDD_DUAL_SID2UID,
WINBINDD_DUAL_SID2GID,
WINBINDD_DUAL_SIDS2XIDS,
WINBINDD_DUAL_UID2SID,
WINBINDD_DUAL_GID2SID,
WINBINDD_DUAL_SET_MAPPING,
WINBINDD_DUAL_SET_HWM,
WINBINDD_DUAL_DUMP_MAPS,
/* Wrapper around possibly blocking unix nss calls */
WINBINDD_DUAL_UID2NAME,
WINBINDD_DUAL_NAME2UID,
WINBINDD_DUAL_GID2NAME,
WINBINDD_DUAL_NAME2GID,
WINBINDD_DUAL_USERINFO,
WINBINDD_DUAL_GETSIDALIASES,
/* Complete the challenge phase of the NTLM authentication
protocol using cached password. */
WINBINDD_CCACHE_NTLMAUTH,
WINBINDD_NUM_CMDS
};
typedef struct winbindd_pw {
fstring pw_name;
fstring pw_passwd;
uid_t pw_uid;
gid_t pw_gid;
fstring pw_gecos;
fstring pw_dir;
fstring pw_shell;
} WINBINDD_PW;
typedef struct winbindd_gr {
fstring gr_name;
fstring gr_passwd;
gid_t gr_gid;
uint32_t num_gr_mem;
uint32_t gr_mem_ofs; /* offset to group membership */
} WINBINDD_GR;
/* PAM specific request flags */
#define WBFLAG_PAM_INFO3_NDR 0x00000001
#define WBFLAG_PAM_INFO3_TEXT 0x00000002
#define WBFLAG_PAM_USER_SESSION_KEY 0x00000004
#define WBFLAG_PAM_LMKEY 0x00000008
#define WBFLAG_PAM_CONTACT_TRUSTDOM 0x00000010
#define WBFLAG_PAM_UNIX_NAME 0x00000080
#define WBFLAG_PAM_AFS_TOKEN 0x00000100
#define WBFLAG_PAM_NT_STATUS_SQUASH 0x00000200
#define WBFLAG_PAM_KRB5 0x00001000
#define WBFLAG_PAM_FALLBACK_AFTER_KRB5 0x00002000
#define WBFLAG_PAM_CACHED_LOGIN 0x00004000
#define WBFLAG_PAM_GET_PWD_POLICY 0x00008000 /* not used */
/* generic request flags */
#define WBFLAG_QUERY_ONLY 0x00000020 /* not used */
/* This is a flag that can only be sent from parent to child */
#define WBFLAG_IS_PRIVILEGED 0x00000400 /* not used */
/* Flag to say this is a winbindd internal send - don't recurse. */
#define WBFLAG_RECURSE 0x00000800
#define WINBINDD_MAX_EXTRA_DATA (128*1024)
/* Winbind request structure */
/*******************************************************************************
* This structure MUST be the same size in the 32bit and 64bit builds
* for compatibility between /lib64/libnss_winbind.so and /lib/libnss_winbind.so
*
* DO NOT CHANGE THIS STRUCTURE WITHOUT TESTING THE 32BIT NSS LIB AGAINST
* A 64BIT WINBINDD --jerry
******************************************************************************/
struct winbindd_request {
uint32_t length;
enum winbindd_cmd cmd; /* Winbindd command to execute */
enum winbindd_cmd original_cmd; /* Original Winbindd command
issued to parent process */
pid_t pid; /* pid of calling process */
uint32_t wb_flags; /* generic flags */
uint32_t flags; /* flags relevant *only* to a given request */
fstring domain_name; /* name of domain for which the request applies */
union {
fstring winsreq; /* WINS request */
fstring username; /* getpwnam */
fstring groupname; /* getgrnam */
uid_t uid; /* getpwuid, uid_to_sid */
gid_t gid; /* getgrgid, gid_to_sid */
struct {
/* We deliberatedly don't split into domain/user to
avoid having the client know what the separator
character is. */
fstring user;
fstring pass;
char require_membership_of_sid[1024];
fstring krb5_cc_type;
uid_t uid;
} auth; /* pam_winbind auth module */
struct {
uint8_t chal[8];
uint32_t logon_parameters;
fstring user;
fstring domain;
fstring lm_resp;
uint32_t lm_resp_len;
fstring nt_resp;
uint32_t nt_resp_len;
fstring workstation;
fstring require_membership_of_sid;
} auth_crap;
struct {
fstring user;
fstring oldpass;
fstring newpass;
} chauthtok; /* pam_winbind passwd module */
struct {
fstring user;
fstring domain;
uint8_t new_nt_pswd[516];
uint16_t new_nt_pswd_len;
uint8_t old_nt_hash_enc[16];
uint16_t old_nt_hash_enc_len;
uint8_t new_lm_pswd[516];
uint16_t new_lm_pswd_len;
uint8_t old_lm_hash_enc[16];
uint16_t old_lm_hash_enc_len;
} chng_pswd_auth_crap;/* pam_winbind passwd module */
struct {
fstring user;
fstring krb5ccname;
uid_t uid;
} logoff; /* pam_winbind session module */
fstring sid; /* lookupsid, sid_to_[ug]id */
struct {
fstring dom_name; /* lookupname */
fstring name;
} name;
uint32_t num_entries; /* getpwent, getgrent */
struct {
fstring username;
fstring groupname;
} acct_mgt;
struct {
bool is_primary;
fstring dcname;
} init_conn;
struct {
fstring sid;
fstring name;
} dual_sid2id;
struct {
fstring sid;
uint32_t type;
uint32_t id;
} dual_idmapset;
bool list_all_domains;
struct {
uid_t uid;
fstring user;
/* the effective uid of the client, must be the uid for 'user'.
This is checked by the main daemon, trusted by children. */
/* if the blobs are length zero, then this doesn't
produce an actual challenge response. It merely
succeeds if there are cached credentials available
that could be used. */
uint32_t initial_blob_len; /* blobs in extra_data */
uint32_t challenge_blob_len;
} ccache_ntlm_auth;
/* padding -- needed to fix alignment between 32bit and 64bit libs.
The size is the sizeof the union without the padding aligned on
an 8 byte boundary. --jerry */
char padding[1800];
} data;
union {
SMB_TIME_T padding;
char *data;
} extra_data;
uint32_t extra_len;
char null_term;
};
/* Response values */
enum winbindd_result {
WINBINDD_ERROR,
WINBINDD_PENDING,
WINBINDD_OK
};
/* Winbind response structure */
/*******************************************************************************
* This structure MUST be the same size in the 32bit and 64bit builds
* for compatibility between /lib64/libnss_winbind.so and /lib/libnss_winbind.so
*
* DO NOT CHANGE THIS STRUCTURE WITHOUT TESTING THE 32BIT NSS LIB AGAINST
* A 64BIT WINBINDD --jerry
******************************************************************************/
struct winbindd_response {
/* Header information */
uint32_t length; /* Length of response */
enum winbindd_result result; /* Result code */
/* Fixed length return data */
union {
int interface_version; /* Try to ensure this is always in the same spot... */
fstring winsresp; /* WINS response */
/* getpwnam, getpwuid */
struct winbindd_pw pw;
/* getgrnam, getgrgid */
struct winbindd_gr gr;
uint32_t num_entries; /* getpwent, getgrent */
struct winbindd_sid {
fstring sid; /* lookupname, [ug]id_to_sid */
int type;
} sid;
struct winbindd_name {
fstring dom_name; /* lookupsid */
fstring name;
int type;
} name;
uid_t uid; /* sid_to_uid */
gid_t gid; /* sid_to_gid */
struct winbindd_info {
char winbind_separator;
fstring samba_version;
} info;
fstring domain_name;
fstring netbios_name;
fstring dc_name;
struct auth_reply {
uint32_t nt_status;
fstring nt_status_string;
fstring error_string;
int pam_error;
char user_session_key[16];
char first_8_lm_hash[8];
fstring krb5ccname;
uint32_t reject_reason;
uint32_t padding;
struct policy_settings {
uint32_t min_length_password;
uint32_t password_history;
uint32_t password_properties;
uint32_t padding;
SMB_TIME_T expire;
SMB_TIME_T min_passwordage;
} policy;
struct info3_text {
SMB_TIME_T logon_time;
SMB_TIME_T logoff_time;
SMB_TIME_T kickoff_time;
SMB_TIME_T pass_last_set_time;
SMB_TIME_T pass_can_change_time;
SMB_TIME_T pass_must_change_time;
uint32_t logon_count;
uint32_t bad_pw_count;
uint32_t user_rid;
uint32_t group_rid;
uint32_t num_groups;
uint32_t user_flgs;
uint32_t acct_flags;
uint32_t num_other_sids;
fstring dom_sid;
fstring user_name;
fstring full_name;
fstring logon_script;
fstring profile_path;
fstring home_dir;
fstring dir_drive;
fstring logon_srv;
fstring logon_dom;
} info3;
} auth;
struct {
fstring name;
fstring alt_name;
fstring sid;
bool native_mode;
bool active_directory;
bool primary;
} domain_info;
uint32_t sequence_number;
struct {
fstring acct_name;
fstring full_name;
fstring homedir;
fstring shell;
uint32_t primary_gid;
uint32_t group_rid;
} user_info;
struct {
uint32_t auth_blob_len; /* blob in extra_data */
} ccache_ntlm_auth;
} data;
/* Variable length return data */
union {
SMB_TIME_T padding;
void *data;
} extra_data;
};
struct WINBINDD_MEMORY_CREDS {
struct WINBINDD_MEMORY_CREDS *next, *prev;
const char *username; /* lookup key. */
uid_t uid;
int ref_count;
size_t len;
uint8_t *nt_hash; /* Base pointer for the following 2 */
uint8_t *lm_hash;
char *pass;
};
struct WINBINDD_CCACHE_ENTRY {
struct WINBINDD_CCACHE_ENTRY *next, *prev;
const char *principal_name;
const char *ccname;
const char *service;
const char *username;
const char *realm;
struct WINBINDD_MEMORY_CREDS *cred_ptr;
int ref_count;
uid_t uid;
time_t create_time;
time_t renew_until;
time_t refresh_time;
struct timed_event *event;
};
#endif

@ -648,7 +648,20 @@ static NTSTATUS dcesrv_bind(struct dcesrv_call_state *call)
pkt.pfc_flags = DCERPC_PFC_FLAG_FIRST | DCERPC_PFC_FLAG_LAST | extra_flags;
pkt.u.bind_ack.max_xmit_frag = 0x2000;
pkt.u.bind_ack.max_recv_frag = 0x2000;
pkt.u.bind_ack.assoc_group_id = iface?call->context->assoc_group_id:0;
/*
make it possible for iface->bind() to specify the assoc_group_id
This helps the openchange mapiproxy plugin to work correctly.
metze
*/
if (call->context) {
pkt.u.bind_ack.assoc_group_id = call->context->assoc_group_id;
} else {
/* we better pick something - this chosen so as to send a non zero assoc_group_id (matching windows), it also matches samba3 */
pkt.u.bind_ack.assoc_group_id = SAMBA_ASSOC_GROUP;
}
if (iface) {
/* FIXME: Use pipe name as specified by endpoint instead of interface name */
pkt.u.bind_ack.secondary_address = talloc_asprintf(call, "\\PIPE\\%s", iface->name);

@ -183,22 +183,19 @@ NTSTATUS wbsrv_samba3_handle_call(struct wbsrv_samba3_call *s3call)
case WINBINDD_ALLOCATE_UID:
case WINBINDD_ALLOCATE_GID:
case WINBINDD_SET_MAPPING:
case WINBINDD_REMOVE_MAPPING:
case WINBINDD_SET_HWM:
case WINBINDD_DUMP_MAPS:
case WINBINDD_DOMAIN_INFO:
case WINBINDD_SHOW_SEQUENCE:
case WINBINDD_WINS_BYIP:
case WINBINDD_WINS_BYNAME:
case WINBINDD_GETGRLST:
case WINBINDD_DSGETDCNAME:
case WINBINDD_INIT_CONNECTION:
case WINBINDD_DUAL_SIDS2XIDS:
case WINBINDD_DUAL_SET_MAPPING:
case WINBINDD_DUAL_REMOVE_MAPPING:
case WINBINDD_DUAL_SET_HWM:
case WINBINDD_DUAL_DUMP_MAPS:
case WINBINDD_DUAL_UID2NAME:
case WINBINDD_DUAL_NAME2UID:
case WINBINDD_DUAL_GID2NAME:
case WINBINDD_DUAL_NAME2GID:
case WINBINDD_DUAL_USERINFO:
case WINBINDD_DUAL_GETSIDALIASES:
case WINBINDD_CCACHE_NTLMAUTH: