mirror of
https://github.com/samba-team/samba.git
synced 2025-01-15 23:24:37 +03:00
Service Control Manager - service enumeration.
(This used to be commit f4dd8f6b566961890b2933b7a413241bf9b93797)
This commit is contained in:
parent
f6c646467d
commit
0504064085
@ -1785,8 +1785,9 @@ BOOL do_svc_open_sc_man(struct cli_state *cli, uint16 fnum,
|
||||
BOOL do_svc_enum_svcs(struct cli_state *cli, uint16 fnum,
|
||||
POLICY_HND *hnd,
|
||||
uint32 services_type, uint32 services_state,
|
||||
uint32 buf_size, uint32 *resume_hnd,
|
||||
ENUM_SRVC_STATUS **svcs);
|
||||
uint32 *buf_size, uint32 *resume_hnd,
|
||||
uint32 *dos_error,
|
||||
ENUM_SRVC_STATUS **svcs, uint32 *num_svcs);
|
||||
BOOL do_svc_close(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd);
|
||||
|
||||
/*The following definitions come from rpc_client/cli_wkssvc.c */
|
||||
@ -2768,6 +2769,7 @@ void display_reg_value_info(FILE *out_hnd, enum action_type action,
|
||||
char *val_name, uint32 val_type, BUFFER2 *value);
|
||||
void display_reg_key_info(FILE *out_hnd, enum action_type action,
|
||||
char *key_name, time_t key_mod_time);
|
||||
void display_svc_info(FILE *out_hnd, enum action_type action, ENUM_SRVC_STATUS *svc);
|
||||
|
||||
/*The following definitions come from rpcclient/rpcclient.c */
|
||||
|
||||
|
@ -97,15 +97,19 @@ do a SVC Enumerate Services
|
||||
BOOL do_svc_enum_svcs(struct cli_state *cli, uint16 fnum,
|
||||
POLICY_HND *hnd,
|
||||
uint32 services_type, uint32 services_state,
|
||||
uint32 buf_size, uint32 *resume_hnd,
|
||||
ENUM_SRVC_STATUS **svcs)
|
||||
uint32 *buf_size, uint32 *resume_hnd,
|
||||
uint32 *dos_error,
|
||||
ENUM_SRVC_STATUS **svcs, uint32 *num_svcs)
|
||||
{
|
||||
prs_struct rbuf;
|
||||
prs_struct buf;
|
||||
SVC_Q_ENUM_SVCS_STATUS q_o;
|
||||
BOOL valid_pol = False;
|
||||
|
||||
if (hnd == NULL) return False;
|
||||
if (hnd == NULL || buf_size == NULL || dos_error == NULL || num_svcs == NULL)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
|
||||
prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
|
||||
@ -116,7 +120,7 @@ BOOL do_svc_enum_svcs(struct cli_state *cli, uint16 fnum,
|
||||
|
||||
make_svc_q_enum_svcs_status(&q_o, hnd,
|
||||
services_type, services_state,
|
||||
buf_size, *resume_hnd);
|
||||
*buf_size, *resume_hnd);
|
||||
|
||||
/* turn parameters into data stream */
|
||||
svc_io_q_enum_svcs_status("", &q_o, &buf, 0);
|
||||
@ -136,13 +140,16 @@ BOOL do_svc_enum_svcs(struct cli_state *cli, uint16 fnum,
|
||||
{
|
||||
/* report error code */
|
||||
DEBUG(0,("SVC_ENUM_SVCS_STATUS: %s\n", smb_err_msg(ERRDOS, r_o.dos_status)));
|
||||
p = r_o.dos_status != ERRmoredata;
|
||||
p = r_o.dos_status == ERRmoredata;
|
||||
}
|
||||
|
||||
if (p)
|
||||
{
|
||||
(*svcs) = r_o.svcs;
|
||||
(*num_svcs) = r_o.num_svcs;
|
||||
(*resume_hnd) = get_enum_hnd(&r_o.resume_hnd);
|
||||
(*buf_size) = r_o.more_buf_size;
|
||||
(*dos_error) = r_o.dos_status;
|
||||
valid_pol = True;
|
||||
}
|
||||
}
|
||||
|
@ -46,10 +46,13 @@ void cmd_svc_enum(struct client_info *info)
|
||||
BOOL res1 = True;
|
||||
int i;
|
||||
uint32 resume_hnd = 0;
|
||||
uint32 buf_size = 0;
|
||||
uint32 dos_error = 0;
|
||||
ENUM_SRVC_STATUS *svcs = NULL;
|
||||
uint32 num_svcs = 0;
|
||||
|
||||
POLICY_HND sc_man_pol;
|
||||
fstring full_keyname;
|
||||
|
||||
fstring srv_name;
|
||||
|
||||
fstrcpy(srv_name, "\\\\");
|
||||
@ -68,50 +71,38 @@ void cmd_svc_enum(struct client_info *info)
|
||||
|
||||
do
|
||||
{
|
||||
buf_size += 0x800;
|
||||
|
||||
/* enumerate services */
|
||||
res1 = res ? do_svc_enum_svcs(smb_cli, fnum,
|
||||
&sc_man_pol,
|
||||
0x00000030, 0x00000003,
|
||||
0x00000080, &resume_hnd, &svcs) : False;
|
||||
&buf_size, &resume_hnd, &dos_error,
|
||||
&svcs, &num_svcs) : False;
|
||||
|
||||
} while (resume_hnd != 0);
|
||||
} while (dos_error == ERRmoredata);
|
||||
|
||||
if (res1 && dos_error == 0x0 && num_svcs > 0 && svcs != NULL)
|
||||
{
|
||||
fprintf(out_hnd,"Services\n");
|
||||
fprintf(out_hnd,"--------\n");
|
||||
}
|
||||
|
||||
for (i = 0; i < num_svcs && svcs != NULL; i++)
|
||||
{
|
||||
if (res1)
|
||||
{
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
if (svcs != NULL)
|
||||
{
|
||||
free(svcs);
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (res1 && num_subkeys > 0)
|
||||
{
|
||||
fprintf(out_hnd,"Subkeys\n");
|
||||
fprintf(out_hnd,"-------\n");
|
||||
}
|
||||
|
||||
for (i = 0; i < num_subkeys; i++)
|
||||
{
|
||||
BOOL res2 = True;
|
||||
/*
|
||||
* enumerate key
|
||||
*/
|
||||
|
||||
/* enum key */
|
||||
res2 = res2 ? do_svc_enum_key(smb_cli, fnum, &key_pol,
|
||||
i, enum_name,
|
||||
&enum_unk1, &enum_unk2,
|
||||
&key_mod_time) : False;
|
||||
|
||||
if (res2)
|
||||
{
|
||||
display_svc_key_info(out_hnd, ACTION_HEADER , enum_name, key_mod_time);
|
||||
display_svc_key_info(out_hnd, ACTION_ENUMERATE, enum_name, key_mod_time);
|
||||
display_svc_key_info(out_hnd, ACTION_FOOTER , enum_name, key_mod_time);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
res = res ? do_svc_close(smb_cli, fnum, &sc_man_pol) : False;
|
||||
|
||||
/* close the session */
|
||||
|
@ -1535,6 +1535,30 @@ void display_reg_key_info(FILE *out_hnd, enum action_type action,
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
display structure
|
||||
****************************************************************************/
|
||||
void display_svc_info(FILE *out_hnd, enum action_type action, ENUM_SRVC_STATUS *svc)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case ACTION_HEADER:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case ACTION_ENUMERATE:
|
||||
{
|
||||
fprintf(out_hnd, "\t%s:", unistr2(svc->uni_srvc_name .buffer)); /* service name unicode string */
|
||||
fprintf(out_hnd, "\t%s\n", unistr2(svc->uni_disp_name .buffer)); /* display name unicode string */
|
||||
break;
|
||||
}
|
||||
case ACTION_FOOTER:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if COPY_THIS_TEMPLATE
|
||||
/****************************************************************************
|
||||
display structure
|
||||
|
Loading…
x
Reference in New Issue
Block a user