2 Unix SMB/Netbios implementation.
4 Samba utility functions
5 Copyright (C) Andrew Tridgell 1992-1998
6 Copyright (C) Luke Kenneth Casson Leighton 1996 - 1998
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 /****************************************************************************
27 convert a SID_NAME_USE to a string
28 ****************************************************************************/
29 char *get_sid_name_use_str(uint8 sid_name_use)
35 case SID_NAME_USER : fstrcpy(type, "User" ); break;
36 case SID_NAME_DOM_GRP : fstrcpy(type, "Domain Group" ); break;
37 case SID_NAME_DOMAIN : fstrcpy(type, "Domain" ); break;
38 case SID_NAME_ALIAS : fstrcpy(type, "Local Group" ); break;
39 case SID_NAME_WKN_GRP : fstrcpy(type, "Well-known Group"); break;
40 case SID_NAME_DELETED : fstrcpy(type, "Deleted" ); break;
41 case SID_NAME_INVALID : fstrcpy(type, "Invalid" ); break;
42 case SID_NAME_UNKNOWN :
43 default : fstrcpy(type, "UNKNOWN" ); break;
49 /****************************************************************************
50 convert a share mode to a string
51 ****************************************************************************/
52 char *get_file_mode_str(uint32 share_mode)
56 switch ((share_mode>>4)&0xF)
58 case DENY_NONE : fstrcpy(mode, "DENY_NONE "); break;
59 case DENY_ALL : fstrcpy(mode, "DENY_ALL "); break;
60 case DENY_DOS : fstrcpy(mode, "DENY_DOS "); break;
61 case DENY_READ : fstrcpy(mode, "DENY_READ "); break;
62 case DENY_WRITE: fstrcpy(mode, "DENY_WRITE "); break;
63 default : fstrcpy(mode, "DENY_???? "); break;
66 switch (share_mode & 0xF)
68 case 0 : fstrcat(mode, "RDONLY"); break;
69 case 1 : fstrcat(mode, "WRONLY"); break;
70 case 2 : fstrcat(mode, "RDWR "); break;
71 default: fstrcat(mode, "R??W??"); break;
77 /****************************************************************************
78 convert an oplock mode to a string
79 ****************************************************************************/
80 char *get_file_oplock_str(uint32 op_type)
82 static fstring oplock;
83 BOOL excl = IS_BITS_SET_ALL(op_type, EXCLUSIVE_OPLOCK);
84 BOOL batch = IS_BITS_SET_ALL(op_type, BATCH_OPLOCK );
88 if (excl ) fstrcat(oplock, "EXCLUSIVE");
89 if (excl && batch) fstrcat(oplock, "+");
90 if ( batch) fstrcat(oplock, "BATCH");
91 if (!excl && !batch) fstrcat(oplock, "NONE");
96 /****************************************************************************
97 convert a share type enum to a string
98 ****************************************************************************/
99 char *get_share_type_str(uint32 type)
101 static fstring typestr;
105 case STYPE_DISKTREE: fstrcpy(typestr, "Disk" ); break;
106 case STYPE_PRINTQ : fstrcpy(typestr, "Printer"); break;
107 case STYPE_DEVICE : fstrcpy(typestr, "Device" ); break;
108 case STYPE_IPC : fstrcpy(typestr, "IPC" ); break;
109 default : fstrcpy(typestr, "????" ); break;
114 /****************************************************************************
115 convert a server type enum to a string
116 ****************************************************************************/
117 char *get_server_type_str(uint32 type)
119 static fstring typestr;
121 if (type == SV_TYPE_ALL)
123 fstrcpy(typestr, "All");
129 for (i = 0; i < 32; i++)
131 if (IS_BITS_SET_ALL(type, 1 << i))
135 case SV_TYPE_WORKSTATION : fstrcat(typestr, "Wk " ); break;
136 case SV_TYPE_SERVER : fstrcat(typestr, "Sv " ); break;
137 case SV_TYPE_SQLSERVER : fstrcat(typestr, "Sql "); break;
138 case SV_TYPE_DOMAIN_CTRL : fstrcat(typestr, "PDC "); break;
139 case SV_TYPE_DOMAIN_BAKCTRL : fstrcat(typestr, "BDC "); break;
140 case SV_TYPE_TIME_SOURCE : fstrcat(typestr, "Tim "); break;
141 case SV_TYPE_AFP : fstrcat(typestr, "AFP "); break;
142 case SV_TYPE_NOVELL : fstrcat(typestr, "Nov "); break;
143 case SV_TYPE_DOMAIN_MEMBER : fstrcat(typestr, "Dom "); break;
144 case SV_TYPE_PRINTQ_SERVER : fstrcat(typestr, "PrQ "); break;
145 case SV_TYPE_DIALIN_SERVER : fstrcat(typestr, "Din "); break;
146 case SV_TYPE_SERVER_UNIX : fstrcat(typestr, "Unx "); break;
147 case SV_TYPE_NT : fstrcat(typestr, "NT " ); break;
148 case SV_TYPE_WFW : fstrcat(typestr, "Wfw "); break;
149 case SV_TYPE_SERVER_MFPN : fstrcat(typestr, "Mfp "); break;
150 case SV_TYPE_SERVER_NT : fstrcat(typestr, "SNT "); break;
151 case SV_TYPE_POTENTIAL_BROWSER: fstrcat(typestr, "PtB "); break;
152 case SV_TYPE_BACKUP_BROWSER : fstrcat(typestr, "BMB "); break;
153 case SV_TYPE_MASTER_BROWSER : fstrcat(typestr, "LMB "); break;
154 case SV_TYPE_DOMAIN_MASTER : fstrcat(typestr, "DMB "); break;
155 case SV_TYPE_SERVER_OSF : fstrcat(typestr, "OSF "); break;
156 case SV_TYPE_SERVER_VMS : fstrcat(typestr, "VMS "); break;
157 case SV_TYPE_WIN95_PLUS : fstrcat(typestr, "W95 "); break;
158 case SV_TYPE_ALTERNATE_XPORT : fstrcat(typestr, "Xpt "); break;
159 case SV_TYPE_LOCAL_LIST_ONLY : fstrcat(typestr, "Dom "); break;
160 case SV_TYPE_DOMAIN_ENUM : fstrcat(typestr, "Loc "); break;
164 i = strlen(typestr)-1;
165 if (typestr[i] == ' ') typestr[i] = 0;
171 /****************************************************************************
172 server info level 101 display function
173 ****************************************************************************/
174 void display_srv_info_101(FILE *out_hnd, enum action_type action,
186 fprintf(out_hnd, "Server Info Level 101:\n");
190 case ACTION_ENUMERATE:
195 fstrcpy(name , unistrn2(sv101->uni_name .buffer, sv101->uni_name .uni_str_len));
196 fstrcpy(comment , unistrn2(sv101->uni_comment .buffer, sv101->uni_comment .uni_str_len));
198 display_server(out_hnd, action, name, sv101->srv_type, comment);
200 fprintf(out_hnd, "\tplatform_id :\t%d\n" , sv101->platform_id);
201 fprintf(out_hnd, "\tos version :\t%d.%d\n" , sv101->ver_major, sv101->ver_minor);
213 /****************************************************************************
214 server info level 102 display function
215 ****************************************************************************/
216 void display_srv_info_102(FILE *out_hnd, enum action_type action,SRV_INFO_102 *sv102)
227 fprintf(out_hnd, "Server Info Level 102:\n");
231 case ACTION_ENUMERATE:
237 fstrcpy(name , unistrn2(sv102->uni_name .buffer, sv102->uni_name .uni_str_len));
238 fstrcpy(comment , unistrn2(sv102->uni_comment .buffer, sv102->uni_comment .uni_str_len));
239 fstrcpy(usr_path, unistrn2(sv102->uni_usr_path.buffer, sv102->uni_usr_path.uni_str_len));
241 display_server(out_hnd, action, name, sv102->srv_type, comment);
243 fprintf(out_hnd, "\tplatform_id :\t%d\n" , sv102->platform_id);
244 fprintf(out_hnd, "\tos version :\t%d.%d\n" , sv102->ver_major, sv102->ver_minor);
246 fprintf(out_hnd, "\tusers :\t%x\n" , sv102->users );
247 fprintf(out_hnd, "\tdisc, hidden :\t%x,%x\n" , sv102->disc , sv102->hidden );
248 fprintf(out_hnd, "\tannounce, delta :\t%d, %d\n", sv102->announce , sv102->ann_delta);
249 fprintf(out_hnd, "\tlicenses :\t%d\n" , sv102->licenses );
250 fprintf(out_hnd, "\tuser path :\t%s\n" , usr_path);
261 /****************************************************************************
262 server info container display function
263 ****************************************************************************/
264 void display_srv_info_ctr(FILE *out_hnd, enum action_type action,SRV_INFO_CTR *ctr)
266 if (ctr == NULL || ctr->ptr_srv_ctr == 0)
268 fprintf(out_hnd, "Server Information: unavailable due to an error\n");
272 switch (ctr->switch_value)
276 display_srv_info_101(out_hnd, action, &(ctr->srv.sv101));
281 display_srv_info_102(out_hnd, action, &(ctr->srv.sv102));
286 fprintf(out_hnd, "Server Information: Unknown Info Level\n");
292 /****************************************************************************
293 connection info level 0 display function
294 ****************************************************************************/
295 void display_conn_info_0(FILE *out_hnd, enum action_type action,
307 fprintf(out_hnd, "Connection Info Level 0:\n");
311 case ACTION_ENUMERATE:
313 fprintf(out_hnd, "\tid:\t%d\n", info0->id);
319 fprintf(out_hnd, "\n");
326 /****************************************************************************
327 connection info level 1 display function
328 ****************************************************************************/
329 void display_conn_info_1(FILE *out_hnd, enum action_type action,
330 CONN_INFO_1 *info1, CONN_INFO_1_STR *str1)
332 if (info1 == NULL || str1 == NULL)
341 fprintf(out_hnd, "Connection Info Level 1:\n");
345 case ACTION_ENUMERATE:
350 fstrcpy(usr_name, unistrn2(str1->uni_usr_name.buffer, str1->uni_usr_name.uni_str_len));
351 fstrcpy(net_name, unistrn2(str1->uni_net_name.buffer, str1->uni_net_name.uni_str_len));
353 fprintf(out_hnd, "\tid :\t%d\n", info1->id);
354 fprintf(out_hnd, "\ttype :\t%s\n", get_share_type_str(info1->type));
355 fprintf(out_hnd, "\tnum_opens:\t%d\n", info1->num_opens);
356 fprintf(out_hnd, "\tnum_users:\t%d\n", info1->num_users);
357 fprintf(out_hnd, "\topen_time:\t%d\n", info1->open_time);
359 fprintf(out_hnd, "\tuser name:\t%s\n", usr_name);
360 fprintf(out_hnd, "\tnet name:\t%s\n", net_name);
366 fprintf(out_hnd, "\n");
373 /****************************************************************************
374 connection info level 0 container display function
375 ****************************************************************************/
376 void display_srv_conn_info_0_ctr(FILE *out_hnd, enum action_type action,
377 SRV_CONN_INFO_0 *ctr)
381 fprintf(out_hnd, "display_srv_conn_info_0_ctr: unavailable due to an internal error\n");
391 case ACTION_ENUMERATE:
395 for (i = 0; i < ctr->num_entries_read; i++)
397 display_conn_info_0(out_hnd, ACTION_HEADER , &(ctr->info_0[i]));
398 display_conn_info_0(out_hnd, ACTION_ENUMERATE, &(ctr->info_0[i]));
399 display_conn_info_0(out_hnd, ACTION_FOOTER , &(ctr->info_0[i]));
410 /****************************************************************************
411 connection info level 1 container display function
412 ****************************************************************************/
413 void display_srv_conn_info_1_ctr(FILE *out_hnd, enum action_type action,
414 SRV_CONN_INFO_1 *ctr)
418 fprintf(out_hnd, "display_srv_conn_info_1_ctr: unavailable due to an internal error\n");
428 case ACTION_ENUMERATE:
432 for (i = 0; i < ctr->num_entries_read; i++)
434 display_conn_info_1(out_hnd, ACTION_HEADER , &(ctr->info_1[i]), &(ctr->info_1_str[i]));
435 display_conn_info_1(out_hnd, ACTION_ENUMERATE, &(ctr->info_1[i]), &(ctr->info_1_str[i]));
436 display_conn_info_1(out_hnd, ACTION_FOOTER , &(ctr->info_1[i]), &(ctr->info_1_str[i]));
447 /****************************************************************************
448 connection info container display function
449 ****************************************************************************/
450 void display_srv_conn_info_ctr(FILE *out_hnd, enum action_type action,
451 SRV_CONN_INFO_CTR *ctr)
453 if (ctr == NULL || ctr->ptr_conn_ctr == 0)
455 fprintf(out_hnd, "display_srv_conn_info_ctr: unavailable due to an internal error\n");
459 switch (ctr->switch_value)
463 display_srv_conn_info_0_ctr(out_hnd, action,
469 display_srv_conn_info_1_ctr(out_hnd, action,
475 fprintf(out_hnd, "display_srv_conn_info_ctr: Unknown Info Level\n");
482 /****************************************************************************
483 share info level 1 display function
484 ****************************************************************************/
485 void display_share_info_1(FILE *out_hnd, enum action_type action,
486 SH_INFO_1 *info1, SH_INFO_1_STR *str1)
488 if (info1 == NULL || str1 == NULL)
497 fprintf(out_hnd, "Share Info Level 1:\n");
501 case ACTION_ENUMERATE:
506 fstrcpy(net_name, unistrn2(str1->uni_netname.buffer, str1->uni_netname.uni_str_len));
507 fstrcpy(remark , unistrn2(str1->uni_remark .buffer, str1->uni_remark .uni_str_len));
509 display_share(out_hnd, action, net_name, info1->type, remark);
515 fprintf(out_hnd, "\n");
522 /****************************************************************************
523 share info level 2 display function
524 ****************************************************************************/
525 void display_share_info_2(FILE *out_hnd, enum action_type action,
526 SH_INFO_2 *info2, SH_INFO_2_STR *str2)
528 if (info2 == NULL || str2 == NULL)
537 fprintf(out_hnd, "Share Info Level 2:\n");
541 case ACTION_ENUMERATE:
548 fstrcpy(net_name, unistrn2(str2->uni_netname.buffer, str2->uni_netname.uni_str_len));
549 fstrcpy(remark , unistrn2(str2->uni_remark .buffer, str2->uni_remark .uni_str_len));
550 fstrcpy(path , unistrn2(str2->uni_path .buffer, str2->uni_path .uni_str_len));
551 fstrcpy(passwd , unistrn2(str2->uni_passwd .buffer, str2->uni_passwd .uni_str_len));
553 display_share2(out_hnd, action, net_name, info2->type, remark,
554 info2->perms, info2->max_uses, info2->num_uses,
561 fprintf(out_hnd, "\n");
568 /****************************************************************************
569 share info level 1 container display function
570 ****************************************************************************/
571 void display_srv_share_info_1_ctr(FILE *out_hnd, enum action_type action,
572 SRV_SHARE_INFO_1 *ctr)
576 fprintf(out_hnd, "display_srv_share_info_1_ctr: unavailable due to an internal error\n");
586 case ACTION_ENUMERATE:
590 for (i = 0; i < ctr->num_entries_read; i++)
592 display_share_info_1(out_hnd, ACTION_HEADER , &(ctr->info_1[i]), &(ctr->info_1_str[i]));
593 display_share_info_1(out_hnd, ACTION_ENUMERATE, &(ctr->info_1[i]), &(ctr->info_1_str[i]));
594 display_share_info_1(out_hnd, ACTION_FOOTER , &(ctr->info_1[i]), &(ctr->info_1_str[i]));
605 /****************************************************************************
606 share info level 2 container display function
607 ****************************************************************************/
608 void display_srv_share_info_2_ctr(FILE *out_hnd, enum action_type action,
609 SRV_SHARE_INFO_2 *ctr)
613 fprintf(out_hnd, "display_srv_share_info_2_ctr: unavailable due to an internal error\n");
623 case ACTION_ENUMERATE:
627 for (i = 0; i < ctr->num_entries_read; i++)
629 display_share_info_2(out_hnd, ACTION_HEADER , &(ctr->info_2[i]), &(ctr->info_2_str[i]));
630 display_share_info_2(out_hnd, ACTION_ENUMERATE, &(ctr->info_2[i]), &(ctr->info_2_str[i]));
631 display_share_info_2(out_hnd, ACTION_FOOTER , &(ctr->info_2[i]), &(ctr->info_2_str[i]));
642 /****************************************************************************
643 share info container display function
644 ****************************************************************************/
645 void display_srv_share_info_ctr(FILE *out_hnd, enum action_type action,
646 SRV_SHARE_INFO_CTR *ctr)
648 if (ctr == NULL || ctr->ptr_share_ctr == 0)
650 fprintf(out_hnd, "display_srv_share_info_ctr: unavailable due to an internal error\n");
654 switch (ctr->switch_value)
658 display_srv_share_info_1_ctr(out_hnd, action,
659 &(ctr->share.info1));
664 display_srv_share_info_2_ctr(out_hnd, action,
665 &(ctr->share.info2));
670 fprintf(out_hnd, "display_srv_share_info_ctr: Unknown Info Level\n");
677 /****************************************************************************
678 file info level 3 display function
679 ****************************************************************************/
680 void display_file_info_3(FILE *out_hnd, enum action_type action,
681 FILE_INFO_3 *info3, FILE_INFO_3_STR *str3)
683 if (info3 == NULL || str3 == NULL)
692 fprintf(out_hnd, "File Info Level 3:\n");
696 case ACTION_ENUMERATE:
701 fstrcpy(path_name, unistrn2(str3->uni_path_name.buffer, str3->uni_path_name.uni_str_len));
702 fstrcpy(user_name, unistrn2(str3->uni_user_name.buffer, str3->uni_user_name.uni_str_len));
704 fprintf(out_hnd, "\tid :\t%d\n", info3->id);
705 fprintf(out_hnd, "\tperms :\t%s\n", get_file_mode_str(info3->perms));
706 fprintf(out_hnd, "\tnum_locks:\t%d\n", info3->num_locks);
708 fprintf(out_hnd, "\tpath name:\t%s\n", path_name);
709 fprintf(out_hnd, "\tuser name:\t%s\n", user_name);
715 fprintf(out_hnd, "\n");
722 /****************************************************************************
723 file info level 3 container display function
724 ****************************************************************************/
725 void display_srv_file_info_3_ctr(FILE *out_hnd, enum action_type action,
726 SRV_FILE_INFO_3 *ctr)
730 fprintf(out_hnd, "display_srv_file_info_3_ctr: unavailable due to an internal error\n");
740 case ACTION_ENUMERATE:
744 for (i = 0; i < ctr->num_entries_read; i++)
746 display_file_info_3(out_hnd, ACTION_HEADER , &(ctr->info_3[i]), &(ctr->info_3_str[i]));
747 display_file_info_3(out_hnd, ACTION_ENUMERATE, &(ctr->info_3[i]), &(ctr->info_3_str[i]));
748 display_file_info_3(out_hnd, ACTION_FOOTER , &(ctr->info_3[i]), &(ctr->info_3_str[i]));
759 /****************************************************************************
760 file info container display function
761 ****************************************************************************/
762 void display_srv_file_info_ctr(FILE *out_hnd, enum action_type action,
763 SRV_FILE_INFO_CTR *ctr)
765 if (ctr == NULL || ctr->ptr_file_ctr == 0)
767 fprintf(out_hnd, "display_srv_file_info_ctr: unavailable due to an internal error\n");
771 switch (ctr->switch_value)
775 display_srv_file_info_3_ctr(out_hnd, action,
781 fprintf(out_hnd, "display_srv_file_info_ctr: Unknown Info Level\n");
787 /****************************************************************************
788 print browse connection on a host
789 ****************************************************************************/
790 void display_server(FILE *out_hnd, enum action_type action,
791 char *sname, uint32 type, char *comment)
799 case ACTION_ENUMERATE:
801 fprintf(out_hnd, "\t%-15.15s%-20s %s\n",
802 sname, get_server_type_str(type), comment);
812 /****************************************************************************
813 print shares on a host
814 ****************************************************************************/
815 void display_share(FILE *out_hnd, enum action_type action,
816 char *sname, uint32 type, char *comment)
824 case ACTION_ENUMERATE:
826 fprintf(out_hnd, "\t%-15.15s%-10.10s%s\n",
827 sname, get_share_type_str(type), comment);
838 /****************************************************************************
839 print shares on a host, level 2
840 ****************************************************************************/
841 void display_share2(FILE *out_hnd, enum action_type action,
842 char *sname, uint32 type, char *comment,
843 uint32 perms, uint32 max_uses, uint32 num_uses,
844 char *path, char *passwd)
852 case ACTION_ENUMERATE:
854 fprintf(out_hnd, "\t%-15.15s%-10.10s%s %x %x %x %s %s\n",
855 sname, get_share_type_str(type), comment,
856 perms, max_uses, num_uses, path, passwd);
867 /****************************************************************************
869 ****************************************************************************/
870 void display_name(FILE *out_hnd, enum action_type action,
879 case ACTION_ENUMERATE:
881 fprintf(out_hnd, "\t%-21.21s\n", sname);
892 /****************************************************************************
893 display alias members
894 ****************************************************************************/
895 void display_alias_members(FILE *out_hnd, enum action_type action,
896 uint32 num_mem, char **sid_mem)
904 fprintf(out_hnd, "\tNo Alias Members\n");
908 fprintf(out_hnd, "\tAlias Members:\n");
909 fprintf(out_hnd, "\t-------------\n");
913 case ACTION_ENUMERATE:
917 for (i = 0; i < num_mem; i++)
919 if (sid_mem[i] != NULL)
921 fprintf(out_hnd, "\tMember Name:\t%s\n", sid_mem[i]);
929 fprintf(out_hnd, "\n");
936 /****************************************************************************
937 display alias rid info
938 ****************************************************************************/
939 void display_alias_rid_info(FILE *out_hnd, enum action_type action,
941 uint32 num_rids, uint32 *rid)
948 sid_to_string(sid_str, sid);
951 fprintf(out_hnd, "\tNo Aliases:\tSid %s\n", sid_str);
955 fprintf(out_hnd, "\tAlias Info:\tSid %s\n", sid_str);
956 fprintf(out_hnd, "\t----------\n");
960 case ACTION_ENUMERATE:
964 for (i = 0; i < num_rids; i++)
966 fprintf(out_hnd, "\tAlias RID:\t%8x\n", rid[i]);
973 fprintf(out_hnd, "\n");
979 /****************************************************************************
980 display group members
981 ****************************************************************************/
982 void display_group_members(FILE *out_hnd, enum action_type action,
983 uint32 num_mem, fstring *name, uint32 *type)
991 fprintf(out_hnd, "\tNo Members\n");
995 fprintf(out_hnd, "\tMembers:\n");
996 fprintf(out_hnd, "\t-------\n");
1000 case ACTION_ENUMERATE:
1004 for (i = 0; i < num_mem; i++)
1006 fprintf(out_hnd, "\tMember Name:\t%s\tType:\t%s\n",
1007 name[i], get_sid_name_use_str(type[i]));
1014 fprintf(out_hnd, "\n");
1023 /****************************************************************************
1025 ****************************************************************************/
1026 void display_group_info1(FILE *out_hnd, enum action_type action, GROUP_INFO1 *info1)
1035 case ACTION_ENUMERATE:
1039 fprintf(out_hnd, "\tGroup Name:\t%s\tDescription:\t%s\tunk1:\t%sunk2:%s\n",
1044 fprintf(out_hnd, "\n");
1051 /****************************************************************************
1052 display group rid info
1053 ****************************************************************************/
1054 void display_group_rid_info(FILE *out_hnd, enum action_type action,
1055 uint32 num_gids, DOM_GID *gid)
1063 fprintf(out_hnd, "\tNo Groups\n");
1067 fprintf(out_hnd, "\tGroup Info\n");
1068 fprintf(out_hnd, "\t----------\n");
1072 case ACTION_ENUMERATE:
1076 for (i = 0; i < num_gids; i++)
1078 fprintf(out_hnd, "\tGroup RID:\t%8x attr:\t%x\n",
1079 gid[i].g_rid, gid[i].attr);
1086 fprintf(out_hnd, "\n");
1093 /****************************************************************************
1094 display alias name info
1095 ****************************************************************************/
1096 void display_alias_name_info(FILE *out_hnd, enum action_type action,
1097 uint32 num_aliases, fstring *alias_name, uint32 *num_als_usrs)
1103 if (num_aliases == 0)
1105 fprintf(out_hnd, "\tNo Aliases\n");
1109 fprintf(out_hnd, "\tAlias Names\n");
1110 fprintf(out_hnd, "\t----------- \n");
1114 case ACTION_ENUMERATE:
1118 for (i = 0; i < num_aliases; i++)
1120 fprintf(out_hnd, "\tAlias Name:\t%s Attributes:\t%3d\n",
1121 alias_name[i], num_als_usrs[i]);
1128 fprintf(out_hnd, "\n");
1135 /****************************************************************************
1136 display sam_user_info_21 structure
1137 ****************************************************************************/
1138 void display_sam_user_info_21(FILE *out_hnd, enum action_type action, SAM_USER_INFO_21 *usr)
1144 fprintf(out_hnd, "\tUser Info, Level 0x15\n");
1145 fprintf(out_hnd, "\t---------------------\n");
1149 case ACTION_ENUMERATE:
1151 fprintf(out_hnd, "\t\tUser Name :\t%s\n", unistrn2(usr->uni_user_name .buffer, usr->uni_user_name .uni_str_len)); /* username unicode string */
1152 fprintf(out_hnd, "\t\tFull Name :\t%s\n", unistrn2(usr->uni_full_name .buffer, usr->uni_full_name .uni_str_len)); /* user's full name unicode string */
1153 fprintf(out_hnd, "\t\tHome Drive :\t%s\n", unistrn2(usr->uni_home_dir .buffer, usr->uni_home_dir .uni_str_len)); /* home directory unicode string */
1154 fprintf(out_hnd, "\t\tDir Drive :\t%s\n", unistrn2(usr->uni_dir_drive .buffer, usr->uni_dir_drive .uni_str_len)); /* home directory drive unicode string */
1155 fprintf(out_hnd, "\t\tProfile Path:\t%s\n", unistrn2(usr->uni_profile_path.buffer, usr->uni_profile_path.uni_str_len)); /* profile path unicode string */
1156 fprintf(out_hnd, "\t\tLogon Script:\t%s\n", unistrn2(usr->uni_logon_script.buffer, usr->uni_logon_script.uni_str_len)); /* logon script unicode string */
1157 fprintf(out_hnd, "\t\tDescription :\t%s\n", unistrn2(usr->uni_acct_desc .buffer, usr->uni_acct_desc .uni_str_len)); /* user description unicode string */
1158 fprintf(out_hnd, "\t\tWorkstations:\t%s\n", unistrn2(usr->uni_workstations.buffer, usr->uni_workstations.uni_str_len)); /* workstaions unicode string */
1159 fprintf(out_hnd, "\t\tUnknown Str :\t%s\n", unistrn2(usr->uni_unknown_str .buffer, usr->uni_unknown_str .uni_str_len)); /* unknown string unicode string */
1160 fprintf(out_hnd, "\t\tRemote Dial :\t%s\n", unistrn2(usr->uni_munged_dial .buffer, usr->uni_munged_dial .uni_str_len)); /* munged remote access unicode string */
1162 fprintf(out_hnd, "\t\tLogon Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->logon_time ))));
1163 fprintf(out_hnd, "\t\tLogoff Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->logoff_time ))));
1164 fprintf(out_hnd, "\t\tKickoff Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->kickoff_time ))));
1165 fprintf(out_hnd, "\t\tPassword last set Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->pass_last_set_time ))));
1166 fprintf(out_hnd, "\t\tPassword can change Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->pass_can_change_time ))));
1167 fprintf(out_hnd, "\t\tPassword must change Time:\t%s\n", http_timestring(nt_time_to_unix(&(usr->pass_must_change_time))));
1169 fprintf(out_hnd, "\t\tunknown_2[0..31]...\n"); /* user passwords? */
1171 fprintf(out_hnd, "\t\tuser_rid :\t%x\n" , usr->user_rid ); /* User ID */
1172 fprintf(out_hnd, "\t\tgroup_rid:\t%x\n" , usr->group_rid); /* Group ID */
1173 fprintf(out_hnd, "\t\tacb_info :\t%04x\n", usr->acb_info ); /* Account Control Info */
1175 fprintf(out_hnd, "\t\tunknown_3:\t%08x\n", usr->unknown_3); /* 0x00ff ffff */
1176 fprintf(out_hnd, "\t\tlogon_divs:\t%d\n", usr->logon_divs); /* 0x0000 00a8 which is 168 which is num hrs in a week */
1177 fprintf(out_hnd, "\t\tunknown_5:\t%08x\n", usr->unknown_5); /* 0x0002 0000 */
1179 fprintf(out_hnd, "\t\tpadding1[0..7]...\n");
1181 if (usr->ptr_logon_hrs)
1183 fprintf(out_hnd, "\t\tlogon_hrs[0..%d]...\n", usr->logon_hrs.len);
1190 fprintf(out_hnd, "\n");
1197 /****************************************************************************
1198 convert a security permissions into a string
1199 ****************************************************************************/
1200 char *get_sec_mask_str(uint32 type)
1202 static fstring typestr;
1207 case SEC_RIGHTS_FULL_CONTROL:
1209 fstrcpy(typestr, "Full Control");
1213 case SEC_RIGHTS_READ:
1215 fstrcpy(typestr, "Read");
1225 for (i = 0; i < 32; i++)
1227 if (IS_BITS_SET_ALL(type, 1 << i))
1231 case SEC_RIGHTS_QUERY_VALUE : fstrcat(typestr, "Query " ); break;
1232 case SEC_RIGHTS_SET_VALUE : fstrcat(typestr, "Set " ); break;
1233 case SEC_RIGHTS_CREATE_SUBKEY : fstrcat(typestr, "Create "); break;
1234 case SEC_RIGHTS_ENUM_SUBKEYS : fstrcat(typestr, "Enum "); break;
1235 case SEC_RIGHTS_NOTIFY : fstrcat(typestr, "Notify "); break;
1236 case SEC_RIGHTS_CREATE_LINK : fstrcat(typestr, "CreateLink "); break;
1237 case SEC_RIGHTS_DELETE : fstrcat(typestr, "Delete "); break;
1238 case SEC_RIGHTS_READ_CONTROL : fstrcat(typestr, "ReadControl "); break;
1239 case SEC_RIGHTS_WRITE_DAC : fstrcat(typestr, "WriteDAC "); break;
1240 case SEC_RIGHTS_WRITE_OWNER : fstrcat(typestr, "WriteOwner "); break;
1246 /* remaining bits get added on as-is */
1250 slprintf(tmp, sizeof(tmp)-1, "[%08x]", type);
1251 fstrcat(typestr, tmp);
1254 /* remove last space */
1255 i = strlen(typestr)-1;
1256 if (typestr[i] == ' ') typestr[i] = 0;
1261 /****************************************************************************
1262 display sec_access structure
1263 ****************************************************************************/
1264 void display_sec_access(FILE *out_hnd, enum action_type action, SEC_ACCESS *info)
1272 case ACTION_ENUMERATE:
1274 fprintf(out_hnd, "\t\tPermissions:\t%s\n",
1275 get_sec_mask_str(info->mask));
1284 /****************************************************************************
1285 display sec_ace structure
1286 ****************************************************************************/
1287 void display_sec_ace(FILE *out_hnd, enum action_type action, SEC_ACE *ace)
1293 fprintf(out_hnd, "\tACE\n");
1296 case ACTION_ENUMERATE:
1300 display_sec_access(out_hnd, ACTION_HEADER , &ace->info);
1301 display_sec_access(out_hnd, ACTION_ENUMERATE, &ace->info);
1302 display_sec_access(out_hnd, ACTION_FOOTER , &ace->info);
1304 sid_to_string(sid_str, &ace->sid);
1305 fprintf(out_hnd, "\t\tSID:\t%s\n", sid_str);
1314 /****************************************************************************
1315 display sec_acl structure
1316 ****************************************************************************/
1317 void display_sec_acl(FILE *out_hnd, enum action_type action, SEC_ACL *sec_acl)
1323 fprintf(out_hnd, "\tACL\tNum ACEs:\t%d\trevision:\t%x\n",
1324 sec_acl->num_aces, sec_acl->revision);
1325 fprintf(out_hnd, "\t---\n");
1329 case ACTION_ENUMERATE:
1331 if (sec_acl->size != 0 && sec_acl->num_aces != 0)
1334 for (i = 0; i < sec_acl->num_aces; i++)
1336 display_sec_ace(out_hnd, ACTION_HEADER , &sec_acl->ace[i]);
1337 display_sec_ace(out_hnd, ACTION_ENUMERATE, &sec_acl->ace[i]);
1338 display_sec_ace(out_hnd, ACTION_FOOTER , &sec_acl->ace[i]);
1346 fprintf(out_hnd, "\n");
1352 /****************************************************************************
1353 display sec_desc structure
1354 ****************************************************************************/
1355 void display_sec_desc(FILE *out_hnd, enum action_type action, SEC_DESC *sec)
1361 fprintf(out_hnd, "\tSecurity Descriptor\trevision:\t%x\ttype:\t%x\n",
1362 sec->revision, sec->type);
1363 fprintf(out_hnd, "\t-------------------\n");
1367 case ACTION_ENUMERATE:
1371 if (sec->off_sacl != 0)
1373 display_sec_acl(out_hnd, ACTION_HEADER , sec->sacl);
1374 display_sec_acl(out_hnd, ACTION_ENUMERATE, sec->sacl);
1375 display_sec_acl(out_hnd, ACTION_FOOTER , sec->sacl);
1377 if (sec->off_dacl != 0)
1379 display_sec_acl(out_hnd, ACTION_HEADER , sec->dacl);
1380 display_sec_acl(out_hnd, ACTION_ENUMERATE, sec->dacl);
1381 display_sec_acl(out_hnd, ACTION_FOOTER , sec->dacl);
1383 if (sec->off_owner_sid != 0)
1385 sid_to_string(sid_str, sec->owner_sid);
1386 fprintf(out_hnd, "\tOwner SID:\t%s\n", sid_str);
1388 if (sec->off_grp_sid != 0)
1390 sid_to_string(sid_str, sec->grp_sid);
1391 fprintf(out_hnd, "\tParent SID:\t%s\n", sid_str);
1398 fprintf(out_hnd, "\n");
1404 /****************************************************************************
1405 convert a security permissions into a string
1406 ****************************************************************************/
1407 char *get_reg_val_type_str(uint32 type)
1409 static fstring typestr;
1415 fstrcpy(typestr, "string");
1421 fstrcpy(typestr, "bytes");
1427 fstrcpy(typestr, "uint32");
1433 fstrcpy(typestr, "multi");
1441 slprintf(typestr, sizeof(typestr)-1, "[%d]", type);
1446 static void print_reg_value(FILE *out_hnd, char *val_name, uint32 val_type, BUFFER2 *value)
1449 fstrcpy(type, get_reg_val_type_str(val_type));
1453 case 0x01: /* unistr */
1455 fprintf(out_hnd,"\t%s:\t%s:\t%s\n", val_name, type, buffer2_to_str(value));
1459 default: /* unknown */
1460 case 0x03: /* bytes */
1462 if (value->buf_len <= 8)
1464 fprintf(out_hnd,"\t%s:\t%s:\t", val_name, type);
1465 out_data(out_hnd, (char*)value->buffer, value->buf_len, 8);
1469 fprintf(out_hnd,"\t%s:\t%s:\n", val_name, type);
1470 out_data(out_hnd, (char*)value->buffer, value->buf_len, 16);
1475 case 0x04: /* uint32 */
1477 fprintf(out_hnd,"\t%s:\t%s:\t0x%08x\n", val_name, type, buffer2_to_uint32(value));
1481 case 0x07: /* multiunistr */
1483 fprintf(out_hnd,"\t%s:\t%s:\t%s\n", val_name, type, buffer2_to_multistr(value));
1489 /****************************************************************************
1491 ****************************************************************************/
1492 void display_reg_value_info(FILE *out_hnd, enum action_type action,
1493 char *val_name, uint32 val_type, BUFFER2 *value)
1501 case ACTION_ENUMERATE:
1503 print_reg_value(out_hnd, val_name, val_type, value);
1513 /****************************************************************************
1515 ****************************************************************************/
1516 void display_reg_key_info(FILE *out_hnd, enum action_type action,
1517 char *key_name, time_t key_mod_time)
1525 case ACTION_ENUMERATE:
1527 fprintf(out_hnd, "\t%s\t(%s)\n",
1528 key_name, http_timestring(key_mod_time));
1538 #if COPY_THIS_TEMPLATE
1539 /****************************************************************************
1541 ****************************************************************************/
1542 void display_(FILE *out_hnd, enum action_type action, *)
1548 fprintf(out_hnd, "\t\n");
1549 fprintf(out_hnd, "\t-------------------\n");
1553 case ACTION_ENUMERATE:
1559 fprintf(out_hnd, "\n");