[SCM] Samba Shared Repository - branch v3-2-test updated - initial-v3-2-unstable-570-gf98082c

Volker Lendecke vl at samba.org
Mon Dec 10 11:19:07 GMT 2007


The branch, v3-2-test has been updated
       via  f98082ccf048a2de6fea8d922264879305b3d2c8 (commit)
       via  4e6df5547167fc235971498cb296a5f74dec8b8b (commit)
       via  49f06a2fa70e469bcb5fe17852af011dac32994b (commit)
       via  874258195278bc8c6bb3011c153c5d646fff9e75 (commit)
       via  2f3c865707010bc7c463a02782dbee3dc2479da1 (commit)
       via  1f317f471af72f8bbc6c9fdd3e79a27c59e6fb6e (commit)
       via  8ee502e1e59960fd8db037f0adf1171b2a18cec5 (commit)
       via  0006b14d38b80562458b37f616c9b68a3168fe64 (commit)
      from  677ac6adc38b0747f825ee597e0502277a8f74b1 (commit)

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


- Log -----------------------------------------------------------------
commit f98082ccf048a2de6fea8d922264879305b3d2c8
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Dec 9 19:03:49 2007 +0100

    Simplify add_session_user

commit 4e6df5547167fc235971498cb296a5f74dec8b8b
Author: Volker Lendecke <vl at sernet.de>
Date:   Fri Dec 7 10:45:33 2007 +0100

    Increase debug level

commit 49f06a2fa70e469bcb5fe17852af011dac32994b
Author: Volker Lendecke <vl at sernet.de>
Date:   Wed Dec 5 21:09:57 2007 +0100

    Move stuff from data to text

commit 874258195278bc8c6bb3011c153c5d646fff9e75
Author: Volker Lendecke <vl at sernet.de>
Date:   Wed Dec 5 20:58:25 2007 +0100

    int->bool

commit 2f3c865707010bc7c463a02782dbee3dc2479da1
Author: Volker Lendecke <vl at sernet.de>
Date:   Wed Dec 5 20:53:22 2007 +0100

    Tiny simplifications
    
    locking.c:open_read_only was unused
    
    don't export the silly boolean flag locking_init(bool read_only)

commit 1f317f471af72f8bbc6c9fdd3e79a27c59e6fb6e
Author: Volker Lendecke <vl at sernet.de>
Date:   Wed Dec 5 20:41:24 2007 +0100

    Remove a static

commit 8ee502e1e59960fd8db037f0adf1171b2a18cec5
Author: Volker Lendecke <vl at sernet.de>
Date:   Wed Dec 5 20:30:53 2007 +0100

    Remove two statics

commit 0006b14d38b80562458b37f616c9b68a3168fe64
Author: Volker Lendecke <vl at sernet.de>
Date:   Wed Dec 5 18:46:53 2007 +0100

    remove a static

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

Summary of changes:
 source/locking/brlock.c    |    7 +----
 source/locking/locking.c   |   44 +++++++++++++++++----------------
 source/locking/posix.c     |   58 +++++++++++++------------------------------
 source/printing/printing.c |   32 ++++++++++++++----------
 source/smbd/dfree.c        |    4 +-
 source/smbd/mangle_hash.c  |    4 +-
 source/smbd/open.c         |    2 +-
 source/smbd/password.c     |   58 +++++++++++++++++++-------------------------
 source/smbd/server.c       |    2 +-
 source/torture/locktest2.c |    2 +-
 source/utils/status.c      |    2 +-
 source/web/statuspage.c    |    2 +-
 12 files changed, 96 insertions(+), 121 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/locking/brlock.c b/source/locking/brlock.c
index f821761..eb42d08 100644
--- a/source/locking/brlock.c
+++ b/source/locking/brlock.c
@@ -258,7 +258,7 @@ static NTSTATUS brl_lock_failed(files_struct *fsp, const struct lock_struct *loc
  Open up the brlock.tdb database.
 ****************************************************************************/
 
-void brl_init(int read_only)
+void brl_init(bool read_only)
 {
 	if (brlock_db) {
 		return;
@@ -279,11 +279,8 @@ void brl_init(int read_only)
  Close down the brlock.tdb database.
 ****************************************************************************/
 
-void brl_shutdown(int read_only)
+void brl_shutdown(void)
 {
-	if (!brlock_db) {
-		return;
-	}
 	TALLOC_FREE(brlock_db);
 }
 
diff --git a/source/locking/locking.c b/source/locking/locking.c
index eb7531d..dab21e5 100644
--- a/source/locking/locking.c
+++ b/source/locking/locking.c
@@ -385,9 +385,7 @@ void locking_close_file(struct messaging_context *msg_ctx,
  Initialise the locking functions.
 ****************************************************************************/
 
-static int open_read_only;
-
-bool locking_init(int read_only)
+static bool locking_init_internal(bool read_only)
 {
 	brl_init(read_only);
 
@@ -408,36 +406,38 @@ bool locking_init(int read_only)
 	if (!posix_locking_init(read_only))
 		return False;
 
-	open_read_only = read_only;
-
 	return True;
 }
 
+bool locking_init(void)
+{
+	return locking_init_internal(false);
+}
+
+bool locking_init_readonly(void)
+{
+	return locking_init_internal(true);
+}
+
 /*******************************************************************
  Deinitialize the share_mode management.
 ******************************************************************/
 
 bool locking_end(void)
 {
-	brl_shutdown(open_read_only);
-	if (lock_db) {
-		TALLOC_FREE(lock_db);
-	}
-	return True;
+	brl_shutdown();
+	TALLOC_FREE(lock_db);
+	return true;
 }
 
 /*******************************************************************
  Form a static locking key for a dev/inode pair.
 ******************************************************************/
 
-static TDB_DATA locking_key(struct file_id id)
+static TDB_DATA locking_key(const struct file_id *id, struct file_id *tmp)
 {
-	static struct file_id key;	
-	TDB_DATA kbuf;
-	key = id;
-	kbuf.dptr = (uint8 *)&key;
-	kbuf.dsize = sizeof(key);
-	return kbuf;
+	*tmp = *id;
+	return make_tdb_data((const uint8_t *)tmp, sizeof(*tmp));
 }
 
 /*******************************************************************
@@ -783,12 +783,13 @@ static bool fill_share_mode_lock(struct share_mode_lock *lck,
 }
 
 struct share_mode_lock *get_share_mode_lock(TALLOC_CTX *mem_ctx,
-					    struct file_id id,
+					    const struct file_id id,
 					    const char *servicepath,
 					    const char *fname)
 {
 	struct share_mode_lock *lck;
-	TDB_DATA key = locking_key(id);
+	struct file_id tmp;
+	TDB_DATA key = locking_key(&id, &tmp);
 
 	if (!(lck = TALLOC_P(mem_ctx, struct share_mode_lock))) {
 		DEBUG(0, ("talloc failed\n"));
@@ -814,12 +815,13 @@ struct share_mode_lock *get_share_mode_lock(TALLOC_CTX *mem_ctx,
 }
 
 struct share_mode_lock *fetch_share_mode_unlocked(TALLOC_CTX *mem_ctx,
-						  struct file_id id,
+						  const struct file_id id,
 						  const char *servicepath,
 						  const char *fname)
 {
 	struct share_mode_lock *lck;
-	TDB_DATA key = locking_key(id);
+	struct file_id tmp;
+	TDB_DATA key = locking_key(&id, &tmp);
 	TDB_DATA data;
 
 	if (!(lck = TALLOC_P(mem_ctx, struct share_mode_lock))) {
diff --git a/source/locking/posix.c b/source/locking/posix.c
index 37cfa04..4b0b91b 100644
--- a/source/locking/posix.c
+++ b/source/locking/posix.c
@@ -322,34 +322,16 @@ struct lock_ref_count_key {
 }; 
 
 /*******************************************************************
- Form a static locking key for a dev/inode pair for the fd array.
-******************************************************************/
-
-static TDB_DATA fd_array_key(struct file_id id)
-{
-	static struct file_id key;
-	TDB_DATA kbuf;
-	key = id;
-	kbuf.dptr = (uint8 *)&key;
-	kbuf.dsize = sizeof(key);
-	return kbuf;
-}
-
-/*******************************************************************
  Form a static locking key for a dev/inode pair for the lock ref count
 ******************************************************************/
 
-static TDB_DATA locking_ref_count_key(struct file_id id)
+static TDB_DATA locking_ref_count_key_fsp(files_struct *fsp,
+					  struct lock_ref_count_key *tmp)
 {
-	static struct lock_ref_count_key key;
-	TDB_DATA kbuf;
-
-	memset(&key, '\0', sizeof(key));
-	key.id = id;
-	key.r = 'r';
-	kbuf.dptr = (uint8 *)&key;
-	kbuf.dsize = sizeof(key);
-	return kbuf;
+	ZERO_STRUCTP(tmp);
+	tmp->id = fsp->file_id;
+	tmp->r = 'r';
+	return make_tdb_data((uint8_t *)tmp, sizeof(*tmp));
 }
 
 /*******************************************************************
@@ -358,23 +340,14 @@ static TDB_DATA locking_ref_count_key(struct file_id id)
 
 static TDB_DATA fd_array_key_fsp(files_struct *fsp)
 {
-	return fd_array_key(fsp->file_id);
-}
-
-/*******************************************************************
- Convenience function to get a lock ref count key from an fsp.
-******************************************************************/
-
-static TDB_DATA locking_ref_count_key_fsp(files_struct *fsp)
-{
-	return locking_ref_count_key(fsp->file_id);
+	return make_tdb_data((uint8 *)&fsp->file_id, sizeof(fsp->file_id));
 }
 
 /*******************************************************************
  Create the in-memory POSIX lock databases.
 ********************************************************************/
 
-bool posix_locking_init(int read_only)
+bool posix_locking_init(bool read_only)
 {
 	if (posix_pending_close_tdb) {
 		return True;
@@ -425,7 +398,8 @@ bool posix_locking_end(void)
 
 static void increment_windows_lock_ref_count(files_struct *fsp)
 {
-	TDB_DATA kbuf = locking_ref_count_key_fsp(fsp);
+	struct lock_ref_count_key tmp;
+	TDB_DATA kbuf = locking_ref_count_key_fsp(fsp, &tmp);
 	TDB_DATA dbuf;
 	int lock_ref_count;
 
@@ -454,7 +428,8 @@ static void increment_windows_lock_ref_count(files_struct *fsp)
 
 static void decrement_windows_lock_ref_count(files_struct *fsp)
 {
-	TDB_DATA kbuf = locking_ref_count_key_fsp(fsp);
+	struct lock_ref_count_key tmp;
+	TDB_DATA kbuf = locking_ref_count_key_fsp(fsp, &tmp);
 	TDB_DATA dbuf;
 	int lock_ref_count;
 
@@ -486,7 +461,8 @@ static void decrement_windows_lock_ref_count(files_struct *fsp)
 
 void reduce_windows_lock_ref_count(files_struct *fsp, unsigned int dcount)
 {
-	TDB_DATA kbuf = locking_ref_count_key_fsp(fsp);
+	struct lock_ref_count_key tmp;
+	TDB_DATA kbuf = locking_ref_count_key_fsp(fsp, &tmp);
 	TDB_DATA dbuf;
 	int lock_ref_count;
 
@@ -518,7 +494,8 @@ void reduce_windows_lock_ref_count(files_struct *fsp, unsigned int dcount)
 
 static int get_windows_lock_ref_count(files_struct *fsp)
 {
-	TDB_DATA kbuf = locking_ref_count_key_fsp(fsp);
+	struct lock_ref_count_key tmp;
+	TDB_DATA kbuf = locking_ref_count_key_fsp(fsp, &tmp);
 	TDB_DATA dbuf;
 	int lock_ref_count;
 
@@ -541,7 +518,8 @@ static int get_windows_lock_ref_count(files_struct *fsp)
 
 static void delete_windows_lock_ref_count(files_struct *fsp)
 {
-	TDB_DATA kbuf = locking_ref_count_key_fsp(fsp);
+	struct lock_ref_count_key tmp;
+	TDB_DATA kbuf = locking_ref_count_key_fsp(fsp, &tmp);
 
 	/* Not a bug if it doesn't exist - no locks were ever granted. */
 	tdb_delete(posix_pending_close_tdb, kbuf);
diff --git a/source/printing/printing.c b/source/printing/printing.c
index 1613828..fa6ed89 100644
--- a/source/printing/printing.c
+++ b/source/printing/printing.c
@@ -264,14 +264,13 @@ static struct printif *get_printer_fns( int snum )
  Useful function to generate a tdb key.
 ****************************************************************************/
 
-static TDB_DATA print_key(uint32 jobid)
+static TDB_DATA print_key(uint32 jobid, uint32 *tmp)
 {
-	static uint32 j;
 	TDB_DATA ret;
 
-	SIVAL(&j, 0, jobid);
-	ret.dptr = (uint8 *)&j;
-	ret.dsize = sizeof(j);
+	SIVAL(tmp, 0, jobid);
+	ret.dptr = (uint8 *)tmp;
+	ret.dsize = sizeof(*tmp);
 	return ret;
 }
 
@@ -333,6 +332,7 @@ int unpack_pjob( uint8 *buf, int buflen, struct printjob *pjob )
 static struct printjob *print_job_find(const char *sharename, uint32 jobid)
 {
 	static struct printjob 	pjob;
+	uint32_t tmp;
 	TDB_DATA 		ret;
 	struct tdb_print_db 	*pdb = get_print_db_byname(sharename);
 	
@@ -343,7 +343,7 @@ static struct printjob *print_job_find(const char *sharename, uint32 jobid)
 		return NULL;
 	}
 
-	ret = tdb_fetch(pdb->tdb, print_key(jobid));
+	ret = tdb_fetch(pdb->tdb, print_key(jobid, &tmp));
 	release_print_db(pdb);
 
 	if (!ret.dptr) {
@@ -430,7 +430,7 @@ uint32 sysjob_to_jobid(int unix_jobid)
  Send notifications based on what has changed after a pjob_store.
 ****************************************************************************/
 
-static struct {
+static const struct {
 	uint32 lpq_status;
 	uint32 spoolss_status;
 } lpq_to_spoolss_status_map[] = {
@@ -512,6 +512,7 @@ static void pjob_store_notify(const char* sharename, uint32 jobid, struct printj
 
 static bool pjob_store(const char* sharename, uint32 jobid, struct printjob *pjob)
 {
+	uint32_t tmp;
 	TDB_DATA 		old_data, new_data;
 	bool 			ret = False;
 	struct tdb_print_db 	*pdb = get_print_db_byname(sharename);
@@ -524,7 +525,7 @@ static bool pjob_store(const char* sharename, uint32 jobid, struct printjob *pjo
 
 	/* Get old data */
 
-	old_data = tdb_fetch(pdb->tdb, print_key(jobid));
+	old_data = tdb_fetch(pdb->tdb, print_key(jobid, &tmp));
 
 	/* Doh!  Now we have to pack/unpack data since the NT_DEVICEMODE was added */
 
@@ -565,7 +566,8 @@ static bool pjob_store(const char* sharename, uint32 jobid, struct printjob *pjo
 
 	new_data.dptr = buf;
 	new_data.dsize = len;
-	ret = (tdb_store(pdb->tdb, print_key(jobid), new_data, TDB_REPLACE) == 0);
+	ret = (tdb_store(pdb->tdb, print_key(jobid, &tmp), new_data,
+			 TDB_REPLACE) == 0);
 
 	release_print_db(pdb);
 
@@ -601,6 +603,7 @@ done:
 
 void pjob_delete(const char* sharename, uint32 jobid)
 {
+	uint32_t tmp;
 	struct printjob *pjob;
 	uint32 job_status = 0;
 	struct tdb_print_db *pdb;
@@ -628,7 +631,7 @@ void pjob_delete(const char* sharename, uint32 jobid)
 	
 	/* Remove from printing.tdb */
 
-	tdb_delete(pdb->tdb, print_key(jobid));
+	tdb_delete(pdb->tdb, print_key(jobid, &tmp));
 	remove_from_jobs_changed(sharename, jobid);
 	release_print_db( pdb );
 	rap_jobid_delete(sharename, jobid);
@@ -1400,7 +1403,7 @@ void start_background_queue(void)
 		claim_connection( NULL, "smbd lpq backend",
 			FLAG_MSG_GENERAL|FLAG_MSG_SMBD|FLAG_MSG_PRINT_GENERAL);
 
-		if (!locking_init(0)) {
+		if (!locking_init()) {
 			exit(1);
 		}
 
@@ -1758,10 +1761,11 @@ bool print_job_exists(const char* sharename, uint32 jobid)
 {
 	struct tdb_print_db *pdb = get_print_db_byname(sharename);
 	bool ret;
+	uint32_t tmp;
 
 	if (!pdb)
 		return False;
-	ret = tdb_exists(pdb->tdb, print_key(jobid));
+	ret = tdb_exists(pdb->tdb, print_key(jobid, &tmp));
 	release_print_db(pdb);
 	return ret;
 }
@@ -2302,10 +2306,12 @@ static bool allocate_print_jobid(struct tdb_print_db *pdb, int snum, const char
 
 	/* Store a dummy placeholder. */
 	{
+		uint32_t tmp;
 		TDB_DATA dum;
 		dum.dptr = NULL;
 		dum.dsize = 0;
-		if (tdb_store(pdb->tdb, print_key(jobid), dum, TDB_INSERT) == -1) {
+		if (tdb_store(pdb->tdb, print_key(jobid, &tmp), dum,
+			      TDB_INSERT) == -1) {
 			DEBUG(3, ("allocate_print_jobid: jobid (%d) failed to store placeholder.\n",
 				jobid ));
 			return False;
diff --git a/source/smbd/dfree.c b/source/smbd/dfree.c
index 31eb9fb..9e7f18a 100644
--- a/source/smbd/dfree.c
+++ b/source/smbd/dfree.c
@@ -150,10 +150,10 @@ SMB_BIG_UINT sys_disk_free(connection_struct *conn, const char *path, bool small
 	}
 
 	if ((*dsize)<1) {
-		static int done;
+		static bool done = false;
 		if (!done) {
 			DEBUG(0,("WARNING: dfree is broken on this system\n"));
-			done=1;
+			done=true;
 		}
 		*dsize = 20*1024*1024/(*bsize);
 		*dfree = MAX(1,*dfree);
diff --git a/source/smbd/mangle_hash.c b/source/smbd/mangle_hash.c
index 44fbe8a..c369f6e 100644
--- a/source/smbd/mangle_hash.c
+++ b/source/smbd/mangle_hash.c
@@ -52,9 +52,9 @@
  *
  */
 
-char magic_char = '~';
+static char magic_char = '~';
 
-static char basechars[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_-!@#$%";
+static const char basechars[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_-!@#$%";
 #define MANGLE_BASE       (sizeof(basechars)/sizeof(char)-1)
 
 static unsigned char chartest[256]  = { 0 };
diff --git a/source/smbd/open.c b/source/smbd/open.c
index b156dbb..0e73ba9 100644
--- a/source/smbd/open.c
+++ b/source/smbd/open.c
@@ -2102,7 +2102,7 @@ NTSTATUS open_directory(connection_struct *conn,
 		 (unsigned int)file_attributes));
 
 	if (is_ntfs_stream_name(fname)) {
-		DEBUG(0,("open_directory: %s is a stream name!\n", fname ));
+		DEBUG(2, ("open_directory: %s is a stream name!\n", fname));
 		return NT_STATUS_NOT_A_DIRECTORY;
 	}
 
diff --git a/source/smbd/password.c b/source/smbd/password.c
index 75f05de..b3005ba 100644
--- a/source/smbd/password.c
+++ b/source/smbd/password.c
@@ -22,7 +22,6 @@
 
 /* users from session setup */
 static char *session_userlist = NULL;
-static int len_session_userlist = 0;
 /* workgroup from session setup. */
 static char *session_workgroup = NULL;
 
@@ -383,46 +382,39 @@ int register_existing_vuid(uint16 vuid,
 
 void add_session_user(const char *user)
 {
-	fstring suser;
-	struct passwd *passwd;
+	struct passwd *pw;
+	char *tmp;
 
-	if (!(passwd = Get_Pwnam(user)))
-		return;
-
-	fstrcpy(suser,passwd->pw_name);
+	pw = Get_Pwnam_alloc(talloc_tos(), user);
 
-	if(!*suser)
+	if (pw == NULL) {
 		return;
+	}
 
-	if( session_userlist && in_list(suser,session_userlist,False) )
-		return;
+	if (session_userlist == NULL) {
+		session_userlist = SMB_STRDUP(pw->pw_name);
+		goto done;
+	}
 
-	if( !session_userlist ||
-	    (strlen(suser) + strlen(session_userlist) + 2 >=
-	     len_session_userlist) ) {
-		char *newlist;
+	if (in_list(pw->pw_name,session_userlist,False) ) {
+		goto done;
+	}
 
-		if (len_session_userlist > 128 * 1024) {
-			DEBUG(3,("add_session_user: session userlist already "
-				 "too large.\n"));
-			return;
-		}
-		newlist = (char *)SMB_REALLOC_KEEP_OLD_ON_ERROR(
-			session_userlist,
-			len_session_userlist + 1024 );
-		if( newlist == NULL ) {
-			DEBUG(1,("Unable to resize session_userlist\n"));
-			return;
-		}
-		if (!session_userlist) {
-			*newlist = '\0';
-		}
-		session_userlist = newlist;
-		len_session_userlist += 1024;
+	if (strlen(session_userlist) > 128 * 1024) {
+		DEBUG(3,("add_session_user: session userlist already "
+			 "too large.\n"));
+		goto done;
+	}
+
+	if (asprintf(&tmp, "%s %s", session_userlist, pw->pw_name) == -1) {
+		DEBUG(3, ("asprintf failed\n"));
+		goto done;
 	}
 
-	safe_strcat(session_userlist," ",len_session_userlist-1);
-	safe_strcat(session_userlist,suser,len_session_userlist-1);
+	SAFE_FREE(session_userlist);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list