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 share mode to a string
28 ****************************************************************************/
29 char *get_file_mode_str(uint32 share_mode)
33 switch (GET_DENY_MODE(share_mode))
35 case DENY_NONE : fstrcpy(mode, "DENY_NONE "); break;
36 case DENY_ALL : fstrcpy(mode, "DENY_ALL "); break;
37 case DENY_DOS : fstrcpy(mode, "DENY_DOS "); break;
38 case DENY_READ : fstrcpy(mode, "DENY_READ "); break;
39 case DENY_WRITE: fstrcpy(mode, "DENY_WRITE "); break;
40 case DENY_FCB: fstrcpy(mode, "DENY_FCB "); break;
41 default : fstrcpy(mode, "DENY_???? "); break;
44 switch (share_mode & 0xF)
46 case 0 : fstrcat(mode, "RDONLY"); break;
47 case 1 : fstrcat(mode, "WRONLY"); break;
48 case 2 : fstrcat(mode, "RDWR "); break;
49 default: fstrcat(mode, "R??W??"); break;
55 /****************************************************************************
56 convert an oplock mode to a string
57 ****************************************************************************/
58 char *get_file_oplock_str(uint32 op_type)
60 static fstring oplock;
61 BOOL excl = ((op_type & EXCLUSIVE_OPLOCK) != 0);
62 BOOL batch = ((op_type & BATCH_OPLOCK ) != 0);
66 if (excl ) fstrcat(oplock, "EXCLUSIVE");
67 if (excl && batch) fstrcat(oplock, "+");
68 if ( batch) fstrcat(oplock, "BATCH");
69 if (!excl && !batch) fstrcat(oplock, "NONE");
74 /****************************************************************************
75 convert a share type enum to a string
76 ****************************************************************************/
77 char *get_share_type_str(uint32 type)
79 static fstring typestr;
83 case STYPE_DISKTREE: fstrcpy(typestr, "Disk" ); break;
84 case STYPE_PRINTQ : fstrcpy(typestr, "Printer"); break;
85 case STYPE_DEVICE : fstrcpy(typestr, "Device" ); break;
86 case STYPE_IPC : fstrcpy(typestr, "IPC" ); break;
87 default : fstrcpy(typestr, "????" ); break;
92 /****************************************************************************
93 convert a server type enum to a string
94 ****************************************************************************/
95 char *get_server_type_str(uint32 type)
97 static fstring typestr;
99 if (type == SV_TYPE_ALL)
101 fstrcpy(typestr, "All");
107 for (i = 0; i < 32; i++)
111 switch (((unsigned)1) << i)
113 case SV_TYPE_WORKSTATION : fstrcat(typestr, "Wk " ); break;
114 case SV_TYPE_SERVER : fstrcat(typestr, "Sv " ); break;
115 case SV_TYPE_SQLSERVER : fstrcat(typestr, "Sql "); break;
116 case SV_TYPE_DOMAIN_CTRL : fstrcat(typestr, "PDC "); break;
117 case SV_TYPE_DOMAIN_BAKCTRL : fstrcat(typestr, "BDC "); break;
118 case SV_TYPE_TIME_SOURCE : fstrcat(typestr, "Tim "); break;
119 case SV_TYPE_AFP : fstrcat(typestr, "AFP "); break;
120 case SV_TYPE_NOVELL : fstrcat(typestr, "Nov "); break;
121 case SV_TYPE_DOMAIN_MEMBER : fstrcat(typestr, "Dom "); break;
122 case SV_TYPE_PRINTQ_SERVER : fstrcat(typestr, "PrQ "); break;
123 case SV_TYPE_DIALIN_SERVER : fstrcat(typestr, "Din "); break;
124 case SV_TYPE_SERVER_UNIX : fstrcat(typestr, "Unx "); break;
125 case SV_TYPE_NT : fstrcat(typestr, "NT " ); break;
126 case SV_TYPE_WFW : fstrcat(typestr, "Wfw "); break;
127 case SV_TYPE_SERVER_MFPN : fstrcat(typestr, "Mfp "); break;
128 case SV_TYPE_SERVER_NT : fstrcat(typestr, "SNT "); break;
129 case SV_TYPE_POTENTIAL_BROWSER: fstrcat(typestr, "PtB "); break;
130 case SV_TYPE_BACKUP_BROWSER : fstrcat(typestr, "BMB "); break;
131 case SV_TYPE_MASTER_BROWSER : fstrcat(typestr, "LMB "); break;
132 case SV_TYPE_DOMAIN_MASTER : fstrcat(typestr, "DMB "); break;
133 case SV_TYPE_SERVER_OSF : fstrcat(typestr, "OSF "); break;
134 case SV_TYPE_SERVER_VMS : fstrcat(typestr, "VMS "); break;
135 case SV_TYPE_WIN95_PLUS : fstrcat(typestr, "W95 "); break;
136 case SV_TYPE_ALTERNATE_XPORT : fstrcat(typestr, "Xpt "); break;
137 case SV_TYPE_LOCAL_LIST_ONLY : fstrcat(typestr, "Dom "); break;
138 case SV_TYPE_DOMAIN_ENUM : fstrcat(typestr, "Loc "); break;
142 i = strlen(typestr)-1;
143 if (typestr[i] == ' ') typestr[i] = 0;
149 /****************************************************************************
150 server info level 101 display function
151 ****************************************************************************/
152 void display_srv_info_101(FILE *out_hnd, enum action_type action,
164 fprintf(out_hnd, "Server Info Level 101:\n");
168 case ACTION_ENUMERATE:
173 rpcstr_pull(name, sv101->uni_name.buffer, sizeof(name), sv101->uni_name.uni_str_len*2, 0);
174 rpcstr_pull(comment, sv101->uni_comment.buffer, sizeof(comment), sv101->uni_comment.uni_str_len*2, 0);
176 display_server(out_hnd, action, name, sv101->srv_type, comment);
178 fprintf(out_hnd, "\tplatform_id : %d\n" , sv101->platform_id);
179 fprintf(out_hnd, "\tos version : %d.%d\n" , sv101->ver_major, sv101->ver_minor);
191 /****************************************************************************
192 server info level 102 display function
193 ****************************************************************************/
194 void display_srv_info_102(FILE *out_hnd, enum action_type action,SRV_INFO_102 *sv102)
205 fprintf(out_hnd, "Server Info Level 102:\n");
209 case ACTION_ENUMERATE:
215 rpcstr_pull(name, sv102->uni_name.buffer, sizeof(name), sv102->uni_name.uni_str_len*2, 0);
216 rpcstr_pull(comment, sv102->uni_comment.buffer, sizeof(comment), sv102->uni_comment.uni_str_len*2, 0);
217 rpcstr_pull(usr_path, sv102->uni_usr_path.buffer, sizeof(usr_path), sv102->uni_usr_path.uni_str_len*2, 0);
219 display_server(out_hnd, action, name, sv102->srv_type, comment);
221 fprintf(out_hnd, "\tplatform_id : %d\n" , sv102->platform_id);
222 fprintf(out_hnd, "\tos version : %d.%d\n" , sv102->ver_major, sv102->ver_minor);
224 fprintf(out_hnd, "\tusers : %x\n" , sv102->users );
225 fprintf(out_hnd, "\tdisc, hidden : %x,%x\n" , sv102->disc , sv102->hidden );
226 fprintf(out_hnd, "\tannounce, delta : %d, %d\n", sv102->announce , sv102->ann_delta);
227 fprintf(out_hnd, "\tlicenses : %d\n" , sv102->licenses );
228 fprintf(out_hnd, "\tuser path : %s\n" , usr_path);
239 /****************************************************************************
240 server info container display function
241 ****************************************************************************/
242 void display_srv_info_ctr(FILE *out_hnd, enum action_type action,SRV_INFO_CTR *ctr)
244 if (ctr == NULL || ctr->ptr_srv_ctr == 0)
246 fprintf(out_hnd, "Server Information: unavailable due to an error\n");
250 switch (ctr->switch_value)
254 display_srv_info_101(out_hnd, action, &(ctr->srv.sv101));
259 display_srv_info_102(out_hnd, action, &(ctr->srv.sv102));
264 fprintf(out_hnd, "Server Information: Unknown Info Level\n");
270 /****************************************************************************
271 connection info level 0 display function
272 ****************************************************************************/
273 void display_conn_info_0(FILE *out_hnd, enum action_type action,
285 fprintf(out_hnd, "Connection Info Level 0:\n");
289 case ACTION_ENUMERATE:
291 fprintf(out_hnd, "\tid: %d\n", info0->id);
297 fprintf(out_hnd, "\n");
304 /****************************************************************************
305 connection info level 1 display function
306 ****************************************************************************/
307 void display_conn_info_1(FILE *out_hnd, enum action_type action,
308 CONN_INFO_1 *info1, CONN_INFO_1_STR *str1)
310 if (info1 == NULL || str1 == NULL)
319 fprintf(out_hnd, "Connection Info Level 1:\n");
323 case ACTION_ENUMERATE:
328 rpcstr_pull(usr_name, str1->uni_usr_name.buffer, sizeof(usr_name), str1->uni_usr_name.uni_str_len*2,0);
329 rpcstr_pull(net_name, str1->uni_net_name.buffer, sizeof(net_name), str1->uni_net_name.uni_str_len*2,0);
331 fprintf(out_hnd, "\tid : %d\n", info1->id);
332 fprintf(out_hnd, "\ttype : %s\n", get_share_type_str(info1->type));
333 fprintf(out_hnd, "\tnum_opens: %d\n", info1->num_opens);
334 fprintf(out_hnd, "\tnum_users: %d\n", info1->num_users);
335 fprintf(out_hnd, "\topen_time: %d\n", info1->open_time);
337 fprintf(out_hnd, "\tuser name: %s\n", usr_name);
338 fprintf(out_hnd, "\tnet name: %s\n", net_name);
344 fprintf(out_hnd, "\n");
351 /****************************************************************************
352 connection info level 0 container display function
353 ****************************************************************************/
354 void display_srv_conn_info_0_ctr(FILE *out_hnd, enum action_type action,
355 SRV_CONN_INFO_0 *ctr)
359 fprintf(out_hnd, "display_srv_conn_info_0_ctr: unavailable due to an internal error\n");
369 case ACTION_ENUMERATE:
373 for (i = 0; i < ctr->num_entries_read; i++)
375 display_conn_info_0(out_hnd, ACTION_HEADER , &(ctr->info_0[i]));
376 display_conn_info_0(out_hnd, ACTION_ENUMERATE, &(ctr->info_0[i]));
377 display_conn_info_0(out_hnd, ACTION_FOOTER , &(ctr->info_0[i]));
388 /****************************************************************************
389 connection info level 1 container display function
390 ****************************************************************************/
391 void display_srv_conn_info_1_ctr(FILE *out_hnd, enum action_type action,
392 SRV_CONN_INFO_1 *ctr)
396 fprintf(out_hnd, "display_srv_conn_info_1_ctr: unavailable due to an internal error\n");
406 case ACTION_ENUMERATE:
410 for (i = 0; i < ctr->num_entries_read; i++)
412 display_conn_info_1(out_hnd, ACTION_HEADER , &(ctr->info_1[i]), &(ctr->info_1_str[i]));
413 display_conn_info_1(out_hnd, ACTION_ENUMERATE, &(ctr->info_1[i]), &(ctr->info_1_str[i]));
414 display_conn_info_1(out_hnd, ACTION_FOOTER , &(ctr->info_1[i]), &(ctr->info_1_str[i]));
425 /****************************************************************************
426 connection info container display function
427 ****************************************************************************/
428 void display_srv_conn_info_ctr(FILE *out_hnd, enum action_type action,
429 SRV_CONN_INFO_CTR *ctr)
431 if (ctr == NULL || ctr->ptr_conn_ctr == 0)
433 fprintf(out_hnd, "display_srv_conn_info_ctr: unavailable due to an internal error\n");
437 switch (ctr->switch_value)
441 display_srv_conn_info_0_ctr(out_hnd, action,
447 display_srv_conn_info_1_ctr(out_hnd, action,
453 fprintf(out_hnd, "display_srv_conn_info_ctr: Unknown Info Level\n");
460 /****************************************************************************
461 share info level 1 display function
462 ****************************************************************************/
463 void display_share_info_1(FILE *out_hnd, enum action_type action,
464 SRV_SHARE_INFO_1 *info1)
475 fprintf(out_hnd, "Share Info Level 1:\n");
479 case ACTION_ENUMERATE:
484 rpcstr_pull(net_name, info1->info_1_str.uni_netname.buffer, sizeof(net_name), info1->info_1_str.uni_netname.uni_str_len*2, 0);
485 rpcstr_pull(remark, info1->info_1_str.uni_remark.buffer, sizeof(remark), info1->info_1_str.uni_remark.uni_str_len*2, 0);
487 display_share(out_hnd, action, net_name, info1->info_1.type, remark);
493 fprintf(out_hnd, "\n");
500 /****************************************************************************
501 share info level 2 display function
502 ****************************************************************************/
503 void display_share_info_2(FILE *out_hnd, enum action_type action,
504 SRV_SHARE_INFO_2 *info2)
515 fprintf(out_hnd, "Share Info Level 2:\n");
519 case ACTION_ENUMERATE:
526 rpcstr_pull(net_name, info2->info_2_str.uni_netname.buffer, sizeof(net_name), info2->info_2_str.uni_netname.uni_str_len*2, 0);
527 rpcstr_pull(remark, info2->info_2_str.uni_remark.buffer, sizeof(remark), info2->info_2_str.uni_remark.uni_str_len*2, 0);
528 rpcstr_pull(path, info2->info_2_str.uni_path.buffer, sizeof(path), info2->info_2_str.uni_path.uni_str_len*2, 0);
529 rpcstr_pull(passwd, info2->info_2_str.uni_passwd.buffer, sizeof(passwd), info2->info_2_str.uni_passwd.uni_str_len*2, 0);
531 display_share2(out_hnd, action, net_name,
532 info2->info_2.type, remark, info2->info_2.perms,
533 info2->info_2.max_uses, info2->info_2.num_uses,
540 fprintf(out_hnd, "\n");
547 /****************************************************************************
548 share info container display function
549 ****************************************************************************/
550 void display_srv_share_info_ctr(FILE *out_hnd, enum action_type action,
551 SRV_SHARE_INFO_CTR *ctr)
555 fprintf(out_hnd, "display_srv_share_info_ctr: unavailable due to an internal error\n");
565 case ACTION_ENUMERATE:
569 for (i = 0; i < ctr->num_entries; i++)
571 switch (ctr->info_level) {
573 display_share_info_1(out_hnd, ACTION_HEADER , &(ctr->share.info1[i]));
574 display_share_info_1(out_hnd, ACTION_ENUMERATE, &(ctr->share.info1[i]));
575 display_share_info_1(out_hnd, ACTION_FOOTER , &(ctr->share.info1[i]));
578 display_share_info_2(out_hnd, ACTION_HEADER , &(ctr->share.info2[i]));
579 display_share_info_2(out_hnd, ACTION_ENUMERATE, &(ctr->share.info2[i]));
580 display_share_info_2(out_hnd, ACTION_FOOTER , &(ctr->share.info2[i]));
583 fprintf(out_hnd, "display_srv_share_info_ctr: Unknown Info Level\n");
596 /****************************************************************************
597 file info level 3 display function
598 ****************************************************************************/
599 void display_file_info_3(FILE *out_hnd, enum action_type action,
600 FILE_INFO_3 *info3, FILE_INFO_3_STR *str3)
602 if (info3 == NULL || str3 == NULL)
611 fprintf(out_hnd, "File Info Level 3:\n");
615 case ACTION_ENUMERATE:
620 rpcstr_pull(path_name, str3->uni_path_name.buffer, sizeof(path_name), str3->uni_path_name.uni_str_len*2, 0);
621 rpcstr_pull(user_name, str3->uni_user_name.buffer, sizeof(user_name), str3->uni_user_name.uni_str_len*2, 0);
623 fprintf(out_hnd, "\tid : %d\n", info3->id);
624 fprintf(out_hnd, "\tperms : %s\n", get_file_mode_str(info3->perms));
625 fprintf(out_hnd, "\tnum_locks: %d\n", info3->num_locks);
627 fprintf(out_hnd, "\tpath name: %s\n", path_name);
628 fprintf(out_hnd, "\tuser name: %s\n", user_name);
634 fprintf(out_hnd, "\n");
641 /****************************************************************************
642 file info level 3 container display function
643 ****************************************************************************/
644 void display_srv_file_info_3_ctr(FILE *out_hnd, enum action_type action,
645 SRV_FILE_INFO_3 *ctr)
649 fprintf(out_hnd, "display_srv_file_info_3_ctr: unavailable due to an internal error\n");
659 case ACTION_ENUMERATE:
663 for (i = 0; i < ctr->num_entries_read; i++)
665 display_file_info_3(out_hnd, ACTION_HEADER , &(ctr->info_3[i]), &(ctr->info_3_str[i]));
666 display_file_info_3(out_hnd, ACTION_ENUMERATE, &(ctr->info_3[i]), &(ctr->info_3_str[i]));
667 display_file_info_3(out_hnd, ACTION_FOOTER , &(ctr->info_3[i]), &(ctr->info_3_str[i]));
678 /****************************************************************************
679 file info container display function
680 ****************************************************************************/
681 void display_srv_file_info_ctr(FILE *out_hnd, enum action_type action,
682 SRV_FILE_INFO_CTR *ctr)
684 if (ctr == NULL || ctr->ptr_file_ctr == 0)
686 fprintf(out_hnd, "display_srv_file_info_ctr: unavailable due to an internal error\n");
690 switch (ctr->switch_value)
694 display_srv_file_info_3_ctr(out_hnd, action,
700 fprintf(out_hnd, "display_srv_file_info_ctr: Unknown Info Level\n");
706 /****************************************************************************
707 print browse connection on a host
708 ****************************************************************************/
709 void display_server(FILE *out_hnd, enum action_type action,
710 char *sname, uint32 type, char *comment)
718 case ACTION_ENUMERATE:
720 fprintf(out_hnd, "\t%-15.15s%-20s %s\n",
721 sname, get_server_type_str(type), comment);
731 /****************************************************************************
732 print shares on a host
733 ****************************************************************************/
734 void display_share(FILE *out_hnd, enum action_type action,
735 char *sname, uint32 type, char *comment)
743 case ACTION_ENUMERATE:
745 fprintf(out_hnd, "\t%-15.15s%-10.10s%s\n",
746 sname, get_share_type_str(type), comment);
757 /****************************************************************************
758 print shares on a host, level 2
759 ****************************************************************************/
760 void display_share2(FILE *out_hnd, enum action_type action,
761 char *sname, uint32 type, char *comment,
762 uint32 perms, uint32 max_uses, uint32 num_uses,
763 char *path, char *passwd)
771 case ACTION_ENUMERATE:
773 fprintf(out_hnd, "\t%-15.15s%-10.10s%s %x %x %x %s %s\n",
774 sname, get_share_type_str(type), comment,
775 perms, max_uses, num_uses, path, passwd);
786 /****************************************************************************
788 ****************************************************************************/
789 void display_name(FILE *out_hnd, enum action_type action,
798 case ACTION_ENUMERATE:
800 fprintf(out_hnd, "\t%-21.21s\n", sname);
811 /****************************************************************************
812 display group rid info
813 ****************************************************************************/
814 void display_group_rid_info(FILE *out_hnd, enum action_type action,
815 uint32 num_gids, DOM_GID *gid)
823 fprintf(out_hnd, "\tNo Groups\n");
827 fprintf(out_hnd, "\tGroup Info\n");
828 fprintf(out_hnd, "\t----------\n");
832 case ACTION_ENUMERATE:
836 for (i = 0; i < num_gids; i++)
838 fprintf(out_hnd, "\tGroup RID: %8x attr: %x\n",
839 gid[i].g_rid, gid[i].attr);
846 fprintf(out_hnd, "\n");
853 /****************************************************************************
854 display alias name info
855 ****************************************************************************/
856 void display_alias_name_info(FILE *out_hnd, enum action_type action,
857 uint32 num_aliases, fstring *alias_name, uint32 *num_als_usrs)
863 if (num_aliases == 0)
865 fprintf(out_hnd, "\tNo Aliases\n");
869 fprintf(out_hnd, "\tAlias Names\n");
870 fprintf(out_hnd, "\t----------- \n");
874 case ACTION_ENUMERATE:
878 for (i = 0; i < num_aliases; i++)
880 fprintf(out_hnd, "\tAlias Name: %s Attributes: %3d\n",
881 alias_name[i], num_als_usrs[i]);
888 fprintf(out_hnd, "\n");
895 /****************************************************************************
896 display sam_user_info_21 structure
897 ****************************************************************************/
898 void display_sam_user_info_21(FILE *out_hnd, enum action_type action, SAM_USER_INFO_21 *usr)
904 fprintf(out_hnd, "\tUser Info, Level 0x15\n");
905 fprintf(out_hnd, "\t---------------------\n");
909 case ACTION_ENUMERATE:
912 rpcstr_pull(tmp, usr->uni_user_name.buffer, sizeof(tmp),usr->uni_user_name.uni_str_len*2, 0);
913 fprintf(out_hnd, "\t\tUser Name : %s\n", tmp); /* username unicode string */
914 rpcstr_pull(tmp, usr->uni_full_name.buffer, sizeof(tmp),usr->uni_full_name.uni_str_len*2, 0);
915 fprintf(out_hnd, "\t\tFull Name : %s\n", tmp); /* user's full name unicode string */
916 rpcstr_pull(tmp, usr->uni_home_dir.buffer, sizeof(tmp),usr->uni_home_dir.uni_str_len*2, 0);
917 fprintf(out_hnd, "\t\tHome Drive : %s\n", tmp); /* home directory unicode string */
918 rpcstr_pull(tmp, usr->uni_dir_drive.buffer, sizeof(tmp),usr->uni_dir_drive.uni_str_len*2, 0);
919 fprintf(out_hnd, "\t\tDir Drive : %s\n", tmp); /* home directory drive unicode string */
920 rpcstr_pull(tmp, usr->uni_profile_path.buffer, sizeof(tmp),usr->uni_profile_path.uni_str_len*2, 0);
921 fprintf(out_hnd, "\t\tProfile Path: %s\n", tmp); /* profile path unicode string */
922 rpcstr_pull(tmp, usr->uni_logon_script.buffer, sizeof(tmp),usr->uni_logon_script.uni_str_len*2, 0);
923 fprintf(out_hnd, "\t\tLogon Script: %s\n", tmp); /* logon script unicode string */
924 rpcstr_pull(tmp, usr->uni_acct_desc.buffer, sizeof(tmp),usr->uni_acct_desc.uni_str_len*2, 0);
925 fprintf(out_hnd, "\t\tDescription : %s\n", tmp); /* user description unicode string */
926 rpcstr_pull(tmp, usr->uni_workstations.buffer, sizeof(tmp),usr->uni_workstations.uni_str_len*2, 0);
927 fprintf(out_hnd, "\t\tWorkstations: %s\n", tmp); /* workstaions unicode string */
928 rpcstr_pull(tmp, usr->uni_unknows_str.buffer, sizeof(tmp),usr->uni_unknown_str.uni_str_len*2, 0);
929 fprintf(out_hnd, "\t\tUnknown Str : %s\n", tmp); /* unknown string unicode string */
930 rpcstr_pull(tmp, usr->uni_munged_dial.buffer, sizeof(tmp),usr->uni_munged_dial.uni_str_len*2, 0);
931 fprintf(out_hnd, "\t\tRemote Dial : %s\n", tmp); /* munged remote access unicode string */
933 fprintf(out_hnd, "\t\tLogon Time : %s\n", http_timestring(nt_time_to_unix(&(usr->logon_time ))));
934 fprintf(out_hnd, "\t\tLogoff Time : %s\n", http_timestring(nt_time_to_unix(&(usr->logoff_time ))));
935 fprintf(out_hnd, "\t\tKickoff Time : %s\n", http_timestring(nt_time_to_unix(&(usr->kickoff_time ))));
936 fprintf(out_hnd, "\t\tPassword last set Time : %s\n", http_timestring(nt_time_to_unix(&(usr->pass_last_set_time ))));
937 fprintf(out_hnd, "\t\tPassword can change Time : %s\n", http_timestring(nt_time_to_unix(&(usr->pass_can_change_time ))));
938 fprintf(out_hnd, "\t\tPassword must change Time: %s\n", http_timestring(nt_time_to_unix(&(usr->pass_must_change_time))));
940 fprintf(out_hnd, "\t\tunknown_2[0..31]...\n"); /* user passwords? */
942 fprintf(out_hnd, "\t\tuser_rid : %x\n" , usr->user_rid ); /* User ID */
943 fprintf(out_hnd, "\t\tgroup_rid: %x\n" , usr->group_rid); /* Group ID */
944 fprintf(out_hnd, "\t\tacb_info : %04x\n", usr->acb_info ); /* Account Control Info */
946 fprintf(out_hnd, "\t\tunknown_3: %08x\n", usr->unknown_3); /* 0x00ff ffff */
947 fprintf(out_hnd, "\t\tlogon_divs: %d\n", usr->logon_divs); /* 0x0000 00a8 which is 168 which is num hrs in a week */
948 fprintf(out_hnd, "\t\tunknown_5: %08x\n", usr->unknown_5); /* 0x0002 0000 */
950 fprintf(out_hnd, "\t\tpadding1[0..7]...\n");
952 if (usr->ptr_logon_hrs)
954 fprintf(out_hnd, "\t\tlogon_hrs[0..%d]...\n", usr->logon_hrs.len);
961 fprintf(out_hnd, "\n");
968 /****************************************************************************
969 convert a security permissions into a string
970 ****************************************************************************/
971 char *get_sec_mask_str(uint32 type)
973 static fstring typestr;
978 case SEC_RIGHTS_FULL_CONTROL:
980 fstrcpy(typestr, "Full Control");
984 case SEC_RIGHTS_READ:
986 fstrcpy(typestr, "Read");
996 for (i = 0; i < 32; i++)
1000 switch (((unsigned)1) << i)
1002 case SEC_RIGHTS_QUERY_VALUE : fstrcat(typestr, "Query " ); break;
1003 case SEC_RIGHTS_SET_VALUE : fstrcat(typestr, "Set " ); break;
1004 case SEC_RIGHTS_CREATE_SUBKEY : fstrcat(typestr, "Create "); break;
1005 case SEC_RIGHTS_ENUM_SUBKEYS : fstrcat(typestr, "Enum "); break;
1006 case SEC_RIGHTS_NOTIFY : fstrcat(typestr, "Notify "); break;
1007 case SEC_RIGHTS_CREATE_LINK : fstrcat(typestr, "CreateLink "); break;
1008 case SEC_RIGHTS_DELETE : fstrcat(typestr, "Delete "); break;
1009 case SEC_RIGHTS_READ_CONTROL : fstrcat(typestr, "ReadControl "); break;
1010 case SEC_RIGHTS_WRITE_DAC : fstrcat(typestr, "WriteDAC "); break;
1011 case SEC_RIGHTS_WRITE_OWNER : fstrcat(typestr, "WriteOwner "); break;
1017 /* remaining bits get added on as-is */
1021 slprintf(tmp, sizeof(tmp)-1, "[%08x]", type);
1022 fstrcat(typestr, tmp);
1025 /* remove last space */
1026 i = strlen(typestr)-1;
1027 if (typestr[i] == ' ') typestr[i] = 0;
1032 /****************************************************************************
1033 display sec_access structure
1034 ****************************************************************************/
1035 void display_sec_access(FILE *out_hnd, enum action_type action, SEC_ACCESS *info)
1043 case ACTION_ENUMERATE:
1045 fprintf(out_hnd, "\t\tPermissions: %s\n",
1046 get_sec_mask_str(info->mask));
1055 /****************************************************************************
1056 display sec_ace structure
1057 ****************************************************************************/
1058 void display_sec_ace(FILE *out_hnd, enum action_type action, SEC_ACE *ace)
1064 fprintf(out_hnd, "\tACE\n");
1067 case ACTION_ENUMERATE:
1071 display_sec_access(out_hnd, ACTION_HEADER , &ace->info);
1072 display_sec_access(out_hnd, ACTION_ENUMERATE, &ace->info);
1073 display_sec_access(out_hnd, ACTION_FOOTER , &ace->info);
1075 sid_to_string(sid_str, &ace->sid);
1076 fprintf(out_hnd, "\t\tSID: %s\n", sid_str);
1085 /****************************************************************************
1086 display sec_acl structure
1087 ****************************************************************************/
1088 void display_sec_acl(FILE *out_hnd, enum action_type action, SEC_ACL *sec_acl)
1094 fprintf(out_hnd, "\tACL\tNum ACEs:\t%d\trevision:\t%x\n",
1095 sec_acl->num_aces, sec_acl->revision);
1096 fprintf(out_hnd, "\t---\n");
1100 case ACTION_ENUMERATE:
1102 if (sec_acl->size != 0 && sec_acl->num_aces != 0)
1105 for (i = 0; i < sec_acl->num_aces; i++)
1107 display_sec_ace(out_hnd, ACTION_HEADER , &sec_acl->ace[i]);
1108 display_sec_ace(out_hnd, ACTION_ENUMERATE, &sec_acl->ace[i]);
1109 display_sec_ace(out_hnd, ACTION_FOOTER , &sec_acl->ace[i]);
1117 fprintf(out_hnd, "\n");
1123 /****************************************************************************
1124 display sec_desc structure
1125 ****************************************************************************/
1126 void display_sec_desc(FILE *out_hnd, enum action_type action, SEC_DESC *sec)
1132 fprintf(out_hnd, "\tSecurity Descriptor\trevision:\t%x\ttype:\t%x\n",
1133 sec->revision, sec->type);
1134 fprintf(out_hnd, "\t-------------------\n");
1138 case ACTION_ENUMERATE:
1142 if (sec->off_sacl != 0)
1144 display_sec_acl(out_hnd, ACTION_HEADER , sec->sacl);
1145 display_sec_acl(out_hnd, ACTION_ENUMERATE, sec->sacl);
1146 display_sec_acl(out_hnd, ACTION_FOOTER , sec->sacl);
1148 if (sec->off_dacl != 0)
1150 display_sec_acl(out_hnd, ACTION_HEADER , sec->dacl);
1151 display_sec_acl(out_hnd, ACTION_ENUMERATE, sec->dacl);
1152 display_sec_acl(out_hnd, ACTION_FOOTER , sec->dacl);
1154 if (sec->off_owner_sid != 0)
1156 sid_to_string(sid_str, sec->owner_sid);
1157 fprintf(out_hnd, "\tOwner SID:\t%s\n", sid_str);
1159 if (sec->off_grp_sid != 0)
1161 sid_to_string(sid_str, sec->grp_sid);
1162 fprintf(out_hnd, "\tParent SID:\t%s\n", sid_str);
1169 fprintf(out_hnd, "\n");
1175 /****************************************************************************
1176 convert a security permissions into a string
1177 ****************************************************************************/
1178 char *get_reg_val_type_str(uint32 type)
1180 static fstring typestr;
1186 fstrcpy(typestr, "string");
1192 fstrcpy(typestr, "bytes");
1198 fstrcpy(typestr, "uint32");
1204 fstrcpy(typestr, "multi");
1212 slprintf(typestr, sizeof(typestr)-1, "[%d]", type);
1217 static void print_reg_value(FILE *out_hnd, char *val_name, uint32 val_type, BUFFER2 *value)
1221 fstrcpy(type, get_reg_val_type_str(val_type));
1225 case 0x01: /* unistr */
1227 rpcstr_pull(intvalue, value->buffer, sizeof(intvalue), value->buf_len, 0);
1228 /*fprintf(out_hnd,"\t%s:\t%s:\t%s\n", val_name, type, dos_buffer2_to_str(value));*/
1229 fprintf(out_hnd,"\t%s:\t%s:\t%s\n", val_name, type, value);
1233 default: /* unknown */
1234 case 0x03: /* bytes */
1236 if (value->buf_len <= 8)
1238 fprintf(out_hnd,"\t%s:\t%s:\t", val_name, type);
1239 out_data(out_hnd, (char*)value->buffer, value->buf_len, 8);
1243 fprintf(out_hnd,"\t%s:\t%s:\n", val_name, type);
1244 out_data(out_hnd, (char*)value->buffer, value->buf_len, 16);
1249 case 0x04: /* uint32 */
1251 fprintf(out_hnd,"\t%s:\t%s: 0x%08x\n", val_name, type, buffer2_to_uint32(value));
1255 case 0x07: /* multiunistr */
1257 fprintf(out_hnd,"\t%s:\t%s:\t%s\n", val_name, type, dos_buffer2_to_multistr(value));
1263 /****************************************************************************
1265 ****************************************************************************/
1266 void display_reg_value_info(FILE *out_hnd, enum action_type action,
1267 char *val_name, uint32 val_type, BUFFER2 *value)
1275 case ACTION_ENUMERATE:
1277 print_reg_value(out_hnd, val_name, val_type, value);
1287 /****************************************************************************
1289 ****************************************************************************/
1290 void display_reg_key_info(FILE *out_hnd, enum action_type action,
1291 char *key_name, time_t key_mod_time)
1299 case ACTION_ENUMERATE:
1301 fprintf(out_hnd, "\t%s\t(%s)\n",
1302 key_name, http_timestring(key_mod_time));
1312 #if COPY_THIS_TEMPLATE
1313 /****************************************************************************
1315 ****************************************************************************/
1316 void display_(FILE *out_hnd, enum action_type action, *)
1322 fprintf(out_hnd, "\t\n");
1323 fprintf(out_hnd, "\t-------------------\n");
1327 case ACTION_ENUMERATE:
1333 fprintf(out_hnd, "\n");