[SCM] Samba Shared Repository - branch master updated - 3dde0cbb769b92d922be13677ad076cae9b6a693

Stefan Metzmacher metze at samba.org
Thu Jan 8 11:22:36 GMT 2009


The branch, master has been updated
       via  3dde0cbb769b92d922be13677ad076cae9b6a693 (commit)
       via  defb574c2573a73335a2735e89e4cb5f96c4c069 (commit)
       via  7a5d07a1c1da70ddfc57d457d0efdd09559349d6 (commit)
       via  1bd317d3e34953bb89e50d2b870d2b9bbc8a90bc (commit)
       via  256101b02244633d5da6d82ba94b620f1f2acf69 (commit)
       via  0a0cd1396a0572dd1f04e8fdd99f682e4e4f91ee (commit)
       via  9ae0c5e5a7375ef58e4dff84eb154be77564d205 (commit)
       via  c19ed7669c3621142fd3634634f58bdb9920ddaf (commit)
       via  0713f9812474ef04df879772f0e3abcdb9e28180 (commit)
       via  d9e81664e5afc9576749241b9e445e232d5f83d6 (commit)
       via  2f9f8fe81e56f9c7bb15e96f9154afe73cf96f1a (commit)
       via  33dd8e850b98deaaada160a811aa6f78a4a012b8 (commit)
       via  7f2cf6b16635fcf7a4307dab4e6f6fed87ba2315 (commit)
      from  07e1e30b96dc17c60604b55a3f2a50afc9c8d791 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 3dde0cbb769b92d922be13677ad076cae9b6a693
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jan 8 12:03:45 2009 +0100

    s3:smbd: move all globals and static variables in globals.[ch]
    
    The goal is to move all this variables into a big context structure.
    
    metze

commit defb574c2573a73335a2735e89e4cb5f96c4c069
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jan 8 12:00:15 2009 +0100

    s3:smbd: variables in a main() don't need to be static
    
    metze

commit 7a5d07a1c1da70ddfc57d457d0efdd09559349d6
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jan 8 11:52:52 2009 +0100

    s3:smbd: open_sockets_smbd() don't need a static variable arrount atexit()
    
    open_sockets_smbd() is only called once.
    
    metze

commit 1bd317d3e34953bb89e50d2b870d2b9bbc8a90bc
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jan 8 11:37:06 2009 +0100

    s3:smbd: keep dmapi globals in one context struct
    
    metze

commit 256101b02244633d5da6d82ba94b620f1f2acf69
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jan 8 10:43:10 2009 +0100

    s3:smbd: remove stupid static variables for the nfs quota code
    
    metze

commit 0a0cd1396a0572dd1f04e8fdd99f682e4e4f91ee
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jan 8 09:04:30 2009 +0100

    s3:smbd: remove pointless static variable in uid.c
    
    We always free the value at the end of the function,
    so we don't need a static variable to hold just NULL
    for the time the function isn't executed.
    
    metze

commit 9ae0c5e5a7375ef58e4dff84eb154be77564d205
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jan 8 09:02:21 2009 +0100

    s3:smbd: make static const in mangle_hash2.c really static const
    
    const char *foo, means a non-const pointer to
    a const char.
    
    const char * const foo, means a const pointer to
    a const char.
    
    char * const foo, would mean a const pointer to
    a non-const char.
    
    metze

commit c19ed7669c3621142fd3634634f58bdb9920ddaf
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jan 8 08:57:52 2009 +0100

    s3:smbd: make const globals in mangle_hash2.c really static const
    
    const char *foo, means a non-const pointer to
    a const char.
    
    const char * const foo, means a const pointer to
    a const char.
    
    char * const foo, would mean a const pointer to
    a non-const char.
    
    metze

commit 0713f9812474ef04df879772f0e3abcdb9e28180
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jan 8 08:51:41 2009 +0100

    s3:smbd: make globals in utmp.c static const
    
    const char *foo, means a non-const pointer to
    a const char.
    
    const char * const foo, means a const pointer to
    a const char.
    
    char * const foo, would mean a const pointer to
    a non-const char.
    
    metze

commit d9e81664e5afc9576749241b9e445e232d5f83d6
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jan 8 08:50:36 2009 +0100

    s3:smbd: it's pointless to have a global magic_char
    
    We call magic_char = lp_magicchar(p) each time it's used.
    
    metze

commit 2f9f8fe81e56f9c7bb15e96f9154afe73cf96f1a
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jan 8 08:47:57 2009 +0100

    s3:smbd: remove pointless static variables in chgpasswd.c
    
    metze

commit 33dd8e850b98deaaada160a811aa6f78a4a012b8
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jan 8 08:38:01 2009 +0100

    s3:smbd: make fake_files[] static const
    
    metze

commit 7f2cf6b16635fcf7a4307dab4e6f6fed87ba2315
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jan 8 08:36:24 2009 +0100

    s3:smbd: make mangle_fns const
    
    metze

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

Summary of changes:
 source3/Makefile.in         |    2 +-
 source3/include/proto.h     |    6 +-
 source3/smbd/aio.c          |   26 ++---
 source3/smbd/blocking.c     |   21 +---
 source3/smbd/chgpasswd.c    |   19 ++--
 source3/smbd/conn.c         |    7 +-
 source3/smbd/dfree.c        |    6 +-
 source3/smbd/dir.c          |   10 +--
 source3/smbd/dmapi.c        |   73 +++++++++------
 source3/smbd/error.c        |    3 +-
 source3/smbd/fake_file.c    |    2 +-
 source3/smbd/fileio.c       |    4 +-
 source3/smbd/files.c        |   18 +----
 source3/smbd/globals.c      |  221 +++++++++++++++++++++++++++++++++++++++++++
 source3/smbd/globals.h      |  219 ++++++++++++++++++++++++++++++++++++++++++
 source3/smbd/ipc.c          |    3 +-
 source3/smbd/mangle.c       |    5 +-
 source3/smbd/mangle_hash.c  |   22 ++--
 source3/smbd/mangle_hash2.c |   26 ++----
 source3/smbd/map_username.c |    3 +-
 source3/smbd/message.c      |    3 +-
 source3/smbd/msdfs.c        |    3 +-
 source3/smbd/negprot.c      |    8 +--
 source3/smbd/notify.c       |    3 +-
 source3/smbd/nttrans.c      |    7 +-
 source3/smbd/open.c         |    3 +-
 source3/smbd/oplock.c       |   10 +--
 source3/smbd/oplock_irix.c  |   17 ++--
 source3/smbd/oplock_linux.c |   32 +++----
 source3/smbd/password.c     |   26 ++----
 source3/smbd/process.c      |   32 +------
 source3/smbd/quotas.c       |   36 ++++---
 source3/smbd/reply.c        |    8 +--
 source3/smbd/seal.c         |    4 +-
 source3/smbd/sec_ctx.c      |   24 +----
 source3/smbd/server.c       |   84 ++++++----------
 source3/smbd/service.c      |    3 +-
 source3/smbd/session.c      |   15 ++--
 source3/smbd/sesssetup.c    |   14 +---
 source3/smbd/srvstr.c       |    2 +-
 source3/smbd/trans2.c       |    6 +-
 source3/smbd/uid.c          |   22 +----
 source3/smbd/utmp.c         |    8 +-
 source3/smbd/vfs.c          |    5 +-
 44 files changed, 667 insertions(+), 404 deletions(-)
 create mode 100644 source3/smbd/globals.c
 create mode 100644 source3/smbd/globals.h


Changeset truncated at 500 lines:

diff --git a/source3/Makefile.in b/source3/Makefile.in
index 1625e65..fdddf36 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -698,7 +698,7 @@ SMBD_OBJ_SRV = smbd/files.o smbd/chgpasswd.o smbd/connection.o \
 	       $(AFS_SETTOKEN_OBJ) smbd/aio.o smbd/statvfs.o \
 	       smbd/dmapi.o \
 	       smbd/file_access.o \
-	       smbd/dnsregister.o \
+	       smbd/dnsregister.o smbd/globals.o \
 	       $(MANGLE_OBJ) @VFS_STATIC@
 
 SMBD_OBJ_BASE = $(PARAM_WITHOUT_REG_OBJ) $(SMBD_OBJ_SRV) $(LIBSMB_OBJ) \
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 35cb490..afc207b 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -6814,12 +6814,12 @@ bool name_to_8_3(const char *in,
 
 /* The following definitions come from smbd/mangle_hash.c  */
 
-struct mangle_fns *mangle_hash_init(void);
+const struct mangle_fns *mangle_hash_init(void);
 
 /* The following definitions come from smbd/mangle_hash2.c  */
 
-struct mangle_fns *mangle_hash2_init(void);
-struct mangle_fns *posix_mangle_init(void);
+const struct mangle_fns *mangle_hash2_init(void);
+const struct mangle_fns *posix_mangle_init(void);
 
 /* The following definitions come from smbd/map_username.c  */
 
diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c
index 8beed07..54ae45a 100644
--- a/source3/smbd/aio.c
+++ b/source3/smbd/aio.c
@@ -19,6 +19,7 @@
 */
 
 #include "includes.h"
+#include "smbd/globals.h"
 
 #if defined(WITH_AIO)
 
@@ -53,8 +54,6 @@ struct aio_extra {
 static int handle_aio_read_complete(struct aio_extra *aio_ex);
 static int handle_aio_write_complete(struct aio_extra *aio_ex);
 
-static struct aio_extra *aio_list_head;
-
 static int aio_extra_destructor(struct aio_extra *aio_ex)
 {
 	DLIST_REMOVE(aio_list_head, aio_ex);
@@ -109,20 +108,15 @@ static struct aio_extra *find_aio_ex(uint16 mid)
  We can have these many aio buffers in flight.
 *****************************************************************************/
 
-static int aio_pending_size;
-static sig_atomic_t signals_received;
-static int outstanding_aio_calls;
-static uint16 *aio_pending_array;
-
 /****************************************************************************
  Signal handler when an aio request completes.
 *****************************************************************************/
 
 void aio_request_done(uint16_t mid)
 {
-	if (signals_received < aio_pending_size) {
-		aio_pending_array[signals_received] = mid;
-		signals_received++;
+	if (aio_signals_received < aio_pending_size) {
+		aio_pending_array[aio_signals_received] = mid;
+		aio_signals_received++;
 	}
 	/* Else signal is lost. */
 }
@@ -139,7 +133,7 @@ static void signal_handler(int sig, siginfo_t *info, void *unused)
 
 bool aio_finished(void)
 {
-	return (signals_received != 0);
+	return (aio_signals_received != 0);
 }
 
 /****************************************************************************
@@ -587,17 +581,17 @@ int process_aio_queue(void)
 	BlockSignals(True, RT_SIGNAL_AIO);
 
 	DEBUG(10,("process_aio_queue: signals_received = %d\n",
-		  (int)signals_received));
+		  (int)aio_signals_received));
 	DEBUG(10,("process_aio_queue: outstanding_aio_calls = %d\n",
 		  outstanding_aio_calls));
 
-	if (!signals_received) {
+	if (!aio_signals_received) {
 		BlockSignals(False, RT_SIGNAL_AIO);
 		return 0;
 	}
 
 	/* Drain all the complete aio_reads. */
-	for (i = 0; i < signals_received; i++) {
+	for (i = 0; i < aio_signals_received; i++) {
 		uint16 mid = aio_pending_array[i];
 		files_struct *fsp = NULL;
 		struct aio_extra *aio_ex = find_aio_ex(mid);
@@ -626,8 +620,8 @@ int process_aio_queue(void)
 		TALLOC_FREE(aio_ex);
 	}
 
-	outstanding_aio_calls -= signals_received;
-	signals_received = 0;
+	outstanding_aio_calls -= aio_signals_received;
+	aio_signals_received = 0;
 	BlockSignals(False, RT_SIGNAL_AIO);
 	return ret;
 }
diff --git a/source3/smbd/blocking.c b/source3/smbd/blocking.c
index 2b90d24..cccc5ce 100644
--- a/source3/smbd/blocking.c
+++ b/source3/smbd/blocking.c
@@ -18,6 +18,8 @@
 */
 
 #include "includes.h"
+#include "smbd/globals.h"
+
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_LOCKING
 
@@ -41,15 +43,6 @@ typedef struct blocking_lock_record {
 	struct smb_request *req;
 } blocking_lock_record;
 
-/* dlink list we store pending lock records on. */
-static blocking_lock_record *blocking_lock_queue;
-
-/* dlink list we move cancelled lock records onto. */
-static blocking_lock_record *blocking_lock_cancelled_queue;
-
-/* The event that makes us process our blocking lock queue */
-static struct timed_event *brl_timeout;
-
 /****************************************************************************
  Determine if this is a secondary element of a chained SMB.
   **************************************************************************/
@@ -148,7 +141,6 @@ bool push_blocking_lock_request( struct byte_range_lock *br_lck,
 		uint64_t count,
 		uint32_t blocking_pid)
 {
-	static bool set_lock_msg;
 	blocking_lock_record *blr;
 	NTSTATUS status;
 
@@ -211,10 +203,10 @@ bool push_blocking_lock_request( struct byte_range_lock *br_lck,
 	recalc_brl_timeout();
 
 	/* Ensure we'll receive messages when this is unlocked. */
-	if (!set_lock_msg) {
+	if (!blocking_lock_unlock_state) {
 		messaging_register(smbd_messaging_context(), NULL,
 				   MSG_SMB_UNLOCK, received_unlock_msg);
-		set_lock_msg = True;
+		blocking_lock_unlock_state = true;
 	}
 
 	DEBUG(3,("push_blocking_lock_request: lock request blocked with "
@@ -784,17 +776,16 @@ bool blocking_lock_cancel(files_struct *fsp,
 			unsigned char locktype,
                         NTSTATUS err)
 {
-	static bool initialized;
 	char msg[MSG_BLOCKING_LOCK_CANCEL_SIZE];
 	blocking_lock_record *blr;
 
-	if (!initialized) {
+	if (!blocking_lock_cancel_state) {
 		/* Register our message. */
 		messaging_register(smbd_messaging_context(), NULL,
 				   MSG_SMB_BLOCKING_LOCK_CANCEL,
 				   process_blocking_lock_cancel_message);
 
-		initialized = True;
+		blocking_lock_cancel_state = True;
 	}
 
 	for (blr = blocking_lock_queue; blr; blr = blr->next) {
diff --git a/source3/smbd/chgpasswd.c b/source3/smbd/chgpasswd.c
index e6d2bbf..78bace7 100644
--- a/source3/smbd/chgpasswd.c
+++ b/source3/smbd/chgpasswd.c
@@ -712,7 +712,7 @@ bool check_lanman_password(char *user, uchar * pass1,
 
 bool change_lanman_password(struct samu *sampass, uchar *pass2)
 {
-	static uchar null_pw[16];
+	uchar null_pw[16];
 	uchar unenc_new_pw[16];
 	bool ret;
 	uint32 acct_ctrl;
@@ -735,20 +735,21 @@ bool change_lanman_password(struct samu *sampass, uchar *pass2)
 	if (pwd == NULL) { 
 		if (acct_ctrl & ACB_PWNOTREQ) {
 			uchar no_pw[14];
-			memset(no_pw, '\0', 14);
+
+			ZERO_STRUCT(no_pw);
+
 			E_P16(no_pw, null_pw);
 
-			/* Get the new lanman hash. */
-			D_P16(null_pw, pass2, unenc_new_pw);
+			pwd = null_pw;
 		} else {
 			DEBUG(0,("change_lanman_password: no lanman password !\n"));
 			return False;
 		}
-	} else {
-		/* Get the new lanman hash. */
-		D_P16(pwd, pass2, unenc_new_pw);
 	}
 
+	/* Get the new lanman hash. */
+	D_P16(pwd, pass2, unenc_new_pw);
+
 	if (!pdb_set_lanman_passwd(sampass, unenc_new_pw, PDB_CHANGED)) {
 		return False;
 	}
@@ -826,8 +827,8 @@ static NTSTATUS check_oem_password(const char *user,
 				   struct samu **hnd,
 				   char **pp_new_passwd)
 {
-	static uchar null_pw[16];
-	static uchar null_ntpw[16];
+	uchar null_pw[16];
+	uchar null_ntpw[16];
 	struct samu *sampass = NULL;
 	uint8 *password_encrypted;
 	const uint8 *encryption_key;
diff --git a/source3/smbd/conn.c b/source3/smbd/conn.c
index 7f34d2b..4b467b0 100644
--- a/source3/smbd/conn.c
+++ b/source3/smbd/conn.c
@@ -19,6 +19,7 @@
 */
 
 #include "includes.h"
+#include "smbd/globals.h"
 
 /* The connections bitmap is expanded in increments of BITMAP_BLOCK_SZ. The
  * maximum size of the bitmap is the largest positive integer, but you will hit
@@ -26,12 +27,6 @@
  */
 #define BITMAP_BLOCK_SZ 128
 
-static connection_struct *Connections;
-
-/* number of open connections */
-static struct bitmap *bmap;
-static int num_open;
-
 /****************************************************************************
 init the conn structures
 ****************************************************************************/
diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c
index cd09d73..dc5719a 100644
--- a/source3/smbd/dfree.c
+++ b/source3/smbd/dfree.c
@@ -18,6 +18,7 @@
 */
 
 #include "includes.h"
+#include "smbd/globals.h"
 
 /****************************************************************************
  Normalise for DOS usage.
@@ -150,10 +151,9 @@ uint64_t sys_disk_free(connection_struct *conn, const char *path, bool small_que
 	}
 
 	if ((*dsize)<1) {
-		static bool done = false;
-		if (!done) {
+		if (!dfree_broken) {
 			DEBUG(0,("WARNING: dfree is broken on this system\n"));
-			done=true;
+			dfree_broken=true;
 		}
 		*dsize = 20*1024*1024/(*bsize);
 		*dfree = MAX(1,*dfree);
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index c2735c0..2b996a4 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -19,6 +19,7 @@
 */
 
 #include "includes.h"
+#include "smbd/globals.h"
 
 /*
    This module implements directory related functions for Samba.
@@ -61,9 +62,6 @@ struct dptr_struct {
 	bool did_stat; /* Optimisation for non-wcard searches. */
 };
 
-static struct bitmap *dptr_bmap;
-static struct dptr_struct *dirptrs;
-static int dirhandles_open = 0;
 
 #define INVALID_DPTR_KEY (-3)
 
@@ -119,17 +117,13 @@ bool make_dir_struct(TALLOC_CTX *ctx,
 
 void init_dptrs(void)
 {
-	static bool dptrs_init=False;
-
-	if (dptrs_init)
+	if (dptr_bmap)
 		return;
 
 	dptr_bmap = bitmap_allocate(MAX_DIRECTORY_HANDLES);
 
 	if (!dptr_bmap)
 		exit_server("out of memory in init_dptrs");
-
-	dptrs_init = True;
 }
 
 /****************************************************************************
diff --git a/source3/smbd/dmapi.c b/source3/smbd/dmapi.c
index 1049c95..dbb799f 100644
--- a/source3/smbd/dmapi.c
+++ b/source3/smbd/dmapi.c
@@ -19,6 +19,7 @@
 */
 
 #include "includes.h"
+#include "smbd/globals.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_DMAPI
@@ -46,15 +47,19 @@ const void * dmapi_get_current_session(void) { return NULL; }
 #define DMAPI_SESSION_NAME "samba"
 #define DMAPI_TRACE 10
 
-static dm_sessid_t samba_dmapi_session = DM_NO_SESSION;
-static unsigned session_num;
+struct smbd_dmapi_context {
+	dm_sessid_t session;
+	unsigned session_num;
+};
+
+static struct smbd_dmapi_context *dmapi_ctx;
 
 /* 
    Initialise DMAPI session. The session is persistant kernel state, 
    so it might already exist, in which case we merely want to 
    reconnect to it. This function should be called as root.
 */
-static int dmapi_init_session(void)
+static int dmapi_init_session(struct smbd_dmapi_context *ctx)
 {
 	char	buf[DM_SESSION_INFO_LEN];
 	size_t	buflen;
@@ -66,11 +71,11 @@ static int dmapi_init_session(void)
 
 	int i, err;
 
-	if (session_num == 0) {
-		session_name = DMAPI_SESSION_NAME;
+	if (ctx->session_num == 0) {
+		session_name = talloc_strdup(tmp_ctx, DMAPI_SESSION_NAME);
 	} else {
 		session_name = talloc_asprintf(tmp_ctx, "%s%u", DMAPI_SESSION_NAME,
-					       session_num);
+					       ctx->session_num);
 	}
 
 	if (session_name == NULL) {
@@ -116,7 +121,7 @@ static int dmapi_init_session(void)
 		err = dm_query_session(sessions[i], sizeof(buf), buf, &buflen);
 		buf[sizeof(buf) - 1] = '\0';
 		if (err == 0 && strcmp(session_name, buf) == 0) {
-			samba_dmapi_session = sessions[i];
+			ctx->session = sessions[i];
 			DEBUGADD(DMAPI_TRACE,
 				("attached to existing DMAPI session "
 				 "named '%s'\n", buf));
@@ -125,15 +130,15 @@ static int dmapi_init_session(void)
 	}
 
 	/* No session already defined. */
-	if (samba_dmapi_session == DM_NO_SESSION) {
+	if (ctx->session == DM_NO_SESSION) {
 		err = dm_create_session(DM_NO_SESSION, 
 					session_name,
-					&samba_dmapi_session);
+					&ctx->session);
 		if (err < 0) {
 			DEBUGADD(DMAPI_TRACE,
 				("failed to create new DMAPI session: %s\n",
 				strerror(errno)));
-			samba_dmapi_session = DM_NO_SESSION;
+			ctx->session = DM_NO_SESSION;
 			talloc_free(tmp_ctx);
 			return -1;
 		}
@@ -142,7 +147,7 @@ static int dmapi_init_session(void)
 			  session_name, version));
 	}
 
-	if (samba_dmapi_session != DM_NO_SESSION) {
+	if (ctx->session != DM_NO_SESSION) {
 		set_effective_capability(DMAPI_ACCESS_CAPABILITY);
 	}
 
@@ -165,11 +170,15 @@ static int dmapi_init_session(void)
 */
 const void *dmapi_get_current_session(void)
 {
-	if (samba_dmapi_session == DM_NO_SESSION) {
+	if (!dmapi_ctx) {
+		return NULL;
+	}
+
+	if (dmapi_ctx->session == DM_NO_SESSION) {
 		return NULL;
 	}
 
-	return (void *)&samba_dmapi_session;
+	return (void *)&dmapi_ctx->session;
 }
 	
 /*
@@ -180,17 +189,22 @@ const void *dmapi_get_current_session(void)
 
 bool dmapi_have_session(void)
 {
-	static bool initialized;
-	if (!initialized) {
-		initialized = true;
+	if (!dmapi_ctx) {
+		dmapi_ctx = talloc(talloc_autofree_context(),
+				   struct smbd_dmapi_context);
+		if (!dmapi_ctx) {
+			exit_server("unable to allocate smbd_dmapi_context");
+		}
+		dmapi_ctx->session = DM_NO_SESSION;
+		dmapi_ctx->session_num = 0;
 
 		become_root();
-		dmapi_init_session();
+		dmapi_init_session(dmapi_ctx);
 		unbecome_root();
 
 	}
 
-	return samba_dmapi_session != DM_NO_SESSION;
+	return dmapi_ctx->session != DM_NO_SESSION;
 }
 
 /*
@@ -202,14 +216,14 @@ bool dmapi_new_session(void)
 {
 	if (dmapi_have_session()) {
 		/* try to destroy the old one - this may not succeed */
-		dm_destroy_session(samba_dmapi_session);
+		dm_destroy_session(dmapi_ctx->session);
 	}
-	samba_dmapi_session = DM_NO_SESSION;
+	dmapi_ctx->session = DM_NO_SESSION;
 	become_root();
-	session_num++;
-	dmapi_init_session();
+	dmapi_ctx->session_num++;
+	dmapi_init_session(dmapi_ctx);
 	unbecome_root();
-	return samba_dmapi_session != DM_NO_SESSION;    
+	return dmapi_ctx->session != DM_NO_SESSION;
 }
 
 /* 
@@ -221,18 +235,21 @@ bool dmapi_new_session(void)
 */
 bool dmapi_destroy_session(void)
 {
-	if (samba_dmapi_session != DM_NO_SESSION) {
+	if (!dmapi_ctx) {
+		return true;
+	}
+	if (dmapi_ctx->session != DM_NO_SESSION) {
 		become_root();
-		if (0 == dm_destroy_session(samba_dmapi_session)) {
-			session_num--;
-			samba_dmapi_session = DM_NO_SESSION;
+		if (0 == dm_destroy_session(dmapi_ctx->session)) {
+			dmapi_ctx->session_num--;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list