diff options
author | Jeremy Allison <jra@samba.org> | 2000-12-15 01:02:11 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2000-12-15 01:02:11 +0000 |
commit | 369f5fd1d7a6e6298bc3cbe01e3aaed0106f6cf4 (patch) | |
tree | e4237cf9927822e2b49faea870dd13012e5a5cb5 /source3/utils | |
parent | 1fc3e43f9b9b431e8499d2ebd7f557b9bf2ff14c (diff) | |
download | samba-369f5fd1d7a6e6298bc3cbe01e3aaed0106f6cf4.tar.gz samba-369f5fd1d7a6e6298bc3cbe01e3aaed0106f6cf4.tar.bz2 samba-369f5fd1d7a6e6298bc3cbe01e3aaed0106f6cf4.zip |
Fixed memory leaks in lsa_XX calls. Fixed memory leaks in smbcacls. Merged
in fixes from appliance-head and 2.2. Fixed multiple connection.tdb open
problem.
Jeremy.
(This used to be commit 0a40bc83e14c69a09948ec09bb6fc5026c4f4c14)
Diffstat (limited to 'source3/utils')
-rw-r--r-- | source3/utils/smbcacls.c | 24 | ||||
-rw-r--r-- | source3/utils/smbcontrol.c | 9 |
2 files changed, 25 insertions, 8 deletions
diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c index c017c16bdf..3240438a7a 100644 --- a/source3/utils/smbcacls.c +++ b/source3/utils/smbcacls.c @@ -120,12 +120,12 @@ static void SidToString(fstring str, DOM_SID *sid) } /* convert a string to a SID, either numeric or username/group */ -static BOOL StringToSid(DOM_SID *sid, fstring str) +static BOOL StringToSid(DOM_SID *sid, char *str) { uint32 *types = NULL; DOM_SID *sids = NULL; int num_sids; - BOOL result = False; + BOOL result = True; /* Short cut */ @@ -136,7 +136,7 @@ static BOOL StringToSid(DOM_SID *sid, fstring str) if (open_policy_hnd() && cli_lsa_lookup_names(&lsa_cli, &pol, 1, &str, &sids, &types, - &num_sids) == NT_STATUS_NOPROBLEMO) { + &num_sids) != NT_STATUS_NOPROBLEMO) { result = string_to_sid(sid, str); goto done; } @@ -147,6 +147,7 @@ static BOOL StringToSid(DOM_SID *sid, fstring str) safe_free(types); done: + return result; } @@ -372,9 +373,12 @@ static SEC_DESC *sec_desc_parse(char *str) if (strncmp(tok,"ACL:", 4) == 0) { SEC_ACE ace; - if (!parse_ace(&ace, tok+4) || - !add_ace(&dacl, &ace)) { - printf("Failed to parse ACL\n"); + if (!parse_ace(&ace, tok+4)) { + printf("Failed to parse ACL %s\n", tok); + return NULL; + } + if(!add_ace(&dacl, &ace)) { + printf("Failed to add ACL %s\n", tok); return NULL; } continue; @@ -565,7 +569,6 @@ static void cacl_set(struct cli_state *cli, char *filename, if (!cli_set_secdesc(cli, fnum, sd)) { printf("ERROR: secdesc set failed: %s\n", cli_errstr(cli)); - return; } free_sec_desc(&sd); @@ -607,12 +610,15 @@ struct cli_state *connect_one(char *share) if (!(c=cli_initialise(NULL)) || (cli_set_port(c, 139) == 0) || !cli_connect(c, server_n, &ip)) { DEBUG(0,("Connection to %s failed\n", server_n)); + cli_shutdown(c); + safe_free(c); return NULL; } if (!cli_session_request(c, &calling, &called)) { DEBUG(0,("session request to %s failed\n", called.name)); cli_shutdown(c); + safe_free(c); if (strcmp(called.name, "*SMBSERVER")) { make_nmb_name(&called , "*SMBSERVER", 0x20); goto again; @@ -625,6 +631,7 @@ struct cli_state *connect_one(char *share) if (!cli_negprot(c)) { DEBUG(0,("protocol negotiation failed\n")); cli_shutdown(c); + safe_free(c); return NULL; } @@ -640,6 +647,8 @@ struct cli_state *connect_one(char *share) password, strlen(password), lp_workgroup())) { DEBUG(0,("session setup failed: %s\n", cli_errstr(c))); + cli_shutdown(c); + safe_free(c); return NULL; } @@ -649,6 +658,7 @@ struct cli_state *connect_one(char *share) password, strlen(password)+1)) { DEBUG(0,("tree connect failed: %s\n", cli_errstr(c))); cli_shutdown(c); + safe_free(c); return NULL; } diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c index 991d1d77d2..87d00eecbd 100644 --- a/source3/utils/smbcontrol.c +++ b/source3/utils/smbcontrol.c @@ -118,10 +118,17 @@ send a message to a named destination static BOOL send_message(char *dest, int msg_type, void *buf, int len, BOOL duplicates) { pid_t pid; + TDB_CONTEXT *the_tdb; + + the_tdb = tdb_open(lock_path("connections.tdb"), 0, 0, O_RDONLY, 0); + if (!the_tdb) { + fprintf(stderr,"Failed to open connections database in send_message.\n"); + return False; + } /* "smbd" is the only broadcast operation */ if (strequal(dest,"smbd")) { - return message_send_all(msg_type, buf, len, duplicates); + return message_send_all(the_tdb,msg_type, buf, len, duplicates); } else if (strequal(dest,"nmbd")) { pid = pidfile_pid(dest); if (pid == 0) { |