diff options
author | Jeremy Allison <jra@samba.org> | 2002-01-02 23:28:55 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2002-01-02 23:28:55 +0000 |
commit | 4178f211d1d2d133b96b420361944f5e197ec556 (patch) | |
tree | 3ba54c0b0776a724d1a3cb406455919dcdd88c14 | |
parent | bb70b7811f91290f8c23e745681951a543c15ed4 (diff) | |
download | samba-4178f211d1d2d133b96b420361944f5e197ec556.tar.gz samba-4178f211d1d2d133b96b420361944f5e197ec556.tar.bz2 samba-4178f211d1d2d133b96b420361944f5e197ec556.zip |
debug statement fixups.
Merge SAFE_FREE fix in tdb from 2.2, and IRIX fix.
Jeremy.
(This used to be commit eb6607466565bcd5b3800492d0bc1ae8a44da4f6)
-rw-r--r-- | source3/auth/auth_sam.c | 32 | ||||
-rw-r--r-- | source3/smbd/sesssetup.c | 5 | ||||
-rw-r--r-- | source3/tdb/tdb.c | 52 | ||||
-rw-r--r-- | source3/tdb/tdb.h | 6 |
4 files changed, 43 insertions, 52 deletions
diff --git a/source3/auth/auth_sam.c b/source3/auth/auth_sam.c index b75e300655..c8b5386f7a 100644 --- a/source3/auth/auth_sam.c +++ b/source3/auth/auth_sam.c @@ -163,7 +163,7 @@ static NTSTATUS sam_password_ok(TALLOC_CTX *mem_ctx, ntlmssp_flags = user_info->ntlmssp_flags; if (nt_pw == NULL) { - DEBUG(3,("smb_password_ok: NO NT password stored for user %s.\n", + DEBUG(3,("sam_password_ok: NO NT password stored for user %s.\n", pdb_get_username(sampass))); /* No return, we want to check the LM hash below in this case */ ntlmssp_flags &= (~(NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_NTLM2)); @@ -173,7 +173,7 @@ static NTSTATUS sam_password_ok(TALLOC_CTX *mem_ctx, /* We have the NT MD4 hash challenge available - see if we can use it (ie. does it exist in the smbpasswd file). */ - DEBUG(4,("smb_password_ok: Checking NTLMv2 password\n")); + DEBUG(4,("sam_password_ok: Checking NTLMv2 password\n")); if (smb_pwd_check_ntlmv2( user_info->nt_resp, nt_pw, auth_info->challenge, user_info->smb_name.str, @@ -182,7 +182,7 @@ static NTSTATUS sam_password_ok(TALLOC_CTX *mem_ctx, { return NT_STATUS_OK; } else { - DEBUG(3,("smb_password_ok: NTLMv2 password check failed\n")); + DEBUG(3,("sam_password_ok: NTLMv2 password check failed\n")); return NT_STATUS_WRONG_PASSWORD; } } else if (ntlmssp_flags & NTLMSSP_NEGOTIATE_NTLM) { @@ -190,53 +190,53 @@ static NTSTATUS sam_password_ok(TALLOC_CTX *mem_ctx, /* We have the NT MD4 hash challenge available - see if we can use it (ie. does it exist in the smbpasswd file). */ - DEBUG(4,("smb_password_ok: Checking NT MD4 password\n")); + DEBUG(4,("sam_password_ok: Checking NT MD4 password\n")); if (smb_pwd_check_ntlmv1(user_info->nt_resp, nt_pw, auth_info->challenge, user_sess_key)) { return NT_STATUS_OK; } else { - DEBUG(3,("smb_password_ok: NT MD4 password check failed for user %s\n",pdb_get_username(sampass))); + DEBUG(3,("sam_password_ok: NT MD4 password check failed for user %s\n",pdb_get_username(sampass))); return NT_STATUS_WRONG_PASSWORD; } } else { - DEBUG(2,("smb_password_ok: NTLMv1 passwords NOT PERMITTED for user %s\n",pdb_get_username(sampass))); + DEBUG(2,("sam_password_ok: NTLMv1 passwords NOT PERMITTED for user %s\n",pdb_get_username(sampass))); /* No return, we want to check the LM hash below in this case */ } } if (lm_pw == NULL) { - DEBUG(3,("smb_password_ok: NO LanMan password set for user %s (and no NT password supplied)\n",pdb_get_username(sampass))); + DEBUG(3,("sam_password_ok: NO LanMan password set for user %s (and no NT password supplied)\n",pdb_get_username(sampass))); ntlmssp_flags &= (~NTLMSSP_NEGOTIATE_OEM); } if (ntlmssp_flags & NTLMSSP_NEGOTIATE_OEM) { if (user_info->lm_resp.length != 24) { - DEBUG(2,("smb_password_ok: invalid LanMan password length (%d) for user %s\n", + DEBUG(2,("sam_password_ok: invalid LanMan password length (%d) for user %s\n", user_info->nt_resp.length, pdb_get_username(sampass))); } if (!lp_lanman_auth()) { - DEBUG(3,("smb_password_ok: Lanman passwords NOT PERMITTED for user %s\n",pdb_get_username(sampass))); + DEBUG(3,("sam_password_ok: Lanman passwords NOT PERMITTED for user %s\n",pdb_get_username(sampass))); return NT_STATUS_LOGON_FAILURE; } - DEBUG(4,("smb_password_ok: Checking LM password\n")); + DEBUG(4,("sam_password_ok: Checking LM password\n")); if (smb_pwd_check_ntlmv1(user_info->lm_resp, lm_pw, auth_info->challenge, user_sess_key)) { return NT_STATUS_OK; } else { - DEBUG(4,("smb_password_ok: LM password check failed for user %s\n",pdb_get_username(sampass))); + DEBUG(4,("sam_password_ok: LM password check failed for user %s\n",pdb_get_username(sampass))); return NT_STATUS_WRONG_PASSWORD; } } /* Should not be reached, but if they send nothing... */ - DEBUG(3,("smb_password_ok: NEITHER LanMan nor NT password supplied for user %s\n",pdb_get_username(sampass))); + DEBUG(3,("sam_password_ok: NEITHER LanMan nor NT password supplied for user %s\n",pdb_get_username(sampass))); return NT_STATUS_WRONG_PASSWORD; } @@ -252,7 +252,7 @@ static NTSTATUS sam_account_ok(TALLOC_CTX *mem_ctx, char *workstation_list; time_t kickoff_time; - DEBUG(4,("smb_password_ok: Checking SMB password for user %s\n",pdb_get_username(sampass))); + DEBUG(4,("sam_account_ok: Checking SMB password for user %s\n",pdb_get_username(sampass))); /* Quit if the account was disabled. */ if (acct_ctrl & ACB_DISABLED) { @@ -313,17 +313,17 @@ static NTSTATUS sam_account_ok(TALLOC_CTX *mem_ctx, } if (acct_ctrl & ACB_DOMTRUST) { - DEBUG(2,("session_trust_account: Domain trust account %s denied by server\n", pdb_get_username(sampass))); + DEBUG(2,("sam_account_ok: Domain trust account %s denied by server\n", pdb_get_username(sampass))); return NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT; } if (acct_ctrl & ACB_SVRTRUST) { - DEBUG(2,("session_trust_account: Server trust account %s denied by server\n", pdb_get_username(sampass))); + DEBUG(2,("sam_account_ok: Server trust account %s denied by server\n", pdb_get_username(sampass))); return NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT; } if (acct_ctrl & ACB_WSTRUST) { - DEBUG(4,("session_trust_account: Wksta trust account %s denied by server\n", pdb_get_username(sampass))); + DEBUG(4,("sam_account_ok: Wksta trust account %s denied by server\n", pdb_get_username(sampass))); return NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT; } diff --git a/source3/smbd/sesssetup.c b/source3/smbd/sesssetup.c index 57e0ee2f3a..41a7a657e2 100644 --- a/source3/smbd/sesssetup.c +++ b/source3/smbd/sesssetup.c @@ -792,8 +792,3 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf, END_PROFILE(SMBsesssetupX); return chain_reply(inbuf,outbuf,length,bufsize); } - - - - - diff --git a/source3/tdb/tdb.c b/source3/tdb/tdb.c index 840b5b4af9..fce5d5c943 100644 --- a/source3/tdb/tdb.c +++ b/source3/tdb/tdb.c @@ -343,7 +343,7 @@ static char *tdb_alloc_read(TDB_CONTEXT *tdb, tdb_off offset, tdb_len len) return TDB_ERRCODE(TDB_ERR_OOM, buf); } if (tdb_read(tdb, offset, buf, len, 0) == -1) { - free(buf); + SAFE_FREE(buf); return NULL; } return buf; @@ -424,8 +424,8 @@ static tdb_off tdb_dump_record(TDB_CONTEXT *tdb, tdb_off offset) } if (tailer != rec.rec_len + sizeof(rec)) { - printf("ERROR: tailer does not match record! tailer=%u totalsize=%u\n", - (unsigned)tailer, (unsigned)(rec.rec_len + sizeof(rec))); + printf("ERROR: tailer does not match record! tailer=%u totalsize=%u\n", + (unsigned)tailer, (unsigned)(rec.rec_len + sizeof(rec))); } return rec.next; } @@ -465,12 +465,11 @@ void tdb_dump_all(TDB_CONTEXT *tdb) void tdb_printfreelist(TDB_CONTEXT *tdb) { long total_free = 0; - tdb_off offset, rec_ptr, last_ptr; + tdb_off offset, rec_ptr; struct list_struct rec; tdb_lock(tdb, -1, F_WRLCK); - last_ptr = 0; offset = FREELIST_TOP; /* read in the freelist top */ @@ -856,7 +855,7 @@ static int tdb_new_database(TDB_CONTEXT *tdb, int hash_size) ret = tdb_create_rwlocks(tdb->fd, hash_size); fail: - free(newdb); + SAFE_FREE(newdb); return ret; } @@ -885,10 +884,10 @@ static tdb_off tdb_find(TDB_CONTEXT *tdb, TDB_DATA key, u32 hash, return 0; if (memcmp(key.dptr, k, key.dsize) == 0) { - free(k); + SAFE_FREE(k); return rec_ptr; } - free(k); + SAFE_FREE(k); } rec_ptr = r->next; } @@ -1196,10 +1195,10 @@ int tdb_traverse(TDB_CONTEXT *tdb, tdb_traverse_func fn, void *state) /* They want us to terminate traversal */ unlock_record(tdb, tl.off); tdb->travlocks.next = tl.next; - free(key.dptr); + SAFE_FREE(key.dptr); return count; } - free(key.dptr); + SAFE_FREE(key.dptr); } tdb->travlocks.next = tl.next; if (ret < 0) @@ -1249,8 +1248,7 @@ TDB_DATA tdb_nextkey(TDB_CONTEXT *tdb, TDB_DATA oldkey) tdb->travlocks.off = 0; } - if (k) - free(k); + SAFE_FREE(k); } if (!tdb->travlocks.off) { @@ -1368,8 +1366,7 @@ int tdb_store(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, int flag) ret = -1; } out: - if (p) - free(p); + SAFE_FREE(p); tdb_unlock(tdb, BUCKET(hash), F_WRLCK); return ret; } @@ -1553,16 +1550,14 @@ TDB_CONTEXT *tdb_open_ex(const char *name, int hash_size, int tdb_flags, if (tdb->map_ptr) { if (tdb->flags & TDB_INTERNAL) - free(tdb->map_ptr); + SAFE_FREE(tdb->map_ptr); else tdb_munmap(tdb); } - if (tdb->name) - free(tdb->name); + SAFE_FREE(tdb->name); if (tdb->fd != -1) close(tdb->fd); - if (tdb->locked) - free(tdb->locked); + SAFE_FREE(tdb->locked); errno = save_errno; return NULL; } @@ -1576,18 +1571,15 @@ int tdb_close(TDB_CONTEXT *tdb) if (tdb->map_ptr) { if (tdb->flags & TDB_INTERNAL) - free(tdb->map_ptr); + SAFE_FREE(tdb->map_ptr); else tdb_munmap(tdb); } - if (tdb->name) - free(tdb->name); + SAFE_FREE(tdb->name); if (tdb->fd != -1) ret = close(tdb->fd); - if (tdb->locked) - free(tdb->locked); - if (tdb->lockedkeys) - free(tdb->lockedkeys); + SAFE_FREE(tdb->locked); + SAFE_FREE(tdb->lockedkeys); /* Remove from contexts list */ for (i = &tdbs; *i; i = &(*i)->next) { @@ -1598,7 +1590,7 @@ int tdb_close(TDB_CONTEXT *tdb) } memset(tdb, 0, sizeof(*tdb)); - free(tdb); + SAFE_FREE(tdb); return ret; } @@ -1663,8 +1655,7 @@ int tdb_lockkeys(TDB_CONTEXT *tdb, u32 number, TDB_DATA keys[]) if (i < number) { for ( j = 0; j < i; j++) tdb_unlock(tdb, j, F_WRLCK); - free(tdb->lockedkeys); - tdb->lockedkeys = NULL; + SAFE_FREE(tdb->lockedkeys); return TDB_ERRCODE(TDB_ERR_NOLOCK, -1); } return 0; @@ -1676,8 +1667,7 @@ void tdb_unlockkeys(TDB_CONTEXT *tdb) u32 i; for (i = 0; i < tdb->lockedkeys[0]; i++) tdb_unlock(tdb, tdb->lockedkeys[i+1], F_WRLCK); - free(tdb->lockedkeys); - tdb->lockedkeys = NULL; + SAFE_FREE(tdb->lockedkeys); } /* lock/unlock one hash chain. This is meant to be used to reduce diff --git a/source3/tdb/tdb.h b/source3/tdb/tdb.h index 6877e5cdf4..da8cca19de 100644 --- a/source3/tdb/tdb.h +++ b/source3/tdb/tdb.h @@ -134,6 +134,12 @@ void tdb_dump_all(TDB_CONTEXT *tdb); void tdb_printfreelist(TDB_CONTEXT *tdb); extern TDB_DATA tdb_null; + +/* free memory if the pointer is valid and zero the pointer */ +#ifndef SAFE_FREE +#define SAFE_FREE(x) do { if ((x) != NULL) {free((x)); (x)=NULL;} } while(0) +#endif + #ifdef __cplusplus } #endif |