summaryrefslogtreecommitdiff
path: root/source3/rpcclient
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1999-01-28 21:11:15 +0000
committerLuke Leighton <lkcl@samba.org>1999-01-28 21:11:15 +0000
commit6b7e1ead37b8655cf3cfb52a421461cedb3d0c90 (patch)
treed20d00e08c00b2d5e70b337c8add390c2749bed2 /source3/rpcclient
parent92aca8b1b7d292d7c558928217f1c8dbbb9dfa87 (diff)
downloadsamba-6b7e1ead37b8655cf3cfb52a421461cedb3d0c90.tar.gz
samba-6b7e1ead37b8655cf3cfb52a421461cedb3d0c90.tar.bz2
samba-6b7e1ead37b8655cf3cfb52a421461cedb3d0c90.zip
rpcclient "Service Control Manager" svcenum [-i] command.
(This used to be commit a022710f1e3996ecbe6bbe035e1df0bc4c050b34)
Diffstat (limited to 'source3/rpcclient')
-rw-r--r--source3/rpcclient/cmd_svcctl.c42
-rw-r--r--source3/rpcclient/display.c56
-rw-r--r--source3/rpcclient/rpcclient.c2
3 files changed, 94 insertions, 6 deletions
diff --git a/source3/rpcclient/cmd_svcctl.c b/source3/rpcclient/cmd_svcctl.c
index 162b0204b7..e30c20af64 100644
--- a/source3/rpcclient/cmd_svcctl.c
+++ b/source3/rpcclient/cmd_svcctl.c
@@ -50,6 +50,8 @@ void cmd_svc_enum(struct client_info *info)
uint32 dos_error = 0;
ENUM_SRVC_STATUS *svcs = NULL;
uint32 num_svcs = 0;
+ fstring tmp;
+ BOOL request_info = False;
POLICY_HND sc_man_pol;
@@ -61,11 +63,16 @@ void cmd_svc_enum(struct client_info *info)
DEBUG(4,("cmd_svc_enum: server:%s\n", srv_name));
+ if (next_token(NULL, tmp, NULL, sizeof(tmp)))
+ {
+ request_info = strequal(tmp, "-i");
+ }
+
/* 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 ? do_svc_open_sc_man(smb_cli, fnum,
+ res = res ? svc_open_sc_man(smb_cli, fnum,
srv_name, NULL, 0x80000004,
&sc_man_pol) : False;
@@ -74,7 +81,7 @@ void cmd_svc_enum(struct client_info *info)
buf_size += 0x800;
/* enumerate services */
- res1 = res ? do_svc_enum_svcs(smb_cli, fnum,
+ res1 = res ? svc_enum_svcs(smb_cli, fnum,
&sc_man_pol,
0x00000030, 0x00000003,
&buf_size, &resume_hnd, &dos_error,
@@ -88,14 +95,39 @@ void cmd_svc_enum(struct client_info *info)
fprintf(out_hnd,"--------\n");
}
- for (i = 0; i < num_svcs && svcs != NULL; i++)
+ for (i = 0; i < num_svcs && svcs != NULL && res1; i++)
{
- if (res1)
+ BOOL res2 = request_info;
+ BOOL res3;
+ POLICY_HND svc_pol;
+ fstring svc_name;
+ QUERY_SERVICE_CONFIG cfg;
+ uint32 svc_buf_size = 0x800;
+
+ fstrcpy(svc_name, unistr2(svcs[i].uni_srvc_name.buffer));
+
+ res2 = res2 ? svc_open_service(smb_cli, fnum,
+ &sc_man_pol,
+ svc_name, 0x80000001,
+ &svc_pol) : False;
+ res3 = res2 ? svc_query_svc_cfg(smb_cli, fnum,
+ &svc_pol, &cfg,
+ &svc_buf_size) : False;
+
+ if (res3)
+ {
+ display_query_svc_cfg(out_hnd, ACTION_HEADER , &cfg);
+ display_query_svc_cfg(out_hnd, ACTION_ENUMERATE, &cfg);
+ display_query_svc_cfg(out_hnd, ACTION_FOOTER , &cfg);
+ }
+ else
{
display_svc_info(out_hnd, ACTION_HEADER , &svcs[i]);
display_svc_info(out_hnd, ACTION_ENUMERATE, &svcs[i]);
display_svc_info(out_hnd, ACTION_FOOTER , &svcs[i]);
}
+
+ res2 = res2 ? svc_close(smb_cli, fnum, &svc_pol) : False;
}
if (svcs != NULL)
@@ -103,7 +135,7 @@ void cmd_svc_enum(struct client_info *info)
free(svcs);
}
- res = res ? do_svc_close(smb_cli, fnum, &sc_man_pol) : False;
+ res = res ? svc_close(smb_cli, fnum, &sc_man_pol) : False;
/* close the session */
cli_nt_session_close(smb_cli, fnum);
diff --git a/source3/rpcclient/display.c b/source3/rpcclient/display.c
index 800b89e563..d37b7283f8 100644
--- a/source3/rpcclient/display.c
+++ b/source3/rpcclient/display.c
@@ -1536,6 +1536,62 @@ void display_reg_key_info(FILE *out_hnd, enum action_type action,
}
/****************************************************************************
+convert a security permissions into a string
+****************************************************************************/
+char *get_svc_start_type_str(uint32 type)
+{
+ static fstring typestr;
+
+ switch (type)
+ {
+ case 0x00: fstrcpy(typestr, "Boot" ); return typestr;
+ case 0x01: fstrcpy(typestr, "System" ); return typestr;
+ case 0x02: fstrcpy(typestr, "Auto" ); return typestr;
+ case 0x03: fstrcpy(typestr, "Manual" ); return typestr;
+ case 0x04: fstrcpy(typestr, "Disabled"); return typestr;
+ default : break;
+ }
+ slprintf(typestr, sizeof(typestr)-1, "[%d]", type);
+ return typestr;
+}
+
+
+/****************************************************************************
+ display structure
+ ****************************************************************************/
+void display_query_svc_cfg(FILE *out_hnd, enum action_type action,
+ QUERY_SERVICE_CONFIG *cfg)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ fprintf(out_hnd, "\tService:\t%s\n", unistr2_to_str(&cfg->uni_display_name)); /* service name unicode string */
+ fprintf(out_hnd, "\t-------\n");
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ fprintf(out_hnd, "\tPath:\t%s\n" , unistr2_to_str(&cfg->uni_bin_path_name));
+ fprintf(out_hnd, "\tLoad Order:\t%s\n" , unistr2_to_str(&cfg->uni_load_order_grp));
+ fprintf(out_hnd, "\tDependencies:\t%s\n" , unistr2_to_str(&cfg->uni_dependencies));
+ fprintf(out_hnd, "\tService Start:\t%s\n", unistr2_to_str(&cfg->uni_service_start_name));
+ fprintf(out_hnd, "\tService Type:\t%d\n" , cfg->service_type);
+ fprintf(out_hnd, "\tStart Type:\t%s\n" , get_svc_start_type_str(cfg->start_type));
+ fprintf(out_hnd, "\tError Control:\t%d\n" , cfg->error_control);
+ fprintf(out_hnd, "\tTag Id:\t%d\n" , cfg->tag_id);
+ break;
+
+ }
+ case ACTION_FOOTER:
+ {
+ fprintf(out_hnd, "\n");
+ break;
+ }
+ }
+}
+
+/****************************************************************************
display structure
****************************************************************************/
void display_svc_info(FILE *out_hnd, enum action_type action, ENUM_SRVC_STATUS *svc)
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index f2926276bc..79ab1b68a1 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -105,7 +105,7 @@ struct
char *description;
} commands[] =
{
- {"svcenum", cmd_svc_enum, "Services Manager Enumeration"},
+ {"svcenum", cmd_svc_enum, "[-i] Lists Services Manager"},
{"regenum", cmd_reg_enum, "<keyname> Registry Enumeration (keys, values)"},
{"regdeletekey",cmd_reg_delete_key, "<keyname> Registry Key Delete"},
{"regcreatekey",cmd_reg_create_key, "<keyname> [keyclass] Registry Key Create"},