diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/include/proto.h | 11 | ||||
-rw-r--r-- | source3/rpcclient/cmd_srvsvc.c | 7 | ||||
-rw-r--r-- | source3/rpcclient/display.c | 196 |
3 files changed, 214 insertions, 0 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 98cb20b12a..ad5fd558cf 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -562,6 +562,7 @@ char *client_addr(int fd); BOOL get_connection_status(struct connect_record **crec, uint32 *connection_count); +BOOL get_session_count(struct connect_record **srec,uint32 *session_count); /*The following definitions come from lib/util_str.c */ @@ -3225,6 +3226,16 @@ void display_srv_file_info_3_ctr(FILE *out_hnd, enum action_type action, SRV_FILE_INFO_3 *ctr); void display_srv_file_info_ctr(FILE *out_hnd, enum action_type action, SRV_FILE_INFO_CTR *ctr); +void display_sess_info_0(FILE *out_hnd, enum action_type action, + SESS_INFO_0 *info0, SESS_INFO_0_STR *str0); +void display_sess_info_1(FILE *out_hnd, enum action_type action, + SESS_INFO_1 *info1, SESS_INFO_1_STR *str1); +void display_srv_sess_info_0_ctr(FILE *out_hnd, enum action_type action, + SRV_SESS_INFO_0 *ctr); +void display_srv_sess_info_1_ctr(FILE *out_hnd, enum action_type action, + SRV_SESS_INFO_1 *ctr); +void display_srv_sess_info_ctr(FILE *out_hnd, enum action_type action, + SRV_SESS_INFO_CTR *ctr); void display_server(FILE *out_hnd, enum action_type action, char *sname, uint32 type, char *comment); void display_share(FILE *out_hnd, enum action_type action, diff --git a/source3/rpcclient/cmd_srvsvc.c b/source3/rpcclient/cmd_srvsvc.c index 477e68561c..c433908e20 100644 --- a/source3/rpcclient/cmd_srvsvc.c +++ b/source3/rpcclient/cmd_srvsvc.c @@ -258,6 +258,13 @@ void cmd_srv_enum_sess(struct client_info *info) res = res ? do_srv_net_srv_sess_enum(smb_cli, nt_pipe_fnum, dest_srv, NULL, NULL, info_level, &ctr, 0x1000, &hnd) : False; + if (res) + { + display_srv_sess_info_ctr(out_hnd, ACTION_HEADER , &ctr); + display_srv_sess_info_ctr(out_hnd, ACTION_ENUMERATE, &ctr); + display_srv_sess_info_ctr(out_hnd, ACTION_FOOTER , &ctr); + } + /* close the session */ cli_nt_session_close(smb_cli, nt_pipe_fnum); diff --git a/source3/rpcclient/display.c b/source3/rpcclient/display.c index fd876c5432..55010390b4 100644 --- a/source3/rpcclient/display.c +++ b/source3/rpcclient/display.c @@ -786,6 +786,202 @@ void display_srv_file_info_ctr(FILE *out_hnd, enum action_type action, } /**************************************************************************** +sess info level 0 display function +****************************************************************************/ +void display_sess_info_0(FILE *out_hnd, enum action_type action, + SESS_INFO_0 *info0, SESS_INFO_0_STR *str0) +{ + if (info0 == NULL || str0 == NULL) + { + return; + } + + switch (action) + { + case ACTION_HEADER: + { + fprintf(out_hnd, "Session Info Level 0:\n"); + + break; + } + case ACTION_ENUMERATE: + { + fstring name; + + unistr2_to_ascii(name, &str0->uni_name, + sizeof(name)-1); + + fprintf(out_hnd, "\tname:\t%s\n", name); + + break; + } + case ACTION_FOOTER: + { + fprintf(out_hnd, "\n"); + break; + } + } + +} + +/**************************************************************************** +sess info level 1 display function +****************************************************************************/ +void display_sess_info_1(FILE *out_hnd, enum action_type action, + SESS_INFO_1 *info1, SESS_INFO_1_STR *str1) +{ + if (info1 == NULL || str1 == NULL) + { + return; + } + + switch (action) + { + case ACTION_HEADER: + { + fprintf(out_hnd, "Session Info Level 1:\n"); + + break; + } + case ACTION_ENUMERATE: + { + fstring name; + fstring user_name; + + unistr2_to_ascii(user_name, &str1->uni_user, + sizeof(user_name)-1); + unistr2_to_ascii(name, &str1->uni_name, + sizeof(name)-1); + + fprintf(out_hnd, "\tname:\t%s\n", name); + + fprintf(out_hnd, "\topen :\t%d\n", info1->num_opens); + fprintf(out_hnd, "\ttime :\t%d\n", info1->open_time); + fprintf(out_hnd, "\tidle :\t%d\n", info1->idle_time); + fprintf(out_hnd, "\tflags:\t%d\n", info1->user_flags); + + fprintf(out_hnd, "\tuser :\t%s\n", user_name); + + break; + } + case ACTION_FOOTER: + { + fprintf(out_hnd, "\n"); + break; + } + } + +} + +/**************************************************************************** +sess info level 0 container display function +****************************************************************************/ +void display_srv_sess_info_0_ctr(FILE *out_hnd, enum action_type action, + SRV_SESS_INFO_0 *ctr) +{ + if (ctr == NULL) + { + fprintf(out_hnd, "display_srv_sess_info_0_ctr: unavailable due to an internal error\n"); + return; + } + + switch (action) + { + case ACTION_HEADER: + { + break; + } + case ACTION_ENUMERATE: + { + int i; + + for (i = 0; i < ctr->num_entries_read; i++) + { + display_sess_info_0(out_hnd, ACTION_HEADER , &(ctr->info_0[i]), &(ctr->info_0_str[i])); + display_sess_info_0(out_hnd, ACTION_ENUMERATE, &(ctr->info_0[i]), &(ctr->info_0_str[i])); + display_sess_info_0(out_hnd, ACTION_FOOTER , &(ctr->info_0[i]), &(ctr->info_0_str[i])); + } + break; + } + case ACTION_FOOTER: + { + break; + } + } +} + +/**************************************************************************** +sess info level 1 container display function +****************************************************************************/ +void display_srv_sess_info_1_ctr(FILE *out_hnd, enum action_type action, + SRV_SESS_INFO_1 *ctr) +{ + if (ctr == NULL) + { + fprintf(out_hnd, "display_srv_sess_info_1_ctr: unavailable due to an internal error\n"); + return; + } + + switch (action) + { + case ACTION_HEADER: + { + break; + } + case ACTION_ENUMERATE: + { + int i; + + for (i = 0; i < ctr->num_entries_read; i++) + { + display_sess_info_1(out_hnd, ACTION_HEADER , &(ctr->info_1[i]), &(ctr->info_1_str[i])); + display_sess_info_1(out_hnd, ACTION_ENUMERATE, &(ctr->info_1[i]), &(ctr->info_1_str[i])); + display_sess_info_1(out_hnd, ACTION_FOOTER , &(ctr->info_1[i]), &(ctr->info_1_str[i])); + } + break; + } + case ACTION_FOOTER: + { + break; + } + } +} + +/**************************************************************************** +sess info container display function +****************************************************************************/ +void display_srv_sess_info_ctr(FILE *out_hnd, enum action_type action, + SRV_SESS_INFO_CTR *ctr) +{ + if (ctr == NULL || ctr->ptr_sess_ctr == 0) + { + fprintf(out_hnd, "display_srv_sess_info_ctr: unavailable due to an internal error\n"); + return; + } + + switch (ctr->switch_value) + { + case 0: + { + display_srv_sess_info_0_ctr(out_hnd, action, + &(ctr->sess.info0)); + break; + } + case 1: + { + display_srv_sess_info_1_ctr(out_hnd, action, + &(ctr->sess.info1)); + break; + } + default: + { + fprintf(out_hnd, "display_srv_sess_info_ctr: Unknown Info Level\n"); + break; + } + } +} + +/**************************************************************************** print browse connection on a host ****************************************************************************/ void display_server(FILE *out_hnd, enum action_type action, |