[SCM] Samba Shared Repository - branch v3-2-test updated -
initial-v3-2-unstable-935-gfada689
Volker Lendecke
vl at samba.org
Fri Dec 28 21:40:18 GMT 2007
The branch, v3-2-test has been updated
via fada689893314bed2fc78588b3fd9b144f4c808a (commit)
via 515f6a8cff7e28b0e98136f3214ef52512cfaf37 (commit)
via 069cd6d63a61065be7926230235e198c456d38ae (commit)
via dbcc213710a9af31b6094d4741a6f68f573dcdad (commit)
via 44775ea38bc320ac8e2208769a8cde2c6f44f640 (commit)
via 476d3abf9c6142d99822212141fc3d843aca4798 (commit)
via fed8f2abd704d1993146ad462d81f69367537cfb (commit)
from 4260c79bf7687bd2ebcc4ca5e0a5f020a759c1fb (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test
- Log -----------------------------------------------------------------
commit fada689893314bed2fc78588b3fd9b144f4c808a
Author: Volker Lendecke <vl at samba.org>
Date: Fri Dec 28 17:24:39 2007 +0100
Convert get_root_nt_token to memcache
commit 515f6a8cff7e28b0e98136f3214ef52512cfaf37
Author: Volker Lendecke <vl at samba.org>
Date: Fri Dec 28 17:16:35 2007 +0100
Remove a global
commit 069cd6d63a61065be7926230235e198c456d38ae
Author: Volker Lendecke <vl at samba.org>
Date: Fri Dec 28 17:09:57 2007 +0100
don't store cache_readonly in gencache
tdb won't allow us to write anyway
commit dbcc213710a9af31b6094d4741a6f68f573dcdad
Author: Volker Lendecke <vl at samba.org>
Date: Fri Dec 28 17:02:34 2007 +0100
Remove static zeros
commit 44775ea38bc320ac8e2208769a8cde2c6f44f640
Author: Volker Lendecke <vl at samba.org>
Date: Fri Dec 28 17:02:07 2007 +0100
Remove a static array
This might be worth it, mangle_hash is hardly used these days
commit 476d3abf9c6142d99822212141fc3d843aca4798
Author: Volker Lendecke <vl at samba.org>
Date: Fri Dec 28 13:13:29 2007 +0100
Convert csamuser to memcache
commit fed8f2abd704d1993146ad462d81f69367537cfb
Author: Volker Lendecke <vl at samba.org>
Date: Sat Dec 22 12:02:33 2007 +0100
bin/vlp needs a dependency on @LIBWBCLIENT_SHARED@
This failed to link if you compile with -j.
-----------------------------------------------------------------------
Summary of changes:
source/Makefile.in | 2 +-
source/auth/auth_util.c | 9 ++++--
source/auth/token_util.c | 18 ++++++++++--
source/include/memcache.h | 2 +
source/lib/gencache.c | 15 ----------
source/lib/memcache.c | 2 +
source/libsmb/ntlm_check.c | 5 +++-
source/libsmb/ntlmssp.c | 7 +++-
source/passdb/pdb_interface.c | 53 ++++++++++++++++++-------------------
source/printing/printing.c | 24 ++++++++++------
source/rpc_client/cli_netlogon.c | 10 ++++---
source/rpc_parse/parse_prs.c | 14 +++++++---
source/smbd/mangle_hash.c | 12 ++++----
13 files changed, 98 insertions(+), 75 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source/Makefile.in b/source/Makefile.in
index 9d8ad3e..01f2988 100644
--- a/source/Makefile.in
+++ b/source/Makefile.in
@@ -1531,7 +1531,7 @@ bin/winbindd at EXEEXT@: $(BINARY_PREREQS) $(WINBINDD_OBJ) @BUILD_POPT@ @LIBWBCLIEN
@POPTLIBS@ $(KRB5LIBS) $(LDAP_LIBS) $(PASSDB_LIBS) \
@WINBIND_LIBS@
-bin/vlp at EXEEXT@: $(BINARY_PREREQS) $(VLP_OBJ)
+bin/vlp at EXEEXT@: $(BINARY_PREREQS) $(VLP_OBJ) @LIBWBCLIENT_SHARED@
@echo "Linking $@"
@$(CC) $(FLAGS) -o $@ $(VLP_OBJ) $(LDFLAGS) $(DYNEXP) $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) @POPTLIBS@ \
$(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) @LIBWBCLIENT_SHARED@
diff --git a/source/auth/auth_util.c b/source/auth/auth_util.c
index 3f65e6b..fea1b2d 100644
--- a/source/auth/auth_util.c
+++ b/source/auth/auth_util.c
@@ -1103,7 +1103,7 @@ static NTSTATUS make_new_server_info_guest(auth_serversupplied_info **server_inf
struct samu *sampass = NULL;
DOM_SID guest_sid;
bool ret;
- static const char zeros[16] = { 0, };
+ char zeros[16];
if ( !(sampass = samu_new( NULL )) ) {
return NT_STATUS_NO_MEMORY;
@@ -1138,6 +1138,7 @@ static NTSTATUS make_new_server_info_guest(auth_serversupplied_info **server_inf
/* annoying, but the Guest really does have a session key, and it is
all zeros! */
+ ZERO_STRUCT(zeros);
(*server_info)->user_session_key = data_blob(zeros, sizeof(zeros));
(*server_info)->lm_session_key = data_blob(zeros, sizeof(zeros));
@@ -1420,7 +1421,7 @@ NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx,
auth_serversupplied_info **server_info,
NET_USER_INFO_3 *info3)
{
- static const char zeros[16] = { 0, };
+ char zeros[16];
NTSTATUS nt_status = NT_STATUS_OK;
char *found_username = NULL;
@@ -1624,7 +1625,9 @@ NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx,
&(info3->uni_logon_srv));
/* ensure we are never given NULL session keys */
-
+
+ ZERO_STRUCT(zeros);
+
if (memcmp(info3->user_sess_key, zeros, sizeof(zeros)) == 0) {
result->user_session_key = data_blob_null;
} else {
diff --git a/source/auth/token_util.c b/source/auth/token_util.c
index 27c98c9..a1b4edf 100644
--- a/source/auth/token_util.c
+++ b/source/auth/token_util.c
@@ -77,12 +77,19 @@ bool nt_token_check_domain_rid( NT_USER_TOKEN *token, uint32 rid )
NT_USER_TOKEN *get_root_nt_token( void )
{
- static NT_USER_TOKEN *token = NULL;
+ struct nt_user_token *token = NULL;
DOM_SID u_sid, g_sid;
struct passwd *pw;
+ void *cache_data;
- if ( token )
- return token;
+ cache_data = memcache_lookup_talloc(
+ NULL, SINGLETON_CACHE_TALLOC,
+ data_blob_string_const("root_nt_token"));
+
+ if (cache_data != NULL) {
+ return talloc_get_type_abort(
+ cache_data, struct nt_user_token);
+ }
if ( !(pw = sys_getpwnam( "root" )) ) {
DEBUG(0,("get_root_nt_token: getpwnam(\"root\") failed!\n"));
@@ -97,6 +104,11 @@ NT_USER_TOKEN *get_root_nt_token( void )
token = create_local_nt_token(NULL, &u_sid, False,
1, &global_sid_Builtin_Administrators);
+
+ memcache_add_talloc(
+ NULL, SINGLETON_CACHE_TALLOC,
+ data_blob_string_const("root_nt_token"), token);
+
return token;
}
diff --git a/source/include/memcache.h b/source/include/memcache.h
index c4a2974..5a0ce63 100644
--- a/source/include/memcache.h
+++ b/source/include/memcache.h
@@ -33,6 +33,8 @@ enum memcache_number {
GETWD_CACHE,
GETPWNAM_CACHE, /* talloc */
MANGLE_HASH2_CACHE,
+ PDB_GETPWSID_CACHE, /* talloc */
+ SINGLETON_CACHE_TALLOC, /* talloc */
SINGLETON_CACHE
};
diff --git a/source/lib/gencache.c b/source/lib/gencache.c
index a50e5d0..663385c 100644
--- a/source/lib/gencache.c
+++ b/source/lib/gencache.c
@@ -32,7 +32,6 @@
#define BLOB_TYPE_LEN 9
static TDB_CONTEXT *cache;
-static bool cache_readonly;
/**
* @file gencache.c
@@ -67,7 +66,6 @@ bool gencache_init(void)
if (!cache && (errno == EACCES)) {
cache = tdb_open_log(cache_fname, 0, TDB_DEFAULT, O_RDONLY, 0644);
if (cache) {
- cache_readonly = True;
DEBUG(5, ("gencache_init: Opening cache file %s read-only.\n", cache_fname));
}
}
@@ -95,7 +93,6 @@ bool gencache_shutdown(void)
DEBUG(5, ("Closing cache file\n"));
ret = tdb_close(cache);
cache = NULL;
- cache_readonly = False;
return ret != -1;
}
@@ -123,10 +120,6 @@ bool gencache_set(const char *keystr, const char *value, time_t timeout)
if (!gencache_init()) return False;
- if (cache_readonly) {
- return False;
- }
-
asprintf(&valstr, CACHE_DATA_FMT, (int)timeout, value);
if (!valstr)
return False;
@@ -161,10 +154,6 @@ bool gencache_del(const char *keystr)
if (!gencache_init()) return False;
- if (cache_readonly) {
- return False;
- }
-
DEBUG(10, ("Deleting cache entry (key = %s)\n", keystr));
ret = tdb_delete_bystring(cache, keystr);
@@ -351,10 +340,6 @@ bool gencache_set_data_blob(const char *keystr, DATA_BLOB *blob, time_t timeout)
return False;
}
- if (cache_readonly) {
- return False;
- }
-
asprintf(&valstr, "%12u/%s", (int)timeout, BLOB_TYPE);
if (!valstr) {
return False;
diff --git a/source/lib/memcache.c b/source/lib/memcache.c
index 457586b..6dee61a 100644
--- a/source/lib/memcache.c
+++ b/source/lib/memcache.c
@@ -46,6 +46,8 @@ static bool memcache_is_talloc(enum memcache_number n)
switch (n) {
case GETPWNAM_CACHE:
+ case PDB_GETPWSID_CACHE:
+ case SINGLETON_CACHE_TALLOC:
result = true;
break;
default:
diff --git a/source/libsmb/ntlm_check.c b/source/libsmb/ntlm_check.c
index f8ed044..ae10d73 100644
--- a/source/libsmb/ntlm_check.c
+++ b/source/libsmb/ntlm_check.c
@@ -182,7 +182,10 @@ NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
DATA_BLOB *user_sess_key,
DATA_BLOB *lm_sess_key)
{
- static const unsigned char zeros[8] = { 0, };
+ unsigned char zeros[8];
+
+ ZERO_STRUCT(zeros);
+
if (nt_pw == NULL) {
DEBUG(3,("ntlm_password_check: NO NT password stored for user %s.\n",
username));
diff --git a/source/libsmb/ntlmssp.c b/source/libsmb/ntlmssp.c
index ed08e81..35c20ed 100644
--- a/source/libsmb/ntlmssp.c
+++ b/source/libsmb/ntlmssp.c
@@ -823,7 +823,8 @@ static NTSTATUS ntlmssp_server_auth(struct ntlmssp_state *ntlmssp_state,
session_key.data);
DEBUG(10,("ntlmssp_server_auth: Created NTLM session key.\n"));
} else {
- static const uint8 zeros[24] = { 0, };
+ uint8 zeros[24];
+ ZERO_STRUCT(zeros);
session_key = data_blob_talloc(
ntlmssp_state->mem_ctx, NULL, 16);
if (session_key.data == NULL) {
@@ -1066,9 +1067,11 @@ static NTSTATUS ntlmssp_client_challenge(struct ntlmssp_state *ntlmssp_state,
}
if (!ntlmssp_state->nt_hash || !ntlmssp_state->lm_hash) {
- static const uchar zeros[16] = { 0, };
+ uchar zeros[16];
/* do nothing - blobs are zero length */
+ ZERO_STRUCT(zeros);
+
/* session key is all zeros */
session_key = data_blob_talloc(ntlmssp_state->mem_ctx, zeros, 16);
diff --git a/source/passdb/pdb_interface.c b/source/passdb/pdb_interface.c
index 2102b57..0ab45ba 100644
--- a/source/passdb/pdb_interface.c
+++ b/source/passdb/pdb_interface.c
@@ -25,10 +25,6 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_PASSDB
-/* Cache of latest SAM lookup query */
-
-static struct samu *csamuser = NULL;
-
static_decl_pdb;
static struct pdb_init_function_entry *backends = NULL;
@@ -211,25 +207,29 @@ static struct pdb_methods *pdb_get_methods(void)
bool pdb_getsampwnam(struct samu *sam_acct, const char *username)
{
struct pdb_methods *pdb = pdb_get_methods();
+ struct samu *cache_copy;
+ const struct dom_sid *user_sid;
if (!NT_STATUS_IS_OK(pdb->getsampwnam(pdb, sam_acct, username))) {
return False;
}
- if ( csamuser ) {
- TALLOC_FREE(csamuser);
- }
-
- csamuser = samu_new( NULL );
- if (!csamuser) {
+ cache_copy = samu_new(NULL);
+ if (cache_copy == NULL) {
return False;
}
- if (!pdb_copy_sam_account(csamuser, sam_acct)) {
- TALLOC_FREE(csamuser);
+ if (!pdb_copy_sam_account(cache_copy, sam_acct)) {
+ TALLOC_FREE(cache_copy);
return False;
}
+ user_sid = pdb_get_user_sid(cache_copy);
+
+ memcache_add_talloc(NULL, PDB_GETPWSID_CACHE,
+ data_blob_const(user_sid, sizeof(*user_sid)),
+ cache_copy);
+
return True;
}
@@ -262,6 +262,7 @@ bool pdb_getsampwsid(struct samu *sam_acct, const DOM_SID *sid)
{
struct pdb_methods *pdb = pdb_get_methods();
uint32 rid;
+ void *cache_data;
/* hard code the Guest RID of 501 */
@@ -274,9 +275,16 @@ bool pdb_getsampwsid(struct samu *sam_acct, const DOM_SID *sid)
}
/* check the cache first */
-
- if ( csamuser && sid_equal(sid, pdb_get_user_sid(csamuser) ) )
- return pdb_copy_sam_account(sam_acct, csamuser);
+
+ cache_data = memcache_lookup_talloc(
+ NULL, PDB_GETPWSID_CACHE, data_blob_const(sid, sizeof(*sid)));
+
+ if (cache_data != NULL) {
+ struct samu *cache_copy = talloc_get_type_abort(
+ cache_data, struct samu);
+
+ return pdb_copy_sam_account(sam_acct, cache_copy);
+ }
return NT_STATUS_IS_OK(pdb->getsampwsid(pdb, sam_acct, sid));
}
@@ -471,10 +479,7 @@ NTSTATUS pdb_update_sam_account(struct samu *sam_acct)
{
struct pdb_methods *pdb = pdb_get_methods();
- if (csamuser != NULL) {
- TALLOC_FREE(csamuser);
- csamuser = NULL;
- }
+ memcache_flush(NULL, PDB_GETPWSID_CACHE);
return pdb->update_sam_account(pdb, sam_acct);
}
@@ -483,10 +488,7 @@ NTSTATUS pdb_delete_sam_account(struct samu *sam_acct)
{
struct pdb_methods *pdb = pdb_get_methods();
- if (csamuser != NULL) {
- TALLOC_FREE(csamuser);
- csamuser = NULL;
- }
+ memcache_flush(NULL, PDB_GETPWSID_CACHE);
return pdb->delete_sam_account(pdb, sam_acct);
}
@@ -497,10 +499,7 @@ NTSTATUS pdb_rename_sam_account(struct samu *oldname, const char *newname)
uid_t uid;
NTSTATUS status;
- if (csamuser != NULL) {
- TALLOC_FREE(csamuser);
- csamuser = NULL;
- }
+ memcache_flush(NULL, PDB_GETPWSID_CACHE);
/* sanity check to make sure we don't rename root */
diff --git a/source/printing/printing.c b/source/printing/printing.c
index fa6ed89..9f2c086 100644
--- a/source/printing/printing.c
+++ b/source/printing/printing.c
@@ -373,13 +373,17 @@ static struct printjob *print_job_find(const char *sharename, uint32 jobid)
/* Convert a unix jobid to a smb jobid */
-static uint32 sysjob_to_jobid_value;
+struct unixjob_traverse_state {
+ int sysjob;
+ uint32 sysjob_to_jobid_value;
+};
static int unixjob_traverse_fn(TDB_CONTEXT *the_tdb, TDB_DATA key,
- TDB_DATA data, void *state)
+ TDB_DATA data, void *private_data)
{
struct printjob *pjob;
- int *sysjob = (int *)state;
+ struct unixjob_traverse_state *state =
+ (struct unixjob_traverse_state *)private_data;
if (!data.dptr || data.dsize == 0)
return 0;
@@ -388,10 +392,10 @@ static int unixjob_traverse_fn(TDB_CONTEXT *the_tdb, TDB_DATA key,
if (key.dsize != sizeof(uint32))
return 0;
- if (*sysjob == pjob->sysjob) {
+ if (state->sysjob == pjob->sysjob) {
uint32 jobid = IVAL(key.dptr,0);
- sysjob_to_jobid_value = jobid;
+ state->sysjob_to_jobid_value = jobid;
return 1;
}
@@ -407,8 +411,10 @@ uint32 sysjob_to_jobid(int unix_jobid)
{
int services = lp_numservices();
int snum;
+ struct unixjob_traverse_state state;
- sysjob_to_jobid_value = (uint32)-1;
+ state.sysjob = unix_jobid;
+ state.sysjob_to_jobid_value = (uint32)-1;
for (snum = 0; snum < services; snum++) {
struct tdb_print_db *pdb;
@@ -418,10 +424,10 @@ uint32 sysjob_to_jobid(int unix_jobid)
if (!pdb) {
continue;
}
- tdb_traverse(pdb->tdb, unixjob_traverse_fn, &unix_jobid);
+ tdb_traverse(pdb->tdb, unixjob_traverse_fn, &state);
release_print_db(pdb);
- if (sysjob_to_jobid_value != (uint32)-1)
- return sysjob_to_jobid_value;
+ if (state.sysjob_to_jobid_value != (uint32)-1)
+ return state.sysjob_to_jobid_value;
}
return (uint32)-1;
}
diff --git a/source/rpc_client/cli_netlogon.c b/source/rpc_client/cli_netlogon.c
index 26d2124..e192e4c 100644
--- a/source/rpc_client/cli_netlogon.c
+++ b/source/rpc_client/cli_netlogon.c
@@ -978,11 +978,12 @@ NTSTATUS rpccli_netlogon_sam_network_logon(struct rpc_pipe_client *cli,
int validation_level = 3;
const char *workstation_name_slash;
const char *server_name_slash;
- static uint8 zeros[16];
+ uint8 zeros[16];
DOM_CRED clnt_creds;
DOM_CRED ret_creds;
int i;
-
+
+ ZERO_STRUCT(zeros);
ZERO_STRUCT(q);
ZERO_STRUCT(r);
ZERO_STRUCT(ret_creds);
@@ -1084,9 +1085,10 @@ NTSTATUS rpccli_netlogon_sam_network_logon_ex(struct rpc_pipe_client *cli,
int validation_level = 3;
const char *workstation_name_slash;
const char *server_name_slash;
- static uint8 zeros[16];
+ uint8 zeros[16];
int i;
-
+
+ ZERO_STRUCT(zeros);
ZERO_STRUCT(q);
ZERO_STRUCT(r);
diff --git a/source/rpc_parse/parse_prs.c b/source/rpc_parse/parse_prs.c
index 23dae9f..638d71a 100644
--- a/source/rpc_parse/parse_prs.c
+++ b/source/rpc_parse/parse_prs.c
@@ -1544,9 +1544,11 @@ static void schannel_digest(struct schannel_auth_struct *a,
uchar digest_final[16])
{
uchar whole_packet_digest[16];
- static const uchar zeros[4] = { 0, };
+ uchar zeros[4];
struct MD5Context ctx3;
-
+
+ ZERO_STRUCT(zeros);
+
/* verfiy the signature on the packet by MD5 over various bits */
MD5Init(&ctx3);
/* use our sequence number, which ensures the packet is not
@@ -1573,11 +1575,13 @@ static void schannel_get_sealing_key(struct schannel_auth_struct *a,
RPC_AUTH_SCHANNEL_CHK *verf,
uchar sealing_key[16])
{
- static const uchar zeros[4] = { 0, };
+ uchar zeros[4];
uchar digest2[16];
uchar sess_kf0[16];
int i;
+ ZERO_STRUCT(zeros);
+
for (i = 0; i < sizeof(sess_kf0); i++) {
sess_kf0[i] = a->sess_key[i] ^ 0xf0;
}
@@ -1600,10 +1604,12 @@ static void schannel_get_sealing_key(struct schannel_auth_struct *a,
static void schannel_deal_with_seq_num(struct schannel_auth_struct *a,
RPC_AUTH_SCHANNEL_CHK *verf)
{
- static const uchar zeros[4] = { 0, };
+ uchar zeros[4];
uchar sequence_key[16];
uchar digest1[16];
+ ZERO_STRUCT(zeros);
+
hmac_md5(a->sess_key, zeros, sizeof(zeros), digest1);
dump_data_pw("(sequence key) digest1:\n", digest1, sizeof(digest1));
diff --git a/source/smbd/mangle_hash.c b/source/smbd/mangle_hash.c
index c369f6e..1dc9c67 100644
--- a/source/smbd/mangle_hash.c
+++ b/source/smbd/mangle_hash.c
@@ -57,8 +57,7 @@ static char magic_char = '~';
static const char basechars[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_-!@#$%";
#define MANGLE_BASE (sizeof(basechars)/sizeof(char)-1)
-static unsigned char chartest[256] = { 0 };
-static bool ct_initialized = False;
+static unsigned char *chartest;
#define mangle(V) ((char)(basechars[(V) % MANGLE_BASE]))
#define BASECHAR_MASK 0xf0
@@ -334,13 +333,13 @@ static void init_chartest( void )
{
const unsigned char *s;
--
Samba Shared Repository
More information about the samba-cvs
mailing list