[SCM] Samba Shared Repository - branch v3-2-stable updated - release-3-2-0pre2-743-g8e1fbbc

Karolin Seeger kseeger at samba.org
Mon Apr 21 06:42:14 GMT 2008


The branch, v3-2-stable has been updated
       via  8e1fbbcee67d122b8b35b4da4c167da0db049f85 (commit)
       via  ee4a34a8bec84308d6a764a884d6c4cf646a3e25 (commit)
       via  594f977c8c4d74cfc8889d492ebbcc55b4fce976 (commit)
       via  bec4b4fbe56b7937c56d834cf30856c7ea10252d (commit)
       via  36babbbe164513ccb0c4678de4b7810cd61af47f (commit)
       via  5fc54f1be39339ae9b4ad41579ea125f7d5a8743 (commit)
       via  260c642da383cec3a9a2349b37ef4d95d022b5fc (commit)
       via  322ee90ea2596e51caca7daeaad14284b29be39c (commit)
       via  825ee29fd332fd8932829b86818f3a908df9db4d (commit)
       via  b12907b8059b2c2e063fada7ebbe1a7e17cb4897 (commit)
       via  3112492283be19940a65c0d1a55b227b8c45cf22 (commit)
       via  606ca61d6576c266fd3f35ef867f4114beb82553 (commit)
       via  a6a71f11e9061211266ad87fba2b03ce7f52260e (commit)
       via  9547b4f8cf7dbe5b46a97572cbfd59d02d6f0777 (commit)
       via  f6ae698ce291dcb58923634ff7b10300e80c065e (commit)
       via  f9caba82f6105d3d62cba89772b956627ec0672e (commit)
       via  c46c6a842b907e3ea3a91fd7bbb7833fbb836f39 (commit)
       via  c4095418c0f140f114bb1549e0a179ab4dffd789 (commit)
       via  d98fd23e3db923ce078b4fda6382ce4f6aa771c7 (commit)
       via  a570ab0b8955987e5f2e9bc5b7b301c83398ad40 (commit)
       via  2677d7d8a9888bc9425fe7f2aa3aabc6606378d0 (commit)
       via  e81d4001d8d41fe37b524644ef2daba09cbcb9d3 (commit)
       via  a52700719e33164929de1308522b5b55bfa33aa8 (commit)
       via  a4b73dfc6745958be1715c488ee759e6fcd9d105 (commit)
      from  42d606bb90b73b561c4570e3b9ebece0abb9633c (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-stable


- Log -----------------------------------------------------------------
commit 8e1fbbcee67d122b8b35b4da4c167da0db049f85
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Apr 19 02:45:10 2008 +0200

    WHATNEW.txt: add my latest changes
    
    metze
    (cherry picked from commit 6ae8544ace0dd9ac67d36abbaa26cf311db880ad)

commit ee4a34a8bec84308d6a764a884d6c4cf646a3e25
Author: Gerald W. Carter <jerry at samba.org>
Date:   Thu Apr 17 18:09:08 2008 +0200

    Remove unused variable from wbcCheckTrustCredentials().
    (cherry picked from commit fea52dc46048ff869299267f7596b93a8c5c8b3d)

commit 594f977c8c4d74cfc8889d492ebbcc55b4fce976
Author: Gerald W. Carter <jerry at samba.org>
Date:   Thu Apr 17 17:49:53 2008 +0200

    Follow error code name convention in libwbclient.
    s/WBC_INVALID_RESPONSE/WBC_ERR_INVALID_RESPONSE/
    (cherry picked from commit d91ce012b0afb30cd22b373412d17de27c55ca86)

commit bec4b4fbe56b7937c56d834cf30856c7ea10252d
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Apr 17 00:17:06 2008 +0200

    wbinfo: use wbcCheckTrustCredentials()
    
    metze
    (cherry picked from commit 2cbe5a006a6df79c38f4aaa68d498cd6d5a34dba)

commit 36babbbe164513ccb0c4678de4b7810cd61af47f
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Apr 16 23:35:12 2008 +0200

    libwbclient: add wbcCheckTrustCredentials()
    
    This only accepts NULL as domain for now,
    because winbindd doesn't support checking
    trust passwords as a domain controller.
    
    metze
    (cherry picked from commit c084ccd70f42ce29ce24565969a9f440dde254e1)

commit 5fc54f1be39339ae9b4ad41579ea125f7d5a8743
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Apr 14 09:35:15 2008 +0200

    wbinfo: use wbcResolveWinsByName() and wbcResolveWinsByIP()
    
    metze
    (cherry picked from commit a4f628d6c9e2a5761c048e268a29e1f5daae4180)

commit 260c642da383cec3a9a2349b37ef4d95d022b5fc
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Apr 14 09:31:46 2008 +0200

    libwbclient: add wbcResolveWinsByName() and wbcResolveWinsByIP()
    
    metze
    (cherry picked from commit 57ba71140fbf6b4a5a917fa3248fa76536be883b)

commit 322ee90ea2596e51caca7daeaad14284b29be39c
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Apr 15 10:57:16 2008 +0200

    winbindd: create the messaging conntext earlier
    
    metze
    (cherry picked from commit 2e1b9130635235efdbf49d0b92a43b342114246c)

commit 825ee29fd332fd8932829b86818f3a908df9db4d
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Apr 15 01:02:42 2008 +0200

    winbindd: call reinit_after_fork() in the child processes
    
    metze
    (cherry picked from commit 8e9fdef792e612e414444e7714a2fd4513892248)

commit b12907b8059b2c2e063fada7ebbe1a7e17cb4897
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Apr 15 10:50:27 2008 +0200

    nmbd: create the messaging conntext earlier
    
    metze
    (cherry picked from commit 056ff094ad2c59992cfdb8b29696c08dab4113d7)

commit 3112492283be19940a65c0d1a55b227b8c45cf22
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Apr 15 10:38:21 2008 +0200

    nmbd: call reinit_after_fork() in all needed cases
    
    metze
    (cherry picked from commit f68829ff14c457bfa98cb2ef9e8ec2e1a0b1d64d)

commit 606ca61d6576c266fd3f35ef867f4114beb82553
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Apr 15 01:48:44 2008 +0200

    printing: call reinit_after_fork() in the backgroundqueue process
    
    metze
    (cherry picked from commit 9adb675a86e81c90e2bddfe984b5ac8f201fec75)

commit a6a71f11e9061211266ad87fba2b03ce7f52260e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Apr 15 10:57:45 2008 +0200

    smbd: create the messaging conntext earlier
    
    metze
    (cherry picked from commit 658d8475336c4397e0dad341f216baf9e1eb6aaf)

commit 9547b4f8cf7dbe5b46a97572cbfd59d02d6f0777
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Apr 15 01:01:59 2008 +0200

    smbd: call reinit_after_fork() in the needed places
    
    metze
    (cherry picked from commit 425b3513a45cf98b53235470a3536be86d56d1c2)

commit f6ae698ce291dcb58923634ff7b10300e80c065e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Apr 18 10:20:01 2008 +0200

    loadparm: make it possible to just load the config without following "include =" statements
    
    metze
    (cherry picked from commit 6b5c76bf1e880ec60d6b044c58115940549049e5)

commit f9caba82f6105d3d62cba89772b956627ec0672e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Apr 15 10:36:15 2008 +0200

    util: add reinit_after_fork() function
    
    metze
    (cherry picked from commit 5f6c3a4f6db68c985884cbe9401a4dbe515f756b)

commit c46c6a842b907e3ea3a91fd7bbb7833fbb836f39
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Apr 15 01:50:13 2008 +0200

    smbd: merge "smbd:backgroundqueue=no" option from the v3-0-ctdb tree
    
    metze
    (cherry picked from commit 16d295d466eb18e3bccce6fb26d53012d5f2c3e8)

commit c4095418c0f140f114bb1549e0a179ab4dffd789
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Apr 15 01:18:50 2008 +0200

    messages_ctdbd: autocreate a ctdb connection, this will fix segfaults in the client tools
    
    metze
    (cherry picked from commit 6f67c4ddf8101b1d06889055e3767a6ce0db360c)

commit d98fd23e3db923ce078b4fda6382ce4f6aa771c7
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Apr 15 01:18:06 2008 +0200

    messages_ctdbd: make sure a ctdbd connection is only used in the process that created it
    
    metze
    (cherry picked from commit 259786980a3a65fa67a4de12a65d33095fa53ce2)

commit a570ab0b8955987e5f2e9bc5b7b301c83398ad40
Author: Michael Adam <obnox at samba.org>
Date:   Sun Apr 6 22:23:54 2008 +0200

    loadparm: reactivate special semantics of "include = registry" for now.
    
    This includes the configuration stored in HKLM/Software/Samba/smbconf .
    
    Michael
    (cherry picked from commit 42c7fb4ddfab9ff7592593533099ae872c1edca7)

commit 2677d7d8a9888bc9425fe7f2aa3aabc6606378d0
Author: Michael Adam <obnox at samba.org>
Date:   Sun Apr 13 21:57:55 2008 +0200

    loadparm: remove pfunc parameter from process_registry_globals().
    
    Use do_parameter() directly.
    
    Michael
    (cherry picked from commit 59b81bfd0abecb190d0c49e62581b26f10b96829)

commit e81d4001d8d41fe37b524644ef2daba09cbcb9d3
Author: Michael Adam <obnox at samba.org>
Date:   Tue Apr 15 20:41:14 2008 +0200

    auth: add SeDiskOperatorsPrivilege to get_root_nt_token to fix registry shares.
    
    Michael
    (cherry picked from commit 6bb107b17d557c27d035ca518ab61296814a3cea)

commit a52700719e33164929de1308522b5b55bfa33aa8
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Apr 15 00:18:34 2008 +0200

    lib/sharesec.c: fix the upgrade code, db_traverse returns the number of records!
    
    metze
    (cherry picked from commit ccdebe97f85b76378e42d8cf08324228bd19cf32)

commit a4b73dfc6745958be1715c488ee759e6fcd9d105
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Apr 15 00:12:45 2008 +0200

    pdb_tdb: fix the upgrade code, db_traverse returns the number of records!
    
    metze
    (cherry picked from commit baaf571d540ace5119c528fd35bceab335bd6741)

-----------------------------------------------------------------------

Summary of changes:
 WHATSNEW.txt                           |    8 +++
 source/auth/token_util.c               |    2 +
 source/lib/messages_ctdbd.c            |   30 +++++++++++-
 source/lib/sharesec.c                  |    6 ++-
 source/lib/util.c                      |   30 ++++++++++++
 source/nmbd/asyncdns.c                 |    5 ++
 source/nmbd/nmbd.c                     |   20 +++++++-
 source/nsswitch/libwbclient/wbc_pam.c  |   63 ++++++++++++++++++++++--
 source/nsswitch/libwbclient/wbc_sid.c  |   10 ++--
 source/nsswitch/libwbclient/wbc_util.c |   81 ++++++++++++++++++++++++++++++++
 source/nsswitch/libwbclient/wbclient.c |    4 +-
 source/nsswitch/libwbclient/wbclient.h |   14 +++++-
 source/nsswitch/wbinfo.c               |   64 +++++++++++--------------
 source/param/loadparm.c                |   80 ++++++++++++++++++++++++++------
 source/passdb/pdb_tdb.c                |    4 +-
 source/printing/printing.c             |    5 ++
 source/smbd/server.c                   |   49 +++++++++----------
 source/winbindd/winbindd.c             |   24 +++++++---
 source/winbindd/winbindd_cm.c          |    5 +-
 source/winbindd/winbindd_dual.c        |    5 +-
 20 files changed, 399 insertions(+), 110 deletions(-)


Changeset truncated at 500 lines:

diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index f81fbeb..462be44 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -285,6 +285,9 @@ o   Stefan Metzmacher <metze at samba.org>
       - wbcSetGidMapping()
       - wbcSetUidHwm()
       - wbcSetGidHwm()
+      - wbcResolveWinsByName()
+      - wbcResolveWinsByIP()
+      - wbcCheckTrustCredentials()
     * Let wbinfo use libwbclient where possible.
     * Let net use only libwbclient to access winbindd.
     * Make socket wrapper pcap support more portable.
@@ -292,6 +295,11 @@ o   Stefan Metzmacher <metze at samba.org>
     * Store the write time in the locking.tdb,
       so that smbd passes the BASE-DELAYWRITE test.
     * Run RAW-SEARCH and BASE-DELAYWRITE by 'make test'.
+    * Let each process use its own connection to ctdb
+      in cluster mode.
+    * Add a reinit_after_fork() helper function to correct
+      reinitialize the same things in all cases.
+    * Fix a chicken and egg problem with "include = registry".
 
 
 o   Karolin Seeger <kseeger at samba.org>
diff --git a/source/auth/token_util.c b/source/auth/token_util.c
index fc93060..6720a2c 100644
--- a/source/auth/token_util.c
+++ b/source/auth/token_util.c
@@ -105,6 +105,8 @@ NT_USER_TOKEN *get_root_nt_token( void )
 	token = create_local_nt_token(NULL, &u_sid, False,
 				      1, &global_sid_Builtin_Administrators);
 
+	token->privileges = se_disk_operators;
+
 	memcache_add_talloc(
 		NULL, SINGLETON_CACHE_TALLOC,
 		data_blob_string_const("root_nt_token"), token);
diff --git a/source/lib/messages_ctdbd.c b/source/lib/messages_ctdbd.c
index f1a02e6..a01c5e0 100644
--- a/source/lib/messages_ctdbd.c
+++ b/source/lib/messages_ctdbd.c
@@ -35,10 +35,36 @@ struct messaging_ctdbd_context {
  * This is a Samba3 hack/optimization. Routines like process_exists need to
  * talk to ctdbd, and they don't get handed a messaging context.
  */
-struct ctdbd_connection *global_ctdbd_connection;
+static struct ctdbd_connection *global_ctdbd_connection;
+static int global_ctdb_connection_pid;
 
 struct ctdbd_connection *messaging_ctdbd_connection(void)
 {
+	if (global_ctdb_connection_pid == 0 &&
+	    global_ctdbd_connection == NULL) {
+		struct event_context *ev;
+		struct messaging_context *msg;
+
+		ev = event_context_init(NULL);
+		if (!msg) {
+			DEBUG(0,("event_context_init failed\n"));
+		}
+
+		msg = messaging_init(NULL, procid_self(), ev);
+		if (!msg) {
+			DEBUG(0,("messaging_init failed\n"));
+		}
+
+		db_tdb2_setup_messaging(msg, false);
+	}
+
+	if (global_ctdb_connection_pid != getpid()) {
+		DEBUG(0,("messaging_ctdbd_connection():"
+			 "valid for pid[%d] but it's [%d]\n",
+			 global_ctdb_connection_pid, getpid()));
+		smb_panic("messaging_ctdbd_connection() invalid process\n");
+	}
+
 	return global_ctdbd_connection;
 }
 
@@ -66,6 +92,7 @@ static int messaging_ctdbd_destructor(struct messaging_ctdbd_context *ctx)
 	/*
 	 * The global connection just went away
 	 */
+	global_ctdb_connection_pid = 0;
 	global_ctdbd_connection = NULL;
 	return 0;
 }
@@ -107,6 +134,7 @@ NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx,
 		return status;
 	}
 
+	global_ctdb_connection_pid = getpid();
 	global_ctdbd_connection = ctx->conn;
 	talloc_set_destructor(ctx, messaging_ctdbd_destructor);
 
diff --git a/source/lib/sharesec.c b/source/lib/sharesec.c
index 471363b..d894347 100644
--- a/source/lib/sharesec.c
+++ b/source/lib/sharesec.c
@@ -94,8 +94,10 @@ static bool share_info_db_init(void)
 	}
 
 	if (vers_id != SHARE_DATABASE_VERSION_V2) {
-		if (share_db->traverse(share_db, delete_fn, NULL) != 0) {
-			DEBUG(0, ("wipe_all failed\n"));
+		int ret;
+		ret = share_db->traverse(share_db, delete_fn, NULL);
+		if (ret < 0) {
+			DEBUG(0, ("traverse failed\n"));
 			goto cancel;
 		}
 		if (dbwrap_store_int32(share_db, vstring,
diff --git a/source/lib/util.c b/source/lib/util.c
index ecd8951..3b2d375 100644
--- a/source/lib/util.c
+++ b/source/lib/util.c
@@ -990,6 +990,36 @@ void become_daemon(bool Fork, bool no_process_group)
 				  attach it to the logfile */
 }
 
+bool reinit_after_fork(struct messaging_context *msg_ctx)
+{
+	NTSTATUS status;
+
+	/* Reset the state of the random
+	 * number generation system, so
+	 * children do not get the same random
+	 * numbers as each other */
+	set_need_random_reseed();
+
+	/* tdb needs special fork handling */
+	if (tdb_reopen_all(1) == -1) {
+		DEBUG(0,("tdb_reopen_all failed.\n"));
+		return false;
+	}
+
+	/*
+	 * For clustering, we need to re-init our ctdbd connection after the
+	 * fork
+	 */
+	status = messaging_reinit(msg_ctx);
+	if (!NT_STATUS_IS_OK(status)) {
+		DEBUG(0,("messaging_reinit() failed: %s\n",
+			 nt_errstr(status)));
+		return false;
+	}
+
+	return true;
+}
+
 /****************************************************************************
  Put up a yes/no prompt.
 ****************************************************************************/
diff --git a/source/nmbd/asyncdns.c b/source/nmbd/asyncdns.c
index 5e55659..0329491 100644
--- a/source/nmbd/asyncdns.c
+++ b/source/nmbd/asyncdns.c
@@ -164,6 +164,11 @@ void start_async_dns(void)
 	CatchSignal(SIGHUP, SIG_IGN);
         CatchSignal(SIGTERM, SIGNAL_CAST sig_term );
 
+	if (!reinit_after_fork(nmbd_messaging_context())) {
+		DEBUG(0,("reinit_after_fork() failed\n"));
+		smb_panic("reinit_after_fork() failed");
+	}
+
 	asyncdns_process();
 }
 
diff --git a/source/nmbd/nmbd.c b/source/nmbd/nmbd.c
index 01ccf24..234c4d5 100644
--- a/source/nmbd/nmbd.c
+++ b/source/nmbd/nmbd.c
@@ -750,6 +750,8 @@ static bool open_sockets(bool isdaemon, int port)
 	};
 	TALLOC_CTX *frame = talloc_stackframe(); /* Setup tos. */
 
+	db_tdb2_setup_messaging(NULL, false);
+
 	load_case_tables();
 
 	global_nmb_port = NMB_PORT;
@@ -835,7 +837,16 @@ static bool open_sockets(bool isdaemon, int port)
 	DEBUG(0,("nmbd version %s started.\n", SAMBA_VERSION_STRING));
 	DEBUGADD(0,("%s\n", COPYRIGHT_STARTUP_MESSAGE));
 
-	db_tdb2_setup_messaging(NULL, false);
+	if (!lp_load_initial_only(get_dyn_CONFIGFILE())) {
+		DEBUG(0, ("error opening config file\n"));
+		exit(1);
+	}
+
+	if (nmbd_messaging_context() == NULL) {
+		return 1;
+	}
+
+	db_tdb2_setup_messaging(nmbd_messaging_context(), true);
 
 	if ( !reload_nmbd_services(False) )
 		return(-1);
@@ -889,6 +900,11 @@ static bool open_sockets(bool isdaemon, int port)
 
 	pidfile_create("nmbd");
 
+	if (!reinit_after_fork(nmbd_messaging_context())) {
+		DEBUG(0,("reinit_after_fork() failed\n"));
+		exit(1);
+	}
+
 	/* get broadcast messages */
 	claim_connection(NULL,"",FLAG_MSG_GENERAL|FLAG_MSG_DBWRAP);
 
@@ -906,8 +922,6 @@ static bool open_sockets(bool isdaemon, int port)
 	messaging_register(nmbd_messaging_context(), NULL,
 			   MSG_SEND_PACKET, msg_nmbd_send_packet);
 
-	db_tdb2_setup_messaging(nmbd_messaging_context(), true);
-
 	TimeInit();
 
 	DEBUG( 3, ( "Opening sockets %d\n", global_nmb_port ) );
diff --git a/source/nsswitch/libwbclient/wbc_pam.c b/source/nsswitch/libwbclient/wbc_pam.c
index 2b33f55..a0e91fa 100644
--- a/source/nsswitch/libwbclient/wbc_pam.c
+++ b/source/nsswitch/libwbclient/wbc_pam.c
@@ -138,7 +138,7 @@ static wbcErr wbc_create_auth_info(TALLOC_CTX *mem_ctx,
 
 	p = (char *)resp->extra_data.data;
 	if (!p) {
-		wbc_status = WBC_INVALID_RESPONSE;
+		wbc_status = WBC_ERR_INVALID_RESPONSE;
 		BAIL_ON_WBC_ERROR(wbc_status);
 	}
 
@@ -149,7 +149,7 @@ static wbcErr wbc_create_auth_info(TALLOC_CTX *mem_ctx,
 		char *s = p;
 		char *e = strchr(p, '\n');
 		if (!e) {
-			wbc_status = WBC_INVALID_RESPONSE;
+			wbc_status = WBC_ERR_INVALID_RESPONSE;
 			BAIL_ON_WBC_ERROR(wbc_status);
 		}
 		e[0] = '\0';
@@ -157,7 +157,7 @@ static wbcErr wbc_create_auth_info(TALLOC_CTX *mem_ctx,
 
 		ret = sscanf(s, "0x%08X:0x%08X", &rid, &attrs);
 		if (ret != 2) {
-			wbc_status = WBC_INVALID_RESPONSE;
+			wbc_status = WBC_ERR_INVALID_RESPONSE;
 			BAIL_ON_WBC_ERROR(wbc_status);
 		}
 
@@ -173,7 +173,7 @@ static wbcErr wbc_create_auth_info(TALLOC_CTX *mem_ctx,
 		char *a;
 		char *e = strchr(p, '\n');
 		if (!e) {
-			wbc_status = WBC_INVALID_RESPONSE;
+			wbc_status = WBC_ERR_INVALID_RESPONSE;
 			BAIL_ON_WBC_ERROR(wbc_status);
 		}
 		e[0] = '\0';
@@ -181,7 +181,7 @@ static wbcErr wbc_create_auth_info(TALLOC_CTX *mem_ctx,
 
 		e = strchr(s, ':');
 		if (!e) {
-			wbc_status = WBC_INVALID_RESPONSE;
+			wbc_status = WBC_ERR_INVALID_RESPONSE;
 			BAIL_ON_WBC_ERROR(wbc_status);
 		}
 		e[0] = '\0';
@@ -190,7 +190,7 @@ static wbcErr wbc_create_auth_info(TALLOC_CTX *mem_ctx,
 		ret = sscanf(a, "0x%08X",
 			     &attrs);
 		if (ret != 1) {
-			wbc_status = WBC_INVALID_RESPONSE;
+			wbc_status = WBC_ERR_INVALID_RESPONSE;
 			BAIL_ON_WBC_ERROR(wbc_status);
 		}
 
@@ -419,3 +419,54 @@ done:
 
 	return wbc_status;
 }
+
+/** @brief Trigger a verification of the trust credentials of a specific domain
+ *
+ * @param *domain      The name of the domain, only NULL for the default domain is
+ *                     supported yet. Other values than NULL will result in
+ *                     WBC_ERR_NOT_IMPLEMENTED.
+ * @param error        Output details on WBC_ERR_AUTH_ERROR
+ *
+ * @return #wbcErr
+ *
+ **/
+wbcErr wbcCheckTrustCredentials(const char *domain,
+				struct wbcAuthErrorInfo **error)
+{
+	struct winbindd_request request;
+	struct winbindd_response response;
+	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+
+	if (domain) {
+		/*
+		 * the current protocol doesn't support
+		 * specifying a domain
+		 */
+		wbc_status = WBC_ERR_NOT_IMPLEMENTED;
+		BAIL_ON_WBC_ERROR(wbc_status);
+	}
+
+	ZERO_STRUCT(request);
+	ZERO_STRUCT(response);
+
+	/* Send request */
+
+	wbc_status = wbcRequestResponse(WINBINDD_CHECK_MACHACC,
+					&request,
+					&response);
+	if (response.data.auth.nt_status != 0) {
+		if (error) {
+			wbc_status = wbc_create_error_info(NULL,
+							   &response,
+							   error);
+			BAIL_ON_WBC_ERROR(wbc_status);
+		}
+
+		wbc_status = WBC_ERR_AUTH_ERROR;
+		BAIL_ON_WBC_ERROR(wbc_status);
+	}
+	BAIL_ON_WBC_ERROR(wbc_status);
+
+ done:
+	return wbc_status;
+}
diff --git a/source/nsswitch/libwbclient/wbc_sid.c b/source/nsswitch/libwbclient/wbc_sid.c
index 6ef9f44..de9b028 100644
--- a/source/nsswitch/libwbclient/wbc_sid.c
+++ b/source/nsswitch/libwbclient/wbc_sid.c
@@ -372,21 +372,21 @@ wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid,
 		char *q;
 
 		if (*p == '\0') {
-			wbc_status = WBC_INVALID_RESPONSE;
+			wbc_status = WBC_ERR_INVALID_RESPONSE;
 			BAIL_ON_WBC_ERROR(wbc_status);
 		}
 
 		(*types)[i] = (enum wbcSidType)strtoul(p, &q, 10);
 
 		if (*q != ' ') {
-			wbc_status = WBC_INVALID_RESPONSE;
+			wbc_status = WBC_ERR_INVALID_RESPONSE;
 			BAIL_ON_WBC_ERROR(wbc_status);
 		}
 
 		p = q+1;
 
 		if ((q = strchr(p, '\n')) == NULL) {
-			wbc_status = WBC_INVALID_RESPONSE;
+			wbc_status = WBC_ERR_INVALID_RESPONSE;
 			BAIL_ON_WBC_ERROR(wbc_status);
 		}
 
@@ -399,7 +399,7 @@ wbcErr wbcLookupRids(struct wbcDomainSid *dom_sid,
 	}
 
 	if (*p != '\0') {
-		wbc_status = WBC_INVALID_RESPONSE;
+		wbc_status = WBC_ERR_INVALID_RESPONSE;
 		BAIL_ON_WBC_ERROR(wbc_status);
 	}
 
@@ -471,7 +471,7 @@ wbcErr wbcLookupUserSids(const struct wbcDomainSid *user_sid,
 
 	if (response.data.num_entries &&
 	    !response.extra_data.data) {
-		wbc_status = WBC_INVALID_RESPONSE;
+		wbc_status = WBC_ERR_INVALID_RESPONSE;
 		BAIL_ON_WBC_ERROR(wbc_status);
 	}
 
diff --git a/source/nsswitch/libwbclient/wbc_util.c b/source/nsswitch/libwbclient/wbc_util.c
index 7bdae91..edcad28 100644
--- a/source/nsswitch/libwbclient/wbc_util.c
+++ b/source/nsswitch/libwbclient/wbc_util.c
@@ -187,3 +187,84 @@ wbcErr wbcDomainInfo(const char *domain, struct wbcDomainInfo **dinfo)
 
 	return wbc_status;
 }
+
+
+/** @brief Resolve a NetbiosName via WINS
+ *
+ * @param name         Name to resolve
+ * @param *ip          Pointer to the ip address string
+ *
+ * @return #wbcErr
+ *
+ **/
+wbcErr wbcResolveWinsByName(const char *name, const char **ip)
+{
+	struct winbindd_request request;
+	struct winbindd_response response;
+	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+	const char *ipaddr;
+
+	ZERO_STRUCT(request);
+	ZERO_STRUCT(response);
+
+	/* Send request */
+
+	strncpy(request.data.winsreq, name,
+		sizeof(request.data.winsreq)-1);
+
+	wbc_status = wbcRequestResponse(WINBINDD_WINS_BYNAME,
+					&request,
+					&response);
+	BAIL_ON_WBC_ERROR(wbc_status);
+
+	/* Display response */
+
+	ipaddr = talloc_strdup(NULL, response.data.winsresp);
+	BAIL_ON_PTR_ERROR(ipaddr, wbc_status);
+
+	*ip = ipaddr;
+	wbc_status = WBC_ERR_SUCCESS;
+
+ done:
+	return wbc_status;
+}
+
+/** @brief Resolve an IP address via WINS into a NetbiosName
+ *
+ * @param ip          The ip address string
+ * @param *name       Pointer to the name
+ *
+ * @return #wbcErr
+ *
+ **/
+wbcErr wbcResolveWinsByIP(const char *ip, const char **name)
+{
+	struct winbindd_request request;
+	struct winbindd_response response;
+	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+	const char *name_str;
+
+	ZERO_STRUCT(request);
+	ZERO_STRUCT(response);
+
+	/* Send request */
+
+	strncpy(request.data.winsreq, ip,
+		sizeof(request.data.winsreq)-1);
+
+	wbc_status = wbcRequestResponse(WINBINDD_WINS_BYIP,
+					&request,
+					&response);
+	BAIL_ON_WBC_ERROR(wbc_status);
+
+	/* Display response */
+
+	name_str = talloc_strdup(NULL, response.data.winsresp);
+	BAIL_ON_PTR_ERROR(name_str, wbc_status);
+
+	*name = name_str;
+	wbc_status = WBC_ERR_SUCCESS;
+
+ done:
+	return wbc_status;
+}
diff --git a/source/nsswitch/libwbclient/wbclient.c b/source/nsswitch/libwbclient/wbclient.c
index e172962..ea34b72 100644
--- a/source/nsswitch/libwbclient/wbclient.c
+++ b/source/nsswitch/libwbclient/wbclient.c
@@ -106,8 +106,8 @@ const char *wbcErrorString(wbcErr error)
 		return "WBC_ERR_WINBIND_NOT_AVAILABLE";
 	case WBC_ERR_DOMAIN_NOT_FOUND:
 		return "WBC_ERR_DOMAIN_NOT_FOUND";
-	case WBC_INVALID_RESPONSE:
-		return "WBC_INVALID_RESPONSE";
+	case WBC_ERR_INVALID_RESPONSE:
+		return "WBC_ERR_INVALID_RESPONSE";
 	case WBC_ERR_NSS_ERROR:
 		return "WBC_ERR_NSS_ERROR";
 	case WBC_ERR_AUTH_ERROR:
diff --git a/source/nsswitch/libwbclient/wbclient.h b/source/nsswitch/libwbclient/wbclient.h
index 4e7e5af..812751d 100644
--- a/source/nsswitch/libwbclient/wbclient.h
+++ b/source/nsswitch/libwbclient/wbclient.h
@@ -40,7 +40,7 @@ enum _wbcErrType {
 	WBC_ERR_INVALID_PARAM,  /**< An Invalid parameter was supplied **/
 	WBC_ERR_WINBIND_NOT_AVAILABLE,   /**< Winbind daemon is not available **/
 	WBC_ERR_DOMAIN_NOT_FOUND,        /**< Domain is not trusted or cannot be found **/
-	WBC_INVALID_RESPONSE,        /**< Winbind returned an invalid response **/
+	WBC_ERR_INVALID_RESPONSE,        /**< Winbind returned an invalid response **/
 	WBC_ERR_NSS_ERROR,            /**< NSS_STATUS error **/
 	WBC_ERR_AUTH_ERROR        /**< Authentication failed **/
 };


-- 
Samba Shared Repository


More information about the samba-cvs mailing list