summaryrefslogtreecommitdiff
path: root/source3/rpcclient
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1999-10-31 05:23:32 +0000
committerLuke Leighton <lkcl@samba.org>1999-10-31 05:23:32 +0000
commite7a9b398c79cb77678de18f3fc448131e1d6eb25 (patch)
treeafe7bc2d01eeeccfea36d075a4d74c178a718c65 /source3/rpcclient
parentce31503de55ffeaa6e694b9177890943442e41c0 (diff)
downloadsamba-e7a9b398c79cb77678de18f3fc448131e1d6eb25.tar.gz
samba-e7a9b398c79cb77678de18f3fc448131e1d6eb25.tar.bz2
samba-e7a9b398c79cb77678de18f3fc448131e1d6eb25.zip
added yet another rpcclient command: svcstart <service name> [arg0] [arg1] ...
works with command-line completion on the service name (ohh yesss, this is becoming my favourite bit of functionality-on-the-side hee hee :) had to fix the svc_io_q_start_service() code which was missing the ptr_argv[] array in between the array-size and the UNISTR2-array. i.e it's actually an array of _pointers_ to unicode strings... (This used to be commit 2903f22e7ed9306229035accfa757fd810645820)
Diffstat (limited to 'source3/rpcclient')
-rw-r--r--source3/rpcclient/cmd_svcctl.c71
-rw-r--r--source3/rpcclient/rpcclient.c7
2 files changed, 78 insertions, 0 deletions
diff --git a/source3/rpcclient/cmd_svcctl.c b/source3/rpcclient/cmd_svcctl.c
index 6af58035c5..f804017926 100644
--- a/source3/rpcclient/cmd_svcctl.c
+++ b/source3/rpcclient/cmd_svcctl.c
@@ -241,3 +241,74 @@ void cmd_svc_enum(struct client_info *info)
}
}
+/****************************************************************************
+nt start service
+****************************************************************************/
+void cmd_svc_start(struct client_info *info)
+{
+ uint16 fnum;
+ BOOL res = True;
+ BOOL res1 = True;
+ fstring svc_name;
+ fstring tmp;
+ BOOL res2 = True;
+ POLICY_HND pol_svc;
+ POLICY_HND pol_scm;
+ uint32 argc = 0;
+ char **argv = NULL;
+
+ fstring srv_name;
+
+ fstrcpy(srv_name, "\\\\");
+ fstrcat(srv_name, info->myhostname);
+ strupper(srv_name);
+
+ DEBUG(4,("cmd_svc_info: server:%s\n", srv_name));
+
+ if (!next_token(NULL, svc_name, NULL, sizeof(svc_name)))
+ {
+ report(out_hnd,"svcstart <service name> [arg 0] [arg 1]...]\n");
+ return;
+ }
+
+ while (next_token(NULL, tmp, NULL, sizeof(tmp)))
+ {
+ add_chars_to_array(&argc, &argv, tmp);
+ }
+
+ /* open SVCCTL session. */
+ res = res ? cli_nt_session_open(smb_cli, PIPE_SVCCTL, &fnum) : False;
+
+ /* open service control manager receive a policy handle */
+ res = res ? svc_open_sc_man(smb_cli, fnum,
+ srv_name, NULL, 0x80000000,
+ &pol_scm) : False;
+
+ res1 = res ? svc_open_service(smb_cli, fnum,
+ &pol_scm,
+ svc_name, 0x80000010,
+ &pol_svc) : False;
+ res2 = res1 ? svc_start_service(smb_cli, fnum,
+ &pol_svc, argc, argv) : False;
+
+ res1 = res1 ? svc_close(smb_cli, fnum, &pol_svc) : False;
+ res = res ? svc_close(smb_cli, fnum, &pol_scm) : False;
+
+ /* close the session */
+ cli_nt_session_close(smb_cli, fnum);
+
+ if (res2)
+ {
+ report(out_hnd,"Started Service %s\n", svc_name);
+ DEBUG(5,("cmd_svc_start: succeeded\n"));
+ }
+ else
+ report(out_hnd,"Failed Service Startup (%s)\n", svc_name);
+ {
+ DEBUG(5,("cmd_svc_start: failed\n"));
+ }
+
+ free_char_array(argc, argv);
+
+}
+
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index 50f77b35a1..9a1193c015 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -146,6 +146,13 @@ commands[] =
{COMPL_SVCLST, COMPL_NONE}
},
+ {
+ "svcstart",
+ cmd_svc_start,
+ "<service> [arg 0] [arg 1] ... Start Service",
+ {COMPL_SVCLST, COMPL_NONE}
+ },
+
/*
* scheduler
*/