summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/net.c11
-rw-r--r--source3/utils/net_lua.c386
-rw-r--r--source3/utils/net_proto.h6
-rw-r--r--source3/utils/net_rpc.c55
-rw-r--r--source3/utils/net_rpc_audit.c10
-rw-r--r--source3/utils/net_rpc_join.c6
-rw-r--r--source3/utils/net_rpc_printer.c41
-rw-r--r--source3/utils/net_rpc_registry.c50
8 files changed, 98 insertions, 467 deletions
diff --git a/source3/utils/net.c b/source3/utils/net.c
index 2063479808..e8920e0b02 100644
--- a/source3/utils/net.c
+++ b/source3/utils/net.c
@@ -53,7 +53,7 @@ extern bool AllowDebugChange;
/* end of internationalization section */
/***********************************************************************/
-uint32 get_sec_channel_type(const char *param)
+enum netr_SchannelType get_sec_channel_type(const char *param)
{
if (!(param && *param)) {
return get_default_sec_channel();
@@ -91,7 +91,7 @@ static int net_changesecretpw(struct net_context *c, int argc,
const char **argv)
{
char *trust_pw;
- uint32 sec_channel_type = SEC_CHAN_WKSTA;
+ enum netr_SchannelType sec_channel_type = SEC_CHAN_WKSTA;
if(c->opt_force) {
if (c->opt_stdin) {
@@ -702,13 +702,6 @@ static struct functable net_func[] = {
N_(" Use 'net help registry' to get more information about "
"'net registry' commands.")
},
- { "lua",
- net_lua,
- NET_TRANSPORT_LOCAL,
- N_("Open a lua interpreter"),
- N_(" Use 'net help lua' to get more information about 'net "
- "lua' commands.")
- },
{ "eventlog",
net_eventlog,
NET_TRANSPORT_LOCAL,
diff --git a/source3/utils/net_lua.c b/source3/utils/net_lua.c
deleted file mode 100644
index b1b0f79ae3..0000000000
--- a/source3/utils/net_lua.c
+++ /dev/null
@@ -1,386 +0,0 @@
-/*
- * Unix SMB/CIFS implementation.
- * Lua experiments
- * Copyright (C) Volker Lendecke 2006
- *
- * 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
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#include "includes.h"
-#include "utils/net.h"
-
-#include "lua-5.1.4/src/lualib.h"
-#include "lua-5.1.4/src/lauxlib.h"
-
-#define SOCK_METATABLE "cade1208-9029-4d76-8748-426dfc1436f7"
-
-struct sock_userdata {
- int fd;
-};
-
-static int sock_userdata_gc(lua_State *L)
-{
- struct sock_userdata *p = (struct sock_userdata *)
- luaL_checkudata(L, 1, SOCK_METATABLE);
- close(p->fd);
- return 0;
-}
-
-static int sock_userdata_tostring(lua_State *L)
-{
- struct sock_userdata *p = (struct sock_userdata *)
- luaL_checkudata(L, 1, SOCK_METATABLE);
-
- lua_pushfstring(L, "socket: %d", p->fd);
- return 1;
-}
-
-static int sock_userdata_connect(lua_State *L)
-{
- struct sock_userdata *p = (struct sock_userdata *)
- luaL_checkudata(L, 1, SOCK_METATABLE);
- const char *hostname;
- int port;
- struct sockaddr_in addr;
- int res;
-
- if (!lua_isstring(L, 2)) {
- luaL_error(L, _("connect: Expected IP-Address"));
- }
- hostname = lua_tostring(L, 2);
-
- if (!lua_isnumber(L, 3)) {
- luaL_error(L, _("connect: Expected port"));
- }
- port = lua_tointeger(L, 3);
-
- if (lua_gettop(L) == 4) {
- /*
- * Here we expect an event context in the last argument to
- * make connect() asynchronous.
- */
- }
-
- addr.sin_family = AF_INET;
- inet_aton(hostname, &addr.sin_addr);
- addr.sin_port = htons(port);
-
- res = connect(p->fd, (struct sockaddr *)&addr, sizeof(addr));
- if (res == -1) {
- int err = errno;
- lua_pushnil(L);
- lua_pushfstring(L, _("connect failed: %s"), strerror(err));
- return 2;
- }
-
- lua_pushboolean(L, 1);
- return 1;
-}
-
-static const struct luaL_Reg sock_methods[] = {
- {"__gc", sock_userdata_gc},
- {"__tostring", sock_userdata_tostring},
- {"connect", sock_userdata_connect},
- {NULL, NULL}
-};
-
-static const struct {
- const char *name;
- int domain;
-} socket_domains[] = {
- {"PF_UNIX", PF_UNIX},
- {"PF_INET", PF_INET},
- {NULL, 0},
-};
-
-static const struct {
- const char *name;
- int type;
-} socket_types[] = {
- {"SOCK_STREAM", SOCK_STREAM},
- {"SOCK_DGRAM", SOCK_DGRAM},
- {NULL, 0},
-};
-
-static int sock_userdata_new(lua_State *L)
-{
- struct sock_userdata *result;
- const char *domain_str = luaL_checkstring(L, 1);
- const char *type_str = luaL_checkstring(L, 2);
- int i, domain, type;
-
- i = 0;
- while (socket_domains[i].name != NULL) {
- if (strcmp(domain_str, socket_domains[i].name) == 0) {
- break;
- }
- i += 1;
- }
- if (socket_domains[i].name == NULL) {
- return luaL_error(L, _("socket domain %s unknown"), domain_str);
- }
- domain = socket_domains[i].domain;
-
- i = 0;
- while (socket_types[i].name != NULL) {
- if (strcmp(type_str, socket_types[i].name) == 0) {
- break;
- }
- i += 1;
- }
- if (socket_types[i].name == NULL) {
- return luaL_error(L, _("socket type %s unknown"), type_str);
- }
- type = socket_types[i].type;
-
- result = (struct sock_userdata *)lua_newuserdata(L, sizeof(*result));
- ZERO_STRUCTP(result);
-
- result->fd = socket(domain, type, 0);
- if (result->fd == -1) {
- int err = errno;
- lua_pushnil(L);
- lua_pushfstring(L, _("socket() failed: %s"), strerror(errno));
- lua_pushinteger(L, err);
- return 3;
- }
-
- luaL_getmetatable(L, SOCK_METATABLE);
- lua_setmetatable(L, -2);
- return 1;
-}
-
-static const struct luaL_Reg sock_funcs[] = {
- {"new", sock_userdata_new},
- {NULL, NULL}
-};
-
-static int sock_lua_init(lua_State *L, const char *libname) {
- luaL_newmetatable(L, SOCK_METATABLE);
-
- lua_pushvalue(L, -1);
- lua_setfield(L, -2, "__index");
-
- luaL_register(L, NULL, sock_methods);
- luaL_register(L, libname, sock_funcs);
- return 1;
-}
-
-#define EVT_METATABLE "c42e0642-b24a-40f0-8483-d8eb4aee9ea3"
-
-/*
- * The userdata we allocate from lua when a new event context is created
- */
-struct evt_userdata {
- struct event_context *ev;
-};
-
-static bool evt_is_main_thread(lua_State *L) {
- int ret;
-
- ret = lua_pushthread(L);
- lua_pop(L, 1);
- return (ret != 0);
-}
-
-/*
- * Per event we allocate a struct thread_reference to keep the coroutine from
- * being garbage-collected. This is also the hook to find the right thread to
- * be resumed.
- */
-
-struct thread_reference {
- struct lua_State *L;
- /*
- * Reference to the Thread (i.e. lua_State) this event is hanging on
- */
- int thread_ref;
-};
-
-static int thread_reference_destructor(struct thread_reference *ref)
-{
- luaL_unref(ref->L, LUA_REGISTRYINDEX, ref->thread_ref);
- return 0;
-}
-
-static struct thread_reference *evt_reference_thread(TALLOC_CTX *mem_ctx,
- lua_State *L)
-{
- struct thread_reference *result;
-
- result = talloc(mem_ctx, struct thread_reference);
- if (result == NULL) {
- return NULL;
- }
-
- lua_pushthread(L);
- result->thread_ref = luaL_ref(L, LUA_REGISTRYINDEX);
- result->L = L;
- talloc_set_destructor(result, thread_reference_destructor);
-
- return result;
-}
-
-static int evt_userdata_gc(lua_State *L)
-{
- struct evt_userdata *p = (struct evt_userdata *)
- luaL_checkudata(L, 1, EVT_METATABLE);
- TALLOC_FREE(p->ev);
- return 0;
-}
-
-static int evt_userdata_tostring(lua_State *L) {
- lua_pushstring(L, "event context");
- return 1;
-}
-
-static void evt_userdata_sleep_done(struct event_context *event_ctx,
- struct timed_event *te,
- struct timeval now,
- void *priv)
-{
- struct thread_reference *ref = talloc_get_type_abort(
- priv, struct thread_reference);
- lua_resume(ref->L, 0);
- TALLOC_FREE(ref);
-}
-
-static int evt_userdata_sleep(lua_State *L)
-{
- struct evt_userdata *p = (struct evt_userdata *)
- luaL_checkudata(L, 1, EVT_METATABLE);
- lua_Integer usecs = luaL_checkint(L, 2);
- struct thread_reference *ref;
- struct timed_event *te;
-
- if (evt_is_main_thread(L)) {
- /*
- * Block in the main thread
- */
- smb_msleep(usecs/1000);
- return 0;
- }
-
- ref = evt_reference_thread(p->ev, L);
- if (ref == NULL) {
- return luaL_error(L, _("evt_reference_thread failed\n"));
- }
-
- te = event_add_timed(p->ev, ref, timeval_current_ofs(0, usecs),
- evt_userdata_sleep_done,
- ref);
-
- if (te == NULL) {
- TALLOC_FREE(ref);
- return luaL_error(L, _("event_add_timed failed"));
- }
-
- return lua_yield(L, 0);
-}
-
-static int evt_userdata_once(lua_State *L)
-{
- struct evt_userdata *p = (struct evt_userdata *)
- luaL_checkudata(L, 1, EVT_METATABLE);
-
- if (!evt_is_main_thread(L)) {
- return luaL_error(L,
- _("event_once called from non-base thread"));
- }
-
- lua_pushinteger(L, event_loop_once(p->ev));
- return 1;
-}
-
-static const struct luaL_Reg evt_methods[] = {
- {"__gc", evt_userdata_gc},
- {"__tostring", evt_userdata_tostring},
- {"sleep", evt_userdata_sleep},
- {"once", evt_userdata_once},
- {NULL, NULL}
-};
-
-static int evt_userdata_new(lua_State *L) {
- struct evt_userdata *result;
-
- result = (struct evt_userdata *)lua_newuserdata(L, sizeof(*result));
- ZERO_STRUCTP(result);
-
- result->ev = event_context_init(NULL);
- if (result->ev == NULL) {
- return luaL_error(L, _("event_context_init failed"));
- }
-
- luaL_getmetatable(L, EVT_METATABLE);
- lua_setmetatable(L, -2);
- return 1;
-}
-
-static const struct luaL_Reg evt_funcs[] = {
- {"new", evt_userdata_new},
- {NULL, NULL}
-};
-
-static int evt_lua_init(lua_State *L, const char *libname) {
- luaL_newmetatable(L, EVT_METATABLE);
-
- lua_pushvalue(L, -1);
- lua_setfield(L, -2, "__index");
-
- luaL_register(L, NULL, evt_methods);
- luaL_register(L, libname, evt_funcs);
- return 1;
-}
-
-int net_lua(struct net_context *c, int argc, const char **argv)
-{
- lua_State *state;
-
- state = lua_open();
- if (state == NULL) {
- d_fprintf(stderr, _("lua_newstate failed\n"));
- return -1;
- }
-
- luaL_openlibs(state);
- evt_lua_init(state, "event");
- sock_lua_init(state, "socket");
-
- while (1) {
- char *line = NULL;
-
- line = smb_readline("lua> ", NULL, NULL);
- if (line == NULL) {
- break;
- }
-
- if (line[0] == ':') {
- if (luaL_dofile(state, &line[1])) {
- d_printf(_("luaL_dofile returned an error\n"));
- continue;
- }
- } else if (line[0] != '\n') {
- if (luaL_dostring(state, line) != 0) {
- d_printf(_("luaL_dostring returned an "
- "error\n"));
- }
- }
-
- SAFE_FREE(line);
- }
-
- lua_close(state);
- return -1;
-}
diff --git a/source3/utils/net_proto.h b/source3/utils/net_proto.h
index 75ac032db9..098e2a22be 100644
--- a/source3/utils/net_proto.h
+++ b/source3/utils/net_proto.h
@@ -42,7 +42,7 @@ void debug_unix_user_token(int dbg_class, int dbg_lev, uid_t uid, gid_t gid,
/* The following definitions come from utils/net.c */
-uint32 get_sec_channel_type(const char *param);
+enum netr_SchannelType get_sec_channel_type(const char *param);
/* The following definitions come from utils/net_ads.c */
@@ -423,10 +423,6 @@ int net_usershare_usage(struct net_context *c, int argc, const char **argv);
int net_usershare_help(struct net_context *c, int argc, const char **argv);
int net_usershare(struct net_context *c, int argc, const char **argv);
-/* The following definitions come from utils/net_lua.c */
-
-int net_lua(struct net_context *c, int argc, const char **argv);
-
/* The following definitions come from utils/net_eventlog.c */
int net_eventlog(struct net_context *c, int argc, const char **argv);
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c
index b4505347b1..455405a3ee 100644
--- a/source3/utils/net_rpc.c
+++ b/source3/utils/net_rpc.c
@@ -239,8 +239,16 @@ static NTSTATUS rpc_changetrustpw_internals(struct net_context *c,
int argc,
const char **argv)
{
+ NTSTATUS status;
+
+ status = trust_pw_find_change_and_store_it(pipe_hnd, mem_ctx, c->opt_target_workgroup);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_fprintf(stderr, _("Failed to change machine account password: %s\n"),
+ nt_errstr(status));
+ return status;
+ }
- return trust_pw_find_change_and_store_it(pipe_hnd, mem_ctx, c->opt_target_workgroup);
+ return NT_STATUS_OK;
}
/**
@@ -301,7 +309,7 @@ static NTSTATUS rpc_oldjoin_internals(struct net_context *c,
fstring trust_passwd;
unsigned char orig_trust_passwd_hash[16];
NTSTATUS result;
- uint32 sec_channel_type;
+ enum netr_SchannelType sec_channel_type;
result = cli_rpc_pipe_open_noauth(cli, &ndr_table_netlogon.syntax_id,
&pipe_hnd);
@@ -336,6 +344,7 @@ static NTSTATUS rpc_oldjoin_internals(struct net_context *c,
E_md4hash(trust_passwd, orig_trust_passwd_hash);
result = trust_pw_change_and_store_it(pipe_hnd, mem_ctx, c->opt_target_workgroup,
+ global_myname(),
orig_trust_passwd_hash,
sec_channel_type);
@@ -5768,18 +5777,12 @@ static NTSTATUS rpc_query_domain_sid(struct net_context *c,
static void print_trusted_domain(DOM_SID *dom_sid, const char *trusted_dom_name)
{
- fstring ascii_sid, padding;
- int pad_len, col_len = 20;
+ fstring ascii_sid;
/* convert sid into ascii string */
sid_to_fstring(ascii_sid, dom_sid);
- /* calculate padding space for d_printf to look nicer */
- pad_len = col_len - strlen(trusted_dom_name);
- padding[pad_len] = 0;
- do padding[--pad_len] = ' '; while (pad_len);
-
- d_printf("%s%s%s\n", trusted_dom_name, padding, ascii_sid);
+ d_printf("%-20s%s\n", trusted_dom_name, ascii_sid);
}
static NTSTATUS vampire_trusted_domain(struct rpc_pipe_client *pipe_hnd,
@@ -6003,14 +6006,13 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv)
NTSTATUS nt_status;
const char *domain_name = NULL;
DOM_SID *queried_dom_sid;
- fstring padding;
int ascii_dom_name_len;
struct policy_handle connect_hnd;
union lsa_PolicyInformation *info = NULL;
/* trusted domains listing variables */
unsigned int num_domains, enum_ctx = 0;
- int i, pad_len, col_len = 20;
+ int i;
struct lsa_DomainList dom_list;
fstring pdc_name;
@@ -6021,7 +6023,7 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv)
if (c->display_usage) {
d_printf(_("Usage:\n"
"net rpc trustdom list\n"
- " List trust relationships\n"));
+ " List in- and outgoing trust relationships\n"));
return 0;
}
@@ -6219,17 +6221,12 @@ static int rpc_trustdom_list(struct net_context *c, int argc, const char **argv)
if (ascii_dom_name_len && ascii_dom_name_len < FSTRING_LEN)
str[ascii_dom_name_len - 1] = '\0';
- /* calculate padding space for d_printf to look nicer */
- pad_len = col_len - strlen(str);
- padding[pad_len] = 0;
- do padding[--pad_len] = ' '; while (pad_len);
-
/* set opt_* variables to remote domain */
strupper_m(str);
c->opt_workgroup = talloc_strdup(mem_ctx, str);
c->opt_target_workgroup = c->opt_workgroup;
- d_printf("%s%s", str, padding);
+ d_printf("%-20s", str);
/* connect to remote domain controller */
nt_status = net_make_ipc_connection(c,
@@ -6292,41 +6289,41 @@ static int rpc_trustdom(struct net_context *c, int argc, const char **argv)
"add",
rpc_trustdom_add,
NET_TRANSPORT_RPC,
- N_("Add trusted domain's account"),
+ N_("Add trusting domain's account"),
N_("net rpc trustdom add\n"
- " Add trusted domain's account")
+ " Add trusting domain's account")
},
{
"del",
rpc_trustdom_del,
NET_TRANSPORT_RPC,
- N_("Remove trusted domain's account"),
+ N_("Remove trusting domain's account"),
N_("net rpc trustdom del\n"
- " Remove trusted domain's account")
+ " Remove trusting domain's account")
},
{
"establish",
rpc_trustdom_establish,
NET_TRANSPORT_RPC,
- N_("Establish trust relationship"),
+ N_("Establish outgoing trust relationship"),
N_("net rpc trustdom establish\n"
- " Establish trust relationship")
+ " Establish outgoing trust relationship")
},
{
"revoke",
rpc_trustdom_revoke,
NET_TRANSPORT_RPC,
- N_("Revoke trust relationship"),
+ N_("Revoke outgoing trust relationship"),
N_("net rpc trustdom revoke\n"
- " Revoke trust relationship")
+ " Revoke outgoing trust relationship")
},
{
"list",
rpc_trustdom_list,
NET_TRANSPORT_RPC,
- N_("List domain trusts"),
+ N_("List in- and outgoing domain trusts"),
N_("net rpc trustdom list\n"
- " List domain trusts")
+ " List in- and outgoing domain trusts")
},
{
"vampire",
diff --git a/source3/utils/net_rpc_audit.c b/source3/utils/net_rpc_audit.c
index f0b440d3be..bc3ed3dba2 100644
--- a/source3/utils/net_rpc_audit.c
+++ b/source3/utils/net_rpc_audit.c
@@ -40,9 +40,6 @@ static int net_help_audit(struct net_context *c, int argc, const char **argv)
static void print_auditing_category(const char *policy, const char *value)
{
- fstring padding;
- int pad_len, col_len = 30;
-
if (policy == NULL) {
policy = N_("Unknown");
}
@@ -50,12 +47,7 @@ static void print_auditing_category(const char *policy, const char *value)
value = N_("Invalid");
}
- /* calculate padding space for d_printf to look nicer */
- pad_len = col_len - strlen(policy);
- padding[pad_len] = 0;
- do padding[--pad_len] = ' '; while (pad_len > 0);
-
- d_printf(_("\t%s%s%s\n"), policy, padding, value);
+ d_printf(_("\t%-30s%s\n"), policy, value);
}
/********************************************************************
diff --git a/source3/utils/net_rpc_join.c b/source3/utils/net_rpc_join.c
index 23913812b0..fd81205a95 100644
--- a/source3/utils/net_rpc_join.c
+++ b/source3/utils/net_rpc_join.c
@@ -138,7 +138,7 @@ int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv)
TALLOC_CTX *mem_ctx;
uint32 acb_info = ACB_WSTRUST;
uint32_t neg_flags = NETLOGON_NEG_AUTH2_ADS_FLAGS;
- uint32 sec_channel_type;
+ enum netr_SchannelType sec_channel_type;
struct rpc_pipe_client *pipe_hnd = NULL;
/* rpc variables */
@@ -186,6 +186,10 @@ int net_rpc_join_newstyle(struct net_context *c, int argc, const char **argv)
acb_info = ACB_DOMTRUST;
break;
#endif
+ default:
+ DEBUG(0,("secure channel type %d not yet supported\n",
+ sec_channel_type));
+ break;
}
/* Make authenticated connection to remote machine */
diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c
index ea7465e33a..5652caf834 100644
--- a/source3/utils/net_rpc_printer.c
+++ b/source3/utils/net_rpc_printer.c
@@ -72,7 +72,8 @@ static void display_print_driver3(struct spoolss_DriverInfo3 *r)
static void display_reg_value(const char *subkey, struct regval_blob value)
{
- char *text;
+ const char *text;
+ DATA_BLOB blob;
switch(value.type) {
case REG_DWORD:
@@ -81,11 +82,8 @@ static void display_reg_value(const char *subkey, struct regval_blob value)
break;
case REG_SZ:
- rpcstr_pull_talloc(talloc_tos(),
- &text,
- value.data_p,
- value.size,
- STR_TERMINATE);
+ blob = data_blob_const(value.data_p, value.size);
+ pull_reg_sz(talloc_tos(), &blob, &text);
if (!text) {
break;
}
@@ -100,17 +98,17 @@ static void display_reg_value(const char *subkey, struct regval_blob value)
break;
case REG_MULTI_SZ: {
- uint32_t i, num_values;
- char **values;
+ uint32_t i;
+ const char **values;
+ blob = data_blob_const(value.data_p, value.size);
- if (!W_ERROR_IS_OK(reg_pull_multi_sz(NULL, value.data_p,
- value.size, &num_values,
- &values))) {
- d_printf(_("reg_pull_multi_sz failed\n"));
+ if (!pull_reg_multi_sz(NULL, &blob, &values)) {
+ d_printf("pull_reg_multi_sz failed\n");
break;
}
- for (i=0; i<num_values; i++) {
+ printf("%s: REG_MULTI_SZ: \n", value.valuename);
+ for (i=0; values[i] != NULL; i++) {
d_printf("%s\n", values[i]);
}
TALLOC_FREE(values);
@@ -2418,7 +2416,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
for (j=0; j < count; j++) {
struct regval_blob value;
- UNISTR2 data;
+ DATA_BLOB blob;
/* although samba replies with sane data in most cases we
should try to avoid writing wrong registry data */
@@ -2432,7 +2430,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
if (strequal(info[j].value_name, SPOOL_REG_PORTNAME)) {
/* although windows uses a multi-sz, we use a sz */
- init_unistr2(&data, SAMBA_PRINTER_PORT_NAME, UNI_STR_TERMINATE);
+ push_reg_sz(mem_ctx, &blob, SAMBA_PRINTER_PORT_NAME);
fstrcpy(value.valuename, SPOOL_REG_PORTNAME);
}
@@ -2442,7 +2440,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
nt_status = NT_STATUS_NO_MEMORY;
goto done;
}
- init_unistr2(&data, unc_name, UNI_STR_TERMINATE);
+ push_reg_sz(mem_ctx, &blob, unc_name);
fstrcpy(value.valuename, SPOOL_REG_UNCNAME);
}
@@ -2456,27 +2454,27 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
nt_status = NT_STATUS_NO_MEMORY;
goto done;
}
- init_unistr2(&data, url, UNI_STR_TERMINATE);
+ push_reg_sz(mem_ctx, &blob, url);
fstrcpy(value.valuename, SPOOL_REG_URL);
#endif
}
if (strequal(info[j].value_name, SPOOL_REG_SERVERNAME)) {
- init_unistr2(&data, longname, UNI_STR_TERMINATE);
+ push_reg_sz(mem_ctx, &blob, longname);
fstrcpy(value.valuename, SPOOL_REG_SERVERNAME);
}
if (strequal(info[j].value_name, SPOOL_REG_SHORTSERVERNAME)) {
- init_unistr2(&data, global_myname(), UNI_STR_TERMINATE);
+ push_reg_sz(mem_ctx, &blob, global_myname());
fstrcpy(value.valuename, SPOOL_REG_SHORTSERVERNAME);
}
value.type = REG_SZ;
- value.size = data.uni_str_len * 2;
+ value.size = blob.length;
if (value.size) {
- value.data_p = (uint8_t *)TALLOC_MEMDUP(mem_ctx, data.buffer, value.size);
+ value.data_p = blob.data;
} else {
value.data_p = NULL;
}
@@ -2492,7 +2490,6 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
} else {
struct regval_blob v;
- DATA_BLOB blob;
result = push_spoolss_PrinterData(mem_ctx, &blob,
info[j].type,
diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c
index 1ad1d74ca0..36e83a75af 100644
--- a/source3/utils/net_rpc_registry.c
+++ b/source3/utils/net_rpc_registry.c
@@ -23,6 +23,46 @@
#include "regfio.h"
#include "reg_objects.h"
+/*******************************************************************
+ connect to a registry hive root (open a registry policy)
+*******************************************************************/
+
+static NTSTATUS rpccli_winreg_Connect(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
+ uint32_t reg_type, uint32_t access_mask,
+ struct policy_handle *reg_hnd)
+{
+ ZERO_STRUCTP(reg_hnd);
+
+ switch (reg_type)
+ {
+ case HKEY_CLASSES_ROOT:
+ return rpccli_winreg_OpenHKCR( cli, mem_ctx, NULL,
+ access_mask, reg_hnd, NULL);
+
+ case HKEY_LOCAL_MACHINE:
+ return rpccli_winreg_OpenHKLM( cli, mem_ctx, NULL,
+ access_mask, reg_hnd, NULL);
+
+ case HKEY_USERS:
+ return rpccli_winreg_OpenHKU( cli, mem_ctx, NULL,
+ access_mask, reg_hnd, NULL);
+
+ case HKEY_CURRENT_USER:
+ return rpccli_winreg_OpenHKCU( cli, mem_ctx, NULL,
+ access_mask, reg_hnd, NULL);
+
+ case HKEY_PERFORMANCE_DATA:
+ return rpccli_winreg_OpenHKPD( cli, mem_ctx, NULL,
+ access_mask, reg_hnd, NULL);
+
+ default:
+ /* fall through to end of function */
+ break;
+ }
+
+ return NT_STATUS_INVALID_PARAMETER;
+}
+
static bool reg_hive_key(TALLOC_CTX *ctx, const char *fullname,
uint32 *reg_type, const char **key_name)
{
@@ -895,8 +935,9 @@ static int rpc_registry_save(struct net_context *c, int argc, const char **argv
static void dump_values( REGF_NK_REC *nk )
{
int i, j;
- char *data_str = NULL;
+ const char *data_str = NULL;
uint32 data_size, data;
+ DATA_BLOB blob;
if ( !nk->values )
return;
@@ -908,11 +949,8 @@ static void dump_values( REGF_NK_REC *nk )
data_size = nk->values[i].data_size & ~VK_DATA_IN_OFFSET;
switch ( nk->values[i].type ) {
case REG_SZ:
- rpcstr_pull_talloc(talloc_tos(),
- &data_str,
- nk->values[i].data,
- -1,
- STR_TERMINATE);
+ blob = data_blob_const(nk->values[i].data, data_size);
+ pull_reg_sz(talloc_tos(), &blob, &data_str);
if (!data_str) {
break;
}