summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/rpcclient/cmd_samr.c4
-rw-r--r--source3/rpcclient/display.c3106
-rw-r--r--source3/rpcclient/display_at.c190
-rw-r--r--source3/rpcclient/display_event.c101
-rw-r--r--source3/rpcclient/display_reg.c168
-rw-r--r--source3/rpcclient/display_sam.c685
-rw-r--r--source3/rpcclient/display_sec.c232
-rw-r--r--source3/rpcclient/display_spool.c457
-rw-r--r--source3/rpcclient/display_srv.c1198
-rw-r--r--source3/rpcclient/display_svc.c126
-rw-r--r--source3/rpcclient/display_sync.c116
-rw-r--r--source3/rpcclient/rpcclient.c69
12 files changed, 3343 insertions, 3109 deletions
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
index 9c0bb9ce7d..c4cb613ee2 100644
--- a/source3/rpcclient/cmd_samr.c
+++ b/source3/rpcclient/cmd_samr.c
@@ -1862,7 +1862,7 @@ void cmd_sam_set_userinfo(struct client_info *info, int argc, char *argv[])
if (True)
{
- SAM_USER_INFO_24 *p = malloc(sizeof(SAM_USER_INFO_24));
+ SAM_USER_INFO_24 *p = (SAM_USER_INFO_24*)malloc(sizeof(SAM_USER_INFO_24));
make_sam_user_info24(p, pwbuf);
usr = p;
@@ -1871,7 +1871,7 @@ void cmd_sam_set_userinfo(struct client_info *info, int argc, char *argv[])
if (False)
{
- SAM_USER_INFO_23 *p = malloc(sizeof(SAM_USER_INFO_23));
+ SAM_USER_INFO_23 *p = (SAM_USER_INFO_23*)malloc(sizeof(SAM_USER_INFO_23));
/* send user info query, level 0x15 */
make_sam_user_info23W(p,
&usr21.logon_time,
diff --git a/source3/rpcclient/display.c b/source3/rpcclient/display.c
deleted file mode 100644
index 58bdba5ffb..0000000000
--- a/source3/rpcclient/display.c
+++ /dev/null
@@ -1,3106 +0,0 @@
-/*
- Unix SMB/Netbios implementation.
- Version 1.9.
- Samba utility functions
- Copyright (C) Andrew Tridgell 1992-1999
- Copyright (C) Luke Kenneth Casson Leighton 1996 - 1999
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#include "includes.h"
-
-
-struct field_info sid_name_info[] =
-{
- { SID_NAME_UNKNOWN, "UNKNOWN" }, /* default */
- { SID_NAME_USER , "User" },
- { SID_NAME_DOM_GRP, "Domain Group" },
- { SID_NAME_DOMAIN , "Domain" },
- { SID_NAME_ALIAS , "Local Group" },
- { SID_NAME_WKN_GRP, "Well-known Group"},
- { SID_NAME_DELETED, "Deleted" },
- { SID_NAME_INVALID, "Invalid" },
- { 0 , NULL }
-};
-
-/****************************************************************************
-convert a SID_NAME_USE to a string
-****************************************************************************/
-char *get_sid_name_use_str(uint8 sid_name_use)
-{
- return enum_field_to_str((uint32)sid_name_use, sid_name_info, True);
-}
-
-/****************************************************************************
-convert a share mode to a string
-****************************************************************************/
-char *get_file_mode_str(uint32 share_mode)
-{
- static fstring mode;
-
- switch ((share_mode>>4)&0xF)
- {
- case DENY_NONE : fstrcpy(mode, "DENY_NONE "); break;
- case DENY_ALL : fstrcpy(mode, "DENY_ALL "); break;
- case DENY_DOS : fstrcpy(mode, "DENY_DOS "); break;
- case DENY_READ : fstrcpy(mode, "DENY_READ "); break;
- case DENY_WRITE: fstrcpy(mode, "DENY_WRITE "); break;
- default : fstrcpy(mode, "DENY_???? "); break;
- }
-
- switch (share_mode & 0xF)
- {
- case 0 : fstrcat(mode, "RDONLY"); break;
- case 1 : fstrcat(mode, "WRONLY"); break;
- case 2 : fstrcat(mode, "RDWR "); break;
- default: fstrcat(mode, "R??W??"); break;
- }
-
- return mode;
-}
-
-/****************************************************************************
-convert an oplock mode to a string
-****************************************************************************/
-char *get_file_oplock_str(uint32 op_type)
-{
- static fstring oplock;
- BOOL excl = IS_BITS_SET_ALL(op_type, EXCLUSIVE_OPLOCK);
- BOOL batch = IS_BITS_SET_ALL(op_type, BATCH_OPLOCK );
-
- oplock[0] = 0;
-
- if (excl ) fstrcat(oplock, "EXCLUSIVE");
- if (excl && batch) fstrcat(oplock, "+");
- if ( batch) fstrcat(oplock, "BATCH");
- if (!excl && !batch) fstrcat(oplock, "NONE");
-
- return oplock;
-}
-
-/****************************************************************************
-convert a share type enum to a string
-****************************************************************************/
-char *get_share_type_str(uint32 type)
-{
- static fstring typestr;
-
- switch (type)
- {
- case STYPE_DISKTREE: fstrcpy(typestr, "Disk" ); break;
- case STYPE_PRINTQ : fstrcpy(typestr, "Printer"); break;
- case STYPE_DEVICE : fstrcpy(typestr, "Device" ); break;
- case STYPE_IPC : fstrcpy(typestr, "IPC" ); break;
- default : fstrcpy(typestr, "????" ); break;
- }
- return typestr;
-}
-
-/****************************************************************************
-convert a server type enum to a string
-****************************************************************************/
-char *get_server_type_str(uint32 type)
-{
- static fstring typestr;
-
- if (type == SV_TYPE_ALL)
- {
- fstrcpy(typestr, "All");
- }
- else
- {
- int i;
- typestr[0] = 0;
- for (i = 0; i < 32; i++)
- {
- if (IS_BITS_SET_ALL(type, 1 << i))
- {
- switch (1 << i)
- {
- case SV_TYPE_WORKSTATION : fstrcat(typestr, "Wk " ); break;
- case SV_TYPE_SERVER : fstrcat(typestr, "Sv " ); break;
- case SV_TYPE_SQLSERVER : fstrcat(typestr, "Sql "); break;
- case SV_TYPE_DOMAIN_CTRL : fstrcat(typestr, "PDC "); break;
- case SV_TYPE_DOMAIN_BAKCTRL : fstrcat(typestr, "BDC "); break;
- case SV_TYPE_TIME_SOURCE : fstrcat(typestr, "Tim "); break;
- case SV_TYPE_AFP : fstrcat(typestr, "AFP "); break;
- case SV_TYPE_NOVELL : fstrcat(typestr, "Nov "); break;
- case SV_TYPE_DOMAIN_MEMBER : fstrcat(typestr, "Dom "); break;
- case SV_TYPE_PRINTQ_SERVER : fstrcat(typestr, "PrQ "); break;
- case SV_TYPE_DIALIN_SERVER : fstrcat(typestr, "Din "); break;
- case SV_TYPE_SERVER_UNIX : fstrcat(typestr, "Unx "); break;
- case SV_TYPE_NT : fstrcat(typestr, "NT " ); break;
- case SV_TYPE_WFW : fstrcat(typestr, "Wfw "); break;
- case SV_TYPE_SERVER_MFPN : fstrcat(typestr, "Mfp "); break;
- case SV_TYPE_SERVER_NT : fstrcat(typestr, "SNT "); break;
- case SV_TYPE_POTENTIAL_BROWSER: fstrcat(typestr, "PtB "); break;
- case SV_TYPE_BACKUP_BROWSER : fstrcat(typestr, "BMB "); break;
- case SV_TYPE_MASTER_BROWSER : fstrcat(typestr, "LMB "); break;
- case SV_TYPE_DOMAIN_MASTER : fstrcat(typestr, "DMB "); break;
- case SV_TYPE_SERVER_OSF : fstrcat(typestr, "OSF "); break;
- case SV_TYPE_SERVER_VMS : fstrcat(typestr, "VMS "); break;
- case SV_TYPE_WIN95_PLUS : fstrcat(typestr, "W95 "); break;
- case SV_TYPE_ALTERNATE_XPORT : fstrcat(typestr, "Xpt "); break;
- case SV_TYPE_LOCAL_LIST_ONLY : fstrcat(typestr, "Dom "); break;
- case SV_TYPE_DOMAIN_ENUM : fstrcat(typestr, "Loc "); break;
- }
- }
- }
- i = strlen(typestr)-1;
- if (typestr[i] == ' ') typestr[i] = 0;
-
- }
- return typestr;
-}
-
-/****************************************************************************
-server info level 101 display function
-****************************************************************************/
-void display_srv_info_101(FILE *out_hnd, enum action_type action,
- SRV_INFO_101 *const sv101)
-{
- if (sv101 == NULL)
- {
- return;
- }
-
- switch (action)
- {
- case ACTION_HEADER:
- {
- report(out_hnd, "Server Info Level 101:\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- fstring name;
- fstring comment;
-
- unistr2_to_ascii(name, &sv101->uni_name, sizeof(name)-1);
- unistr2_to_ascii(comment, &sv101->uni_comment, sizeof(comment)-1);
-
- display_server(out_hnd, action, name, sv101->srv_type, comment);
-
- report(out_hnd, "\tplatform_id :\t%d\n" , sv101->platform_id);
- report(out_hnd, "\tos version :\t%d.%d\n" , sv101->ver_major, sv101->ver_minor);
-
- break;
- }
- case ACTION_FOOTER:
- {
- break;
- }
- }
-
-}
-
-/****************************************************************************
-server info level 102 display function
-****************************************************************************/
-void display_srv_info_102(FILE *out_hnd, enum action_type action, SRV_INFO_102 *const sv102)
-{
- if (sv102 == NULL)
- {
- return;
- }
-
- switch (action)
- {
- case ACTION_HEADER:
- {
- report(out_hnd, "Server Info Level 102:\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- fstring name;
- fstring comment;
- fstring usr_path;
-
- unistr2_to_ascii(name, &sv102->uni_name, sizeof(name)-1);
- unistr2_to_ascii(comment, &sv102->uni_comment, sizeof(comment)-1);
- unistr2_to_ascii(usr_path, &sv102->uni_usr_path,
- sizeof(usr_path)-1);
-
- display_server(out_hnd, action, name, sv102->srv_type, comment);
-
- report(out_hnd, "\tplatform_id :\t%d\n" , sv102->platform_id);
- report(out_hnd, "\tos version :\t%d.%d\n" , sv102->ver_major, sv102->ver_minor);
-
- report(out_hnd, "\tusers :\t%x\n" , sv102->users );
- report(out_hnd, "\tdisc, hidden :\t%x, %x\n" , sv102->disc , sv102->hidden );
- report(out_hnd, "\tannounce, delta :\t%d, %d\n", sv102->announce , sv102->ann_delta);
- report(out_hnd, "\tlicenses :\t%d\n" , sv102->licenses );
- report(out_hnd, "\tuser path :\t%s\n" , usr_path);
-
- break;
- }
- case ACTION_FOOTER:
- {
- break;
- }
- }
-}
-
-/****************************************************************************
-server info container display function
-****************************************************************************/
-void display_srv_info_ctr(FILE *out_hnd, enum action_type action, SRV_INFO_CTR *const ctr)
-{
- if (ctr == NULL || ctr->ptr_srv_ctr == 0)
- {
- report(out_hnd, "Server Information: unavailable due to an error\n");
- return;
- }
-
- switch (ctr->switch_value)
- {
- case 101:
- {
- display_srv_info_101(out_hnd, action, &(ctr->srv.sv101));
- break;
- }
- case 102:
- {
- display_srv_info_102(out_hnd, action, &(ctr->srv.sv102));
- break;
- }
- default:
- {
- report(out_hnd, "Server Information: Unknown Info Level\n");
- break;
- }
- }
-}
-
-/****************************************************************************
-connection info level 0 display function
-****************************************************************************/
-void display_conn_info_0(FILE *out_hnd, enum action_type action,
- CONN_INFO_0 *const info0)
-{
- if (info0 == NULL)
- {
- return;
- }
-
- switch (action)
- {
- case ACTION_HEADER:
- {
- report(out_hnd, "Connection Info Level 0:\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- report(out_hnd, "\tid:\t%d\n", info0->id);
-
- break;
- }
- case ACTION_FOOTER:
- {
- report(out_hnd, "\n");
- break;
- }
- }
-
-}
-
-/****************************************************************************
-connection info level 1 display function
-****************************************************************************/
-void display_conn_info_1(FILE *out_hnd, enum action_type action,
- CONN_INFO_1 *const info1, CONN_INFO_1_STR *const str1)
-{
- if (info1 == NULL || str1 == NULL)
- {
- return;
- }
-
- switch (action)
- {
- case ACTION_HEADER:
- {
- report(out_hnd, "Connection Info Level 1:\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- fstring usr_name;
- fstring net_name;
-
- unistr2_to_ascii(usr_name, &str1->uni_usr_name, sizeof(usr_name)-1);
- unistr2_to_ascii(net_name, &str1->uni_net_name, sizeof(net_name)-1);
-
- report(out_hnd, "\tid :\t%d\n", info1->id);
- report(out_hnd, "\ttype :\t%s\n", get_share_type_str(info1->type));
- report(out_hnd, "\tnum_opens:\t%d\n", info1->num_opens);
- report(out_hnd, "\tnum_users:\t%d\n", info1->num_users);
- report(out_hnd, "\topen_time:\t%d\n", info1->open_time);
-
- report(out_hnd, "\tuser name:\t%s\n", usr_name);
- report(out_hnd, "\tnet name:\t%s\n", net_name);
-
- break;
- }
- case ACTION_FOOTER:
- {
- report(out_hnd, "\n");
- break;
- }
- }
-
-}
-
-/****************************************************************************
-connection info level 0 container display function
-****************************************************************************/
-void display_srv_conn_info_0_ctr(FILE *out_hnd, enum action_type action,
- SRV_CONN_INFO_0 *const ctr)
-{
- if (ctr == NULL)
- {
- report(out_hnd, "display_srv_conn_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_conn_info_0(out_hnd, ACTION_HEADER , &(ctr->info_0[i]));
- display_conn_info_0(out_hnd, ACTION_ENUMERATE, &(ctr->info_0[i]));
- display_conn_info_0(out_hnd, ACTION_FOOTER , &(ctr->info_0[i]));
- }
- break;
- }
- case ACTION_FOOTER:
- {
- break;
- }
- }
-}
-
-/****************************************************************************
-connection info level 1 container display function
-****************************************************************************/
-void display_srv_conn_info_1_ctr(FILE *out_hnd, enum action_type action,
- SRV_CONN_INFO_1 *const ctr)
-{
- if (ctr == NULL)
- {
- report(out_hnd, "display_srv_conn_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_conn_info_1(out_hnd, ACTION_HEADER , &(ctr->info_1[i]), &(ctr->info_1_str[i]));
- display_conn_info_1(out_hnd, ACTION_ENUMERATE, &(ctr->info_1[i]), &(ctr->info_1_str[i]));
- display_conn_info_1(out_hnd, ACTION_FOOTER , &(ctr->info_1[i]), &(ctr->info_1_str[i]));
- }
- break;
- }
- case ACTION_FOOTER:
- {
- break;
- }
- }
-}
-
-/****************************************************************************
-connection info container display function
-****************************************************************************/
-void display_srv_conn_info_ctr(FILE *out_hnd, enum action_type action,
- SRV_CONN_INFO_CTR *const ctr)
-{
- if (ctr == NULL || ctr->ptr_conn_ctr == 0)
- {
- report(out_hnd, "display_srv_conn_info_ctr: unavailable due to an internal error\n");
- return;
- }
-
- switch (ctr->switch_value)
- {
- case 0:
- {
- display_srv_conn_info_0_ctr(out_hnd, action,
- &(ctr->conn.info0));
- break;
- }
- case 1:
- {
- display_srv_conn_info_1_ctr(out_hnd, action,
- &(ctr->conn.info1));
- break;
- }
- default:
- {
- report(out_hnd, "display_srv_conn_info_ctr: Unknown Info Level\n");
- break;
- }
- }
-}
-
-
-/****************************************************************************
-transport info level 0 display function
-****************************************************************************/
-void display_tprt_info_0(FILE *out_hnd, enum action_type action,
- TPRT_INFO_0 *const info0, TPRT_INFO_0_STR *const str0)
-{
- if (info0 == NULL || str0 == NULL)
- {
- return;
- }
-
- switch (action)
- {
- case ACTION_HEADER:
- {
- report(out_hnd, "Transport Info Level 0:\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- fstring trans_name;
- fstring trans_addr;
- fstring addr_name;
-
- unistr2_to_ascii(trans_name, &str0->uni_trans_name, sizeof(trans_name)-1);
- buffer4_to_str(trans_addr, &str0->buf_trans_addr, sizeof(trans_addr)-1);
- unistr2_to_ascii(addr_name, &str0->uni_addr_name, sizeof(addr_name)-1);
-
- report(out_hnd, "\tnum_vcs :\t%d\n", info0->num_vcs);
- report(out_hnd, "\ttransport name:\t%s\n", trans_name);
- report(out_hnd, "\ttransport addr:\t%s\n", trans_addr);
- report(out_hnd, "\taddress name:\t%s\n", addr_name);
-
- break;
- }
- case ACTION_FOOTER:
- {
- report(out_hnd, "\n");
- break;
- }
- }
-
-}
-
-/****************************************************************************
-transport info level 0 container display function
-****************************************************************************/
-void display_srv_tprt_info_0_ctr(FILE *out_hnd, enum action_type action,
- const SRV_TPRT_INFO_0 *const ctr)
-{
- if (ctr == NULL)
- {
- report(out_hnd, "display_srv_tprt_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_tprt_info_0(out_hnd, ACTION_HEADER , &(ctr->info_0[i]), &(ctr->info_0_str[i]));
- display_tprt_info_0(out_hnd, ACTION_ENUMERATE, &(ctr->info_0[i]), &(ctr->info_0_str[i]));
- display_tprt_info_0(out_hnd, ACTION_FOOTER , &(ctr->info_0[i]), &(ctr->info_0_str[i]));
- }
- break;
- }
- case ACTION_FOOTER:
- {
- break;
- }
- }
-}
-
-/****************************************************************************
-transport info container display function
-****************************************************************************/
-void display_srv_tprt_info_ctr(FILE *out_hnd, enum action_type action,
- const SRV_TPRT_INFO_CTR *const ctr)
-{
- if (ctr == NULL || ctr->ptr_tprt_ctr == 0)
- {
- report(out_hnd, "display_srv_tprt_info_ctr: unavailable due to an internal error\n");
- return;
- }
-
- switch (ctr->switch_value)
- {
- case 0:
- {
- display_srv_tprt_info_0_ctr(out_hnd, action,
- &(ctr->tprt.info0));
- break;
- }
- default:
- {
- report(out_hnd, "display_srv_tprt_info_ctr: Unknown Info Level\n");
- break;
- }
- }
-}
-
-
-/****************************************************************************
-share info level 1 display function
-****************************************************************************/
-void display_share_info_1(FILE *out_hnd, enum action_type action,
- SH_INFO_1 *const info1, SH_INFO_1_STR *const str1)
-{
- if (info1 == NULL || str1 == NULL)
- {
- return;
- }
-
- switch (action)
- {
- case ACTION_HEADER:
- {
- report(out_hnd, "Share Info Level 1:\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- fstring remark ;
- fstring net_name;
-
- unistr2_to_ascii(net_name, &str1->uni_netname, sizeof(net_name)-1);
- unistr2_to_ascii(remark, &str1->uni_remark, sizeof(remark)-1);
-
- display_share(out_hnd, action, net_name, info1->type, remark);
-
- break;
- }
- case ACTION_FOOTER:
- {
- report(out_hnd, "\n");
- break;
- }
- }
-
-}
-
-/****************************************************************************
-share info level 2 display function
-****************************************************************************/
-void display_share_info_2(FILE *out_hnd, enum action_type action,
- SH_INFO_2 *const info2, SH_INFO_2_STR *const str2)
-{
- if (info2 == NULL || str2 == NULL)
- {
- return;
- }
-
- switch (action)
- {
- case ACTION_HEADER:
- {
- report(out_hnd, "Share Info Level 2:\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- fstring remark ;
- fstring net_name;
- fstring path ;
- fstring passwd ;
-
- unistr2_to_ascii(net_name, &str2->uni_netname, sizeof(net_name)-1);
- unistr2_to_ascii(remark, &str2->uni_remark, sizeof(remark)-1);
- unistr2_to_ascii(path, &str2->uni_path, sizeof(path)-1);
- unistr2_to_ascii(passwd, &str2->uni_passwd, sizeof(passwd)-1);
-
- display_share2(out_hnd, action, net_name, info2->type, remark,
- info2->perms, info2->max_uses, info2->num_uses,
- path, passwd);
-
- break;
- }
- case ACTION_FOOTER:
- {
- report(out_hnd, "\n");
- break;
- }
- }
-
-}
-
-/****************************************************************************
-share info level 1 container display function
-****************************************************************************/
-void display_srv_share_info_1_ctr(FILE *out_hnd, enum action_type action,
- SRV_SHARE_INFO_1 *const ctr)
-{
- if (ctr == NULL)
- {
- report(out_hnd, "display_srv_share_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_share_info_1(out_hnd, ACTION_HEADER , &(ctr->info_1[i]), &(ctr->info_1_str[i]));
- display_share_info_1(out_hnd, ACTION_ENUMERATE, &(ctr->info_1[i]), &(ctr->info_1_str[i]));
- display_share_info_1(out_hnd, ACTION_FOOTER , &(ctr->info_1[i]), &(ctr->info_1_str[i]));
- }
- break;
- }
- case ACTION_FOOTER:
- {
- break;
- }
- }
-}
-
-/****************************************************************************
-share info level 2 container display function
-****************************************************************************/
-void display_srv_share_info_2_ctr(FILE *out_hnd, enum action_type action,
- SRV_SHARE_INFO_2 *const ctr)
-{
- if (ctr == NULL)
- {
- report(out_hnd, "display_srv_share_info_2_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_share_info_2(out_hnd, ACTION_HEADER , &(ctr->info_2[i]), &(ctr->info_2_str[i]));
- display_share_info_2(out_hnd, ACTION_ENUMERATE, &(ctr->info_2[i]), &(ctr->info_2_str[i]));
- display_share_info_2(out_hnd, ACTION_FOOTER , &(ctr->info_2[i]), &(ctr->info_2_str[i]));
- }
- break;
- }
- case ACTION_FOOTER:
- {
- break;
- }
- }
-}
-
-/****************************************************************************
-share info container display function
-****************************************************************************/
-void display_srv_share_info_ctr(FILE *out_hnd, enum action_type action,
- SRV_SHARE_INFO_CTR *const ctr)
-{
- if (ctr == NULL || ctr->ptr_share_ctr == 0)
- {
- report(out_hnd, "display_srv_share_info_ctr: unavailable due to an internal error\n");
- return;
- }
-
- switch (ctr->switch_value)
- {
- case 1:
- {
- display_srv_share_info_1_ctr(out_hnd, action,
- &(ctr->share.info1));
- break;
- }
- case 2:
- {
- display_srv_share_info_2_ctr(out_hnd, action,
- &(ctr->share.info2));
- break;
- }
- default:
- {
- report(out_hnd, "display_srv_share_info_ctr: Unknown Info Level\n");
- break;
- }
- }
-}
-
-
-/****************************************************************************
-file info level 3 display function
-****************************************************************************/
-void display_file_info_3(FILE *out_hnd, enum action_type action,
- FILE_INFO_3 *const info3, FILE_INFO_3_STR *const str3)
-{
- if (info3 == NULL || str3 == NULL)
- {
- return;
- }
-
- switch (action)
- {
- case ACTION_HEADER:
- {
- report(out_hnd, "File Info Level 3:\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- fstring path_name;
- fstring user_name;
-
- unistr2_to_ascii(path_name, &str3->uni_path_name,
- sizeof(path_name)-1);
- unistr2_to_ascii(user_name, &str3->uni_user_name,
- sizeof(user_name)-1);
-
- report(out_hnd, "\tid :\t%d\n", info3->id);
- report(out_hnd, "\tperms :\t%s\n", get_file_mode_str(info3->perms));
- report(out_hnd, "\tnum_locks:\t%d\n", info3->num_locks);
-
- report(out_hnd, "\tpath name:\t%s\n", path_name);
- report(out_hnd, "\tuser name:\t%s\n", user_name);
-
- break;
- }
- case ACTION_FOOTER:
- {
- report(out_hnd, "\n");
- break;
- }
- }
-
-}
-
-/****************************************************************************
-file info level 3 container display function
-****************************************************************************/
-void display_srv_file_info_3_ctr(FILE *out_hnd, enum action_type action,
- SRV_FILE_INFO_3 *const ctr)
-{
- if (ctr == NULL)
- {
- report(out_hnd, "display_srv_file_info_3_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_file_info_3(out_hnd, ACTION_HEADER , &(ctr->info_3[i]), &(ctr->info_3_str[i]));
- display_file_info_3(out_hnd, ACTION_ENUMERATE, &(ctr->info_3[i]), &(ctr->info_3_str[i]));
- display_file_info_3(out_hnd, ACTION_FOOTER , &(ctr->info_3[i]), &(ctr->info_3_str[i]));
- }
- break;
- }
- case ACTION_FOOTER:
- {
- break;
- }
- }
-}
-
-/****************************************************************************
-file info container display function
-****************************************************************************/
-void display_srv_file_info_ctr(FILE *out_hnd, enum action_type action,
- SRV_FILE_INFO_CTR *const ctr)
-{
- if (ctr == NULL || ctr->ptr_file_ctr == 0)
- {
- report(out_hnd, "display_srv_file_info_ctr: unavailable due to an internal error\n");
- return;
- }
-
- switch (ctr->switch_value)
- {
- case 3:
- {
- display_srv_file_info_3_ctr(out_hnd, action,
- &(ctr->file.info3));
- break;
- }
- default:
- {
- report(out_hnd, "display_srv_file_info_ctr: Unknown Info Level\n");
- break;
- }
- }
-}
-
-/****************************************************************************
-sess info level 0 display function
-****************************************************************************/
-void display_sess_info_0(FILE *out_hnd, enum action_type action,
- SESS_INFO_0 *const info0, SESS_INFO_0_STR *const str0)
-{
- if (info0 == NULL || str0 == NULL)
- {
- return;
- }
-
- switch (action)
- {
- case ACTION_HEADER:
- {
- report(out_hnd, "Session Info Level 0:\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- fstring name;
-
- unistr2_to_ascii(name, &str0->uni_name,
- sizeof(name)-1);
-
- report(out_hnd, "\tname:\t%s\n", name);
-
- break;
- }
- case ACTION_FOOTER:
- {
- report(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 *const info1, SESS_INFO_1_STR *const str1)
-{
- if (info1 == NULL || str1 == NULL)
- {
- return;
- }
-
- switch (action)
- {
- case ACTION_HEADER:
- {
- report(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);
-
- report(out_hnd, "\tname:\t%s\n", name);
-
- report(out_hnd, "\topen :\t%d\n", info1->num_opens);
- report(out_hnd, "\ttime :\t%d\n", info1->open_time);
- report(out_hnd, "\tidle :\t%d\n", info1->idle_time);
- report(out_hnd, "\tflags:\t%d\n", info1->user_flags);
-
- report(out_hnd, "\tuser :\t%s\n", user_name);
-
- break;
- }
- case ACTION_FOOTER:
- {
- report(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 *const ctr)
-{
- if (ctr == NULL)
- {
- report(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 *const ctr)
-{
- if (ctr == NULL)
- {
- report(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 *const ctr)
-{
- if (ctr == NULL || ctr->ptr_sess_ctr == 0)
- {
- report(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:
- {
- report(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,
- char *const sname, uint32 type, char *const comment)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- break;
- }
- case ACTION_ENUMERATE:
- {
- report(out_hnd, "\t%-15.15s%-20s %s\n",
- sname, get_server_type_str(type), comment);
- break;
- }
- case ACTION_FOOTER:
- {
- break;
- }
- }
-}
-
-/****************************************************************************
-print shares on a host
-****************************************************************************/
-void display_share(FILE *out_hnd, enum action_type action,
- char *const sname, uint32 type, char *const comment)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- break;
- }
- case ACTION_ENUMERATE:
- {
- report(out_hnd, "\t%-15.15s%-10.10s%s\n",
- sname, get_share_type_str(type), comment);
- break;
- }
- case ACTION_FOOTER:
- {
- break;
- }
- }
-}
-
-
-/****************************************************************************
-print shares on a host, level 2
-****************************************************************************/
-void display_share2(FILE *out_hnd, enum action_type action,
- char *const sname, uint32 type, char *const comment,
- uint32 perms, uint32 max_uses, uint32 num_uses,
- char *const path, char *const passwd)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- break;
- }
- case ACTION_ENUMERATE:
- {
- report(out_hnd, "\t%-15.15s%-10.10s%s %x %x %x %s %s\n",
- sname, get_share_type_str(type), comment,
- perms, max_uses, num_uses, path, passwd);
- break;
- }
- case ACTION_FOOTER:
- {
- break;
- }
- }
-}
-
-
-/****************************************************************************
-print name info
-****************************************************************************/
-void display_name(FILE *out_hnd, enum action_type action,
- char *const sname)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- break;
- }
- case ACTION_ENUMERATE:
- {
- report(out_hnd, "\t%-21.21s\n", sname);
- break;
- }
- case ACTION_FOOTER:
- {
- break;
- }
- }
-}
-
-
-/****************************************************************************
- display alias members
- ****************************************************************************/
-void display_alias_members(FILE *out_hnd, enum action_type action,
- uint32 num_mem, char *const *const sid_mem,
- uint8 *const type)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- if (num_mem == 0)
- {
- report(out_hnd, "\tNo Alias Members\n");
- }
- else
- {
- report(out_hnd, "\tAlias Members:\n");
- report(out_hnd, "\t-------------\n");
- }
- break;
- }
- case ACTION_ENUMERATE:
- {
- int i;
-
- for (i = 0; i < num_mem; i++)
- {
- if (sid_mem[i] != NULL)
- {
- report(out_hnd, "\tMember Name:\t%s\tType:\t%s\n",
- sid_mem[i],
- get_sid_name_use_str(type[i]));
- }
- }
-
- break;
- }
- case ACTION_FOOTER:
- {
- report(out_hnd, "\n");
- break;
- }
- }
-}
-
-
-/****************************************************************************
- display alias rid info
- ****************************************************************************/
-void display_alias_rid_info(FILE *out_hnd, enum action_type action,
- DOM_SID *const sid,
- uint32 num_rids, uint32 *const rid)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- fstring sid_str;
- sid_to_string(sid_str, sid);
- if (num_rids == 0)
- {
- report(out_hnd, "\tNo Aliases:\tSid %s\n", sid_str);
- }
- else
- {
- report(out_hnd, "\tAlias Info:\tSid %s\n", sid_str);
- report(out_hnd, "\t----------\n");
- }
- break;
- }
- case ACTION_ENUMERATE:
- {
- int i;
-
- for (i = 0; i < num_rids; i++)
- {
- report(out_hnd, "\tAlias RID:\t%8x\n", rid[i]);
- }
-
- break;
- }
- case ACTION_FOOTER:
- {
- report(out_hnd, "\n");
- break;
- }
- }
-}
-
-/****************************************************************************
- display group members
- ****************************************************************************/
-void display_group_members(FILE *out_hnd, enum action_type action,
- uint32 num_mem, char *const *const name, uint32 *const type)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- if (num_mem == 0)
- {
- report(out_hnd, "\tNo Members\n");
- }
- else
- {
- report(out_hnd, "\tMembers:\n");
- report(out_hnd, "\t-------\n");
- }
- break;
- }
- case ACTION_ENUMERATE:
- {
- int i;
-
- for (i = 0; i < num_mem; i++)
- {
- report(out_hnd, "\tMember Name:\t%s\tType:\t%s\n",
- name[i], get_sid_name_use_str(type[i]));
- }
-
- break;
- }
- case ACTION_FOOTER:
- {
- report(out_hnd, "\n");
- break;
- }
- }
-}
-
-
-/****************************************************************************
- display group info
- ****************************************************************************/
-void display_group_info1(FILE *out_hnd, enum action_type action, GROUP_INFO1 *const info1)
-
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- break;
- }
- case ACTION_ENUMERATE:
- {
- fstring temp;
-
- unistr2_to_ascii(temp, &info1->uni_acct_name, sizeof(temp)-1);
- report(out_hnd, "\tGroup Name:\t%s\n", temp);
- unistr2_to_ascii(temp, &info1->uni_acct_desc, sizeof(temp)-1);
- report(out_hnd, "\tDescription:\t%s\n", temp);
- report(out_hnd, "\tunk1:%d\n", info1->unknown_1);
- report(out_hnd, "\tNum Members:%d\n", info1->num_members);
- break;
- }
- case ACTION_FOOTER:
- {
- break;
- }
- }
-}
-
-/****************************************************************************
- display group info
- ****************************************************************************/
-void display_group_info4(FILE *out_hnd, enum action_type action, GROUP_INFO4 *const info4)
-
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- break;
- }
- case ACTION_ENUMERATE:
- {
- fstring desc;
-
- unistr2_to_ascii(desc, &info4->uni_acct_desc, sizeof(desc)-1);
- report(out_hnd, "\tGroup Description:%s\n",
- desc);
- break;
- }
- case ACTION_FOOTER:
- {
- break;
- }
- }
-}
-
-/****************************************************************************
- display sam sync structure
- ****************************************************************************/
-void display_group_info_ctr(FILE *out_hnd, enum action_type action,
- GROUP_INFO_CTR *const ctr)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- report(out_hnd, "\tSAM Group Info\n");
- report(out_hnd, "\t--------------\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- switch (ctr->switch_value1)
- {
- case 1:
- {
- display_group_info1(out_hnd, ACTION_HEADER , &ctr->group.info1);
- display_group_info1(out_hnd, ACTION_ENUMERATE, &ctr->group.info1);
- display_group_info1(out_hnd, ACTION_FOOTER , &ctr->group.info1);
- break;
- }
- case 4:
- {
- display_group_info4(out_hnd, ACTION_HEADER , &ctr->group.info4);
- display_group_info4(out_hnd, ACTION_ENUMERATE, &ctr->group.info4);
- display_group_info4(out_hnd, ACTION_FOOTER , &ctr->group.info4);
- break;
- }
- }
- break;
- }
- case ACTION_FOOTER:
- {
- report(out_hnd, "\n");
- break;
- }
- }
-}
-
-/****************************************************************************
- display group rid info
- ****************************************************************************/
-void display_group_rid_info(FILE *out_hnd, enum action_type action,
- uint32 num_gids, DOM_GID *const gid)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- if (num_gids == 0)
- {
- report(out_hnd, "\tNo Groups\n");
- }
- else
- {
- report(out_hnd, "\tGroup Info\n");
- report(out_hnd, "\t----------\n");
- }
- break;
- }
- case ACTION_ENUMERATE:
- {
- int i;
-
- for (i = 0; i < num_gids; i++)
- {
- report(out_hnd, "\tGroup RID:\t%8x attr:\t%x\n",
- gid[i].g_rid, gid[i].attr);
- }
-
- break;
- }
- case ACTION_FOOTER:
- {
- report(out_hnd, "\n");
- break;
- }
- }
-}
-
-
-/****************************************************************************
- display alias name info
- ****************************************************************************/
-void display_alias_name_info(FILE *out_hnd, enum action_type action,
- uint32 num_aliases, fstring *const alias_name, const uint32 *const num_als_usrs)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- if (num_aliases == 0)
- {
- report(out_hnd, "\tNo Aliases\n");
- }
- else
- {
- report(out_hnd, "\tAlias Names\n");
- report(out_hnd, "\t----------- \n");
- }
- break;
- }
- case ACTION_ENUMERATE:
- {
- int i;
-
- for (i = 0; i < num_aliases; i++)
- {
- report(out_hnd, "\tAlias Name:\t%s Attributes:\t%3d\n",
- alias_name[i], num_als_usrs[i]);
- }
-
- break;
- }
- case ACTION_FOOTER:
- {
- report(out_hnd, "\n");
- break;
- }
- }
-}
-
-/****************************************************************************
- display alias info
- ****************************************************************************/
-void display_alias_info3(FILE *out_hnd, enum action_type action, ALIAS_INFO3 *const info3)
-
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- break;
- }
- case ACTION_ENUMERATE:
- {
- fstring temp;
-
- unistr2_to_ascii(temp, &info3->uni_acct_desc, sizeof(temp)-1);
- report(out_hnd, "\tDescription:\t%s\n", temp);
- break;
- }
- case ACTION_FOOTER:
- {
- break;
- }
- }
-}
-
-/****************************************************************************
- display sam sync structure
- ****************************************************************************/
-void display_alias_info_ctr(FILE *out_hnd, enum action_type action,
- ALIAS_INFO_CTR *const ctr)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- report(out_hnd, "\tSAM Group Info\n");
- report(out_hnd, "\t--------------\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- switch (ctr->switch_value1)
- {
- case 3:
- {
- display_alias_info3(out_hnd, ACTION_HEADER , &ctr->alias.info3);
- display_alias_info3(out_hnd, ACTION_ENUMERATE, &ctr->alias.info3);
- display_alias_info3(out_hnd, ACTION_FOOTER , &ctr->alias.info3);
- break;
- }
- }
- break;
- }
- case ACTION_FOOTER:
- {
- report(out_hnd, "\n");
- break;
- }
- }
-}
-
-
-/****************************************************************************
- display sam_user_info_21 structure
- ****************************************************************************/
-void display_sam_user_info_21(FILE *out_hnd, enum action_type action, SAM_USER_INFO_21 *const usr)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- report(out_hnd, "\tUser Info, Level 0x15\n");
- report(out_hnd, "\t---------------------\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- fstring temp;
-
- unistr2_to_ascii(temp, &usr->uni_user_name, sizeof(temp)-1);
- report(out_hnd, "\t\tUser Name :\t%s\n", temp);
-
- unistr2_to_ascii(temp, &usr->uni_full_name, sizeof(temp)-1);
- report(out_hnd, "\t\tFull Name :\t%s\n", temp);
-
- unistr2_to_ascii(temp, &usr->uni_home_dir, sizeof(temp)-1);
- report(out_hnd, "\t\tHome Drive :\t%s\n", temp);
-
- unistr2_to_ascii(temp, &usr->uni_dir_drive, sizeof(temp)-1);
- report(out_hnd, "\t\tDir Drive :\t%s\n", temp);
-
- unistr2_to_ascii(temp, &usr->uni_profile_path, sizeof(temp)-1);
- report(out_hnd, "\t\tProfile Path:\t%s\n", temp);
-
- unistr2_to_ascii(temp, &usr->uni_logon_script, sizeof(temp)-1);
- report(out_hnd, "\t\tLogon Script:\t%s\n", temp);
-
- unistr2_to_ascii(temp, &usr->uni_acct_desc, sizeof(temp)-1);
- report(out_hnd, "\t\tDescription :\t%s\n", temp);
-
- unistr2_to_ascii(temp, &usr->uni_workstations, sizeof(temp)-1);
- report(out_hnd, "\t\tWorkstations:\t%s\n", temp);
-
- unistr2_to_ascii(temp, &usr->uni_unknown_str, sizeof(temp)-1);
- report(out_hnd, "\t\tUnknown Str :\t%s\n", temp);
-
- unistr2_to_ascii(temp, &usr->uni_munged_dial, sizeof(temp)-1);
- report(out_hnd, "\t\tRemote Dial :\t%s\n", temp);
-
- report(out_hnd, "\t\tLogon Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->logon_time ))));
- report(out_hnd, "\t\tLogoff Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->logoff_time ))));
- report(out_hnd, "\t\tKickoff Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->kickoff_time ))));
- report(out_hnd, "\t\tPassword last set Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->pass_last_set_time ))));
- report(out_hnd, "\t\tPassword can change Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->pass_can_change_time ))));
- report(out_hnd, "\t\tPassword must change Time:\t%s\n", http_timestring(nt_time_to_unix(&(usr->pass_must_change_time))));
-
- report(out_hnd, "\t\tunknown_2[0..31]...\n"); /* user passwords? */
-
- report(out_hnd, "\t\tuser_rid :\t%x\n" , usr->user_rid ); /* User ID */
- report(out_hnd, "\t\tgroup_rid:\t%x\n" , usr->group_rid); /* Group ID */
- report(out_hnd, "\t\tacb_info :\t%04x\n", usr->acb_info ); /* Account Control Info */
-
- report(out_hnd, "\t\tunknown_3:\t%08x\n", usr->unknown_3); /* 0x00ff ffff */
- report(out_hnd, "\t\tlogon_divs:\t%d\n", usr->logon_divs); /* 0x0000 00a8 which is 168 which is num hrs in a week */
- report(out_hnd, "\t\tunknown_5:\t%08x\n", usr->unknown_5); /* 0x0002 0000 */
-
- report(out_hnd, "\t\tpadding1[0..7]...\n");
-
- if (usr->ptr_logon_hrs)
- {
- report(out_hnd, "\t\tlogon_hrs[0..%d]...\n", usr->logon_hrs.len);
- }
-
- break;
- }
- case ACTION_FOOTER:
- {
- report(out_hnd, "\n");
- break;
- }
- }
-}
-
-
-/****************************************************************************
-convert a security permissions into a string
-****************************************************************************/
-char *get_sec_mask_str(uint32 type)
-{
- static fstring typestr;
- int i;
-
- switch (type)
- {
- case SEC_RIGHTS_FULL_CONTROL:
- {
- fstrcpy(typestr, "Full Control");
- return typestr;
- }
-
- case SEC_RIGHTS_READ:
- {
- fstrcpy(typestr, "Read");
- return typestr;
- }
- default:
- {
- break;
- }
- }
-
- typestr[0] = 0;
- for (i = 0; i < 32; i++)
- {
- if (IS_BITS_SET_ALL(type, 1 << i))
- {
- switch (1 << i)
- {
- case SEC_RIGHTS_QUERY_VALUE : fstrcat(typestr, "Query " ); break;
- case SEC_RIGHTS_SET_VALUE : fstrcat(typestr, "Set " ); break;
- case SEC_RIGHTS_CREATE_SUBKEY : fstrcat(typestr, "Create "); break;
- case SEC_RIGHTS_ENUM_SUBKEYS : fstrcat(typestr, "Enum "); break;
- case SEC_RIGHTS_NOTIFY : fstrcat(typestr, "Notify "); break;
- case SEC_RIGHTS_CREATE_LINK : fstrcat(typestr, "CreateLink "); break;
- case SEC_RIGHTS_DELETE : fstrcat(typestr, "Delete "); break;
- case SEC_RIGHTS_READ_CONTROL : fstrcat(typestr, "ReadControl "); break;
- case SEC_RIGHTS_WRITE_DAC : fstrcat(typestr, "WriteDAC "); break;
- case SEC_RIGHTS_WRITE_OWNER : fstrcat(typestr, "WriteOwner "); break;
- }
- type &= ~(1 << i);
- }
- }
-
- /* remaining bits get added on as-is */
- if (type != 0)
- {
- fstring tmp;
- slprintf(tmp, sizeof(tmp)-1, "[%08x]", type);
- fstrcat(typestr, tmp);
- }
-
- /* remove last space */
- i = strlen(typestr)-1;
- if (typestr[i] == ' ') typestr[i] = 0;
-
- return typestr;
-}
-
-/****************************************************************************
- display sec_access structure
- ****************************************************************************/
-void display_sec_access(FILE *out_hnd, enum action_type action, SEC_ACCESS *const info)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- break;
- }
- case ACTION_ENUMERATE:
- {
- report(out_hnd, "\t\tPermissions:\t%s\n",
- get_sec_mask_str(info->mask));
- }
- case ACTION_FOOTER:
- {
- break;
- }
- }
-}
-
-/****************************************************************************
- display sec_ace structure
- ****************************************************************************/
-void display_sec_ace(FILE *out_hnd, enum action_type action, SEC_ACE *const ace)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- report(out_hnd, "\tACE\n");
- break;
- }
- case ACTION_ENUMERATE:
- {
- fstring sid_str;
-
- display_sec_access(out_hnd, ACTION_HEADER , &ace->info);
- display_sec_access(out_hnd, ACTION_ENUMERATE, &ace->info);
- display_sec_access(out_hnd, ACTION_FOOTER , &ace->info);
-
- sid_to_string(sid_str, &ace->sid);
- report(out_hnd, "\t\tSID:\t%s\n", sid_str);
- }
- case ACTION_FOOTER:
- {
- break;
- }
- }
-}
-
-/****************************************************************************
- display sec_acl structure
- ****************************************************************************/
-void display_sec_acl(FILE *out_hnd, enum action_type action, SEC_ACL *const sec_acl)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- report(out_hnd, "\tACL\tNum ACEs:\t%d\trevision:\t%x\n",
- sec_acl->num_aces, sec_acl->revision);
- report(out_hnd, "\t---\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- if (sec_acl->size != 0 && sec_acl->num_aces != 0)
- {
- int i;
- for (i = 0; i < sec_acl->num_aces; i++)
- {
- display_sec_ace(out_hnd, ACTION_HEADER , &sec_acl->ace[i]);
- display_sec_ace(out_hnd, ACTION_ENUMERATE, &sec_acl->ace[i]);
- display_sec_ace(out_hnd, ACTION_FOOTER , &sec_acl->ace[i]);
- }
- }
-
- break;
- }
- case ACTION_FOOTER:
- {
- report(out_hnd, "\n");
- break;
- }
- }
-}
-
-/****************************************************************************
- display sec_desc structure
- ****************************************************************************/
-void display_sec_desc(FILE *out_hnd, enum action_type action, SEC_DESC *const sec)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- report(out_hnd, "\tSecurity Descriptor\trevision:\t%x\ttype:\t%x\n",
- sec->revision, sec->type);
- report(out_hnd, "\t-------------------\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- fstring sid_str;
-
- if (sec->off_sacl != 0)
- {
- display_sec_acl(out_hnd, ACTION_HEADER , sec->sacl);
- display_sec_acl(out_hnd, ACTION_ENUMERATE, sec->sacl);
- display_sec_acl(out_hnd, ACTION_FOOTER , sec->sacl);
- }
- if (sec->off_dacl != 0)
- {
- display_sec_acl(out_hnd, ACTION_HEADER , sec->dacl);
- display_sec_acl(out_hnd, ACTION_ENUMERATE, sec->dacl);
- display_sec_acl(out_hnd, ACTION_FOOTER , sec->dacl);
- }
- if (sec->off_owner_sid != 0)
- {
- sid_to_string(sid_str, sec->owner_sid);
- report(out_hnd, "\tOwner SID:\t%s\n", sid_str);
- }
- if (sec->off_grp_sid != 0)
- {
- sid_to_string(sid_str, sec->grp_sid);
- report(out_hnd, "\tParent SID:\t%s\n", sid_str);
- }
-
- break;
- }
- case ACTION_FOOTER:
- {
- report(out_hnd, "\n");
- break;
- }
- }
-}
-
-/****************************************************************************
-convert a security permissions into a string
-****************************************************************************/
-char *get_reg_val_type_str(uint32 type)
-{
- static fstring typestr;
-
- switch (type)
- {
- case 0x01:
- {
- fstrcpy(typestr, "string");
- return typestr;
- }
-
- case 0x03:
- {
- fstrcpy(typestr, "bytes");
- return typestr;
- }
-
- case 0x04:
- {
- fstrcpy(typestr, "uint32");
- return typestr;
- }
-
- case 0x07:
- {
- fstrcpy(typestr, "multi");
- return typestr;
- }
- default:
- {
- break;
- }
- }
- slprintf(typestr, sizeof(typestr)-1, "[%d]", type);
- return typestr;
-}
-
-
-static void print_reg_value(FILE *out_hnd, const char *val_name,
- uint32 val_type, const BUFFER2 *value)
-{
- fstring type;
- fstring valstr;
-
- fstrcpy(type, get_reg_val_type_str(val_type));
-
- switch (val_type)
- {
- case 0x01: /* unistr */
- {
- unibuf_to_ascii(valstr, value->buffer,
- MIN(value->buf_len, sizeof(valstr)-1));
- report(out_hnd, "\t%s:\t%s:\t%s\n", val_name, type, valstr);
- break;
- }
-
- default: /* unknown */
- case 0x03: /* bytes */
- {
- if (value->buf_len <= 8)
- {
- report(out_hnd, "\t%s:\t%s:\t", val_name, type);
- out_data(out_hnd, (const char*)value->buffer,
- value->buf_len, 8);
- }
- else
- {
- report(out_hnd, "\t%s:\t%s:\n", val_name, type);
- out_data(out_hnd, (const char*)value->buffer,
- value->buf_len, 16);
- }
- break;
- }
-
- case 0x04: /* uint32 */
- {
- report(out_hnd, "\t%s:\t%s:\t0x%08x\n", val_name, type, buffer2_to_uint32(value));
- break;
- }
-
- case 0x07: /* multiunistr */
- {
- buffer2_to_multistr(valstr, value, sizeof(valstr)-1);
- report(out_hnd, "\t%s:\t%s:\t%s\n", val_name, type, valstr);
- break;
- }
- }
-}
-
-/****************************************************************************
- display structure
- ****************************************************************************/
-void display_reg_value_info(FILE *out_hnd, enum action_type action,
- const char *val_name,
- uint32 val_type, const BUFFER2 *value)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- break;
- }
- case ACTION_ENUMERATE:
- {
- print_reg_value(out_hnd, val_name, val_type, value);
- break;
- }
- case ACTION_FOOTER:
- {
- break;
- }
- }
-}
-
-/****************************************************************************
- display structure
- ****************************************************************************/
-void display_reg_key_info(FILE *out_hnd, enum action_type action,
- const char *key_name, time_t key_mod_time)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- break;
- }
- case ACTION_ENUMERATE:
- {
- report(out_hnd, "\t%s\t(%s)\n",
- key_name, http_timestring(key_mod_time));
- break;
- }
- case ACTION_FOOTER:
- {
- break;
- }
- }
-}
-
-/****************************************************************************
-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,
- const QUERY_SERVICE_CONFIG *const cfg)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- fstring service;
-
- unistr2_to_ascii(service, &cfg->uni_display_name, sizeof(service)-1);
- report(out_hnd, "\tService:\t%s\n", service);
- report(out_hnd, "\t-------\n");
- break;
- }
- case ACTION_ENUMERATE:
- {
- fstring temp;
-
- unistr2_to_ascii(temp, &cfg->uni_bin_path_name, sizeof(temp)-1);
- report(out_hnd, "\tPath:\t%s\n", temp);
-
- unistr2_to_ascii(temp, &cfg->uni_load_order_grp, sizeof(temp)-1);
- report(out_hnd, "\tLoad Order:\t%s\n", temp);
-
- unistr2_to_ascii(temp, &cfg->uni_dependencies, sizeof(temp)-1);
- report(out_hnd, "\tDependencies:\t%s\n", temp);
-
- unistr2_to_ascii(temp, &cfg->uni_service_start_name, sizeof(temp)-1);
- report(out_hnd, "\tService Start:\t%s\n", temp);
-
- report(out_hnd, "\tService Type:\t%d\n", cfg->service_type);
- report(out_hnd, "\tStart Type:\t%s\n" , get_svc_start_type_str(cfg->start_type));
- report(out_hnd, "\tError Control:\t%d\n" , cfg->error_control);
- report(out_hnd, "\tTag Id:\t%d\n" , cfg->tag_id);
- break;
-
- }
- case ACTION_FOOTER:
- {
- report(out_hnd, "\n");
- break;
- }
- }
-}
-
-/****************************************************************************
- display structure
- ****************************************************************************/
-void display_svc_info(FILE *out_hnd, enum action_type action,
- const ENUM_SRVC_STATUS *const svc)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- break;
- }
- case ACTION_ENUMERATE:
- {
- fstring name;
-
- unistr_to_ascii(name, svc->uni_srvc_name.buffer,
- sizeof(name)-1); /* service name */
- report(out_hnd, "\t%s:", name);
-
- unistr_to_ascii(name, svc->uni_disp_name.buffer,
- sizeof(name)-1); /* display name */
- report(out_hnd, "\t%s\n", name);
- break;
- }
- case ACTION_FOOTER:
- {
- break;
- }
- }
-}
-
-static char *get_at_time_str(uint32 t)
-{
- static fstring timestr;
- unsigned int hours, minutes, seconds;
-
- hours = t / 1000;
- seconds = hours % 60;
- hours /= 60;
- minutes = hours % 60;
- hours /= 60;
-
- slprintf(timestr, sizeof(timestr)-1, "%2d:%02d:%02d",
- hours, minutes, seconds);
-
- return timestr;
-}
-
-extern char *daynames_short[];
-
-static char *get_at_days_str(uint32 monthdays, uint8 weekdays, uint8 flags)
-{
- static fstring days;
- fstring numstr;
- int day, bit;
- BOOL first = True;
-
- if (monthdays == 0 && weekdays == 0)
- return "Once";
-
- if (flags & JOB_PERIODIC)
- {
- if (IS_BITS_SET_ALL(weekdays, 0x7F))
- return "Every Day";
-
- fstrcpy(days, "Every ");
- }
- else
- {
- fstrcpy(days, "Next ");
- }
-
- for (day = 1, bit = 1; day < 32; day++, bit <<= 1)
- {
- if (monthdays & bit)
- {
- if (first)
- first = False;
- else
- fstrcat(days, ", ");
-
- slprintf(numstr, sizeof(numstr)-1, "%d", day);
- fstrcat(days, numstr);
- }
- }
-
- for (day = 0, bit = 1; day < 7; day++, bit <<= 1)
- {
- if (weekdays & bit)
- {
- if (first)
- first = False;
- else
- fstrcat(days, ", ");
-
- fstrcat(days, daynames_short[day]);
- }
- }
-
- return days;
-}
-
-/****************************************************************************
- display scheduled jobs
- ****************************************************************************/
-void display_at_enum_info(FILE *out_hnd, enum action_type action,
- uint32 num_jobs, const AT_ENUM_INFO *const jobs,
- char *const *const commands)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- if (num_jobs == 0)
- {
- report(out_hnd, "\tNo Jobs.\n");
- }
- else
- {
- report(out_hnd, "\tJobs:\n");
- report(out_hnd, "\t-----\n");
- }
- break;
- }
- case ACTION_ENUMERATE:
- {
- int i;
-
- for (i = 0; i < num_jobs; i++)
- {
- const AT_JOB_INFO *const job = &jobs[i].info;
-
- report(out_hnd, "\t%d\t%s\t%s\t%s\n",
- jobs[i].jobid,
- get_at_time_str(job->time),
- get_at_days_str(job->monthdays,
- job->weekdays,
- job->flags),
- commands[i]);
- }
-
- break;
- }
- case ACTION_FOOTER:
- {
- report(out_hnd, "\n");
- break;
- }
- }
-}
-
-/****************************************************************************
- display information about a scheduled job
- ****************************************************************************/
-void display_at_job_info(FILE *out_hnd, enum action_type action,
- AT_JOB_INFO *const job, fstring command)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- report(out_hnd, "\tJob Information:\n");
- report(out_hnd, "\t----------------\n");
- break;
- }
- case ACTION_ENUMERATE:
- {
- report(out_hnd, "\tTime: %s\n",
- get_at_time_str(job->time));
-
- report(out_hnd, "\tSchedule: %s\n",
- get_at_days_str(job->monthdays, job->weekdays,
- job->flags));
-
- report(out_hnd, "\tStatus: %s",
- (job->flags & JOB_EXEC_ERR) ? "Failed" : "OK");
-
- if (job->flags & JOB_RUNS_TODAY)
- {
- report(out_hnd, ", Runs Today");
- }
-
- report(out_hnd, "\n\tInteractive: %s\n",
- (job->flags & JOB_NONINTERACTIVE) ? "No"
- : "Yes");
-
- report(out_hnd, "\tCommand: %s\n", command);
- break;
- }
- case ACTION_FOOTER:
- {
- report(out_hnd, "\n");
- break;
- }
- }
-}
-
-/****************************************************************************
- display structure
- ****************************************************************************/
-void display_eventlog_eventrecord(FILE *out_hnd, enum action_type action, EVENTLOGRECORD *const ev)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- report(out_hnd, "\tevent log records\n");
- report(out_hnd, "\t-----------------\n");
- break;
- }
- case ACTION_ENUMERATE:
- {
- fstring temp;
- report(out_hnd, "\t\trecord n.:\t%d\n", ev->recordnumber);
-
- report(out_hnd, "\t\tsource\teventnumber\teventtype\tcategory\n");
- unistr_to_ascii(temp, ev->sourcename.buffer, sizeof(temp)-1);
-
- report(out_hnd, "\t\t%s", temp);
-
- report(out_hnd, "\t%d\t\t", ev->eventnumber&0x0000FFFF);
-
- switch (ev->eventtype)
- {
- case EVENTLOG_OK:
- report(out_hnd, "Normal");
- break;
-
- case EVENTLOG_ERROR:
- report(out_hnd, "Error");
- break;
-
- case EVENTLOG_WARNING:
- report(out_hnd, "Warning");
- break;
-
- case EVENTLOG_INFORMATION:
- report(out_hnd, "Information");
- break;
-
- case EVENTLOG_AUDIT_OK:
- report(out_hnd, "Audit Normal");
- break;
-
- case EVENTLOG_AUDIT_ERROR:
- report(out_hnd, "Audit Error\n");
- break;
- }
-
- report(out_hnd, "\t%d\n", ev->category);
- report(out_hnd, "\t\tcreationtime:\t%s\n", http_timestring(ev->creationtime));
- report(out_hnd, "\t\twritetime:\t%s\n", http_timestring(ev->writetime));
-
- unistr_to_ascii(temp, ev->computername.buffer, sizeof(temp)-1);
- report(out_hnd, "\t\tcomputer:\t%s\n", temp);
-
- if (ev->num_of_strings!=0)
- {
- unistr_to_ascii(temp, ev->strings.buffer, sizeof(temp)-1);
- report(out_hnd, "\t\tdescription:\t%s\n", temp);
- }
-
- report(out_hnd, "\n");
- break;
- }
- case ACTION_FOOTER:
- {
- report(out_hnd, "\n");
- break;
- }
- }
-}
-
-/****************************************************************************
- display sam sync structure
- ****************************************************************************/
-void display_sam_sync_ctr(FILE *out_hnd, enum action_type action,
- SAM_DELTA_HDR *const delta,
- SAM_DELTA_CTR *const ctr)
-{
- fstring name;
-
- switch (action)
- {
- case ACTION_HEADER:
- {
- break;
- }
- case ACTION_ENUMERATE:
- {
- switch (delta->type)
- {
- case 1:
- {
- unistr2_to_ascii(name, &(ctr->domain_info.uni_dom_name), sizeof(name)-1);
- report(out_hnd, "Domain: %s\n", name);
- break;
- }
- case 2:
- {
- unistr2_to_ascii(name, &(ctr->group_info.uni_grp_name), sizeof(name)-1);
- report(out_hnd, "Group: %s\n", name);
- break;
- }
- case 5:
- {
- unsigned char lm_pwd[16];
- unsigned char nt_pwd[16];
-
- unistr2_to_ascii(name, &(ctr->account_info.uni_acct_name), sizeof(name)-1);
- report(out_hnd, "Account: %s\n", name);
-
- sam_pwd_hash(ctr->account_info.user_rid, ctr->account_info.pass.buf_lm_pwd, lm_pwd, 0);
- out_struct(out_hnd, lm_pwd, 16, 8);
-
- sam_pwd_hash(ctr->account_info.user_rid, ctr->account_info.pass.buf_nt_pwd, nt_pwd, 0);
- out_struct(out_hnd, nt_pwd, 16, 8);
- }
- }
- break;
- }
- case ACTION_FOOTER:
- {
- break;
- }
- }
-}
-
-/****************************************************************************
- display sam sync structure
- ****************************************************************************/
-void display_sam_sync(FILE *out_hnd, enum action_type action,
- SAM_DELTA_HDR *const deltas,
- SAM_DELTA_CTR *const ctr,
- uint32 num)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- report(out_hnd, "\tSAM Database Sync\n");
- report(out_hnd, "\t-----------------\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- int i;
- for (i = 0; i < num; i++)
- {
- display_sam_sync_ctr(out_hnd, ACTION_HEADER , &deltas[i], &ctr[i]);
- display_sam_sync_ctr(out_hnd, ACTION_ENUMERATE, &deltas[i], &ctr[i]);
- display_sam_sync_ctr(out_hnd, ACTION_FOOTER , &deltas[i], &ctr[i]);
- }
- break;
- }
- case ACTION_FOOTER:
- {
- report(out_hnd, "\n");
- break;
- }
- }
-}
-
-/****************************************************************************
- display sam sync structure
- ****************************************************************************/
-void display_sam_unk_info_2(FILE *out_hnd, enum action_type action,
- SAM_UNK_INFO_2 *const info2)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- break;
- }
- case ACTION_ENUMERATE:
- {
- fstring name;
- unistr2_to_ascii(name, &(info2->uni_domain), sizeof(name)-1);
- report(out_hnd, "Domain:\t%s\n", name);
-
- unistr2_to_ascii(name, &(info2->uni_server), sizeof(name)-1);
- report(out_hnd, "Server:\t%s\n", name);
-
- report(out_hnd, "Total Users:\t%d\n", info2->num_domain_usrs);
- report(out_hnd, "Total Groups:\t%d\n", info2->num_domain_grps);
- report(out_hnd, "Total Aliases:\t%d\n", info2->num_local_grps);
-
- report(out_hnd, "Sequence No:\t%d\n", info2->seq_num);
-
- report(out_hnd, "Unknown 0:\t0x%x\n", info2->unknown_0);
- report(out_hnd, "Unknown 1:\t0x%x\n", info2->unknown_1);
- report(out_hnd, "Unknown 2:\t0x%x\n", info2->unknown_2);
- report(out_hnd, "Unknown 3:\t0x%x\n", info2->unknown_3);
- report(out_hnd, "Unknown 4:\t0x%x\n", info2->unknown_4);
- report(out_hnd, "Unknown 5:\t0x%x\n", info2->unknown_5);
- report(out_hnd, "Unknown 6:\t0x%x\n", info2->unknown_6);
-
- break;
- }
- case ACTION_FOOTER:
- {
- report(out_hnd, "\n");
- break;
- }
- }
-}
-
-/****************************************************************************
- display sam sync structure
- ****************************************************************************/
-void display_sam_unk_ctr(FILE *out_hnd, enum action_type action,
- uint32 switch_value, SAM_UNK_CTR *const ctr)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- report(out_hnd, "\tSAM Domain Info\n");
- report(out_hnd, "\t---------------\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- switch (switch_value)
- {
- case 2:
- {
- display_sam_unk_info_2(out_hnd, ACTION_HEADER , &ctr->info.inf2);
- display_sam_unk_info_2(out_hnd, ACTION_ENUMERATE, &ctr->info.inf2);
- display_sam_unk_info_2(out_hnd, ACTION_FOOTER , &ctr->info.inf2);
- break;
- }
- }
- break;
- }
- case ACTION_FOOTER:
- {
- report(out_hnd, "\n");
- break;
- }
- }
-}
-
-/****************************************************************************
-sam info level 1 display function
-****************************************************************************/
-void display_sam_info_1(FILE *out_hnd, enum action_type action,
- SAM_ENTRY1 *const e1, SAM_STR1 *const s1)
-{
- if (e1 == NULL)
- {
- return;
- }
-
- switch (action)
- {
- case ACTION_HEADER:
- {
- report(out_hnd, "Sam Level 1:\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- fstring tmp;
-
- report(out_hnd, "\tIndex:\t%d\n", e1->user_idx);
- report(out_hnd, "\tRID:\t0x%x\n", e1->rid_user);
- report(out_hnd, "\tACB:\t%s\n",
- pwdb_encode_acct_ctrl(e1->acb_info,
- NEW_PW_FORMAT_SPACE_PADDED_LEN));
-
- unistr_to_ascii(tmp, s1->uni_acct_name.buffer, sizeof(tmp)-1);
- report(out_hnd, "\tAccount Name:\t%s\n", tmp);
- unistr_to_ascii(tmp, s1->uni_full_name.buffer, sizeof(tmp)-1);
- report(out_hnd, "\tFull Name:\t%s\n", tmp);
- unistr_to_ascii(tmp, s1->uni_acct_desc.buffer, sizeof(tmp)-1);
- report(out_hnd, "\tUser Description:\t%s\n", tmp);
-
- break;
- }
- case ACTION_FOOTER:
- {
- report(out_hnd, "\n");
- break;
- }
- }
-
-}
-
-/****************************************************************************
-connection info level 1 container display function
-****************************************************************************/
-void display_sam_info_1_ctr(FILE *out_hnd, enum action_type action,
- uint32 count, SAM_DISPINFO_1 *const ctr)
-{
- if (ctr == NULL)
- {
- report(out_hnd, "display_sam_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 < count; i++)
- {
- display_sam_info_1(out_hnd, ACTION_HEADER , &ctr->sam[i], &ctr->str[i]);
- display_sam_info_1(out_hnd, ACTION_ENUMERATE, &ctr->sam[i], &ctr->str[i]);
- display_sam_info_1(out_hnd, ACTION_FOOTER , &ctr->sam[i], &ctr->str[i]);
- }
- break;
- }
- case ACTION_FOOTER:
- {
- break;
- }
- }
-}
-
-/****************************************************************************
-connection info container display function
-****************************************************************************/
-void display_sam_disp_info_ctr(FILE *out_hnd, enum action_type action,
- uint16 level, uint32 count,
- SAM_DISPINFO_CTR *const ctr)
-{
- if (ctr == NULL)
- {
- report(out_hnd, "display_sam_info_ctr: unavailable due to an internal error\n");
- return;
- }
-
- switch (level)
- {
- case 1:
- {
- display_sam_info_1_ctr(out_hnd, action,
- count, ctr->sam.info1);
- break;
- }
- default:
- {
- report(out_hnd, "display_sam_info_ctr: Unknown Info Level\n");
- break;
- }
- }
-}
-
-/****************************************************************************
-printer info level 0 display function
-****************************************************************************/
-void display_print_info_0(FILE *out_hnd, enum action_type action,
- PRINTER_INFO_0 *const i0)
-{
- if (i0 == NULL)
- {
- return;
- }
-
- switch (action)
- {
- case ACTION_HEADER:
- {
- report(out_hnd, "Printer Info Level 0:\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- fstring name;
- fstring serv;
-
- unistr_to_ascii(name, i0->printername.buffer, sizeof(name)-1);
- unistr_to_ascii(serv, i0->servername .buffer, sizeof(serv)-1);
-
- report(out_hnd, "\tprinter name:\t%s\n", name);
- report(out_hnd, "\tserver name:\t%s\n", serv);
- report(out_hnd, "\t[Other info not displayed]\n");
-
- break;
- }
- case ACTION_FOOTER:
- {
- report(out_hnd, "\n");
- break;
- }
- }
-
-}
-
-/****************************************************************************
-printer info level 1 display function
-****************************************************************************/
-void display_print_info_1(FILE *out_hnd, enum action_type action,
- PRINTER_INFO_1 *const i1)
-{
- if (i1 == NULL)
- {
- return;
- }
-
- switch (action)
- {
- case ACTION_HEADER:
- {
- report(out_hnd, "Printer Info Level 1:\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- fstring desc;
- fstring name;
- fstring comm;
-
- unistr_to_ascii(desc, i1->description.buffer, sizeof(desc)-1);
- unistr_to_ascii(name, i1->name .buffer, sizeof(name)-1);
- unistr_to_ascii(comm, i1->comment .buffer, sizeof(comm)-1);
-
- report(out_hnd, "\tflags:\t%d\n", i1->flags);
- report(out_hnd, "\tname:\t%s\n", name);
- report(out_hnd, "\tdescription:\t%s\n", desc);
- report(out_hnd, "\tcomment:\t%s\n", comm);
-
- break;
- }
- case ACTION_FOOTER:
- {
- report(out_hnd, "\n");
- break;
- }
- }
-
-}
-
-/****************************************************************************
-connection info level 0 container display function
-****************************************************************************/
-void display_printer_info_0_ctr(FILE *out_hnd, enum action_type action,
- uint32 count, PRINTER_INFO_0 *const *const ctr)
-{
- if (ctr == NULL)
- {
- report(out_hnd, "display_printer_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 < count; i++)
- {
- display_print_info_0(out_hnd, ACTION_HEADER , ctr[i]);
- display_print_info_0(out_hnd, ACTION_ENUMERATE, ctr[i]);
- display_print_info_0(out_hnd, ACTION_FOOTER , ctr[i]);
- }
- break;
- }
- case ACTION_FOOTER:
- {
- break;
- }
- }
-}
-
-/****************************************************************************
-connection info level 1 container display function
-****************************************************************************/
-void display_printer_info_1_ctr(FILE *out_hnd, enum action_type action,
- uint32 count, PRINTER_INFO_1 *const *const ctr)
-{
- if (ctr == NULL)
- {
- report(out_hnd, "display_printer_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 < count; i++)
- {
- display_print_info_1(out_hnd, ACTION_HEADER , ctr[i]);
- display_print_info_1(out_hnd, ACTION_ENUMERATE, ctr[i]);
- display_print_info_1(out_hnd, ACTION_FOOTER , ctr[i]);
- }
- break;
- }
- case ACTION_FOOTER:
- {
- break;
- }
- }
-}
-
-/****************************************************************************
-connection info container display function
-****************************************************************************/
-void display_printer_info_ctr(FILE *out_hnd, enum action_type action,
- uint32 level, uint32 count,
- void *const *const ctr)
-{
- if (ctr == NULL)
- {
- report(out_hnd, "display_printer_info_ctr: unavailable due to an internal error\n");
- return;
- }
-
- switch (level)
- {
- case 0:
- {
- display_printer_info_0_ctr(out_hnd, action,
- count, (PRINTER_INFO_0*const*const)ctr);
- break;
- }
- case 1:
- {
- display_printer_info_1_ctr(out_hnd, action,
- count, (PRINTER_INFO_1*const*const)ctr);
- break;
- }
- default:
- {
- report(out_hnd, "display_printer_info_ctr: Unknown Info Level\n");
- break;
- }
- }
-}
-
-/****************************************************************************
-job info level 2 display function
-****************************************************************************/
-void display_job_info_2(FILE *out_hnd, enum action_type action,
- JOB_INFO_2 *const i2)
-{
- if (i2 == NULL)
- {
- return;
- }
-
- switch (action)
- {
- case ACTION_HEADER:
- {
- report(out_hnd, "Job Info Level 2:\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- fstring tmp;
-
- report(out_hnd, "\tjob id:\t%d\n", i2->jobid);
- unistr_to_ascii(tmp, i2->printername.buffer, sizeof(tmp)-1);
- report(out_hnd, "\tprinter name:\t%s\n", tmp);
- unistr_to_ascii(tmp, i2->machinename.buffer, sizeof(tmp)-1);
- report(out_hnd, "\tmachine name:\t%s\n", tmp);
- unistr_to_ascii(tmp, i2->username.buffer, sizeof(tmp)-1);
- report(out_hnd, "\tusername:\t%s\n", tmp);
- unistr_to_ascii(tmp, i2->document.buffer, sizeof(tmp)-1);
- report(out_hnd, "\tdocument:\t%s\n", tmp);
- unistr_to_ascii(tmp, i2->notifyname.buffer, sizeof(tmp)-1);
- report(out_hnd, "\tnotify name:\t%s\n", tmp);
- unistr_to_ascii(tmp, i2->datatype.buffer, sizeof(tmp)-1);
- report(out_hnd, "\tdata type:\t%s\n", tmp);
- unistr_to_ascii(tmp, i2->printprocessor.buffer, sizeof(tmp)-1);
- report(out_hnd, "\tprint processor:\t%s\n", tmp);
- unistr_to_ascii(tmp, i2->parameters.buffer, sizeof(tmp)-1);
- report(out_hnd, "\tparameters:\t%s\n", tmp);
- unistr_to_ascii(tmp, i2->drivername.buffer, sizeof(tmp)-1);
- report(out_hnd, "\tdriver name:\t%s\n", tmp);
- report(out_hnd, "\tDevice Mode:\tNOT DISPLAYED YET\n");
-/*
- DEVICEMODE *devmode;
-*/
- unistr_to_ascii(tmp, i2->text_status.buffer, sizeof(tmp)-1);
- report(out_hnd, "\ttext status:\t%s\n", tmp);
- /* SEC_DESC sec_desc;*/
- report(out_hnd, "\tstatus:\t%d\n", i2->status);
- report(out_hnd, "\tpriority:\t%d\n", i2->priority);
- report(out_hnd, "\tposition:\t%d\n", i2->position);
- report(out_hnd, "\tstarttime:\t%d\n", i2->starttime);
- report(out_hnd, "\tuntiltime:\t%d\n", i2->untiltime);
- report(out_hnd, "\ttotalpages:\t%d\n", i2->totalpages);
- report(out_hnd, "\tsize:\t%d\n", i2->size);
-/*
- SYSTEMTIME submitted;
-*/
- report(out_hnd, "\tsubmitted:\tNOT DISPLAYED YET\n");
- report(out_hnd, "\ttimeelapsed:\t%d\n", i2->timeelapsed);
- report(out_hnd, "\tpagesprinted:\t%d\n", i2->pagesprinted);
- }
- case ACTION_FOOTER:
- {
- report(out_hnd, "\n");
- break;
- }
- }
-
-}
-
-/****************************************************************************
-job info level 1 display function
-****************************************************************************/
-void display_job_info_1(FILE *out_hnd, enum action_type action,
- JOB_INFO_1 *const i1)
-{
- if (i1 == NULL)
- {
- return;
- }
-
- switch (action)
- {
- case ACTION_HEADER:
- {
- report(out_hnd, "Job Info Level 1:\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- fstring tmp;
-
- report(out_hnd, "\tjob id:\t%d\n", i1->jobid);
- unistr_to_ascii(tmp, i1->printername.buffer, sizeof(tmp)-1);
- report(out_hnd, "\tprinter name:\t%s\n", tmp);
- unistr_to_ascii(tmp, i1->machinename.buffer, sizeof(tmp)-1);
- report(out_hnd, "\tmachine name:\t%s\n", tmp);
- unistr_to_ascii(tmp, i1->username.buffer, sizeof(tmp)-1);
- report(out_hnd, "\tusername:\t%s\n", tmp);
- unistr_to_ascii(tmp, i1->document.buffer, sizeof(tmp)-1);
- report(out_hnd, "\tdocument:\t%s\n", tmp);
- unistr_to_ascii(tmp, i1->datatype.buffer, sizeof(tmp)-1);
- report(out_hnd, "\tdata type:\t%s\n", tmp);
- unistr_to_ascii(tmp, i1->text_status.buffer, sizeof(tmp)-1);
- report(out_hnd, "\ttext status:\t%s\n", tmp);
- report(out_hnd, "\tstatus:\t%d\n", i1->status);
- report(out_hnd, "\tpriority:\t%d\n", i1->priority);
- report(out_hnd, "\tposition:\t%d\n", i1->position);
- report(out_hnd, "\ttotalpages:\t%d\n", i1->totalpages);
-/*
- SYSTEMTIME submitted;
-*/
- report(out_hnd, "\tsubmitted:\tNOT DISPLAYED YET\n");
- report(out_hnd, "\tpagesprinted:\t%d\n", i1->pagesprinted);
-
- break;
- }
- case ACTION_FOOTER:
- {
- report(out_hnd, "\n");
- break;
- }
- }
-
-}
-
-/****************************************************************************
-connection info level 2 container display function
-****************************************************************************/
-void display_job_info_2_ctr(FILE *out_hnd, enum action_type action,
- uint32 count, JOB_INFO_2 *const *const ctr)
-{
- if (ctr == NULL)
- {
- report(out_hnd, "display_job_info_2_ctr: unavailable due to an internal error\n");
- return;
- }
-
- switch (action)
- {
- case ACTION_HEADER:
- {
- break;
- }
- case ACTION_ENUMERATE:
- {
- int i;
-
- for (i = 0; i < count; i++)
- {
- display_job_info_2(out_hnd, ACTION_HEADER , ctr[i]);
- display_job_info_2(out_hnd, ACTION_ENUMERATE, ctr[i]);
- display_job_info_2(out_hnd, ACTION_FOOTER , ctr[i]);
- }
- break;
- }
- case ACTION_FOOTER:
- {
- break;
- }
- }
-}
-
-/****************************************************************************
-connection info level 1 container display function
-****************************************************************************/
-void display_job_info_1_ctr(FILE *out_hnd, enum action_type action,
- uint32 count, JOB_INFO_1 *const *const ctr)
-{
- if (ctr == NULL)
- {
- report(out_hnd, "display_job_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 < count; i++)
- {
- display_job_info_1(out_hnd, ACTION_HEADER , ctr[i]);
- display_job_info_1(out_hnd, ACTION_ENUMERATE, ctr[i]);
- display_job_info_1(out_hnd, ACTION_FOOTER , ctr[i]);
- }
- break;
- }
- case ACTION_FOOTER:
- {
- break;
- }
- }
-}
-
-/****************************************************************************
-connection info container display function
-****************************************************************************/
-void display_job_info_ctr(FILE *out_hnd, enum action_type action,
- uint32 level, uint32 count,
- void *const *const ctr)
-{
- if (ctr == NULL)
- {
- report(out_hnd, "display_job_info_ctr: unavailable due to an internal error\n");
- return;
- }
-
- switch (level)
- {
- case 1:
- {
- display_job_info_1_ctr(out_hnd, action,
- count, (JOB_INFO_1*const*const)ctr);
- break;
- }
- case 2:
- {
- display_job_info_2_ctr(out_hnd, action,
- count, (JOB_INFO_2*const*const)ctr);
- break;
- }
- default:
- {
- report(out_hnd, "display_job_info_ctr: Unknown Info Level\n");
- break;
- }
- }
-}
-
-#if COPY_THIS_TEMPLATE
-/****************************************************************************
- display structure
- ****************************************************************************/
- void display_(FILE *out_hnd, enum action_type action, *)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- report(out_hnd, "\t\n");
- report(out_hnd, "\t-------------------\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- break;
- }
- case ACTION_FOOTER:
- {
- report(out_hnd, "\n");
- break;
- }
- }
-}
-
-#endif
diff --git a/source3/rpcclient/display_at.c b/source3/rpcclient/display_at.c
new file mode 100644
index 0000000000..29daf9f333
--- /dev/null
+++ b/source3/rpcclient/display_at.c
@@ -0,0 +1,190 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Samba utility functions
+ Copyright (C) Andrew Tridgell 1992-1999
+ Copyright (C) Luke Kenneth Casson Leighton 1996 - 1999
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+
+static char *get_at_time_str(uint32 t)
+{
+ static fstring timestr;
+ unsigned int hours, minutes, seconds;
+
+ hours = t / 1000;
+ seconds = hours % 60;
+ hours /= 60;
+ minutes = hours % 60;
+ hours /= 60;
+
+ slprintf(timestr, sizeof(timestr)-1, "%2d:%02d:%02d",
+ hours, minutes, seconds);
+
+ return timestr;
+}
+
+extern char *daynames_short[];
+
+static char *get_at_days_str(uint32 monthdays, uint8 weekdays, uint8 flags)
+{
+ static fstring days;
+ fstring numstr;
+ int day, bit;
+ BOOL first = True;
+
+ if (monthdays == 0 && weekdays == 0)
+ return "Once";
+
+ if (flags & JOB_PERIODIC)
+ {
+ if (IS_BITS_SET_ALL(weekdays, 0x7F))
+ return "Every Day";
+
+ fstrcpy(days, "Every ");
+ }
+ else
+ {
+ fstrcpy(days, "Next ");
+ }
+
+ for (day = 1, bit = 1; day < 32; day++, bit <<= 1)
+ {
+ if (monthdays & bit)
+ {
+ if (first)
+ first = False;
+ else
+ fstrcat(days, ", ");
+
+ slprintf(numstr, sizeof(numstr)-1, "%d", day);
+ fstrcat(days, numstr);
+ }
+ }
+
+ for (day = 0, bit = 1; day < 7; day++, bit <<= 1)
+ {
+ if (weekdays & bit)
+ {
+ if (first)
+ first = False;
+ else
+ fstrcat(days, ", ");
+
+ fstrcat(days, daynames_short[day]);
+ }
+ }
+
+ return days;
+}
+
+/****************************************************************************
+ display scheduled jobs
+ ****************************************************************************/
+void display_at_enum_info(FILE *out_hnd, enum action_type action,
+ uint32 num_jobs, const AT_ENUM_INFO *const jobs,
+ char *const *const commands)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ if (num_jobs == 0)
+ {
+ report(out_hnd, "\tNo Jobs.\n");
+ }
+ else
+ {
+ report(out_hnd, "\tJobs:\n");
+ report(out_hnd, "\t-----\n");
+ }
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ int i;
+
+ for (i = 0; i < num_jobs; i++)
+ {
+ const AT_JOB_INFO *const job = &jobs[i].info;
+
+ report(out_hnd, "\t%d\t%s\t%s\t%s\n",
+ jobs[i].jobid,
+ get_at_time_str(job->time),
+ get_at_days_str(job->monthdays,
+ job->weekdays,
+ job->flags),
+ commands[i]);
+ }
+
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+ display information about a scheduled job
+ ****************************************************************************/
+void display_at_job_info(FILE *out_hnd, enum action_type action,
+ AT_JOB_INFO *const job, fstring command)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ report(out_hnd, "\tJob Information:\n");
+ report(out_hnd, "\t----------------\n");
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ report(out_hnd, "\tTime: %s\n",
+ get_at_time_str(job->time));
+
+ report(out_hnd, "\tSchedule: %s\n",
+ get_at_days_str(job->monthdays, job->weekdays,
+ job->flags));
+
+ report(out_hnd, "\tStatus: %s",
+ (job->flags & JOB_EXEC_ERR) ? "Failed" : "OK");
+
+ if (job->flags & JOB_RUNS_TODAY)
+ {
+ report(out_hnd, ", Runs Today");
+ }
+
+ report(out_hnd, "\n\tInteractive: %s\n",
+ (job->flags & JOB_NONINTERACTIVE) ? "No"
+ : "Yes");
+
+ report(out_hnd, "\tCommand: %s\n", command);
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
+ }
+}
+
diff --git a/source3/rpcclient/display_event.c b/source3/rpcclient/display_event.c
new file mode 100644
index 0000000000..cd941851ac
--- /dev/null
+++ b/source3/rpcclient/display_event.c
@@ -0,0 +1,101 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Samba utility functions
+ Copyright (C) Andrew Tridgell 1992-1999
+ Copyright (C) Luke Kenneth Casson Leighton 1996 - 1999
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+
+
+/****************************************************************************
+ display structure
+ ****************************************************************************/
+void display_eventlog_eventrecord(FILE *out_hnd, enum action_type action, EVENTLOGRECORD *const ev)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ report(out_hnd, "\tevent log records\n");
+ report(out_hnd, "\t-----------------\n");
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ fstring temp;
+ report(out_hnd, "\t\trecord n.:\t%d\n", ev->recordnumber);
+
+ report(out_hnd, "\t\tsource\teventnumber\teventtype\tcategory\n");
+ unistr_to_ascii(temp, ev->sourcename.buffer, sizeof(temp)-1);
+
+ report(out_hnd, "\t\t%s", temp);
+
+ report(out_hnd, "\t%d\t\t", ev->eventnumber&0x0000FFFF);
+
+ switch (ev->eventtype)
+ {
+ case EVENTLOG_OK:
+ report(out_hnd, "Normal");
+ break;
+
+ case EVENTLOG_ERROR:
+ report(out_hnd, "Error");
+ break;
+
+ case EVENTLOG_WARNING:
+ report(out_hnd, "Warning");
+ break;
+
+ case EVENTLOG_INFORMATION:
+ report(out_hnd, "Information");
+ break;
+
+ case EVENTLOG_AUDIT_OK:
+ report(out_hnd, "Audit Normal");
+ break;
+
+ case EVENTLOG_AUDIT_ERROR:
+ report(out_hnd, "Audit Error\n");
+ break;
+ }
+
+ report(out_hnd, "\t%d\n", ev->category);
+ report(out_hnd, "\t\tcreationtime:\t%s\n", http_timestring(ev->creationtime));
+ report(out_hnd, "\t\twritetime:\t%s\n", http_timestring(ev->writetime));
+
+ unistr_to_ascii(temp, ev->computername.buffer, sizeof(temp)-1);
+ report(out_hnd, "\t\tcomputer:\t%s\n", temp);
+
+ if (ev->num_of_strings!=0)
+ {
+ unistr_to_ascii(temp, ev->strings.buffer, sizeof(temp)-1);
+ report(out_hnd, "\t\tdescription:\t%s\n", temp);
+ }
+
+ report(out_hnd, "\n");
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
+ }
+}
+
diff --git a/source3/rpcclient/display_reg.c b/source3/rpcclient/display_reg.c
new file mode 100644
index 0000000000..d832d1bffb
--- /dev/null
+++ b/source3/rpcclient/display_reg.c
@@ -0,0 +1,168 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Samba utility functions
+ Copyright (C) Andrew Tridgell 1992-1999
+ Copyright (C) Luke Kenneth Casson Leighton 1996 - 1999
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+
+
+/****************************************************************************
+convert a security permissions into a string
+****************************************************************************/
+char *get_reg_val_type_str(uint32 type)
+{
+ static fstring typestr;
+
+ switch (type)
+ {
+ case 0x01:
+ {
+ fstrcpy(typestr, "string");
+ return typestr;
+ }
+
+ case 0x03:
+ {
+ fstrcpy(typestr, "bytes");
+ return typestr;
+ }
+
+ case 0x04:
+ {
+ fstrcpy(typestr, "uint32");
+ return typestr;
+ }
+
+ case 0x07:
+ {
+ fstrcpy(typestr, "multi");
+ return typestr;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ slprintf(typestr, sizeof(typestr)-1, "[%d]", type);
+ return typestr;
+}
+
+
+static void print_reg_value(FILE *out_hnd, const char *val_name,
+ uint32 val_type, const BUFFER2 *value)
+{
+ fstring type;
+ fstring valstr;
+
+ fstrcpy(type, get_reg_val_type_str(val_type));
+
+ switch (val_type)
+ {
+ case 0x01: /* unistr */
+ {
+ unibuf_to_ascii(valstr, value->buffer,
+ MIN(value->buf_len, sizeof(valstr)-1));
+ report(out_hnd, "\t%s:\t%s:\t%s\n", val_name, type, valstr);
+ break;
+ }
+
+ default: /* unknown */
+ case 0x03: /* bytes */
+ {
+ if (value->buf_len <= 8)
+ {
+ report(out_hnd, "\t%s:\t%s:\t", val_name, type);
+ out_data(out_hnd, (const char*)value->buffer,
+ value->buf_len, 8);
+ }
+ else
+ {
+ report(out_hnd, "\t%s:\t%s:\n", val_name, type);
+ out_data(out_hnd, (const char*)value->buffer,
+ value->buf_len, 16);
+ }
+ break;
+ }
+
+ case 0x04: /* uint32 */
+ {
+ report(out_hnd, "\t%s:\t%s:\t0x%08x\n", val_name, type, buffer2_to_uint32(value));
+ break;
+ }
+
+ case 0x07: /* multiunistr */
+ {
+ buffer2_to_multistr(valstr, value, sizeof(valstr)-1);
+ report(out_hnd, "\t%s:\t%s:\t%s\n", val_name, type, valstr);
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+ display structure
+ ****************************************************************************/
+void display_reg_value_info(FILE *out_hnd, enum action_type action,
+ const char *val_name,
+ uint32 val_type, const BUFFER2 *value)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ print_reg_value(out_hnd, val_name, val_type, value);
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+ display structure
+ ****************************************************************************/
+void display_reg_key_info(FILE *out_hnd, enum action_type action,
+ const char *key_name, time_t key_mod_time)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ report(out_hnd, "\t%s\t(%s)\n",
+ key_name, http_timestring(key_mod_time));
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
diff --git a/source3/rpcclient/display_sam.c b/source3/rpcclient/display_sam.c
new file mode 100644
index 0000000000..59bb2bfa54
--- /dev/null
+++ b/source3/rpcclient/display_sam.c
@@ -0,0 +1,685 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Samba utility functions
+ Copyright (C) Andrew Tridgell 1992-1999
+ Copyright (C) Luke Kenneth Casson Leighton 1996 - 1999
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+
+/****************************************************************************
+ display alias members
+ ****************************************************************************/
+void display_alias_members(FILE *out_hnd, enum action_type action,
+ uint32 num_mem, char *const *const sid_mem,
+ uint8 *const type)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ if (num_mem == 0)
+ {
+ report(out_hnd, "\tNo Alias Members\n");
+ }
+ else
+ {
+ report(out_hnd, "\tAlias Members:\n");
+ report(out_hnd, "\t-------------\n");
+ }
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ int i;
+
+ for (i = 0; i < num_mem; i++)
+ {
+ if (sid_mem[i] != NULL)
+ {
+ report(out_hnd, "\tMember Name:\t%s\tType:\t%s\n",
+ sid_mem[i],
+ get_sid_name_use_str(type[i]));
+ }
+ }
+
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
+ }
+}
+
+
+/****************************************************************************
+ display alias rid info
+ ****************************************************************************/
+void display_alias_rid_info(FILE *out_hnd, enum action_type action,
+ DOM_SID *const sid,
+ uint32 num_rids, uint32 *const rid)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ fstring sid_str;
+ sid_to_string(sid_str, sid);
+ if (num_rids == 0)
+ {
+ report(out_hnd, "\tNo Aliases:\tSid %s\n", sid_str);
+ }
+ else
+ {
+ report(out_hnd, "\tAlias Info:\tSid %s\n", sid_str);
+ report(out_hnd, "\t----------\n");
+ }
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ int i;
+
+ for (i = 0; i < num_rids; i++)
+ {
+ report(out_hnd, "\tAlias RID:\t%8x\n", rid[i]);
+ }
+
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+ display group members
+ ****************************************************************************/
+void display_group_members(FILE *out_hnd, enum action_type action,
+ uint32 num_mem, char *const *const name, uint32 *const type)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ if (num_mem == 0)
+ {
+ report(out_hnd, "\tNo Members\n");
+ }
+ else
+ {
+ report(out_hnd, "\tMembers:\n");
+ report(out_hnd, "\t-------\n");
+ }
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ int i;
+
+ for (i = 0; i < num_mem; i++)
+ {
+ report(out_hnd, "\tMember Name:\t%s\tType:\t%s\n",
+ name[i], get_sid_name_use_str(type[i]));
+ }
+
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
+ }
+}
+
+
+/****************************************************************************
+ display group info
+ ****************************************************************************/
+void display_group_info1(FILE *out_hnd, enum action_type action, GROUP_INFO1 *const info1)
+
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ fstring temp;
+
+ unistr2_to_ascii(temp, &info1->uni_acct_name, sizeof(temp)-1);
+ report(out_hnd, "\tGroup Name:\t%s\n", temp);
+ unistr2_to_ascii(temp, &info1->uni_acct_desc, sizeof(temp)-1);
+ report(out_hnd, "\tDescription:\t%s\n", temp);
+ report(out_hnd, "\tunk1:%d\n", info1->unknown_1);
+ report(out_hnd, "\tNum Members:%d\n", info1->num_members);
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+ display group info
+ ****************************************************************************/
+void display_group_info4(FILE *out_hnd, enum action_type action, GROUP_INFO4 *const info4)
+
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ fstring desc;
+
+ unistr2_to_ascii(desc, &info4->uni_acct_desc, sizeof(desc)-1);
+ report(out_hnd, "\tGroup Description:%s\n",
+ desc);
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+ display sam sync structure
+ ****************************************************************************/
+void display_group_info_ctr(FILE *out_hnd, enum action_type action,
+ GROUP_INFO_CTR *const ctr)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ report(out_hnd, "\tSAM Group Info\n");
+ report(out_hnd, "\t--------------\n");
+
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ switch (ctr->switch_value1)
+ {
+ case 1:
+ {
+ display_group_info1(out_hnd, ACTION_HEADER , &ctr->group.info1);
+ display_group_info1(out_hnd, ACTION_ENUMERATE, &ctr->group.info1);
+ display_group_info1(out_hnd, ACTION_FOOTER , &ctr->group.info1);
+ break;
+ }
+ case 4:
+ {
+ display_group_info4(out_hnd, ACTION_HEADER , &ctr->group.info4);
+ display_group_info4(out_hnd, ACTION_ENUMERATE, &ctr->group.info4);
+ display_group_info4(out_hnd, ACTION_FOOTER , &ctr->group.info4);
+ break;
+ }
+ }
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+ display group rid info
+ ****************************************************************************/
+void display_group_rid_info(FILE *out_hnd, enum action_type action,
+ uint32 num_gids, DOM_GID *const gid)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ if (num_gids == 0)
+ {
+ report(out_hnd, "\tNo Groups\n");
+ }
+ else
+ {
+ report(out_hnd, "\tGroup Info\n");
+ report(out_hnd, "\t----------\n");
+ }
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ int i;
+
+ for (i = 0; i < num_gids; i++)
+ {
+ report(out_hnd, "\tGroup RID:\t%8x attr:\t%x\n",
+ gid[i].g_rid, gid[i].attr);
+ }
+
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
+ }
+}
+
+
+/****************************************************************************
+ display alias name info
+ ****************************************************************************/
+void display_alias_name_info(FILE *out_hnd, enum action_type action,
+ uint32 num_aliases, fstring *const alias_name, const uint32 *const num_als_usrs)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ if (num_aliases == 0)
+ {
+ report(out_hnd, "\tNo Aliases\n");
+ }
+ else
+ {
+ report(out_hnd, "\tAlias Names\n");
+ report(out_hnd, "\t----------- \n");
+ }
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ int i;
+
+ for (i = 0; i < num_aliases; i++)
+ {
+ report(out_hnd, "\tAlias Name:\t%s Attributes:\t%3d\n",
+ alias_name[i], num_als_usrs[i]);
+ }
+
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+ display alias info
+ ****************************************************************************/
+void display_alias_info3(FILE *out_hnd, enum action_type action, ALIAS_INFO3 *const info3)
+
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ fstring temp;
+
+ unistr2_to_ascii(temp, &info3->uni_acct_desc, sizeof(temp)-1);
+ report(out_hnd, "\tDescription:\t%s\n", temp);
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+ display sam sync structure
+ ****************************************************************************/
+void display_alias_info_ctr(FILE *out_hnd, enum action_type action,
+ ALIAS_INFO_CTR *const ctr)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ report(out_hnd, "\tSAM Group Info\n");
+ report(out_hnd, "\t--------------\n");
+
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ switch (ctr->switch_value1)
+ {
+ case 3:
+ {
+ display_alias_info3(out_hnd, ACTION_HEADER , &ctr->alias.info3);
+ display_alias_info3(out_hnd, ACTION_ENUMERATE, &ctr->alias.info3);
+ display_alias_info3(out_hnd, ACTION_FOOTER , &ctr->alias.info3);
+ break;
+ }
+ }
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
+ }
+}
+
+
+/****************************************************************************
+ display sam_user_info_21 structure
+ ****************************************************************************/
+void display_sam_user_info_21(FILE *out_hnd, enum action_type action, SAM_USER_INFO_21 *const usr)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ report(out_hnd, "\tUser Info, Level 0x15\n");
+ report(out_hnd, "\t---------------------\n");
+
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ fstring temp;
+
+ unistr2_to_ascii(temp, &usr->uni_user_name, sizeof(temp)-1);
+ report(out_hnd, "\t\tUser Name :\t%s\n", temp);
+
+ unistr2_to_ascii(temp, &usr->uni_full_name, sizeof(temp)-1);
+ report(out_hnd, "\t\tFull Name :\t%s\n", temp);
+
+ unistr2_to_ascii(temp, &usr->uni_home_dir, sizeof(temp)-1);
+ report(out_hnd, "\t\tHome Drive :\t%s\n", temp);
+
+ unistr2_to_ascii(temp, &usr->uni_dir_drive, sizeof(temp)-1);
+ report(out_hnd, "\t\tDir Drive :\t%s\n", temp);
+
+ unistr2_to_ascii(temp, &usr->uni_profile_path, sizeof(temp)-1);
+ report(out_hnd, "\t\tProfile Path:\t%s\n", temp);
+
+ unistr2_to_ascii(temp, &usr->uni_logon_script, sizeof(temp)-1);
+ report(out_hnd, "\t\tLogon Script:\t%s\n", temp);
+
+ unistr2_to_ascii(temp, &usr->uni_acct_desc, sizeof(temp)-1);
+ report(out_hnd, "\t\tDescription :\t%s\n", temp);
+
+ unistr2_to_ascii(temp, &usr->uni_workstations, sizeof(temp)-1);
+ report(out_hnd, "\t\tWorkstations:\t%s\n", temp);
+
+ unistr2_to_ascii(temp, &usr->uni_unknown_str, sizeof(temp)-1);
+ report(out_hnd, "\t\tUnknown Str :\t%s\n", temp);
+
+ unistr2_to_ascii(temp, &usr->uni_munged_dial, sizeof(temp)-1);
+ report(out_hnd, "\t\tRemote Dial :\t%s\n", temp);
+
+ report(out_hnd, "\t\tLogon Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->logon_time ))));
+ report(out_hnd, "\t\tLogoff Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->logoff_time ))));
+ report(out_hnd, "\t\tKickoff Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->kickoff_time ))));
+ report(out_hnd, "\t\tPassword last set Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->pass_last_set_time ))));
+ report(out_hnd, "\t\tPassword can change Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->pass_can_change_time ))));
+ report(out_hnd, "\t\tPassword must change Time:\t%s\n", http_timestring(nt_time_to_unix(&(usr->pass_must_change_time))));
+
+ report(out_hnd, "\t\tunknown_2[0..31]...\n"); /* user passwords? */
+
+ report(out_hnd, "\t\tuser_rid :\t%x\n" , usr->user_rid ); /* User ID */
+ report(out_hnd, "\t\tgroup_rid:\t%x\n" , usr->group_rid); /* Group ID */
+ report(out_hnd, "\t\tacb_info :\t%04x\n", usr->acb_info ); /* Account Control Info */
+
+ report(out_hnd, "\t\tunknown_3:\t%08x\n", usr->unknown_3); /* 0x00ff ffff */
+ report(out_hnd, "\t\tlogon_divs:\t%d\n", usr->logon_divs); /* 0x0000 00a8 which is 168 which is num hrs in a week */
+ report(out_hnd, "\t\tunknown_5:\t%08x\n", usr->unknown_5); /* 0x0002 0000 */
+
+ report(out_hnd, "\t\tpadding1[0..7]...\n");
+
+ if (usr->ptr_logon_hrs)
+ {
+ report(out_hnd, "\t\tlogon_hrs[0..%d]...\n", usr->logon_hrs.len);
+ }
+
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
+ }
+}
+
+
+/****************************************************************************
+ display sam sync structure
+ ****************************************************************************/
+void display_sam_unk_info_2(FILE *out_hnd, enum action_type action,
+ SAM_UNK_INFO_2 *const info2)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ fstring name;
+ unistr2_to_ascii(name, &(info2->uni_domain), sizeof(name)-1);
+ report(out_hnd, "Domain:\t%s\n", name);
+
+ unistr2_to_ascii(name, &(info2->uni_server), sizeof(name)-1);
+ report(out_hnd, "Server:\t%s\n", name);
+
+ report(out_hnd, "Total Users:\t%d\n", info2->num_domain_usrs);
+ report(out_hnd, "Total Groups:\t%d\n", info2->num_domain_grps);
+ report(out_hnd, "Total Aliases:\t%d\n", info2->num_local_grps);
+
+ report(out_hnd, "Sequence No:\t%d\n", info2->seq_num);
+
+ report(out_hnd, "Unknown 0:\t0x%x\n", info2->unknown_0);
+ report(out_hnd, "Unknown 1:\t0x%x\n", info2->unknown_1);
+ report(out_hnd, "Unknown 2:\t0x%x\n", info2->unknown_2);
+ report(out_hnd, "Unknown 3:\t0x%x\n", info2->unknown_3);
+ report(out_hnd, "Unknown 4:\t0x%x\n", info2->unknown_4);
+ report(out_hnd, "Unknown 5:\t0x%x\n", info2->unknown_5);
+ report(out_hnd, "Unknown 6:\t0x%x\n", info2->unknown_6);
+
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+ display sam sync structure
+ ****************************************************************************/
+void display_sam_unk_ctr(FILE *out_hnd, enum action_type action,
+ uint32 switch_value, SAM_UNK_CTR *const ctr)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ report(out_hnd, "\tSAM Domain Info\n");
+ report(out_hnd, "\t---------------\n");
+
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ switch (switch_value)
+ {
+ case 2:
+ {
+ display_sam_unk_info_2(out_hnd, ACTION_HEADER , &ctr->info.inf2);
+ display_sam_unk_info_2(out_hnd, ACTION_ENUMERATE, &ctr->info.inf2);
+ display_sam_unk_info_2(out_hnd, ACTION_FOOTER , &ctr->info.inf2);
+ break;
+ }
+ }
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+sam info level 1 display function
+****************************************************************************/
+void display_sam_info_1(FILE *out_hnd, enum action_type action,
+ SAM_ENTRY1 *const e1, SAM_STR1 *const s1)
+{
+ if (e1 == NULL)
+ {
+ return;
+ }
+
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ report(out_hnd, "Sam Level 1:\n");
+
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ fstring tmp;
+
+ report(out_hnd, "\tIndex:\t%d\n", e1->user_idx);
+ report(out_hnd, "\tRID:\t0x%x\n", e1->rid_user);
+ report(out_hnd, "\tACB:\t%s\n",
+ pwdb_encode_acct_ctrl(e1->acb_info,
+ NEW_PW_FORMAT_SPACE_PADDED_LEN));
+
+ unistr_to_ascii(tmp, s1->uni_acct_name.buffer, sizeof(tmp)-1);
+ report(out_hnd, "\tAccount Name:\t%s\n", tmp);
+ unistr_to_ascii(tmp, s1->uni_full_name.buffer, sizeof(tmp)-1);
+ report(out_hnd, "\tFull Name:\t%s\n", tmp);
+ unistr_to_ascii(tmp, s1->uni_acct_desc.buffer, sizeof(tmp)-1);
+ report(out_hnd, "\tUser Description:\t%s\n", tmp);
+
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
+ }
+
+}
+
+/****************************************************************************
+connection info level 1 container display function
+****************************************************************************/
+void display_sam_info_1_ctr(FILE *out_hnd, enum action_type action,
+ uint32 count, SAM_DISPINFO_1 *const ctr)
+{
+ if (ctr == NULL)
+ {
+ report(out_hnd, "display_sam_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 < count; i++)
+ {
+ display_sam_info_1(out_hnd, ACTION_HEADER , &ctr->sam[i], &ctr->str[i]);
+ display_sam_info_1(out_hnd, ACTION_ENUMERATE, &ctr->sam[i], &ctr->str[i]);
+ display_sam_info_1(out_hnd, ACTION_FOOTER , &ctr->sam[i], &ctr->str[i]);
+ }
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+connection info container display function
+****************************************************************************/
+void display_sam_disp_info_ctr(FILE *out_hnd, enum action_type action,
+ uint16 level, uint32 count,
+ SAM_DISPINFO_CTR *const ctr)
+{
+ if (ctr == NULL)
+ {
+ report(out_hnd, "display_sam_info_ctr: unavailable due to an internal error\n");
+ return;
+ }
+
+ switch (level)
+ {
+ case 1:
+ {
+ display_sam_info_1_ctr(out_hnd, action,
+ count, ctr->sam.info1);
+ break;
+ }
+ default:
+ {
+ report(out_hnd, "display_sam_info_ctr: Unknown Info Level\n");
+ break;
+ }
+ }
+}
+
diff --git a/source3/rpcclient/display_sec.c b/source3/rpcclient/display_sec.c
new file mode 100644
index 0000000000..b29a27fefa
--- /dev/null
+++ b/source3/rpcclient/display_sec.c
@@ -0,0 +1,232 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Samba utility functions
+ Copyright (C) Andrew Tridgell 1992-1999
+ Copyright (C) Luke Kenneth Casson Leighton 1996 - 1999
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+
+
+/****************************************************************************
+convert a security permissions into a string
+****************************************************************************/
+char *get_sec_mask_str(uint32 type)
+{
+ static fstring typestr;
+ int i;
+
+ switch (type)
+ {
+ case SEC_RIGHTS_FULL_CONTROL:
+ {
+ fstrcpy(typestr, "Full Control");
+ return typestr;
+ }
+
+ case SEC_RIGHTS_READ:
+ {
+ fstrcpy(typestr, "Read");
+ return typestr;
+ }
+ default:
+ {
+ break;
+ }
+ }
+
+ typestr[0] = 0;
+ for (i = 0; i < 32; i++)
+ {
+ if (IS_BITS_SET_ALL(type, 1 << i))
+ {
+ switch (1 << i)
+ {
+ case SEC_RIGHTS_QUERY_VALUE : fstrcat(typestr, "Query " ); break;
+ case SEC_RIGHTS_SET_VALUE : fstrcat(typestr, "Set " ); break;
+ case SEC_RIGHTS_CREATE_SUBKEY : fstrcat(typestr, "Create "); break;
+ case SEC_RIGHTS_ENUM_SUBKEYS : fstrcat(typestr, "Enum "); break;
+ case SEC_RIGHTS_NOTIFY : fstrcat(typestr, "Notify "); break;
+ case SEC_RIGHTS_CREATE_LINK : fstrcat(typestr, "CreateLink "); break;
+ case SEC_RIGHTS_DELETE : fstrcat(typestr, "Delete "); break;
+ case SEC_RIGHTS_READ_CONTROL : fstrcat(typestr, "ReadControl "); break;
+ case SEC_RIGHTS_WRITE_DAC : fstrcat(typestr, "WriteDAC "); break;
+ case SEC_RIGHTS_WRITE_OWNER : fstrcat(typestr, "WriteOwner "); break;
+ }
+ type &= ~(1 << i);
+ }
+ }
+
+ /* remaining bits get added on as-is */
+ if (type != 0)
+ {
+ fstring tmp;
+ slprintf(tmp, sizeof(tmp)-1, "[%08x]", type);
+ fstrcat(typestr, tmp);
+ }
+
+ /* remove last space */
+ i = strlen(typestr)-1;
+ if (typestr[i] == ' ') typestr[i] = 0;
+
+ return typestr;
+}
+
+/****************************************************************************
+ display sec_access structure
+ ****************************************************************************/
+void display_sec_access(FILE *out_hnd, enum action_type action, SEC_ACCESS *const info)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ report(out_hnd, "\t\tPermissions:\t%s\n",
+ get_sec_mask_str(info->mask));
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+ display sec_ace structure
+ ****************************************************************************/
+void display_sec_ace(FILE *out_hnd, enum action_type action, SEC_ACE *const ace)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ report(out_hnd, "\tACE\n");
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ fstring sid_str;
+
+ display_sec_access(out_hnd, ACTION_HEADER , &ace->info);
+ display_sec_access(out_hnd, ACTION_ENUMERATE, &ace->info);
+ display_sec_access(out_hnd, ACTION_FOOTER , &ace->info);
+
+ sid_to_string(sid_str, &ace->sid);
+ report(out_hnd, "\t\tSID:\t%s\n", sid_str);
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+ display sec_acl structure
+ ****************************************************************************/
+void display_sec_acl(FILE *out_hnd, enum action_type action, SEC_ACL *const sec_acl)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ report(out_hnd, "\tACL\tNum ACEs:\t%d\trevision:\t%x\n",
+ sec_acl->num_aces, sec_acl->revision);
+ report(out_hnd, "\t---\n");
+
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ if (sec_acl->size != 0 && sec_acl->num_aces != 0)
+ {
+ int i;
+ for (i = 0; i < sec_acl->num_aces; i++)
+ {
+ display_sec_ace(out_hnd, ACTION_HEADER , &sec_acl->ace[i]);
+ display_sec_ace(out_hnd, ACTION_ENUMERATE, &sec_acl->ace[i]);
+ display_sec_ace(out_hnd, ACTION_FOOTER , &sec_acl->ace[i]);
+ }
+ }
+
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+ display sec_desc structure
+ ****************************************************************************/
+void display_sec_desc(FILE *out_hnd, enum action_type action, SEC_DESC *const sec)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ report(out_hnd, "\tSecurity Descriptor\trevision:\t%x\ttype:\t%x\n",
+ sec->revision, sec->type);
+ report(out_hnd, "\t-------------------\n");
+
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ fstring sid_str;
+
+ if (sec->off_sacl != 0)
+ {
+ display_sec_acl(out_hnd, ACTION_HEADER , sec->sacl);
+ display_sec_acl(out_hnd, ACTION_ENUMERATE, sec->sacl);
+ display_sec_acl(out_hnd, ACTION_FOOTER , sec->sacl);
+ }
+ if (sec->off_dacl != 0)
+ {
+ display_sec_acl(out_hnd, ACTION_HEADER , sec->dacl);
+ display_sec_acl(out_hnd, ACTION_ENUMERATE, sec->dacl);
+ display_sec_acl(out_hnd, ACTION_FOOTER , sec->dacl);
+ }
+ if (sec->off_owner_sid != 0)
+ {
+ sid_to_string(sid_str, sec->owner_sid);
+ report(out_hnd, "\tOwner SID:\t%s\n", sid_str);
+ }
+ if (sec->off_grp_sid != 0)
+ {
+ sid_to_string(sid_str, sec->grp_sid);
+ report(out_hnd, "\tParent SID:\t%s\n", sid_str);
+ }
+
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
+ }
+}
+
diff --git a/source3/rpcclient/display_spool.c b/source3/rpcclient/display_spool.c
new file mode 100644
index 0000000000..252fc88156
--- /dev/null
+++ b/source3/rpcclient/display_spool.c
@@ -0,0 +1,457 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Samba utility functions
+ Copyright (C) Andrew Tridgell 1992-1999
+ Copyright (C) Luke Kenneth Casson Leighton 1996 - 1999
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+
+/****************************************************************************
+printer info level 0 display function
+****************************************************************************/
+void display_print_info_0(FILE *out_hnd, enum action_type action,
+ PRINTER_INFO_0 *const i0)
+{
+ if (i0 == NULL)
+ {
+ return;
+ }
+
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ report(out_hnd, "Printer Info Level 0:\n");
+
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ fstring name;
+ fstring serv;
+
+ unistr_to_ascii(name, i0->printername.buffer, sizeof(name)-1);
+ unistr_to_ascii(serv, i0->servername .buffer, sizeof(serv)-1);
+
+ report(out_hnd, "\tprinter name:\t%s\n", name);
+ report(out_hnd, "\tserver name:\t%s\n", serv);
+ report(out_hnd, "\t[Other info not displayed]\n");
+
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
+ }
+
+}
+
+/****************************************************************************
+printer info level 1 display function
+****************************************************************************/
+void display_print_info_1(FILE *out_hnd, enum action_type action,
+ PRINTER_INFO_1 *const i1)
+{
+ if (i1 == NULL)
+ {
+ return;
+ }
+
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ report(out_hnd, "Printer Info Level 1:\n");
+
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ fstring desc;
+ fstring name;
+ fstring comm;
+
+ unistr_to_ascii(desc, i1->description.buffer, sizeof(desc)-1);
+ unistr_to_ascii(name, i1->name .buffer, sizeof(name)-1);
+ unistr_to_ascii(comm, i1->comment .buffer, sizeof(comm)-1);
+
+ report(out_hnd, "\tflags:\t%d\n", i1->flags);
+ report(out_hnd, "\tname:\t%s\n", name);
+ report(out_hnd, "\tdescription:\t%s\n", desc);
+ report(out_hnd, "\tcomment:\t%s\n", comm);
+
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
+ }
+
+}
+
+/****************************************************************************
+connection info level 0 container display function
+****************************************************************************/
+void display_printer_info_0_ctr(FILE *out_hnd, enum action_type action,
+ uint32 count, PRINTER_INFO_0 *const *const ctr)
+{
+ if (ctr == NULL)
+ {
+ report(out_hnd, "display_printer_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 < count; i++)
+ {
+ display_print_info_0(out_hnd, ACTION_HEADER , ctr[i]);
+ display_print_info_0(out_hnd, ACTION_ENUMERATE, ctr[i]);
+ display_print_info_0(out_hnd, ACTION_FOOTER , ctr[i]);
+ }
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+connection info level 1 container display function
+****************************************************************************/
+void display_printer_info_1_ctr(FILE *out_hnd, enum action_type action,
+ uint32 count, PRINTER_INFO_1 *const *const ctr)
+{
+ if (ctr == NULL)
+ {
+ report(out_hnd, "display_printer_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 < count; i++)
+ {
+ display_print_info_1(out_hnd, ACTION_HEADER , ctr[i]);
+ display_print_info_1(out_hnd, ACTION_ENUMERATE, ctr[i]);
+ display_print_info_1(out_hnd, ACTION_FOOTER , ctr[i]);
+ }
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+connection info container display function
+****************************************************************************/
+void display_printer_info_ctr(FILE *out_hnd, enum action_type action,
+ uint32 level, uint32 count,
+ void *const *const ctr)
+{
+ if (ctr == NULL)
+ {
+ report(out_hnd, "display_printer_info_ctr: unavailable due to an internal error\n");
+ return;
+ }
+
+ switch (level)
+ {
+ case 0:
+ {
+ display_printer_info_0_ctr(out_hnd, action,
+ count, (PRINTER_INFO_0*const*const)ctr);
+ break;
+ }
+ case 1:
+ {
+ display_printer_info_1_ctr(out_hnd, action,
+ count, (PRINTER_INFO_1*const*const)ctr);
+ break;
+ }
+ default:
+ {
+ report(out_hnd, "display_printer_info_ctr: Unknown Info Level\n");
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+job info level 2 display function
+****************************************************************************/
+void display_job_info_2(FILE *out_hnd, enum action_type action,
+ JOB_INFO_2 *const i2)
+{
+ if (i2 == NULL)
+ {
+ return;
+ }
+
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ report(out_hnd, "Job Info Level 2:\n");
+
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ fstring tmp;
+
+ report(out_hnd, "\tjob id:\t%d\n", i2->jobid);
+ unistr_to_ascii(tmp, i2->printername.buffer, sizeof(tmp)-1);
+ report(out_hnd, "\tprinter name:\t%s\n", tmp);
+ unistr_to_ascii(tmp, i2->machinename.buffer, sizeof(tmp)-1);
+ report(out_hnd, "\tmachine name:\t%s\n", tmp);
+ unistr_to_ascii(tmp, i2->username.buffer, sizeof(tmp)-1);
+ report(out_hnd, "\tusername:\t%s\n", tmp);
+ unistr_to_ascii(tmp, i2->document.buffer, sizeof(tmp)-1);
+ report(out_hnd, "\tdocument:\t%s\n", tmp);
+ unistr_to_ascii(tmp, i2->notifyname.buffer, sizeof(tmp)-1);
+ report(out_hnd, "\tnotify name:\t%s\n", tmp);
+ unistr_to_ascii(tmp, i2->datatype.buffer, sizeof(tmp)-1);
+ report(out_hnd, "\tdata type:\t%s\n", tmp);
+ unistr_to_ascii(tmp, i2->printprocessor.buffer, sizeof(tmp)-1);
+ report(out_hnd, "\tprint processor:\t%s\n", tmp);
+ unistr_to_ascii(tmp, i2->parameters.buffer, sizeof(tmp)-1);
+ report(out_hnd, "\tparameters:\t%s\n", tmp);
+ unistr_to_ascii(tmp, i2->drivername.buffer, sizeof(tmp)-1);
+ report(out_hnd, "\tdriver name:\t%s\n", tmp);
+ report(out_hnd, "\tDevice Mode:\tNOT DISPLAYED YET\n");
+/*
+ DEVICEMODE *devmode;
+*/
+ unistr_to_ascii(tmp, i2->text_status.buffer, sizeof(tmp)-1);
+ report(out_hnd, "\ttext status:\t%s\n", tmp);
+ /* SEC_DESC sec_desc;*/
+ report(out_hnd, "\tstatus:\t%d\n", i2->status);
+ report(out_hnd, "\tpriority:\t%d\n", i2->priority);
+ report(out_hnd, "\tposition:\t%d\n", i2->position);
+ report(out_hnd, "\tstarttime:\t%d\n", i2->starttime);
+ report(out_hnd, "\tuntiltime:\t%d\n", i2->untiltime);
+ report(out_hnd, "\ttotalpages:\t%d\n", i2->totalpages);
+ report(out_hnd, "\tsize:\t%d\n", i2->size);
+/*
+ SYSTEMTIME submitted;
+*/
+ report(out_hnd, "\tsubmitted:\tNOT DISPLAYED YET\n");
+ report(out_hnd, "\ttimeelapsed:\t%d\n", i2->timeelapsed);
+ report(out_hnd, "\tpagesprinted:\t%d\n", i2->pagesprinted);
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
+ }
+
+}
+
+/****************************************************************************
+job info level 1 display function
+****************************************************************************/
+void display_job_info_1(FILE *out_hnd, enum action_type action,
+ JOB_INFO_1 *const i1)
+{
+ if (i1 == NULL)
+ {
+ return;
+ }
+
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ report(out_hnd, "Job Info Level 1:\n");
+
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ fstring tmp;
+
+ report(out_hnd, "\tjob id:\t%d\n", i1->jobid);
+ unistr_to_ascii(tmp, i1->printername.buffer, sizeof(tmp)-1);
+ report(out_hnd, "\tprinter name:\t%s\n", tmp);
+ unistr_to_ascii(tmp, i1->machinename.buffer, sizeof(tmp)-1);
+ report(out_hnd, "\tmachine name:\t%s\n", tmp);
+ unistr_to_ascii(tmp, i1->username.buffer, sizeof(tmp)-1);
+ report(out_hnd, "\tusername:\t%s\n", tmp);
+ unistr_to_ascii(tmp, i1->document.buffer, sizeof(tmp)-1);
+ report(out_hnd, "\tdocument:\t%s\n", tmp);
+ unistr_to_ascii(tmp, i1->datatype.buffer, sizeof(tmp)-1);
+ report(out_hnd, "\tdata type:\t%s\n", tmp);
+ unistr_to_ascii(tmp, i1->text_status.buffer, sizeof(tmp)-1);
+ report(out_hnd, "\ttext status:\t%s\n", tmp);
+ report(out_hnd, "\tstatus:\t%d\n", i1->status);
+ report(out_hnd, "\tpriority:\t%d\n", i1->priority);
+ report(out_hnd, "\tposition:\t%d\n", i1->position);
+ report(out_hnd, "\ttotalpages:\t%d\n", i1->totalpages);
+/*
+ SYSTEMTIME submitted;
+*/
+ report(out_hnd, "\tsubmitted:\tNOT DISPLAYED YET\n");
+ report(out_hnd, "\tpagesprinted:\t%d\n", i1->pagesprinted);
+
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
+ }
+
+}
+
+/****************************************************************************
+connection info level 2 container display function
+****************************************************************************/
+void display_job_info_2_ctr(FILE *out_hnd, enum action_type action,
+ uint32 count, JOB_INFO_2 *const *const ctr)
+{
+ if (ctr == NULL)
+ {
+ report(out_hnd, "display_job_info_2_ctr: unavailable due to an internal error\n");
+ return;
+ }
+
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ int i;
+
+ for (i = 0; i < count; i++)
+ {
+ display_job_info_2(out_hnd, ACTION_HEADER , ctr[i]);
+ display_job_info_2(out_hnd, ACTION_ENUMERATE, ctr[i]);
+ display_job_info_2(out_hnd, ACTION_FOOTER , ctr[i]);
+ }
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+connection info level 1 container display function
+****************************************************************************/
+void display_job_info_1_ctr(FILE *out_hnd, enum action_type action,
+ uint32 count, JOB_INFO_1 *const *const ctr)
+{
+ if (ctr == NULL)
+ {
+ report(out_hnd, "display_job_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 < count; i++)
+ {
+ display_job_info_1(out_hnd, ACTION_HEADER , ctr[i]);
+ display_job_info_1(out_hnd, ACTION_ENUMERATE, ctr[i]);
+ display_job_info_1(out_hnd, ACTION_FOOTER , ctr[i]);
+ }
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+connection info container display function
+****************************************************************************/
+void display_job_info_ctr(FILE *out_hnd, enum action_type action,
+ uint32 level, uint32 count,
+ void *const *const ctr)
+{
+ if (ctr == NULL)
+ {
+ report(out_hnd, "display_job_info_ctr: unavailable due to an internal error\n");
+ return;
+ }
+
+ switch (level)
+ {
+ case 1:
+ {
+ display_job_info_1_ctr(out_hnd, action,
+ count, (JOB_INFO_1*const*const)ctr);
+ break;
+ }
+ case 2:
+ {
+ display_job_info_2_ctr(out_hnd, action,
+ count, (JOB_INFO_2*const*const)ctr);
+ break;
+ }
+ default:
+ {
+ report(out_hnd, "display_job_info_ctr: Unknown Info Level\n");
+ break;
+ }
+ }
+}
diff --git a/source3/rpcclient/display_srv.c b/source3/rpcclient/display_srv.c
new file mode 100644
index 0000000000..9b6cd4b350
--- /dev/null
+++ b/source3/rpcclient/display_srv.c
@@ -0,0 +1,1198 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Samba utility functions
+ Copyright (C) Andrew Tridgell 1992-1999
+ Copyright (C) Luke Kenneth Casson Leighton 1996 - 1999
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+
+
+struct field_info sid_name_info[] =
+{
+ { SID_NAME_UNKNOWN, "UNKNOWN" }, /* default */
+ { SID_NAME_USER , "User" },
+ { SID_NAME_DOM_GRP, "Domain Group" },
+ { SID_NAME_DOMAIN , "Domain" },
+ { SID_NAME_ALIAS , "Local Group" },
+ { SID_NAME_WKN_GRP, "Well-known Group"},
+ { SID_NAME_DELETED, "Deleted" },
+ { SID_NAME_INVALID, "Invalid" },
+ { 0 , NULL }
+};
+
+/****************************************************************************
+convert a SID_NAME_USE to a string
+****************************************************************************/
+char *get_sid_name_use_str(uint8 sid_name_use)
+{
+ return enum_field_to_str((uint32)sid_name_use, sid_name_info, True);
+}
+
+/****************************************************************************
+convert a share mode to a string
+****************************************************************************/
+char *get_file_mode_str(uint32 share_mode)
+{
+ static fstring mode;
+
+ switch ((share_mode>>4)&0xF)
+ {
+ case DENY_NONE : fstrcpy(mode, "DENY_NONE "); break;
+ case DENY_ALL : fstrcpy(mode, "DENY_ALL "); break;
+ case DENY_DOS : fstrcpy(mode, "DENY_DOS "); break;
+ case DENY_READ : fstrcpy(mode, "DENY_READ "); break;
+ case DENY_WRITE: fstrcpy(mode, "DENY_WRITE "); break;
+ default : fstrcpy(mode, "DENY_???? "); break;
+ }
+
+ switch (share_mode & 0xF)
+ {
+ case 0 : fstrcat(mode, "RDONLY"); break;
+ case 1 : fstrcat(mode, "WRONLY"); break;
+ case 2 : fstrcat(mode, "RDWR "); break;
+ default: fstrcat(mode, "R??W??"); break;
+ }
+
+ return mode;
+}
+
+/****************************************************************************
+convert an oplock mode to a string
+****************************************************************************/
+char *get_file_oplock_str(uint32 op_type)
+{
+ static fstring oplock;
+ BOOL excl = IS_BITS_SET_ALL(op_type, EXCLUSIVE_OPLOCK);
+ BOOL batch = IS_BITS_SET_ALL(op_type, BATCH_OPLOCK );
+
+ oplock[0] = 0;
+
+ if (excl ) fstrcat(oplock, "EXCLUSIVE");
+ if (excl && batch) fstrcat(oplock, "+");
+ if ( batch) fstrcat(oplock, "BATCH");
+ if (!excl && !batch) fstrcat(oplock, "NONE");
+
+ return oplock;
+}
+
+/****************************************************************************
+convert a share type enum to a string
+****************************************************************************/
+char *get_share_type_str(uint32 type)
+{
+ static fstring typestr;
+
+ switch (type)
+ {
+ case STYPE_DISKTREE: fstrcpy(typestr, "Disk" ); break;
+ case STYPE_PRINTQ : fstrcpy(typestr, "Printer"); break;
+ case STYPE_DEVICE : fstrcpy(typestr, "Device" ); break;
+ case STYPE_IPC : fstrcpy(typestr, "IPC" ); break;
+ default : fstrcpy(typestr, "????" ); break;
+ }
+ return typestr;
+}
+
+/****************************************************************************
+convert a server type enum to a string
+****************************************************************************/
+char *get_server_type_str(uint32 type)
+{
+ static fstring typestr;
+
+ if (type == SV_TYPE_ALL)
+ {
+ fstrcpy(typestr, "All");
+ }
+ else
+ {
+ int i;
+ typestr[0] = 0;
+ for (i = 0; i < 32; i++)
+ {
+ if (IS_BITS_SET_ALL(type, 1 << i))
+ {
+ switch (1 << i)
+ {
+ case SV_TYPE_WORKSTATION : fstrcat(typestr, "Wk " ); break;
+ case SV_TYPE_SERVER : fstrcat(typestr, "Sv " ); break;
+ case SV_TYPE_SQLSERVER : fstrcat(typestr, "Sql "); break;
+ case SV_TYPE_DOMAIN_CTRL : fstrcat(typestr, "PDC "); break;
+ case SV_TYPE_DOMAIN_BAKCTRL : fstrcat(typestr, "BDC "); break;
+ case SV_TYPE_TIME_SOURCE : fstrcat(typestr, "Tim "); break;
+ case SV_TYPE_AFP : fstrcat(typestr, "AFP "); break;
+ case SV_TYPE_NOVELL : fstrcat(typestr, "Nov "); break;
+ case SV_TYPE_DOMAIN_MEMBER : fstrcat(typestr, "Dom "); break;
+ case SV_TYPE_PRINTQ_SERVER : fstrcat(typestr, "PrQ "); break;
+ case SV_TYPE_DIALIN_SERVER : fstrcat(typestr, "Din "); break;
+ case SV_TYPE_SERVER_UNIX : fstrcat(typestr, "Unx "); break;
+ case SV_TYPE_NT : fstrcat(typestr, "NT " ); break;
+ case SV_TYPE_WFW : fstrcat(typestr, "Wfw "); break;
+ case SV_TYPE_SERVER_MFPN : fstrcat(typestr, "Mfp "); break;
+ case SV_TYPE_SERVER_NT : fstrcat(typestr, "SNT "); break;
+ case SV_TYPE_POTENTIAL_BROWSER: fstrcat(typestr, "PtB "); break;
+ case SV_TYPE_BACKUP_BROWSER : fstrcat(typestr, "BMB "); break;
+ case SV_TYPE_MASTER_BROWSER : fstrcat(typestr, "LMB "); break;
+ case SV_TYPE_DOMAIN_MASTER : fstrcat(typestr, "DMB "); break;
+ case SV_TYPE_SERVER_OSF : fstrcat(typestr, "OSF "); break;
+ case SV_TYPE_SERVER_VMS : fstrcat(typestr, "VMS "); break;
+ case SV_TYPE_WIN95_PLUS : fstrcat(typestr, "W95 "); break;
+ case SV_TYPE_ALTERNATE_XPORT : fstrcat(typestr, "Xpt "); break;
+ case SV_TYPE_LOCAL_LIST_ONLY : fstrcat(typestr, "Dom "); break;
+ case SV_TYPE_DOMAIN_ENUM : fstrcat(typestr, "Loc "); break;
+ }
+ }
+ }
+ i = strlen(typestr)-1;
+ if (typestr[i] == ' ') typestr[i] = 0;
+
+ }
+ return typestr;
+}
+
+/****************************************************************************
+server info level 101 display function
+****************************************************************************/
+void display_srv_info_101(FILE *out_hnd, enum action_type action,
+ SRV_INFO_101 *const sv101)
+{
+ if (sv101 == NULL)
+ {
+ return;
+ }
+
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ report(out_hnd, "Server Info Level 101:\n");
+
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ fstring name;
+ fstring comment;
+
+ unistr2_to_ascii(name, &sv101->uni_name, sizeof(name)-1);
+ unistr2_to_ascii(comment, &sv101->uni_comment, sizeof(comment)-1);
+
+ display_server(out_hnd, action, name, sv101->srv_type, comment);
+
+ report(out_hnd, "\tplatform_id :\t%d\n" , sv101->platform_id);
+ report(out_hnd, "\tos version :\t%d.%d\n" , sv101->ver_major, sv101->ver_minor);
+
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+
+}
+
+/****************************************************************************
+server info level 102 display function
+****************************************************************************/
+void display_srv_info_102(FILE *out_hnd, enum action_type action, SRV_INFO_102 *const sv102)
+{
+ if (sv102 == NULL)
+ {
+ return;
+ }
+
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ report(out_hnd, "Server Info Level 102:\n");
+
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ fstring name;
+ fstring comment;
+ fstring usr_path;
+
+ unistr2_to_ascii(name, &sv102->uni_name, sizeof(name)-1);
+ unistr2_to_ascii(comment, &sv102->uni_comment, sizeof(comment)-1);
+ unistr2_to_ascii(usr_path, &sv102->uni_usr_path,
+ sizeof(usr_path)-1);
+
+ display_server(out_hnd, action, name, sv102->srv_type, comment);
+
+ report(out_hnd, "\tplatform_id :\t%d\n" , sv102->platform_id);
+ report(out_hnd, "\tos version :\t%d.%d\n" , sv102->ver_major, sv102->ver_minor);
+
+ report(out_hnd, "\tusers :\t%x\n" , sv102->users );
+ report(out_hnd, "\tdisc, hidden :\t%x, %x\n" , sv102->disc , sv102->hidden );
+ report(out_hnd, "\tannounce, delta :\t%d, %d\n", sv102->announce , sv102->ann_delta);
+ report(out_hnd, "\tlicenses :\t%d\n" , sv102->licenses );
+ report(out_hnd, "\tuser path :\t%s\n" , usr_path);
+
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+server info container display function
+****************************************************************************/
+void display_srv_info_ctr(FILE *out_hnd, enum action_type action, SRV_INFO_CTR *const ctr)
+{
+ if (ctr == NULL || ctr->ptr_srv_ctr == 0)
+ {
+ report(out_hnd, "Server Information: unavailable due to an error\n");
+ return;
+ }
+
+ switch (ctr->switch_value)
+ {
+ case 101:
+ {
+ display_srv_info_101(out_hnd, action, &(ctr->srv.sv101));
+ break;
+ }
+ case 102:
+ {
+ display_srv_info_102(out_hnd, action, &(ctr->srv.sv102));
+ break;
+ }
+ default:
+ {
+ report(out_hnd, "Server Information: Unknown Info Level\n");
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+connection info level 0 display function
+****************************************************************************/
+void display_conn_info_0(FILE *out_hnd, enum action_type action,
+ CONN_INFO_0 *const info0)
+{
+ if (info0 == NULL)
+ {
+ return;
+ }
+
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ report(out_hnd, "Connection Info Level 0:\n");
+
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ report(out_hnd, "\tid:\t%d\n", info0->id);
+
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
+ }
+
+}
+
+/****************************************************************************
+connection info level 1 display function
+****************************************************************************/
+void display_conn_info_1(FILE *out_hnd, enum action_type action,
+ CONN_INFO_1 *const info1, CONN_INFO_1_STR *const str1)
+{
+ if (info1 == NULL || str1 == NULL)
+ {
+ return;
+ }
+
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ report(out_hnd, "Connection Info Level 1:\n");
+
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ fstring usr_name;
+ fstring net_name;
+
+ unistr2_to_ascii(usr_name, &str1->uni_usr_name, sizeof(usr_name)-1);
+ unistr2_to_ascii(net_name, &str1->uni_net_name, sizeof(net_name)-1);
+
+ report(out_hnd, "\tid :\t%d\n", info1->id);
+ report(out_hnd, "\ttype :\t%s\n", get_share_type_str(info1->type));
+ report(out_hnd, "\tnum_opens:\t%d\n", info1->num_opens);
+ report(out_hnd, "\tnum_users:\t%d\n", info1->num_users);
+ report(out_hnd, "\topen_time:\t%d\n", info1->open_time);
+
+ report(out_hnd, "\tuser name:\t%s\n", usr_name);
+ report(out_hnd, "\tnet name:\t%s\n", net_name);
+
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
+ }
+
+}
+
+/****************************************************************************
+connection info level 0 container display function
+****************************************************************************/
+void display_srv_conn_info_0_ctr(FILE *out_hnd, enum action_type action,
+ SRV_CONN_INFO_0 *const ctr)
+{
+ if (ctr == NULL)
+ {
+ report(out_hnd, "display_srv_conn_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_conn_info_0(out_hnd, ACTION_HEADER , &(ctr->info_0[i]));
+ display_conn_info_0(out_hnd, ACTION_ENUMERATE, &(ctr->info_0[i]));
+ display_conn_info_0(out_hnd, ACTION_FOOTER , &(ctr->info_0[i]));
+ }
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+connection info level 1 container display function
+****************************************************************************/
+void display_srv_conn_info_1_ctr(FILE *out_hnd, enum action_type action,
+ SRV_CONN_INFO_1 *const ctr)
+{
+ if (ctr == NULL)
+ {
+ report(out_hnd, "display_srv_conn_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_conn_info_1(out_hnd, ACTION_HEADER , &(ctr->info_1[i]), &(ctr->info_1_str[i]));
+ display_conn_info_1(out_hnd, ACTION_ENUMERATE, &(ctr->info_1[i]), &(ctr->info_1_str[i]));
+ display_conn_info_1(out_hnd, ACTION_FOOTER , &(ctr->info_1[i]), &(ctr->info_1_str[i]));
+ }
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+connection info container display function
+****************************************************************************/
+void display_srv_conn_info_ctr(FILE *out_hnd, enum action_type action,
+ SRV_CONN_INFO_CTR *const ctr)
+{
+ if (ctr == NULL || ctr->ptr_conn_ctr == 0)
+ {
+ report(out_hnd, "display_srv_conn_info_ctr: unavailable due to an internal error\n");
+ return;
+ }
+
+ switch (ctr->switch_value)
+ {
+ case 0:
+ {
+ display_srv_conn_info_0_ctr(out_hnd, action,
+ &(ctr->conn.info0));
+ break;
+ }
+ case 1:
+ {
+ display_srv_conn_info_1_ctr(out_hnd, action,
+ &(ctr->conn.info1));
+ break;
+ }
+ default:
+ {
+ report(out_hnd, "display_srv_conn_info_ctr: Unknown Info Level\n");
+ break;
+ }
+ }
+}
+
+
+/****************************************************************************
+transport info level 0 display function
+****************************************************************************/
+void display_tprt_info_0(FILE *out_hnd, enum action_type action,
+ TPRT_INFO_0 *const info0, TPRT_INFO_0_STR *const str0)
+{
+ if (info0 == NULL || str0 == NULL)
+ {
+ return;
+ }
+
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ report(out_hnd, "Transport Info Level 0:\n");
+
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ fstring trans_name;
+ fstring trans_addr;
+ fstring addr_name;
+
+ unistr2_to_ascii(trans_name, &str0->uni_trans_name, sizeof(trans_name)-1);
+ buffer4_to_str(trans_addr, &str0->buf_trans_addr, sizeof(trans_addr)-1);
+ unistr2_to_ascii(addr_name, &str0->uni_addr_name, sizeof(addr_name)-1);
+
+ report(out_hnd, "\tnum_vcs :\t%d\n", info0->num_vcs);
+ report(out_hnd, "\ttransport name:\t%s\n", trans_name);
+ report(out_hnd, "\ttransport addr:\t%s\n", trans_addr);
+ report(out_hnd, "\taddress name:\t%s\n", addr_name);
+
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
+ }
+
+}
+
+/****************************************************************************
+transport info level 0 container display function
+****************************************************************************/
+void display_srv_tprt_info_0_ctr(FILE *out_hnd, enum action_type action,
+ const SRV_TPRT_INFO_0 *const ctr)
+{
+ if (ctr == NULL)
+ {
+ report(out_hnd, "display_srv_tprt_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_tprt_info_0(out_hnd, ACTION_HEADER , &(ctr->info_0[i]), &(ctr->info_0_str[i]));
+ display_tprt_info_0(out_hnd, ACTION_ENUMERATE, &(ctr->info_0[i]), &(ctr->info_0_str[i]));
+ display_tprt_info_0(out_hnd, ACTION_FOOTER , &(ctr->info_0[i]), &(ctr->info_0_str[i]));
+ }
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+transport info container display function
+****************************************************************************/
+void display_srv_tprt_info_ctr(FILE *out_hnd, enum action_type action,
+ const SRV_TPRT_INFO_CTR *const ctr)
+{
+ if (ctr == NULL || ctr->ptr_tprt_ctr == 0)
+ {
+ report(out_hnd, "display_srv_tprt_info_ctr: unavailable due to an internal error\n");
+ return;
+ }
+
+ switch (ctr->switch_value)
+ {
+ case 0:
+ {
+ display_srv_tprt_info_0_ctr(out_hnd, action,
+ &(ctr->tprt.info0));
+ break;
+ }
+ default:
+ {
+ report(out_hnd, "display_srv_tprt_info_ctr: Unknown Info Level\n");
+ break;
+ }
+ }
+}
+
+
+/****************************************************************************
+share info level 1 display function
+****************************************************************************/
+void display_share_info_1(FILE *out_hnd, enum action_type action,
+ SH_INFO_1 *const info1, SH_INFO_1_STR *const str1)
+{
+ if (info1 == NULL || str1 == NULL)
+ {
+ return;
+ }
+
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ report(out_hnd, "Share Info Level 1:\n");
+
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ fstring remark ;
+ fstring net_name;
+
+ unistr2_to_ascii(net_name, &str1->uni_netname, sizeof(net_name)-1);
+ unistr2_to_ascii(remark, &str1->uni_remark, sizeof(remark)-1);
+
+ display_share(out_hnd, action, net_name, info1->type, remark);
+
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
+ }
+
+}
+
+/****************************************************************************
+share info level 2 display function
+****************************************************************************/
+void display_share_info_2(FILE *out_hnd, enum action_type action,
+ SH_INFO_2 *const info2, SH_INFO_2_STR *const str2)
+{
+ if (info2 == NULL || str2 == NULL)
+ {
+ return;
+ }
+
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ report(out_hnd, "Share Info Level 2:\n");
+
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ fstring remark ;
+ fstring net_name;
+ fstring path ;
+ fstring passwd ;
+
+ unistr2_to_ascii(net_name, &str2->uni_netname, sizeof(net_name)-1);
+ unistr2_to_ascii(remark, &str2->uni_remark, sizeof(remark)-1);
+ unistr2_to_ascii(path, &str2->uni_path, sizeof(path)-1);
+ unistr2_to_ascii(passwd, &str2->uni_passwd, sizeof(passwd)-1);
+
+ display_share2(out_hnd, action, net_name, info2->type, remark,
+ info2->perms, info2->max_uses, info2->num_uses,
+ path, passwd);
+
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
+ }
+
+}
+
+/****************************************************************************
+share info level 1 container display function
+****************************************************************************/
+void display_srv_share_info_1_ctr(FILE *out_hnd, enum action_type action,
+ SRV_SHARE_INFO_1 *const ctr)
+{
+ if (ctr == NULL)
+ {
+ report(out_hnd, "display_srv_share_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_share_info_1(out_hnd, ACTION_HEADER , &(ctr->info_1[i]), &(ctr->info_1_str[i]));
+ display_share_info_1(out_hnd, ACTION_ENUMERATE, &(ctr->info_1[i]), &(ctr->info_1_str[i]));
+ display_share_info_1(out_hnd, ACTION_FOOTER , &(ctr->info_1[i]), &(ctr->info_1_str[i]));
+ }
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+share info level 2 container display function
+****************************************************************************/
+void display_srv_share_info_2_ctr(FILE *out_hnd, enum action_type action,
+ SRV_SHARE_INFO_2 *const ctr)
+{
+ if (ctr == NULL)
+ {
+ report(out_hnd, "display_srv_share_info_2_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_share_info_2(out_hnd, ACTION_HEADER , &(ctr->info_2[i]), &(ctr->info_2_str[i]));
+ display_share_info_2(out_hnd, ACTION_ENUMERATE, &(ctr->info_2[i]), &(ctr->info_2_str[i]));
+ display_share_info_2(out_hnd, ACTION_FOOTER , &(ctr->info_2[i]), &(ctr->info_2_str[i]));
+ }
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+share info container display function
+****************************************************************************/
+void display_srv_share_info_ctr(FILE *out_hnd, enum action_type action,
+ SRV_SHARE_INFO_CTR *const ctr)
+{
+ if (ctr == NULL || ctr->ptr_share_ctr == 0)
+ {
+ report(out_hnd, "display_srv_share_info_ctr: unavailable due to an internal error\n");
+ return;
+ }
+
+ switch (ctr->switch_value)
+ {
+ case 1:
+ {
+ display_srv_share_info_1_ctr(out_hnd, action,
+ &(ctr->share.info1));
+ break;
+ }
+ case 2:
+ {
+ display_srv_share_info_2_ctr(out_hnd, action,
+ &(ctr->share.info2));
+ break;
+ }
+ default:
+ {
+ report(out_hnd, "display_srv_share_info_ctr: Unknown Info Level\n");
+ break;
+ }
+ }
+}
+
+
+/****************************************************************************
+file info level 3 display function
+****************************************************************************/
+void display_file_info_3(FILE *out_hnd, enum action_type action,
+ FILE_INFO_3 *const info3, FILE_INFO_3_STR *const str3)
+{
+ if (info3 == NULL || str3 == NULL)
+ {
+ return;
+ }
+
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ report(out_hnd, "File Info Level 3:\n");
+
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ fstring path_name;
+ fstring user_name;
+
+ unistr2_to_ascii(path_name, &str3->uni_path_name,
+ sizeof(path_name)-1);
+ unistr2_to_ascii(user_name, &str3->uni_user_name,
+ sizeof(user_name)-1);
+
+ report(out_hnd, "\tid :\t%d\n", info3->id);
+ report(out_hnd, "\tperms :\t%s\n", get_file_mode_str(info3->perms));
+ report(out_hnd, "\tnum_locks:\t%d\n", info3->num_locks);
+
+ report(out_hnd, "\tpath name:\t%s\n", path_name);
+ report(out_hnd, "\tuser name:\t%s\n", user_name);
+
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
+ }
+
+}
+
+/****************************************************************************
+file info level 3 container display function
+****************************************************************************/
+void display_srv_file_info_3_ctr(FILE *out_hnd, enum action_type action,
+ SRV_FILE_INFO_3 *const ctr)
+{
+ if (ctr == NULL)
+ {
+ report(out_hnd, "display_srv_file_info_3_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_file_info_3(out_hnd, ACTION_HEADER , &(ctr->info_3[i]), &(ctr->info_3_str[i]));
+ display_file_info_3(out_hnd, ACTION_ENUMERATE, &(ctr->info_3[i]), &(ctr->info_3_str[i]));
+ display_file_info_3(out_hnd, ACTION_FOOTER , &(ctr->info_3[i]), &(ctr->info_3_str[i]));
+ }
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+file info container display function
+****************************************************************************/
+void display_srv_file_info_ctr(FILE *out_hnd, enum action_type action,
+ SRV_FILE_INFO_CTR *const ctr)
+{
+ if (ctr == NULL || ctr->ptr_file_ctr == 0)
+ {
+ report(out_hnd, "display_srv_file_info_ctr: unavailable due to an internal error\n");
+ return;
+ }
+
+ switch (ctr->switch_value)
+ {
+ case 3:
+ {
+ display_srv_file_info_3_ctr(out_hnd, action,
+ &(ctr->file.info3));
+ break;
+ }
+ default:
+ {
+ report(out_hnd, "display_srv_file_info_ctr: Unknown Info Level\n");
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+sess info level 0 display function
+****************************************************************************/
+void display_sess_info_0(FILE *out_hnd, enum action_type action,
+ SESS_INFO_0 *const info0, SESS_INFO_0_STR *const str0)
+{
+ if (info0 == NULL || str0 == NULL)
+ {
+ return;
+ }
+
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ report(out_hnd, "Session Info Level 0:\n");
+
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ fstring name;
+
+ unistr2_to_ascii(name, &str0->uni_name,
+ sizeof(name)-1);
+
+ report(out_hnd, "\tname:\t%s\n", name);
+
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(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 *const info1, SESS_INFO_1_STR *const str1)
+{
+ if (info1 == NULL || str1 == NULL)
+ {
+ return;
+ }
+
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ report(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);
+
+ report(out_hnd, "\tname:\t%s\n", name);
+
+ report(out_hnd, "\topen :\t%d\n", info1->num_opens);
+ report(out_hnd, "\ttime :\t%d\n", info1->open_time);
+ report(out_hnd, "\tidle :\t%d\n", info1->idle_time);
+ report(out_hnd, "\tflags:\t%d\n", info1->user_flags);
+
+ report(out_hnd, "\tuser :\t%s\n", user_name);
+
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(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 *const ctr)
+{
+ if (ctr == NULL)
+ {
+ report(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 *const ctr)
+{
+ if (ctr == NULL)
+ {
+ report(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 *const ctr)
+{
+ if (ctr == NULL || ctr->ptr_sess_ctr == 0)
+ {
+ report(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:
+ {
+ report(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,
+ char *const sname, uint32 type, char *const comment)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ report(out_hnd, "\t%-15.15s%-20s %s\n",
+ sname, get_server_type_str(type), comment);
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+print shares on a host
+****************************************************************************/
+void display_share(FILE *out_hnd, enum action_type action,
+ char *const sname, uint32 type, char *const comment)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ report(out_hnd, "\t%-15.15s%-10.10s%s\n",
+ sname, get_share_type_str(type), comment);
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
+
+/****************************************************************************
+print shares on a host, level 2
+****************************************************************************/
+void display_share2(FILE *out_hnd, enum action_type action,
+ char *const sname, uint32 type, char *const comment,
+ uint32 perms, uint32 max_uses, uint32 num_uses,
+ char *const path, char *const passwd)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ report(out_hnd, "\t%-15.15s%-10.10s%s %x %x %x %s %s\n",
+ sname, get_share_type_str(type), comment,
+ perms, max_uses, num_uses, path, passwd);
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
+
+/****************************************************************************
+print name info
+****************************************************************************/
+void display_name(FILE *out_hnd, enum action_type action,
+ char *const sname)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ report(out_hnd, "\t%-21.21s\n", sname);
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
diff --git a/source3/rpcclient/display_svc.c b/source3/rpcclient/display_svc.c
new file mode 100644
index 0000000000..04b366a216
--- /dev/null
+++ b/source3/rpcclient/display_svc.c
@@ -0,0 +1,126 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Samba utility functions
+ Copyright (C) Andrew Tridgell 1992-1999
+ Copyright (C) Luke Kenneth Casson Leighton 1996 - 1999
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+
+
+/****************************************************************************
+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,
+ const QUERY_SERVICE_CONFIG *const cfg)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ fstring service;
+
+ unistr2_to_ascii(service, &cfg->uni_display_name, sizeof(service)-1);
+ report(out_hnd, "\tService:\t%s\n", service);
+ report(out_hnd, "\t-------\n");
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ fstring temp;
+
+ unistr2_to_ascii(temp, &cfg->uni_bin_path_name, sizeof(temp)-1);
+ report(out_hnd, "\tPath:\t%s\n", temp);
+
+ unistr2_to_ascii(temp, &cfg->uni_load_order_grp, sizeof(temp)-1);
+ report(out_hnd, "\tLoad Order:\t%s\n", temp);
+
+ unistr2_to_ascii(temp, &cfg->uni_dependencies, sizeof(temp)-1);
+ report(out_hnd, "\tDependencies:\t%s\n", temp);
+
+ unistr2_to_ascii(temp, &cfg->uni_service_start_name, sizeof(temp)-1);
+ report(out_hnd, "\tService Start:\t%s\n", temp);
+
+ report(out_hnd, "\tService Type:\t%d\n", cfg->service_type);
+ report(out_hnd, "\tStart Type:\t%s\n" , get_svc_start_type_str(cfg->start_type));
+ report(out_hnd, "\tError Control:\t%d\n" , cfg->error_control);
+ report(out_hnd, "\tTag Id:\t%d\n" , cfg->tag_id);
+ break;
+
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+ display structure
+ ****************************************************************************/
+void display_svc_info(FILE *out_hnd, enum action_type action,
+ const ENUM_SRVC_STATUS *const svc)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ fstring name;
+
+ unistr_to_ascii(name, svc->uni_srvc_name.buffer,
+ sizeof(name)-1); /* service name */
+ report(out_hnd, "\t%s:", name);
+
+ unistr_to_ascii(name, svc->uni_disp_name.buffer,
+ sizeof(name)-1); /* display name */
+ report(out_hnd, "\t%s\n", name);
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
diff --git a/source3/rpcclient/display_sync.c b/source3/rpcclient/display_sync.c
new file mode 100644
index 0000000000..8250a96f02
--- /dev/null
+++ b/source3/rpcclient/display_sync.c
@@ -0,0 +1,116 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ Samba utility functions
+ Copyright (C) Andrew Tridgell 1992-1999
+ Copyright (C) Luke Kenneth Casson Leighton 1996 - 1999
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+
+
+/****************************************************************************
+ display sam sync structure
+ ****************************************************************************/
+void display_sam_sync_ctr(FILE *out_hnd, enum action_type action,
+ SAM_DELTA_HDR *const delta,
+ SAM_DELTA_CTR *const ctr)
+{
+ fstring name;
+
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ switch (delta->type)
+ {
+ case 1:
+ {
+ unistr2_to_ascii(name, &(ctr->domain_info.uni_dom_name), sizeof(name)-1);
+ report(out_hnd, "Domain: %s\n", name);
+ break;
+ }
+ case 2:
+ {
+ unistr2_to_ascii(name, &(ctr->group_info.uni_grp_name), sizeof(name)-1);
+ report(out_hnd, "Group: %s\n", name);
+ break;
+ }
+ case 5:
+ {
+ unsigned char lm_pwd[16];
+ unsigned char nt_pwd[16];
+
+ unistr2_to_ascii(name, &(ctr->account_info.uni_acct_name), sizeof(name)-1);
+ report(out_hnd, "Account: %s\n", name);
+
+ sam_pwd_hash(ctr->account_info.user_rid, ctr->account_info.pass.buf_lm_pwd, lm_pwd, 0);
+ out_struct(out_hnd, lm_pwd, 16, 8);
+
+ sam_pwd_hash(ctr->account_info.user_rid, ctr->account_info.pass.buf_nt_pwd, nt_pwd, 0);
+ out_struct(out_hnd, nt_pwd, 16, 8);
+ }
+ }
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+ display sam sync structure
+ ****************************************************************************/
+void display_sam_sync(FILE *out_hnd, enum action_type action,
+ SAM_DELTA_HDR *const deltas,
+ SAM_DELTA_CTR *const ctr,
+ uint32 num)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ report(out_hnd, "\tSAM Database Sync\n");
+ report(out_hnd, "\t-----------------\n");
+
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ int i;
+ for (i = 0; i < num; i++)
+ {
+ display_sam_sync_ctr(out_hnd, ACTION_HEADER , &deltas[i], &ctr[i]);
+ display_sam_sync_ctr(out_hnd, ACTION_ENUMERATE, &deltas[i], &ctr[i]);
+ display_sam_sync_ctr(out_hnd, ACTION_FOOTER , &deltas[i], &ctr[i]);
+ }
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
+ }
+}
+
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index c55f99fcaf..f5dbe3245b 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -46,6 +46,7 @@ static int process_tok(fstring tok);
static void cmd_help(struct client_info *info, int argc, char *argv[]);
static void cmd_quit(struct client_info *info, int argc, char *argv[]);
static void cmd_set (struct client_info *info, int argc, char *argv[]);
+static void cmd_net (struct client_info *info, int argc, char *argv[]);
static struct user_credentials usr;
@@ -489,12 +490,21 @@ struct command_set commands[] =
{COMPL_NONE, COMPL_NONE}
},
+ /* maintenance */
+
{
"rpcclient",
cmd_set,
"run rpcclient inside rpcclient (change options etc.)",
{COMPL_NONE, COMPL_NONE}
},
+
+ {
+ "net",
+ cmd_net,
+ "net use and net view",
+ {COMPL_NONE, COMPL_NONE}
+ },
/*
* bye bye
*/
@@ -724,7 +734,7 @@ static void wait_keyboard(struct cli_state *cli)
timeout.tv_sec = 20;
timeout.tv_usec = 0;
- sys_select(MAX(cli->fd,fileno(stdin))+1,&fds,&timeout);
+ sys_select(MAX(cli->fd,fileno(stdin))+1,NULL, &fds,&timeout);
if (FD_ISSET(fileno(stdin),&fds))
return;
@@ -1339,6 +1349,63 @@ static char *complete_cmd_null(char *text, int state)
#endif /* HAVE_LIBREADLINE */
+static void cmd_net(struct client_info *info, int argc, char *argv[])
+{
+ char opt;
+ BOOL net_use = False;
+ BOOL net_use_del = False;
+ BOOL net_use_add = False;
+
+ while ((opt = getopt(argc, argv, "udS:U:W:")) != EOF)
+ {
+ switch (opt)
+ {
+ case 'u':
+ {
+ net_use = True;
+ break;
+ }
+
+ default:
+ {
+ report(out_hnd, "net -S \\server [-U user%%pass] [-W domain] [-d]\n");
+ report(out_hnd, "net -u\n");
+ break;
+ }
+ }
+ }
+
+ if (net_use)
+ {
+ int i;
+ uint32 num_uses;
+ struct use_info **use;
+ cli_net_use_enum(&num_uses, &use);
+
+ if (num_uses == 0)
+ {
+ report(out_hnd, "No connections\n");
+ }
+ else
+ {
+ report(out_hnd, "Connections:\n");
+
+ for (i = 0; i < num_uses; i++)
+ {
+ if (use[i] != NULL && use[i]->connected)
+ {
+ report(out_hnd, "Server:\t%s\t",
+ use[i]->srv_name);
+ report(out_hnd, "User:\t%s\t",
+ use[i]->user_name);
+ report(out_hnd, "Domain:\t%s\n",
+ use[i]->domain);
+ }
+ }
+ }
+ }
+}
+
static void set_user_password(struct user_credentials *u,
BOOL got_pass, char *password)
{