summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2006-09-26 15:15:26 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:14:46 -0500
commitbbaa0b178d834f4962ab440dff0e1837029369df (patch)
tree99d6b5c007301ffe8ce55deb3be43a0582a724c4 /source3/utils
parentcda3a18f2343d4c2f5ff8b08be6015eec37647c3 (diff)
downloadsamba-bbaa0b178d834f4962ab440dff0e1837029369df.tar.gz
samba-bbaa0b178d834f4962ab440dff0e1837029369df.tar.bz2
samba-bbaa0b178d834f4962ab440dff0e1837029369df.zip
r18919: * Get the new rpccli_winreg_XXXX() functions into the tree
There some broken functionality here that I'm still working on. * remove unneeded parsing routines (This used to be commit cbfe1a4b498593a48fc34f584754ed4a9ef72cc5)
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/net_rpc.c53
-rw-r--r--source3/utils/net_rpc_registry.c72
2 files changed, 63 insertions, 62 deletions
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c
index a09ed3cb3c..c22ffb9878 100644
--- a/source3/utils/net_rpc.c
+++ b/source3/utils/net_rpc.c
@@ -4937,7 +4937,7 @@ static NTSTATUS rpc_shutdown_abort_internals(const DOM_SID *domain_sid,
{
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- result = rpccli_shutdown_abort(pipe_hnd, mem_ctx);
+ result = rpccli_initshutdown_Abort(pipe_hnd, mem_ctx, NULL);
if (NT_STATUS_IS_OK(result)) {
d_printf("\nShutdown successfully aborted\n");
@@ -5038,6 +5038,8 @@ static NTSTATUS rpc_init_shutdown_internals(const DOM_SID *domain_sid,
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
const char *msg = "This machine will be shutdown shortly";
uint32 timeout = 20;
+ struct initshutdown_String msg_string;
+ struct initshutdown_String_sub s;
if (opt_comment) {
msg = opt_comment;
@@ -5046,9 +5048,12 @@ static NTSTATUS rpc_init_shutdown_internals(const DOM_SID *domain_sid,
timeout = opt_timeout;
}
+ s.name = msg;
+ msg_string.name = &s;
+
/* create an entry */
- result = rpccli_shutdown_init(pipe_hnd, mem_ctx, msg, timeout, opt_reboot,
- opt_force);
+ result = rpccli_initshutdown_Init(pipe_hnd, mem_ctx, NULL,
+ &msg_string, timeout, opt_force, opt_reboot);
if (NT_STATUS_IS_OK(result)) {
d_printf("\nShutdown of remote machine succeeded\n");
@@ -5083,55 +5088,37 @@ static NTSTATUS rpc_reg_shutdown_internals(const DOM_SID *domain_sid,
int argc,
const char **argv)
{
- WERROR result;
const char *msg = "This machine will be shutdown shortly";
uint32 timeout = 20;
-#if 0
- poptContext pc;
- int rc;
-
- struct poptOption long_options[] = {
- {"message", 'm', POPT_ARG_STRING, &msg},
- {"timeout", 't', POPT_ARG_INT, &timeout},
- {"reboot", 'r', POPT_ARG_NONE, &reboot},
- {"force", 'f', POPT_ARG_NONE, &force},
- { 0, 0, 0, 0}
- };
-
- pc = poptGetContext(NULL, argc, (const char **) argv, long_options,
- POPT_CONTEXT_KEEP_FIRST);
+ struct initshutdown_String msg_string;
+ struct initshutdown_String_sub s;
+ NTSTATUS result;
- rc = poptGetNextOpt(pc);
-
- if (rc < -1) {
- /* an error occurred during option processing */
- DEBUG(0, ("%s: %s\n",
- poptBadOption(pc, POPT_BADOPTION_NOALIAS),
- poptStrerror(rc)));
- return NT_STATUS_INVALID_PARAMETER;
- }
-#endif
if (opt_comment) {
msg = opt_comment;
}
+ s.name = msg;
+ msg_string.name = &s;
+
if (opt_timeout) {
timeout = opt_timeout;
}
/* create an entry */
- result = rpccli_reg_shutdown(pipe_hnd, mem_ctx, msg, timeout, opt_reboot, opt_force);
+ result = rpccli_winreg_InitiateSystemShutdown(pipe_hnd, mem_ctx, NULL,
+ &msg_string, timeout, opt_force, opt_reboot);
- if (W_ERROR_IS_OK(result)) {
+ if (NT_STATUS_IS_OK(result)) {
d_printf("\nShutdown of remote machine succeeded\n");
} else {
d_fprintf(stderr, "\nShutdown of remote machine failed\n");
- if (W_ERROR_EQUAL(result,WERR_MACHINE_LOCKED))
+ if ( W_ERROR_EQUAL(ntstatus_to_werror(result),WERR_MACHINE_LOCKED) )
d_fprintf(stderr, "\nMachine locked, use -f switch to force\n");
else
- d_fprintf(stderr, "\nresult was: %s\n", dos_errstr(result));
+ d_fprintf(stderr, "\nresult was: %s\n", nt_errstr(result));
}
- return werror_to_ntstatus(result);
+ return result;
}
/**
diff --git a/source3/utils/net_rpc_registry.c b/source3/utils/net_rpc_registry.c
index 3eaff90155..36a925ae13 100644
--- a/source3/utils/net_rpc_registry.c
+++ b/source3/utils/net_rpc_registry.c
@@ -85,6 +85,8 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid,
pstring subpath;
POLICY_HND pol_hive, pol_key;
uint32 idx;
+ NTSTATUS status;
+ struct winreg_String subkeyname;
if (argc != 1 ) {
d_printf("Usage: net rpc enumerate <path> [recurse]\n");
@@ -99,16 +101,17 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid,
/* open the top level hive and then the registry key */
- result = rpccli_reg_connect(pipe_hnd, mem_ctx, hive, MAXIMUM_ALLOWED_ACCESS, &pol_hive );
- if ( !W_ERROR_IS_OK(result) ) {
+ status = rpccli_winreg_connect(pipe_hnd, mem_ctx, hive, MAXIMUM_ALLOWED_ACCESS, &pol_hive );
+ if ( !NT_STATUS_IS_OK(status) ) {
d_fprintf(stderr, "Unable to connect to remote registry: "
"%s\n", dos_errstr(result));
- return werror_to_ntstatus(result);
+ return status;
}
- result = rpccli_reg_open_entry(pipe_hnd, mem_ctx, &pol_hive, subpath,
- MAXIMUM_ALLOWED_ACCESS, &pol_key );
- if ( !W_ERROR_IS_OK(result) ) {
+ subkeyname.name = subpath;
+ status = rpccli_winreg_OpenKey(pipe_hnd, mem_ctx, &pol_hive, subkeyname,
+ 0, MAXIMUM_ALLOWED_ACCESS, &pol_key );
+ if ( !NT_STATUS_IS_OK(status) ) {
d_fprintf(stderr, "Unable to open [%s]: %s\n", argv[0],
dos_errstr(result));
return werror_to_ntstatus(result);
@@ -116,17 +119,17 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid,
/* get the subkeys */
- result = WERR_OK;
+ status = NT_STATUS_OK;
idx = 0;
- while ( W_ERROR_IS_OK(result) ) {
+ while ( NT_STATUS_IS_OK(status) ) {
time_t modtime;
fstring keyname, classname;
- result = rpccli_reg_enum_key(pipe_hnd, mem_ctx, &pol_key, idx,
+ status = rpccli_winreg_enum_key(pipe_hnd, mem_ctx, &pol_key, idx,
keyname, classname, &modtime );
- if ( W_ERROR_EQUAL(result, WERR_NO_MORE_ITEMS) ) {
- result = WERR_OK;
+ if ( W_ERROR_EQUAL(ntstatus_to_werror(status), WERR_NO_MORE_ITEMS) ) {
+ status = NT_STATUS_OK;
break;
}
@@ -138,14 +141,14 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid,
idx++;
}
- if ( !W_ERROR_IS_OK(result) )
+ if ( !NT_STATUS_IS_OK(status) )
goto out;
/* get the values */
- result = WERR_OK;
+ status = NT_STATUS_OK;
idx = 0;
- while ( W_ERROR_IS_OK(result) ) {
+ while ( NT_STATUS_IS_OK(status) ) {
uint32 type;
fstring name;
REGVAL_BUFFER value;
@@ -153,11 +156,11 @@ static NTSTATUS rpc_registry_enumerate_internal(const DOM_SID *domain_sid,
fstrcpy( name, "" );
ZERO_STRUCT( value );
- result = rpccli_reg_enum_val(pipe_hnd, mem_ctx, &pol_key, idx,
+ status = rpccli_winreg_enum_val(pipe_hnd, mem_ctx, &pol_key, idx,
name, &type, &value );
- if ( W_ERROR_EQUAL(result, WERR_NO_MORE_ITEMS) ) {
- result = WERR_OK;
+ if ( W_ERROR_EQUAL(ntstatus_to_werror(status), WERR_NO_MORE_ITEMS) ) {
+ status = NT_STATUS_OK;
break;
}
@@ -175,10 +178,10 @@ out:
/* cleanup */
if ( strlen( subpath ) != 0 )
- rpccli_reg_close(pipe_hnd, mem_ctx, &pol_key );
- rpccli_reg_close(pipe_hnd, mem_ctx, &pol_hive );
+ rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_key );
+ rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_hive );
- return werror_to_ntstatus(result);
+ return status;
}
/********************************************************************
@@ -205,6 +208,8 @@ static NTSTATUS rpc_registry_save_internal(const DOM_SID *domain_sid,
uint32 hive;
pstring subpath;
POLICY_HND pol_hive, pol_key;
+ NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
+ struct winreg_String subkeyname;
if (argc != 2 ) {
d_printf("Usage: net rpc backup <path> <file> \n");
@@ -218,30 +223,39 @@ static NTSTATUS rpc_registry_save_internal(const DOM_SID *domain_sid,
/* open the top level hive and then the registry key */
- result = rpccli_reg_connect(pipe_hnd, mem_ctx, hive, MAXIMUM_ALLOWED_ACCESS, &pol_hive );
- if ( !W_ERROR_IS_OK(result) ) {
+ status = rpccli_winreg_connect(pipe_hnd, mem_ctx, hive, MAXIMUM_ALLOWED_ACCESS, &pol_hive );
+ if ( !NT_STATUS_IS_OK(status) ) {
d_fprintf(stderr, "Unable to connect to remote registry\n");
- return werror_to_ntstatus(result);
+ return status;
}
- result = rpccli_reg_open_entry(pipe_hnd, mem_ctx, &pol_hive, subpath, MAXIMUM_ALLOWED_ACCESS, &pol_key );
- if ( !W_ERROR_IS_OK(result) ) {
+ subkeyname.name = subpath;
+ status = rpccli_winreg_OpenKey(pipe_hnd, mem_ctx, &pol_hive, subkeyname,
+ 0, MAXIMUM_ALLOWED_ACCESS, &pol_key );
+ if ( !NT_STATUS_IS_OK(status) ) {
d_fprintf(stderr, "Unable to open [%s]\n", argv[0]);
return werror_to_ntstatus(result);
}
- result = rpccli_reg_save_key(pipe_hnd, mem_ctx, &pol_key, argv[1] );
+#if 0 /* IDL not implemented */
+ /* original call was: rpccli_reg_save_key(pipe_hnd, mem_ctx, &pol_key, argv[1] ); */
+
+ status = rpccli_winreg_SaveKey( cli, mem_ctx );
if ( !W_ERROR_IS_OK(result) ) {
d_fprintf(stderr, "Unable to save [%s] to %s:%s\n", argv[0], cli->desthost, argv[1]);
}
+#else
+ d_printf("Call not implemented.\n");
+ status = NT_STATUS_NOT_IMPLEMENTED;
+#endif
/* cleanup */
- rpccli_reg_close(pipe_hnd, mem_ctx, &pol_key );
- rpccli_reg_close(pipe_hnd, mem_ctx, &pol_hive );
+ rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_key );
+ rpccli_winreg_CloseKey(pipe_hnd, mem_ctx, &pol_hive );
- return werror_to_ntstatus(result);
+ return status;
}
/********************************************************************