summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2001-12-30 19:38:24 +0000
committerSimo Sorce <idra@samba.org>2001-12-30 19:38:24 +0000
commit88ce2b3ee70a469d5b39c29f96a0d56e7a55cd9f (patch)
tree96f4e4aed84ce4797fe59ae6b41e14cb70683a3a
parent46ce2d47c73d467df5502d8ac684f98335daca64 (diff)
downloadsamba-88ce2b3ee70a469d5b39c29f96a0d56e7a55cd9f.tar.gz
samba-88ce2b3ee70a469d5b39c29f96a0d56e7a55cd9f.tar.xz
samba-88ce2b3ee70a469d5b39c29f96a0d56e7a55cd9f.zip
backport from head, passdb backends are a bit different (I've seen only the ldap init fns) so I leave to other (jeremy, jerry ?) to backports the mods if they think it is ok.
-rw-r--r--source/lib/util_sid.c17
-rw-r--r--source/libsmb/cli_reg.c8
-rw-r--r--source/rpcclient/cmd_reg.c20
3 files changed, 18 insertions, 27 deletions
diff --git a/source/lib/util_sid.c b/source/lib/util_sid.c
index 71d80c9c6b0..74dcc2d2371 100644
--- a/source/lib/util_sid.c
+++ b/source/lib/util_sid.c
@@ -366,23 +366,30 @@ char *sid_to_string(fstring sidstr_out, DOM_SID *sid)
Convert a string to a SID. Returns True on success, False on fail.
*****************************************************************/
-BOOL string_to_sid(DOM_SID *sidout, char *sidstr)
+BOOL string_to_sid(DOM_SID *sidout, const char *sidstr)
{
pstring tok;
- char *p = sidstr;
+ char *p;
/* BIG NOTE: this function only does SIDS where the identauth is not >= 2^32 */
uint32 ia;
- memset((char *)sidout, '\0', sizeof(DOM_SID));
if (StrnCaseCmp( sidstr, "S-", 2)) {
DEBUG(0,("string_to_sid: Sid %s does not start with 'S-'.\n", sidstr));
return False;
}
- p += 2;
+ memset((char *)sidout, '\0', sizeof(DOM_SID));
+
+ p = strdup(sidstr + 2);
+ if (p == NULL) {
+ DEBUG(0, ("string_to_sid: out of memory!\n"));
+ return False;
+ }
+
if (!next_token(&p, tok, "-", sizeof(tok))) {
DEBUG(0,("string_to_sid: Sid %s is not in a valid format.\n", sidstr));
+ SAFE_FREE(p);
return False;
}
@@ -391,6 +398,7 @@ BOOL string_to_sid(DOM_SID *sidout, char *sidstr)
if (!next_token(&p, tok, "-", sizeof(tok))) {
DEBUG(0,("string_to_sid: Sid %s is not in a valid format.\n", sidstr));
+ SAFE_FREE(p);
return False;
}
@@ -418,6 +426,7 @@ BOOL string_to_sid(DOM_SID *sidout, char *sidstr)
DEBUG(7,("string_to_sid: converted SID %s ok\n", sidstr));
+ SAFE_FREE(p);
return True;
}
diff --git a/source/libsmb/cli_reg.c b/source/libsmb/cli_reg.c
index 73eea58cb77..b88b3532ef7 100644
--- a/source/libsmb/cli_reg.c
+++ b/source/libsmb/cli_reg.c
@@ -7,7 +7,7 @@
Copyright (C) Luke Kenneth Casson Leighton 1996-1998,
Copyright (C) Paul Ashton 1997-1998.
Copyright (C) Jeremy Allison 1999.
- Copyright (C) Simo Sorce 2000
+ Copyright (C) Simo Sorce 2001
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -38,8 +38,7 @@ struct cli_state *cli_winreg_initialise(struct cli_state *cli,
/* Shutdown a server */
NTSTATUS cli_reg_shutdown(struct cli_state * cli, TALLOC_CTX *mem_ctx,
- const char *srv_name, const char *msg,
- uint32 timeout, uint16 flags)
+ const char *msg, uint32 timeout, uint16 flags)
{
prs_struct qbuf;
prs_struct rbuf;
@@ -78,8 +77,7 @@ done:
/* Abort a server shutdown */
-NTSTATUS cli_reg_abort_shutdown(struct cli_state * cli, TALLOC_CTX *mem_ctx,
- const char *srv_name)
+NTSTATUS cli_reg_abort_shutdown(struct cli_state * cli, TALLOC_CTX *mem_ctx)
{
prs_struct rbuf;
prs_struct qbuf;
diff --git a/source/rpcclient/cmd_reg.c b/source/rpcclient/cmd_reg.c
index 991d76b3a32..e67d65397d1 100644
--- a/source/rpcclient/cmd_reg.c
+++ b/source/rpcclient/cmd_reg.c
@@ -904,14 +904,6 @@ static NTSTATUS cmd_reg_shutdown(struct cli_state *cli, TALLOC_CTX *mem_ctx,
uint16 flgs = 0;
int opt;
int ret;
- char *srv_name;
-
- ret = asprintf (&srv_name, "\\\\%s", cli->desthost);
- if (ret < 0) {
- DEBUG(0,("cmd_reg_shutdown: Not enough memory!\n"));
- return NT_STATUS_UNSUCCESSFUL;
- }
- strupper(srv_name);
*msg = 0;
optind = 0; /* TODO: test if this hack works on other systems too --simo */
@@ -948,7 +940,7 @@ static NTSTATUS cmd_reg_shutdown(struct cli_state *cli, TALLOC_CTX *mem_ctx,
}
/* create an entry */
- result = cli_reg_shutdown(cli, mem_ctx, srv_name, msg, timeout, flgs);
+ result = cli_reg_shutdown(cli, mem_ctx, msg, timeout, flgs);
if (NT_STATUS_IS_OK(result))
DEBUG(5,("cmd_reg_shutdown: query succeeded\n"));
@@ -967,16 +959,8 @@ static NTSTATUS cmd_reg_abort_shutdown(struct cli_state *cli,
{
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
int ret;
- char *srv_name;
-
- ret = asprintf(&srv_name, "\\\\%s", cli->desthost);
- if (ret < 0) {
- DEBUG(0,("cmd_reg_shutdown: Not enough memory!\n"));
- return NT_STATUS_UNSUCCESSFUL;
- }
- strupper(srv_name);
- result = cli_reg_abort_shutdown(cli, mem_ctx, srv_name);
+ result = cli_reg_abort_shutdown(cli, mem_ctx);
if (NT_STATUS_IS_OK(result))
DEBUG(5,("cmd_reg_abort_shutdown: query succeeded\n"));