+++ /dev/null
-/*
- Unix SMB/Netbios implementation.
- Version 1.9.
- NT Domain Authentication SMB / MSRPC client
- Copyright (C) Andrew Tridgell 1994-1997
- Copyright (C) Luke Kenneth Casson Leighton 1996-1997
-
- 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.
-*/
-
-
-
-#ifdef SYSLOG
-#undef SYSLOG
-#endif
-
-#include "includes.h"
-
-extern int DEBUGLEVEL;
-
-extern struct cli_state *smb_cli;
-extern int smb_tidx;
-
-extern FILE* out_hnd;
-
-/*
- * keys. of the form:
- * ----
- *
- * [HKLM]|[HKU]\[parent_keyname_components]\[subkey]|[value]
- *
- * reg_getsubkey() splits this down into:
- * [HKLM]|[HKU]\[parent_keyname_components] and [subkey]|[value]
- *
- * do_reg_connect() splits the left side down further into:
- * [HKLM]|[HKU] and [parent_keyname_components].
- *
- * HKLM is short for HKEY_LOCAL_MACHINE
- * HKU is short for HKEY_USERS
- *
- * oh, and HKEY stands for "Hive Key".
- *
- */
-
-/****************************************************************************
-nt registry enum
-****************************************************************************/
-void cmd_reg_enum(struct client_info *info)
-{
- BOOL res = True;
- BOOL res1 = True;
- BOOL res2 = True;
- int i;
-
- POLICY_HND key_pol;
- fstring full_keyname;
- fstring key_name;
-
- /*
- * query key info
- */
-
- fstring key_class;
- uint32 max_class_len = 0;
- uint32 num_subkeys;
- uint32 max_subkeylen;
- uint32 max_subkeysize;
- uint32 num_values;
- uint32 max_valnamelen;
- uint32 max_valbufsize;
- uint32 sec_desc;
- NTTIME mod_time;
-
- /*
- * unknown 0x1a request
- */
-
- uint32 unk_1a_response;
-
- DEBUG(5, ("cmd_reg_enum: smb_cli->fd:%d\n", smb_cli->fd));
-
- if (!next_token(NULL, full_keyname, NULL, sizeof(full_keyname)))
- {
- fprintf(out_hnd, "regenum <key_name>\n");
- return;
- }
-
- /* open WINREG session. */
- res = res ? cli_nt_session_open(smb_cli, PIPE_WINREG) : False;
-
- /* open registry receive a policy handle */
- res = res ? do_reg_connect(smb_cli, full_keyname, key_name,
- &info->dom.reg_pol_connect) : False;
-
- if ((*key_name) != 0)
- {
- /* open an entry */
- res1 = res ? do_reg_open_entry(smb_cli, &info->dom.reg_pol_connect,
- key_name, 0x02000000, &key_pol) : False;
- }
- else
- {
- memcpy(&key_pol, &info->dom.reg_pol_connect, sizeof(key_pol));
- }
-
- res1 = res1 ? do_reg_query_key(smb_cli,
- &key_pol,
- key_class, &max_class_len,
- &num_subkeys, &max_subkeylen, &max_subkeysize,
- &num_values, &max_valnamelen, &max_valbufsize,
- &sec_desc, &mod_time) : False;
-
- if (res1 && num_subkeys > 0)
- {
- fprintf(out_hnd,"Subkeys\n");
- fprintf(out_hnd,"-------\n");
- }
-
- for (i = 0; i < num_subkeys; i++)
- {
- /*
- * enumerate key
- */
-
- fstring enum_name;
- uint32 enum_unk1;
- uint32 enum_unk2;
- time_t key_mod_time;
-
- /* unknown 1a it */
- res2 = res1 ? do_reg_unknown_1a(smb_cli, &key_pol,
- &unk_1a_response) : False;
-
- if (res2 && unk_1a_response != 5)
- {
- fprintf(out_hnd,"Unknown 1a response: %x\n", unk_1a_response);
- }
-
- /* enum key */
- res2 = res2 ? do_reg_enum_key(smb_cli, &key_pol,
- i, enum_name,
- &enum_unk1, &enum_unk2,
- &key_mod_time) : False;
-
- if (res2)
- {
- display_reg_key_info(out_hnd, ACTION_HEADER , enum_name, key_mod_time);
- display_reg_key_info(out_hnd, ACTION_ENUMERATE, enum_name, key_mod_time);
- display_reg_key_info(out_hnd, ACTION_FOOTER , enum_name, key_mod_time);
- }
-
- }
-
- if (num_values > 0)
- {
- fprintf(out_hnd,"Key Values\n");
- fprintf(out_hnd,"----------\n");
- }
-
- for (i = 0; i < num_values; i++)
- {
- /*
- * enumerate key
- */
-
- uint32 val_type;
- BUFFER2 value;
- fstring val_name;
-
- /* unknown 1a it */
- res2 = res1 ? do_reg_unknown_1a(smb_cli, &key_pol,
- &unk_1a_response) : False;
-
- if (res2 && unk_1a_response != 5)
- {
- fprintf(out_hnd,"Unknown 1a response: %x\n", unk_1a_response);
- }
-
- /* enum key */
- res2 = res2 ? do_reg_enum_val(smb_cli, &key_pol,
- i, max_valnamelen, max_valbufsize,
- val_name, &val_type, &value) : False;
-
- if (res2)
- {
- display_reg_value_info(out_hnd, ACTION_HEADER , val_name, val_type, &value);
- display_reg_value_info(out_hnd, ACTION_ENUMERATE, val_name, val_type, &value);
- display_reg_value_info(out_hnd, ACTION_FOOTER , val_name, val_type, &value);
- }
- }
-
- /* close the handles */
- if ((*key_name) != 0)
- {
- res1 = res1 ? do_reg_close(smb_cli, &key_pol) : False;
- }
- res = res ? do_reg_close(smb_cli, &info->dom.reg_pol_connect) : False;
-
- /* close the session */
- cli_nt_session_close(smb_cli);
-
- if (res && res1 && res2)
- {
- DEBUG(5,("cmd_reg_enum: query succeeded\n"));
- }
- else
- {
- DEBUG(5,("cmd_reg_enum: query failed\n"));
- }
-}
-
-/****************************************************************************
-nt registry query key
-****************************************************************************/
-void cmd_reg_query_key(struct client_info *info)
-{
- BOOL res = True;
- BOOL res1 = True;
-
- POLICY_HND key_pol;
- fstring full_keyname;
- fstring key_name;
-
- /*
- * query key info
- */
-
- fstring key_class;
- uint32 key_class_len = 0;
- uint32 num_subkeys;
- uint32 max_subkeylen;
- uint32 max_subkeysize;
- uint32 num_values;
- uint32 max_valnamelen;
- uint32 max_valbufsize;
- uint32 sec_desc;
- NTTIME mod_time;
-
- DEBUG(5, ("cmd_reg_enum: smb_cli->fd:%d\n", smb_cli->fd));
-
- if (!next_token(NULL, full_keyname, NULL, sizeof(full_keyname)))
- {
- fprintf(out_hnd, "regquery key_name\n");
- return;
- }
-
- /* open WINREG session. */
- res = res ? cli_nt_session_open(smb_cli, PIPE_WINREG) : False;
-
- /* open registry receive a policy handle */
- res = res ? do_reg_connect(smb_cli, full_keyname, key_name,
- &info->dom.reg_pol_connect) : False;
-
- if ((*key_name) != 0)
- {
- /* open an entry */
- res1 = res ? do_reg_open_entry(smb_cli, &info->dom.reg_pol_connect,
- key_name, 0x02000000, &key_pol) : False;
- }
- else
- {
- memcpy(&key_pol, &info->dom.reg_pol_connect, sizeof(key_pol));
- }
-
- res1 = res1 ? do_reg_query_key(smb_cli,
- &key_pol,
- key_class, &key_class_len,
- &num_subkeys, &max_subkeylen, &max_subkeysize,
- &num_values, &max_valnamelen, &max_valbufsize,
- &sec_desc, &mod_time) : False;
-
- if (res1 && key_class_len != 0)
- {
- res1 = res1 ? do_reg_query_key(smb_cli,
- &key_pol,
- key_class, &key_class_len,
- &num_subkeys, &max_subkeylen, &max_subkeysize,
- &num_values, &max_valnamelen, &max_valbufsize,
- &sec_desc, &mod_time) : False;
- }
-
- if (res1)
- {
- fprintf(out_hnd,"Registry Query Info Key\n");
- fprintf(out_hnd,"key class: %s\n", key_class);
- fprintf(out_hnd,"subkeys, max_len, max_size: %d %d %d\n", num_subkeys, max_subkeylen, max_subkeysize);
- fprintf(out_hnd,"vals, max_len, max_size: 0x%x 0x%x 0x%x\n", num_values, max_valnamelen, max_valbufsize);
- fprintf(out_hnd,"sec desc: 0x%x\n", sec_desc);
- fprintf(out_hnd,"mod time: %s\n", http_timestring(nt_time_to_unix(&mod_time)));
- }
-
- /* close the handles */
- if ((*key_name) != 0)
- {
- res1 = res1 ? do_reg_close(smb_cli, &key_pol) : False;
- }
- res = res ? do_reg_close(smb_cli, &info->dom.reg_pol_connect) : False;
-
- /* close the session */
- cli_nt_session_close(smb_cli);
-
- if (res && res1)
- {
- DEBUG(5,("cmd_reg_query: query succeeded\n"));
- }
- else
- {
- DEBUG(5,("cmd_reg_query: query failed\n"));
- }
-}
-
-/****************************************************************************
-nt registry create value
-****************************************************************************/
-void cmd_reg_create_val(struct client_info *info)
-{
- BOOL res = True;
- BOOL res3 = True;
- BOOL res4 = True;
-
- POLICY_HND parent_pol;
- fstring full_keyname;
- fstring keyname;
- fstring parent_name;
- fstring val_name;
- fstring tmp;
- uint32 val_type;
- BUFFER3 value;
-
-#if 0
- uint32 unk_0;
- uint32 unk_1;
- /* query it */
- res1 = res1 ? do_reg_query_info(smb_cli, &val_pol,
- val_name, *val_type) : False;
-#endif
-
- DEBUG(5, ("cmd_reg_create_val: smb_cli->fd:%d\n", smb_cli->fd));
-
- if (!next_token(NULL, full_keyname, NULL, sizeof(full_keyname)))
- {
- fprintf(out_hnd, "regcreate <val_name> <val_type> <val>\n");
- return;
- }
-
- reg_get_subkey(full_keyname, keyname, val_name);
-
- if (keyname[0] == 0 || val_name[0] == 0)
- {
- fprintf(out_hnd, "invalid key name\n");
- return;
- }
-
- if (!next_token(NULL, tmp, NULL, sizeof(tmp)))
- {
- fprintf(out_hnd, "regcreate <val_name> <val_type (1|4)> <val>\n");
- return;
- }
-
- val_type = atoi(tmp);
-
- if (val_type != 1 && val_type != 3 && val_type != 4)
- {
- fprintf(out_hnd, "val_type 1=UNISTR, 3=BYTES, 4=DWORD supported\n");
- return;
- }
-
- if (!next_token(NULL, tmp, NULL, sizeof(tmp)))
- {
- fprintf(out_hnd, "regcreate <val_name> <val_type (1|4)> <val>\n");
- return;
- }
-
- switch (val_type)
- {
- case 0x01: /* UNISTR */
- {
- init_buffer3_str(&value, tmp, strlen(tmp)+1);
- break;
- }
- case 0x03: /* BYTES */
- {
- init_buffer3_hex(&value, tmp);
- break;
- }
- case 0x04: /* DWORD */
- {
- uint32 tmp_val;
- if (strnequal(tmp, "0x", 2))
- {
- tmp_val = strtol(tmp, (char**)NULL, 16);
- }
- else
- {
- tmp_val = strtol(tmp, (char**)NULL, 10);
- }
- init_buffer3_uint32(&value, tmp_val);
- break;
- }
- default:
- {
- fprintf(out_hnd, "i told you i only deal with UNISTR, DWORD and BYTES!\n");
- return;
- }
- }
-
- DEBUG(10,("key data:\n"));
- dump_data(10, (char *)value.buffer, value.buf_len);
-
- /* open WINREG session. */
- res = res ? cli_nt_session_open(smb_cli, PIPE_WINREG) : False;
-
- /* open registry receive a policy handle */
- res = res ? do_reg_connect(smb_cli, keyname, parent_name,
- &info->dom.reg_pol_connect) : False;
-
- if ((*val_name) != 0)
- {
- /* open an entry */
- res3 = res ? do_reg_open_entry(smb_cli, &info->dom.reg_pol_connect,
- parent_name, 0x02000000, &parent_pol) : False;
- }
- else
- {
- memcpy(&parent_pol, &info->dom.reg_pol_connect, sizeof(parent_pol));
- }
-
- /* create an entry */
- res4 = res3 ? do_reg_create_val(smb_cli, &parent_pol,
- val_name, val_type, &value) : False;
-
- /* flush the modified key */
- res4 = res4 ? do_reg_flush_key(smb_cli, &parent_pol) : False;
-
- /* close the val handle */
- if ((*val_name) != 0)
- {
- res3 = res3 ? do_reg_close(smb_cli, &parent_pol) : False;
- }
-
- /* close the registry handles */
- res = res ? do_reg_close(smb_cli, &info->dom.reg_pol_connect) : False;
-
- /* close the session */
- cli_nt_session_close(smb_cli);
-
- if (res && res3 && res4)
- {
- DEBUG(5,("cmd_reg_create_val: query succeeded\n"));
- fprintf(out_hnd,"OK\n");
- }
- else
- {
- DEBUG(5,("cmd_reg_create_val: query failed\n"));
- }
-}
-
-/****************************************************************************
-nt registry delete value
-****************************************************************************/
-void cmd_reg_delete_val(struct client_info *info)
-{
- BOOL res = True;
- BOOL res3 = True;
- BOOL res4 = True;
-
- POLICY_HND parent_pol;
- fstring full_keyname;
- fstring keyname;
- fstring parent_name;
- fstring val_name;
-
- DEBUG(5, ("cmd_reg_delete_val: smb_cli->fd:%d\n", smb_cli->fd));
-
- if (!next_token(NULL, full_keyname, NULL, sizeof(full_keyname)))
- {
- fprintf(out_hnd, "regdelete <val_name>\n");
- return;
- }
-
- reg_get_subkey(full_keyname, keyname, val_name);
-
- if (keyname[0] == 0 || val_name[0] == 0)
- {
- fprintf(out_hnd, "invalid key name\n");
- return;
- }
-
- /* open WINREG session. */
- res = res ? cli_nt_session_open(smb_cli, PIPE_WINREG) : False;
-
- /* open registry receive a policy handle */
- res = res ? do_reg_connect(smb_cli, keyname, parent_name,
- &info->dom.reg_pol_connect) : False;
-
- if ((*val_name) != 0)
- {
- /* open an entry */
- res3 = res ? do_reg_open_entry(smb_cli, &info->dom.reg_pol_connect,
- parent_name, 0x02000000, &parent_pol) : False;
- }
- else
- {
- memcpy(&parent_pol, &info->dom.reg_pol_connect, sizeof(parent_pol));
- }
-
- /* delete an entry */
- res4 = res3 ? do_reg_delete_val(smb_cli, &parent_pol, val_name) : False;
-
- /* flush the modified key */
- res4 = res4 ? do_reg_flush_key(smb_cli, &parent_pol) : False;
-
- /* close the key handle */
- res3 = res3 ? do_reg_close(smb_cli, &parent_pol) : False;
-
- /* close the registry handles */
- res = res ? do_reg_close(smb_cli, &info->dom.reg_pol_connect) : False;
-
- /* close the session */
- cli_nt_session_close(smb_cli);
-
- if (res && res3 && res4)
- {
- DEBUG(5,("cmd_reg_delete_val: query succeeded\n"));
- fprintf(out_hnd,"OK\n");
- }
- else
- {
- DEBUG(5,("cmd_reg_delete_val: query failed\n"));
- }
-}
-
-/****************************************************************************
-nt registry delete key
-****************************************************************************/
-void cmd_reg_delete_key(struct client_info *info)
-{
- BOOL res = True;
- BOOL res3 = True;
- BOOL res4 = True;
-
- POLICY_HND parent_pol;
- fstring full_keyname;
- fstring parent_name;
- fstring key_name;
- fstring subkey_name;
-
- DEBUG(5, ("cmd_reg_delete_key: smb_cli->fd:%d\n", smb_cli->fd));
-
- if (!next_token(NULL, full_keyname, NULL, sizeof(full_keyname)))
- {
- fprintf(out_hnd, "regdeletekey <key_name>\n");
- return;
- }
-
- reg_get_subkey(full_keyname, parent_name, subkey_name);
-
- if (parent_name[0] == 0 || subkey_name[0] == 0)
- {
- fprintf(out_hnd, "invalid key name\n");
- return;
- }
-
- /* open WINREG session. */
- res = res ? cli_nt_session_open(smb_cli, PIPE_WINREG) : False;
-
- /* open registry receive a policy handle */
- res = res ? do_reg_connect(smb_cli, parent_name, key_name,
- &info->dom.reg_pol_connect) : False;
-
- if ((*key_name) != 0)
- {
- /* open an entry */
- res3 = res ? do_reg_open_entry(smb_cli, &info->dom.reg_pol_connect,
- key_name, 0x02000000, &parent_pol) : False;
- }
- else
- {
- memcpy(&parent_pol, &info->dom.reg_pol_connect, sizeof(parent_pol));
- }
-
- /* create an entry */
- res4 = res3 ? do_reg_delete_key(smb_cli, &parent_pol, subkey_name) : False;
-
- /* flush the modified key */
- res4 = res4 ? do_reg_flush_key(smb_cli, &parent_pol) : False;
-
- /* close the key handle */
- if ((*key_name) != 0)
- {
- res3 = res3 ? do_reg_close(smb_cli, &parent_pol) : False;
- }
-
- /* close the registry handles */
- res = res ? do_reg_close(smb_cli, &info->dom.reg_pol_connect) : False;
-
- /* close the session */
- cli_nt_session_close(smb_cli);
-
- if (res && res3 && res4)
- {
- DEBUG(5,("cmd_reg_delete_key: query succeeded\n"));
- fprintf(out_hnd,"OK\n");
- }
- else
- {
- DEBUG(5,("cmd_reg_delete_key: query failed\n"));
- }
-}
-
-/****************************************************************************
-nt registry create key
-****************************************************************************/
-void cmd_reg_create_key(struct client_info *info)
-{
- BOOL res = True;
- BOOL res3 = True;
- BOOL res4 = True;
-
- POLICY_HND parent_pol;
- POLICY_HND key_pol;
- fstring full_keyname;
- fstring parent_key;
- fstring parent_name;
- fstring key_name;
- fstring key_class;
- SEC_ACCESS sam_access;
-
- DEBUG(5, ("cmd_reg_create_key: smb_cli->fd:%d\n", smb_cli->fd));
-
- if (!next_token(NULL, full_keyname, NULL, sizeof(full_keyname)))
- {
- fprintf(out_hnd, "regcreate <key_name> [key_class]\n");
- return;
- }
-
- reg_get_subkey(full_keyname, parent_key, key_name);
-
- if (parent_key[0] == 0 || key_name[0] == 0)
- {
- fprintf(out_hnd, "invalid key name\n");
- return;
- }
-
- if (!next_token(NULL, key_class, NULL, sizeof(key_class)))
- {
- memset(key_class, 0, sizeof(key_class));
- }
-
- /* set access permissions */
- sam_access.mask = SEC_RIGHTS_READ;
-
- /* open WINREG session. */
- res = res ? cli_nt_session_open(smb_cli, PIPE_WINREG) : False;
-
- /* open registry receive a policy handle */
- res = res ? do_reg_connect(smb_cli, parent_key, parent_name,
- &info->dom.reg_pol_connect) : False;
-
- if ((*parent_name) != 0)
- {
- /* open an entry */
- res3 = res ? do_reg_open_entry(smb_cli, &info->dom.reg_pol_connect,
- parent_name, 0x02000000, &parent_pol) : False;
- }
- else
- {
- memcpy(&parent_pol, &info->dom.reg_pol_connect, sizeof(parent_pol));
- }
-
- /* create an entry */
- res4 = res3 ? do_reg_create_key(smb_cli, &parent_pol,
- key_name, key_class, &sam_access, &key_pol) : False;
-
- /* flush the modified key */
- res4 = res4 ? do_reg_flush_key(smb_cli, &parent_pol) : False;
-
- /* close the key handle */
- res4 = res4 ? do_reg_close(smb_cli, &key_pol) : False;
-
- /* close the key handle */
- if ((*parent_name) != 0)
- {
- res3 = res3 ? do_reg_close(smb_cli, &parent_pol) : False;
- }
-
- /* close the registry handles */
- res = res ? do_reg_close(smb_cli, &info->dom.reg_pol_connect) : False;
-
- /* close the session */
- cli_nt_session_close(smb_cli);
-
- if (res && res3 && res4)
- {
- DEBUG(5,("cmd_reg_create_key: query succeeded\n"));
- fprintf(out_hnd,"OK\n");
- }
- else
- {
- DEBUG(5,("cmd_reg_create_key: query failed\n"));
- }
-}
-
-/****************************************************************************
-nt registry security info
-****************************************************************************/
-void cmd_reg_test_key_sec(struct client_info *info)
-{
- BOOL res = True;
- BOOL res3 = True;
- BOOL res4 = True;
-
- POLICY_HND key_pol;
- fstring full_keyname;
- fstring key_name;
-
- /*
- * security info
- */
-
- uint32 sec_buf_size;
- SEC_DESC_BUF *psdb;
-
- DEBUG(5, ("cmd_reg_get_key_sec: smb_cli->fd:%d\n", smb_cli->fd));
-
- if (!next_token(NULL, full_keyname, NULL, sizeof(full_keyname)))
- {
- fprintf(out_hnd, "reggetsec <key_name>\n");
- return;
- }
-
- /* open WINREG session. */
- res = res ? cli_nt_session_open(smb_cli, PIPE_WINREG) : False;
-
- /* open registry receive a policy handle */
- res = res ? do_reg_connect(smb_cli, full_keyname, key_name,
- &info->dom.reg_pol_connect) : False;
-
- if ((*key_name) != 0)
- {
- /* open an entry */
- res3 = res ? do_reg_open_entry(smb_cli, &info->dom.reg_pol_connect,
- key_name, 0x02000000, &key_pol) : False;
- }
- else
- {
- memcpy(&key_pol, &info->dom.reg_pol_connect, sizeof(key_pol));
- }
-
- /* open an entry */
- res3 = res ? do_reg_open_entry(smb_cli, &info->dom.reg_pol_connect,
- key_name, 0x02000000, &key_pol) : False;
-
- /* query key sec info. first call sets sec_buf_size. */
-
- sec_buf_size = 0;
- res4 = res3 ? do_reg_get_key_sec(smb_cli, &key_pol,
- &sec_buf_size, &psdb) : False;
-
- free_sec_desc_buf(&psdb);
-
- res4 = res4 ? do_reg_get_key_sec(smb_cli, &key_pol,
- &sec_buf_size, &psdb) : False;
-
- if (res4 && psdb->len > 0 && psdb->sec != NULL)
- {
- display_sec_desc(out_hnd, ACTION_HEADER , psdb->sec);
- display_sec_desc(out_hnd, ACTION_ENUMERATE, psdb->sec);
- display_sec_desc(out_hnd, ACTION_FOOTER , psdb->sec);
-
- res4 = res4 ? do_reg_set_key_sec(smb_cli, &key_pol, psdb) : False;
- }
-
- free_sec_desc_buf(&psdb);
-
- /* close the key handle */
- if ((*key_name) != 0)
- {
- res3 = res3 ? do_reg_close(smb_cli, &key_pol) : False;
- }
-
- /* close the registry handles */
- res = res ? do_reg_close(smb_cli, &info->dom.reg_pol_connect) : False;
-
- /* close the session */
- cli_nt_session_close(smb_cli);
-
- if (res && res3 && res4)
- {
- DEBUG(5,("cmd_reg_test2: query succeeded\n"));
- fprintf(out_hnd,"Registry Test2\n");
- }
- else
- {
- DEBUG(5,("cmd_reg_test2: query failed\n"));
- }
-}
-
-/****************************************************************************
-nt registry security info
-****************************************************************************/
-void cmd_reg_get_key_sec(struct client_info *info)
-{
- BOOL res = True;
- BOOL res3 = True;
- BOOL res4 = True;
-
- POLICY_HND key_pol;
- fstring full_keyname;
- fstring key_name;
-
- /*
- * security info
- */
-
- uint32 sec_buf_size;
- SEC_DESC_BUF *psdb;
-
- DEBUG(5, ("cmd_reg_get_key_sec: smb_cli->fd:%d\n", smb_cli->fd));
-
- if (!next_token(NULL, full_keyname, NULL, sizeof(full_keyname)))
- {
- fprintf(out_hnd, "reggetsec <key_name>\n");
- return;
- }
-
- /* open WINREG session. */
- res = res ? cli_nt_session_open(smb_cli, PIPE_WINREG) : False;
-
- /* open registry receive a policy handle */
- res = res ? do_reg_connect(smb_cli, full_keyname, key_name,
- &info->dom.reg_pol_connect) : False;
-
- if ((*key_name) != 0)
- {
- /* open an entry */
- res3 = res ? do_reg_open_entry(smb_cli, &info->dom.reg_pol_connect,
- key_name, 0x02000000, &key_pol) : False;
- }
- else
- {
- memcpy(&key_pol, &info->dom.reg_pol_connect, sizeof(key_pol));
- }
-
- /* open an entry */
- res3 = res ? do_reg_open_entry(smb_cli, &info->dom.reg_pol_connect,
- key_name, 0x02000000, &key_pol) : False;
-
- /* Get the size. */
- sec_buf_size = 0;
- res4 = res3 ? do_reg_get_key_sec(smb_cli, &key_pol,
- &sec_buf_size, &psdb) : False;
-
- free_sec_desc_buf(&psdb);
-
- res4 = res4 ? do_reg_get_key_sec(smb_cli, &key_pol,
- &sec_buf_size, &psdb) : False;
-
- if (res4 && psdb->len > 0 && psdb->sec != NULL)
- {
- display_sec_desc(out_hnd, ACTION_HEADER , psdb->sec);
- display_sec_desc(out_hnd, ACTION_ENUMERATE, psdb->sec);
- display_sec_desc(out_hnd, ACTION_FOOTER , psdb->sec);
- }
-
- free_sec_desc_buf(&psdb);
-
- /* close the key handle */
- if ((*key_name) != 0)
- {
- res3 = res3 ? do_reg_close(smb_cli, &key_pol) : False;
- }
-
- /* close the registry handles */
- res = res ? do_reg_close(smb_cli, &info->dom.reg_pol_connect) : False;
-
- /* close the session */
- cli_nt_session_close(smb_cli);
-
- if (res && res3 && res4)
- {
- DEBUG(5,("cmd_reg_get_key_sec: query succeeded\n"));
- }
- else
- {
- DEBUG(5,("cmd_reg_get_key_sec: query failed\n"));
- }
-}
+++ /dev/null
-/*
- Unix SMB/Netbios implementation.
- Version 1.9.
- Samba utility functions
- Copyright (C) Andrew Tridgell 1992-1998
- Copyright (C) Luke Kenneth Casson Leighton 1996 - 1998
-
- 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 share mode to a string
-****************************************************************************/
-char *get_file_mode_str(uint32 share_mode)
-{
- static fstring mode;
-
- switch (GET_DENY_MODE(share_mode))
- {
- 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;
- case DENY_FCB: fstrcpy(mode, "DENY_FCB "); 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 = ((op_type & EXCLUSIVE_OPLOCK) != 0);
- BOOL batch = ((op_type & BATCH_OPLOCK ) != 0);
-
- 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 (type & (1 << i))
- {
- switch (((unsigned)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 *sv101)
-{
- if (sv101 == NULL)
- {
- return;
- }
-
- switch (action)
- {
- case ACTION_HEADER:
- {
- fprintf(out_hnd, "Server Info Level 101:\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- fstring name;
- fstring comment;
-
- fstrcpy(name , dos_unistrn2(sv101->uni_name .buffer, sv101->uni_name .uni_str_len));
- fstrcpy(comment , dos_unistrn2(sv101->uni_comment .buffer, sv101->uni_comment .uni_str_len));
-
- display_server(out_hnd, action, name, sv101->srv_type, comment);
-
- fprintf(out_hnd, "\tplatform_id : %d\n" , sv101->platform_id);
- fprintf(out_hnd, "\tos version : %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 *sv102)
-{
- if (sv102 == NULL)
- {
- return;
- }
-
- switch (action)
- {
- case ACTION_HEADER:
- {
- fprintf(out_hnd, "Server Info Level 102:\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- fstring name;
- fstring comment;
- fstring usr_path;
-
- fstrcpy(name , dos_unistrn2(sv102->uni_name .buffer, sv102->uni_name .uni_str_len));
- fstrcpy(comment , dos_unistrn2(sv102->uni_comment .buffer, sv102->uni_comment .uni_str_len));
- fstrcpy(usr_path, dos_unistrn2(sv102->uni_usr_path.buffer, sv102->uni_usr_path.uni_str_len));
-
- display_server(out_hnd, action, name, sv102->srv_type, comment);
-
- fprintf(out_hnd, "\tplatform_id : %d\n" , sv102->platform_id);
- fprintf(out_hnd, "\tos version : %d.%d\n" , sv102->ver_major, sv102->ver_minor);
-
- fprintf(out_hnd, "\tusers : %x\n" , sv102->users );
- fprintf(out_hnd, "\tdisc, hidden : %x,%x\n" , sv102->disc , sv102->hidden );
- fprintf(out_hnd, "\tannounce, delta : %d, %d\n", sv102->announce , sv102->ann_delta);
- fprintf(out_hnd, "\tlicenses : %d\n" , sv102->licenses );
- fprintf(out_hnd, "\tuser path : %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 *ctr)
-{
- if (ctr == NULL || ctr->ptr_srv_ctr == 0)
- {
- fprintf(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:
- {
- fprintf(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 *info0)
-{
- if (info0 == NULL)
- {
- return;
- }
-
- switch (action)
- {
- case ACTION_HEADER:
- {
- fprintf(out_hnd, "Connection Info Level 0:\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- fprintf(out_hnd, "\tid: %d\n", info0->id);
-
- break;
- }
- case ACTION_FOOTER:
- {
- fprintf(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 *info1, CONN_INFO_1_STR *str1)
-{
- if (info1 == NULL || str1 == NULL)
- {
- return;
- }
-
- switch (action)
- {
- case ACTION_HEADER:
- {
- fprintf(out_hnd, "Connection Info Level 1:\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- fstring usr_name;
- fstring net_name;
-
- fstrcpy(usr_name, dos_unistrn2(str1->uni_usr_name.buffer, str1->uni_usr_name.uni_str_len));
- fstrcpy(net_name, dos_unistrn2(str1->uni_net_name.buffer, str1->uni_net_name.uni_str_len));
-
- fprintf(out_hnd, "\tid : %d\n", info1->id);
- fprintf(out_hnd, "\ttype : %s\n", get_share_type_str(info1->type));
- fprintf(out_hnd, "\tnum_opens: %d\n", info1->num_opens);
- fprintf(out_hnd, "\tnum_users: %d\n", info1->num_users);
- fprintf(out_hnd, "\topen_time: %d\n", info1->open_time);
-
- fprintf(out_hnd, "\tuser name: %s\n", usr_name);
- fprintf(out_hnd, "\tnet name: %s\n", net_name);
-
- break;
- }
- case ACTION_FOOTER:
- {
- fprintf(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 *ctr)
-{
- if (ctr == NULL)
- {
- fprintf(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 *ctr)
-{
- if (ctr == NULL)
- {
- fprintf(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 *ctr)
-{
- if (ctr == NULL || ctr->ptr_conn_ctr == 0)
- {
- fprintf(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:
- {
- fprintf(out_hnd, "display_srv_conn_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,
- SRV_SHARE_INFO_1 *info1)
-{
- if (info1 == NULL)
- {
- return;
- }
-
- switch (action)
- {
- case ACTION_HEADER:
- {
- fprintf(out_hnd, "Share Info Level 1:\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- fstring remark ;
- fstring net_name;
-
- fstrcpy(net_name, dos_unistrn2(info1->info_1_str.uni_netname.buffer, info1->info_1_str.uni_netname.uni_str_len));
- fstrcpy(remark , dos_unistrn2(info1->info_1_str.uni_remark .buffer, info1->info_1_str.uni_remark .uni_str_len));
-
- display_share(out_hnd, action, net_name, info1->info_1.type, remark);
-
- break;
- }
- case ACTION_FOOTER:
- {
- fprintf(out_hnd, "\n");
- break;
- }
- }
-
-}
-
-/****************************************************************************
-share info level 2 display function
-****************************************************************************/
-void display_share_info_2(FILE *out_hnd, enum action_type action,
- SRV_SHARE_INFO_2 *info2)
-{
- if (info2 == NULL)
- {
- return;
- }
-
- switch (action)
- {
- case ACTION_HEADER:
- {
- fprintf(out_hnd, "Share Info Level 2:\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- fstring remark ;
- fstring net_name;
- fstring path ;
- fstring passwd ;
-
- fstrcpy(net_name, dos_unistrn2(info2->info_2_str.uni_netname.buffer, info2->info_2_str.uni_netname.uni_str_len));
- fstrcpy(remark , dos_unistrn2(info2->info_2_str.uni_remark .buffer, info2->info_2_str.uni_remark .uni_str_len));
- fstrcpy(path , dos_unistrn2(info2->info_2_str.uni_path .buffer, info2->info_2_str.uni_path .uni_str_len));
- fstrcpy(passwd , dos_unistrn2(info2->info_2_str.uni_passwd .buffer, info2->info_2_str.uni_passwd .uni_str_len));
-
- display_share2(out_hnd, action, net_name,
- info2->info_2.type, remark, info2->info_2.perms,
- info2->info_2.max_uses, info2->info_2.num_uses,
- path, passwd);
-
- break;
- }
- case ACTION_FOOTER:
- {
- fprintf(out_hnd, "\n");
- break;
- }
- }
-
-}
-
-/****************************************************************************
-share info container display function
-****************************************************************************/
-void display_srv_share_info_ctr(FILE *out_hnd, enum action_type action,
- SRV_SHARE_INFO_CTR *ctr)
-{
- if (ctr == NULL)
- {
- fprintf(out_hnd, "display_srv_share_info_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; i++)
- {
- switch (ctr->info_level) {
- case 1:
- display_share_info_1(out_hnd, ACTION_HEADER , &(ctr->share.info1[i]));
- display_share_info_1(out_hnd, ACTION_ENUMERATE, &(ctr->share.info1[i]));
- display_share_info_1(out_hnd, ACTION_FOOTER , &(ctr->share.info1[i]));
- break;
- case 2:
- display_share_info_2(out_hnd, ACTION_HEADER , &(ctr->share.info2[i]));
- display_share_info_2(out_hnd, ACTION_ENUMERATE, &(ctr->share.info2[i]));
- display_share_info_2(out_hnd, ACTION_FOOTER , &(ctr->share.info2[i]));
- break;
- default:
- fprintf(out_hnd, "display_srv_share_info_ctr: Unknown Info Level\n");
- break;
- }
- }
- break;
- }
- case ACTION_FOOTER:
- {
- break;
- }
- }
-}
-
-/****************************************************************************
-file info level 3 display function
-****************************************************************************/
-void display_file_info_3(FILE *out_hnd, enum action_type action,
- FILE_INFO_3 *info3, FILE_INFO_3_STR *str3)
-{
- if (info3 == NULL || str3 == NULL)
- {
- return;
- }
-
- switch (action)
- {
- case ACTION_HEADER:
- {
- fprintf(out_hnd, "File Info Level 3:\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- fstring path_name;
- fstring user_name;
-
- fstrcpy(path_name, dos_unistrn2(str3->uni_path_name.buffer, str3->uni_path_name.uni_str_len));
- fstrcpy(user_name, dos_unistrn2(str3->uni_user_name.buffer, str3->uni_user_name.uni_str_len));
-
- fprintf(out_hnd, "\tid : %d\n", info3->id);
- fprintf(out_hnd, "\tperms : %s\n", get_file_mode_str(info3->perms));
- fprintf(out_hnd, "\tnum_locks: %d\n", info3->num_locks);
-
- fprintf(out_hnd, "\tpath name: %s\n", path_name);
- fprintf(out_hnd, "\tuser name: %s\n", user_name);
-
- break;
- }
- case ACTION_FOOTER:
- {
- fprintf(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 *ctr)
-{
- if (ctr == NULL)
- {
- fprintf(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 *ctr)
-{
- if (ctr == NULL || ctr->ptr_file_ctr == 0)
- {
- fprintf(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:
- {
- fprintf(out_hnd, "display_srv_file_info_ctr: Unknown Info Level\n");
- break;
- }
- }
-}
-
-/****************************************************************************
- print browse connection on a host
- ****************************************************************************/
-void display_server(FILE *out_hnd, enum action_type action,
- char *sname, uint32 type, char *comment)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- break;
- }
- case ACTION_ENUMERATE:
- {
- fprintf(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 *sname, uint32 type, char *comment)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- break;
- }
- case ACTION_ENUMERATE:
- {
- fprintf(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 *sname, uint32 type, char *comment,
- uint32 perms, uint32 max_uses, uint32 num_uses,
- char *path, char *passwd)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- break;
- }
- case ACTION_ENUMERATE:
- {
- fprintf(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 *sname)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- break;
- }
- case ACTION_ENUMERATE:
- {
- fprintf(out_hnd, "\t%-21.21s\n", sname);
- break;
- }
- case ACTION_FOOTER:
- {
- break;
- }
- }
-}
-
-
-/****************************************************************************
- display group rid info
- ****************************************************************************/
-void display_group_rid_info(FILE *out_hnd, enum action_type action,
- uint32 num_gids, DOM_GID *gid)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- if (num_gids == 0)
- {
- fprintf(out_hnd, "\tNo Groups\n");
- }
- else
- {
- fprintf(out_hnd, "\tGroup Info\n");
- fprintf(out_hnd, "\t----------\n");
- }
- break;
- }
- case ACTION_ENUMERATE:
- {
- int i;
-
- for (i = 0; i < num_gids; i++)
- {
- fprintf(out_hnd, "\tGroup RID: %8x attr: %x\n",
- gid[i].g_rid, gid[i].attr);
- }
-
- break;
- }
- case ACTION_FOOTER:
- {
- fprintf(out_hnd, "\n");
- break;
- }
- }
-}
-
-
-/****************************************************************************
- display alias name info
- ****************************************************************************/
-void display_alias_name_info(FILE *out_hnd, enum action_type action,
- uint32 num_aliases, fstring *alias_name, uint32 *num_als_usrs)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- if (num_aliases == 0)
- {
- fprintf(out_hnd, "\tNo Aliases\n");
- }
- else
- {
- fprintf(out_hnd, "\tAlias Names\n");
- fprintf(out_hnd, "\t----------- \n");
- }
- break;
- }
- case ACTION_ENUMERATE:
- {
- int i;
-
- for (i = 0; i < num_aliases; i++)
- {
- fprintf(out_hnd, "\tAlias Name: %s Attributes: %3d\n",
- alias_name[i], num_als_usrs[i]);
- }
-
- break;
- }
- case ACTION_FOOTER:
- {
- fprintf(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 *usr)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- fprintf(out_hnd, "\tUser Info, Level 0x15\n");
- fprintf(out_hnd, "\t---------------------\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- fprintf(out_hnd, "\t\tUser Name : %s\n", dos_unistrn2(usr->uni_user_name .buffer, usr->uni_user_name .uni_str_len)); /* username unicode string */
- fprintf(out_hnd, "\t\tFull Name : %s\n", dos_unistrn2(usr->uni_full_name .buffer, usr->uni_full_name .uni_str_len)); /* user's full name unicode string */
- fprintf(out_hnd, "\t\tHome Drive : %s\n", dos_unistrn2(usr->uni_home_dir .buffer, usr->uni_home_dir .uni_str_len)); /* home directory unicode string */
- fprintf(out_hnd, "\t\tDir Drive : %s\n", dos_unistrn2(usr->uni_dir_drive .buffer, usr->uni_dir_drive .uni_str_len)); /* home directory drive unicode string */
- fprintf(out_hnd, "\t\tProfile Path: %s\n", dos_unistrn2(usr->uni_profile_path.buffer, usr->uni_profile_path.uni_str_len)); /* profile path unicode string */
- fprintf(out_hnd, "\t\tLogon Script: %s\n", dos_unistrn2(usr->uni_logon_script.buffer, usr->uni_logon_script.uni_str_len)); /* logon script unicode string */
- fprintf(out_hnd, "\t\tDescription : %s\n", dos_unistrn2(usr->uni_acct_desc .buffer, usr->uni_acct_desc .uni_str_len)); /* user description unicode string */
- fprintf(out_hnd, "\t\tWorkstations: %s\n", dos_unistrn2(usr->uni_workstations.buffer, usr->uni_workstations.uni_str_len)); /* workstaions unicode string */
- fprintf(out_hnd, "\t\tUnknown Str : %s\n", dos_unistrn2(usr->uni_unknown_str .buffer, usr->uni_unknown_str .uni_str_len)); /* unknown string unicode string */
- fprintf(out_hnd, "\t\tRemote Dial : %s\n", dos_unistrn2(usr->uni_munged_dial .buffer, usr->uni_munged_dial .uni_str_len)); /* munged remote access unicode string */
-
- fprintf(out_hnd, "\t\tLogon Time : %s\n", http_timestring(nt_time_to_unix(&(usr->logon_time ))));
- fprintf(out_hnd, "\t\tLogoff Time : %s\n", http_timestring(nt_time_to_unix(&(usr->logoff_time ))));
- fprintf(out_hnd, "\t\tKickoff Time : %s\n", http_timestring(nt_time_to_unix(&(usr->kickoff_time ))));
- fprintf(out_hnd, "\t\tPassword last set Time : %s\n", http_timestring(nt_time_to_unix(&(usr->pass_last_set_time ))));
- fprintf(out_hnd, "\t\tPassword can change Time : %s\n", http_timestring(nt_time_to_unix(&(usr->pass_can_change_time ))));
- fprintf(out_hnd, "\t\tPassword must change Time: %s\n", http_timestring(nt_time_to_unix(&(usr->pass_must_change_time))));
-
- fprintf(out_hnd, "\t\tunknown_2[0..31]...\n"); /* user passwords? */
-
- fprintf(out_hnd, "\t\tuser_rid : %x\n" , usr->user_rid ); /* User ID */
- fprintf(out_hnd, "\t\tgroup_rid: %x\n" , usr->group_rid); /* Group ID */
- fprintf(out_hnd, "\t\tacb_info : %04x\n", usr->acb_info ); /* Account Control Info */
-
- fprintf(out_hnd, "\t\tunknown_3: %08x\n", usr->unknown_3); /* 0x00ff ffff */
- fprintf(out_hnd, "\t\tlogon_divs: %d\n", usr->logon_divs); /* 0x0000 00a8 which is 168 which is num hrs in a week */
- fprintf(out_hnd, "\t\tunknown_5: %08x\n", usr->unknown_5); /* 0x0002 0000 */
-
- fprintf(out_hnd, "\t\tpadding1[0..7]...\n");
-
- if (usr->ptr_logon_hrs)
- {
- fprintf(out_hnd, "\t\tlogon_hrs[0..%d]...\n", usr->logon_hrs.len);
- }
-
- break;
- }
- case ACTION_FOOTER:
- {
- fprintf(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 (type & (1 << i))
- {
- switch (((unsigned)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 *info)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- break;
- }
- case ACTION_ENUMERATE:
- {
- fprintf(out_hnd, "\t\tPermissions: %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 *ace)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- fprintf(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);
- fprintf(out_hnd, "\t\tSID: %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 *sec_acl)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- fprintf(out_hnd, "\tACL\tNum ACEs:\t%d\trevision:\t%x\n",
- sec_acl->num_aces, sec_acl->revision);
- fprintf(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:
- {
- fprintf(out_hnd, "\n");
- break;
- }
- }
-}
-
-/****************************************************************************
- display sec_desc structure
- ****************************************************************************/
-void display_sec_desc(FILE *out_hnd, enum action_type action, SEC_DESC *sec)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- fprintf(out_hnd, "\tSecurity Descriptor\trevision:\t%x\ttype:\t%x\n",
- sec->revision, sec->type);
- fprintf(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);
- fprintf(out_hnd, "\tOwner SID:\t%s\n", sid_str);
- }
- if (sec->off_grp_sid != 0)
- {
- sid_to_string(sid_str, sec->grp_sid);
- fprintf(out_hnd, "\tParent SID:\t%s\n", sid_str);
- }
-
- break;
- }
- case ACTION_FOOTER:
- {
- fprintf(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, char *val_name, uint32 val_type, BUFFER2 *value)
-{
- fstring type;
- fstrcpy(type, get_reg_val_type_str(val_type));
-
- switch (val_type)
- {
- case 0x01: /* unistr */
- {
- fprintf(out_hnd,"\t%s:\t%s:\t%s\n", val_name, type, dos_buffer2_to_str(value));
- break;
- }
-
- default: /* unknown */
- case 0x03: /* bytes */
- {
- if (value->buf_len <= 8)
- {
- fprintf(out_hnd,"\t%s:\t%s:\t", val_name, type);
- out_data(out_hnd, (char*)value->buffer, value->buf_len, 8);
- }
- else
- {
- fprintf(out_hnd,"\t%s:\t%s:\n", val_name, type);
- out_data(out_hnd, (char*)value->buffer, value->buf_len, 16);
- }
- break;
- }
-
- case 0x04: /* uint32 */
- {
- fprintf(out_hnd,"\t%s:\t%s: 0x%08x\n", val_name, type, buffer2_to_uint32(value));
- break;
- }
-
- case 0x07: /* multiunistr */
- {
- fprintf(out_hnd,"\t%s:\t%s:\t%s\n", val_name, type, dos_buffer2_to_multistr(value));
- break;
- }
- }
-}
-
-/****************************************************************************
- display structure
- ****************************************************************************/
-void display_reg_value_info(FILE *out_hnd, enum action_type action,
- char *val_name, uint32 val_type, 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,
- char *key_name, time_t key_mod_time)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- break;
- }
- case ACTION_ENUMERATE:
- {
- fprintf(out_hnd, "\t%s\t(%s)\n",
- key_name, http_timestring(key_mod_time));
- break;
- }
- case ACTION_FOOTER:
- {
- break;
- }
- }
-}
-
-#if COPY_THIS_TEMPLATE
-/****************************************************************************
- display structure
- ****************************************************************************/
- void display_(FILE *out_hnd, enum action_type action, *)
-{
- switch (action)
- {
- case ACTION_HEADER:
- {
- fprintf(out_hnd, "\t\n");
- fprintf(out_hnd, "\t-------------------\n");
-
- break;
- }
- case ACTION_ENUMERATE:
- {
- break;
- }
- case ACTION_FOOTER:
- {
- fprintf(out_hnd, "\n");
- break;
- }
- }
-}
-
-#endif
+++ /dev/null
-/*
- 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"
-#include "rpcclient.h"
-
-
-/****************************************************************************
-convert a security permissions into a string
-****************************************************************************/
-static const 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 (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 DELETE_ACCESS : fstrcat(typestr, "Delete "); break;
- case READ_CONTROL_ACCESS : fstrcat(typestr, "ReadControl "); break;
- case WRITE_DAC_ACCESS : fstrcat(typestr, "WriteDAC "); break;
- case WRITE_OWNER_ACCESS : 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
- ****************************************************************************/
-static 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
- ****************************************************************************/
-static 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;
-
- report(out_hnd,
- "\t\tType:%2x Flags:%2x Perms:%04x\n",
- ace->type, ace->flags,
- (uint32) ace->info.mask);
-
- 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
- ****************************************************************************/
-static void display_sec_acl(FILE *out_hnd, enum action_type action, SEC_ACL *const sec_acl)
-{
- if (sec_acl == NULL)
- {
- return;
- }
- 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;
- }
- }
-}
-
+++ /dev/null
-/*
- 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
-****************************************************************************/
-static void display_print_info_0(FILE *out_hnd, PRINTER_INFO_0 *i1)
-{
- fstring name;
- fstring server;
- if (i1 == NULL)
- return;
-
- unistr_to_ascii(name, i1->printername.buffer, sizeof(name)-1);
- unistr_to_ascii(server, i1->servername.buffer, sizeof(server)-1);
-
- report(out_hnd, "\tprintername:[%s]\n", name);
- report(out_hnd, "\tservername:[%s]\n", server);
- report(out_hnd, "\tcjobs:[%x]\n", i1->cjobs);
- report(out_hnd, "\ttotal_jobs:[%x]\n", i1->total_jobs);
-
- report(out_hnd, "\t:date: [%d]-[%d]-[%d] (%d)\n", i1->year, i1->month, i1->day, i1->dayofweek);
- report(out_hnd, "\t:time: [%d]-[%d]-[%d]-[%d]\n", i1->hour, i1->minute, i1->second, i1->milliseconds);
-
- report(out_hnd, "\tglobal_counter:[%x]\n", i1->global_counter);
- report(out_hnd, "\ttotal_pages:[%x]\n", i1->total_pages);
-
- report(out_hnd, "\tmajorversion:[%x]\n", i1->major_version);
- report(out_hnd, "\tbuildversion:[%x]\n", i1->build_version);
-
- report(out_hnd, "\tunknown7:[%x]\n", i1->unknown7);
- report(out_hnd, "\tunknown8:[%x]\n", i1->unknown8);
- report(out_hnd, "\tunknown9:[%x]\n", i1->unknown9);
- report(out_hnd, "\tsession_counter:[%x]\n", i1->session_counter);
- report(out_hnd, "\tunknown11:[%x]\n", i1->unknown11);
- report(out_hnd, "\tprinter_errors:[%x]\n", i1->printer_errors);
- report(out_hnd, "\tunknown13:[%x]\n", i1->unknown13);
- report(out_hnd, "\tunknown14:[%x]\n", i1->unknown14);
- report(out_hnd, "\tunknown15:[%x]\n", i1->unknown15);
- report(out_hnd, "\tunknown16:[%x]\n", i1->unknown16);
- report(out_hnd, "\tchange_id:[%x]\n", i1->change_id);
- report(out_hnd, "\tunknown18:[%x]\n", i1->unknown18);
- report(out_hnd, "\tstatus:[%x]\n", i1->status);
- report(out_hnd, "\tunknown20:[%x]\n", i1->unknown20);
- report(out_hnd, "\tc_setprinter:[%x]\n", i1->c_setprinter);
- report(out_hnd, "\tunknown22:[%x]\n", i1->unknown22);
- report(out_hnd, "\tunknown23:[%x]\n", i1->unknown23);
- report(out_hnd, "\tunknown24:[%x]\n", i1->unknown24);
- report(out_hnd, "\tunknown25:[%x]\n", i1->unknown25);
- report(out_hnd, "\tunknown26:[%x]\n", i1->unknown26);
- report(out_hnd, "\tunknown27:[%x]\n", i1->unknown27);
- report(out_hnd, "\tunknown28:[%x]\n", i1->unknown28);
- report(out_hnd, "\tunknown29:[%x]\n", i1->unknown29);
-}
-
-/****************************************************************************
-printer info level 1 display function
-****************************************************************************/
-static void display_print_info_1(FILE *out_hnd, PRINTER_INFO_1 *i1)
-{
- fstring desc;
- fstring name;
- fstring comm;
- if (i1 == NULL)
- return;
-
- 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:[%x]\n", i1->flags);
- report(out_hnd, "\tname:[%s]\n", name);
- report(out_hnd, "\tdescription:[%s]\n", desc);
- report(out_hnd, "\tcomment:[%s]\n\n", comm);
-}
-
-/****************************************************************************
-printer info level 2 display function
-****************************************************************************/
-static void display_print_info_2(FILE *out_hnd, PRINTER_INFO_2 *i2)
-{
- fstring servername;
- fstring printername;
- fstring sharename;
- fstring portname;
- fstring drivername;
- fstring comment;
- fstring location;
- fstring sepfile;
- fstring printprocessor;
- fstring datatype;
- fstring parameters;
-
- if (i2 == NULL)
- return;
-
- unistr_to_ascii(servername, i2->servername.buffer, sizeof(servername)-1);
- unistr_to_ascii(printername, i2->printername.buffer, sizeof(printername)-1);
- unistr_to_ascii(sharename, i2->sharename.buffer, sizeof(sharename)-1);
- unistr_to_ascii(portname, i2->portname.buffer, sizeof(portname)-1);
- unistr_to_ascii(drivername, i2->drivername.buffer, sizeof(drivername)-1);
- unistr_to_ascii(comment, i2->comment.buffer, sizeof(comment)-1);
- unistr_to_ascii(location, i2->location.buffer, sizeof(location)-1);
- unistr_to_ascii(sepfile, i2->sepfile.buffer, sizeof(sepfile)-1);
- unistr_to_ascii(printprocessor, i2->printprocessor.buffer, sizeof(printprocessor)-1);
- unistr_to_ascii(datatype, i2->datatype.buffer, sizeof(datatype)-1);
- unistr_to_ascii(parameters, i2->parameters.buffer, sizeof(parameters)-1);
-
- report(out_hnd, "\tservername:[%s]\n", servername);
- report(out_hnd, "\tprintername:[%s]\n", printername);
- report(out_hnd, "\tsharename:[%s]\n", sharename);
- report(out_hnd, "\tportname:[%s]\n", portname);
- report(out_hnd, "\tdrivername:[%s]\n", drivername);
- report(out_hnd, "\tcomment:[%s]\n", comment);
- report(out_hnd, "\tlocation:[%s]\n", location);
- report(out_hnd, "\tsepfile:[%s]\n", sepfile);
- report(out_hnd, "\tprintprocessor:[%s]\n", printprocessor);
- report(out_hnd, "\tdatatype:[%s]\n", datatype);
- report(out_hnd, "\tparameters:[%s]\n", parameters);
- report(out_hnd, "\tattributes:[%x]\n", i2->attributes);
- report(out_hnd, "\tpriority:[%x]\n", i2->priority);
- report(out_hnd, "\tdefaultpriority:[%x]\n", i2->defaultpriority);
- report(out_hnd, "\tstarttime:[%x]\n", i2->starttime);
- report(out_hnd, "\tuntiltime:[%x]\n", i2->untiltime);
- report(out_hnd, "\tstatus:[%x]\n", i2->status);
- report(out_hnd, "\tcjobs:[%x]\n", i2->cjobs);
- report(out_hnd, "\taverageppm:[%x]\n\n", i2->averageppm);
-
- if (i2->secdesc != NULL)
- {
- display_sec_desc(out_hnd, ACTION_HEADER , i2->secdesc);
- display_sec_desc(out_hnd, ACTION_ENUMERATE, i2->secdesc);
- display_sec_desc(out_hnd, ACTION_FOOTER , i2->secdesc);
- }
-}
-
-/****************************************************************************
-printer info level 3 display function
-****************************************************************************/
-static void display_print_info_3(FILE *out_hnd, PRINTER_INFO_3 *i3)
-{
- if (i3 == NULL)
- return;
-
- report(out_hnd, "\tflags:[%x]\n", i3->flags);
-
- display_sec_desc(out_hnd, ACTION_HEADER , i3->secdesc);
- display_sec_desc(out_hnd, ACTION_ENUMERATE, i3->secdesc);
- display_sec_desc(out_hnd, ACTION_FOOTER , i3->secdesc);
-}
-
-/****************************************************************************
-connection info level 0 container display function
-****************************************************************************/
-static void display_printer_info_0_ctr(FILE *out_hnd, enum action_type action, uint32 count, PRINTER_INFO_CTR ctr)
-{
- int i;
- PRINTER_INFO_0 *in;
-
- switch (action)
- {
- case ACTION_HEADER:
- report(out_hnd, "Printer Info Level 0:\n");
- break;
- case ACTION_ENUMERATE:
- for (i = 0; i < count; i++) {
- in=ctr.printers_0;
- display_print_info_0(out_hnd, &(in[i]) );
- }
- break;
- case ACTION_FOOTER:
- report(out_hnd, "\n");
- break;
- }
-}
-
-/****************************************************************************
-connection info level 1 container display function
-****************************************************************************/
-static void display_printer_info_1_ctr(FILE *out_hnd, enum action_type action, uint32 count, PRINTER_INFO_CTR ctr)
-{
- int i;
- PRINTER_INFO_1 *in;
-
- switch (action)
- {
- case ACTION_HEADER:
- report(out_hnd, "Printer Info Level 1:\n");
- break;
- case ACTION_ENUMERATE:
- for (i = 0; i < count; i++) {
- in=ctr.printers_1;
- display_print_info_1(out_hnd, &(in[i]) );
- }
- break;
- case ACTION_FOOTER:
- report(out_hnd, "\n");
- break;
- }
-}
-
-/****************************************************************************
-connection info level 2 container display function
-****************************************************************************/
-static void display_printer_info_2_ctr(FILE *out_hnd, enum action_type action, uint32 count, PRINTER_INFO_CTR ctr)
-{
- int i;
- PRINTER_INFO_2 *in;
-
- switch (action)
- {
- case ACTION_HEADER:
- report(out_hnd, "Printer Info Level 2:\n");
- break;
- case ACTION_ENUMERATE:
- for (i = 0; i < count; i++) {
- in=ctr.printers_2;
- display_print_info_2(out_hnd, &(in[i]) );
- }
- break;
- case ACTION_FOOTER:
- report(out_hnd, "\n");
- break;
- }
-}
-
-/****************************************************************************
-connection info level 3 container display function
-****************************************************************************/
-static void display_printer_info_3_ctr(FILE *out_hnd, enum action_type action, uint32 count, PRINTER_INFO_CTR ctr)
-{
- int i;
- PRINTER_INFO_3 *in;
-
- switch (action)
- {
- case ACTION_HEADER:
- report(out_hnd, "Printer Info Level 3:\n");
- break;
- case ACTION_ENUMERATE:
- for (i = 0; i < count; i++) {
- in=ctr.printers_3;
- display_print_info_3(out_hnd, &(in[i]) );
- }
- break;
- case ACTION_FOOTER:
- report(out_hnd, "\n");
- break;
- }
-}
-
-/****************************************************************************
-connection info container display function
-****************************************************************************/
-void display_printer_info_ctr(FILE *out_hnd, enum action_type action, uint32 level,
- uint32 count, PRINTER_INFO_CTR ctr)
-{
- switch (level) {
- case 0:
- display_printer_info_0_ctr(out_hnd, action, count, ctr);
- break;
- case 1:
- display_printer_info_1_ctr(out_hnd, action, count, ctr);
- break;
- case 2:
- display_printer_info_2_ctr(out_hnd, action, count, ctr);
- break;
- case 3:
- display_printer_info_3_ctr(out_hnd, action, count, ctr);
- break;
- default:
- report(out_hnd, "display_printer_info_ctr: Unknown Info Level\n");
- break;
- }
-}
-
-/****************************************************************************
-connection info level 3 container display function
-****************************************************************************/
-static void display_port_info_1_ctr(FILE *out_hnd, enum action_type action,
- uint32 count, PORT_INFO_CTR *ctr)
-{
- uint32 i = 0;
- switch (action)
- {
- case ACTION_HEADER:
- report(out_hnd, "Port Info Level 1:\n");
- break;
- case ACTION_ENUMERATE:
- for (i=0; i<count; i++)
- display_port_info_1(out_hnd, action, &ctr->port.info_1[i]);
- break;
- case ACTION_FOOTER:
- report(out_hnd, "\n");
- break;
- }
-}
-
-/****************************************************************************
-connection info level 3 container display function
-****************************************************************************/
-static void display_port_info_2_ctr(FILE *out_hnd, enum action_type action,
- uint32 count, PORT_INFO_CTR *ctr)
-{
- uint32 i = 0;
- switch (action)
- {
- case ACTION_HEADER:
- report(out_hnd, "Port Info Level 2:\n");
- break;
- case ACTION_ENUMERATE:
- for (i=0; i<count; i++)
- display_port_info_2(out_hnd, action, &ctr->port.info_2[i]);
- break;
- case ACTION_FOOTER:
- report(out_hnd, "\n");
- break;
- }
-}
-
-/****************************************************************************
-connection info container display function
-****************************************************************************/
-void display_port_info_ctr(FILE *out_hnd, enum action_type action, uint32 level,
- uint32 count, PORT_INFO_CTR *ctr)
-{
- switch (level) {
- case 1:
- display_port_info_1_ctr(out_hnd, action, count, ctr);
- break;
- case 2:
- display_port_info_2_ctr(out_hnd, action, count, ctr);
- break;
- default:
- report(out_hnd, "display_port_info_ctr: Unknown Info Level\n");
- break;
- }
-}
-
-/****************************************************************************
-connection info container display function
-****************************************************************************/
-void display_port_info_1(FILE *out_hnd, enum action_type action, PORT_INFO_1 *i1)
-{
- fstring buffer;
-
- switch (action)
- {
- case ACTION_HEADER:
- report(out_hnd, "Port:\n");
- break;
- case ACTION_ENUMERATE:
- unistr_to_ascii(buffer, i1->port_name.buffer, sizeof(buffer)-1);
- fprintf (out_hnd, "\tPort Name:\t[%s]\n\n", buffer);
- break;
- case ACTION_FOOTER:
- report(out_hnd, "\n");
- break;
- }
-}
-
-/****************************************************************************
-connection info container display function
-****************************************************************************/
-void display_port_info_2(FILE *out_hnd, enum action_type action, PORT_INFO_2 *i2)
-{
- fstring buffer;
-
- switch (action)
- {
- case ACTION_HEADER:
- report(out_hnd, "Port:\n");
- break;
- case ACTION_ENUMERATE:
- unistr_to_ascii(buffer, i2->port_name.buffer, sizeof(buffer)-1);
- fprintf (out_hnd, "\tPort Name:\t[%s]\n", buffer);
- unistr_to_ascii(buffer, i2->monitor_name.buffer, sizeof(buffer)-1);
- fprintf (out_hnd, "\tMonitor Name:\t[%s]\n", buffer);
- unistr_to_ascii(buffer, i2->description.buffer, sizeof(buffer)-1);
- fprintf (out_hnd, "\tDescription:\t[%s]\n", buffer);
- fprintf (out_hnd, "\tPort Type:\t[%d]\n", i2->port_type);
- fprintf (out_hnd, "\tReserved:\t[%d]\n", i2->reserved);
- fprintf (out_hnd, "\n");
- break;
- case ACTION_FOOTER:
- report(out_hnd, "\n");
- break;
- }
-}
-
-/****************************************************************************
-connection info container display function
-****************************************************************************/
-void display_printer_enumdata(FILE *out_hnd, enum action_type action, uint32 idx,
- uint32 valuelen, uint16 *value, uint32 rvaluelen,
- uint32 type,
- uint32 datalen, uint8 *data, uint32 rdatalen)
-{
- fstring buffer;
-
- switch (action)
- {
- case ACTION_HEADER:
- report(out_hnd, "Printer enum data:\n");
- report(out_hnd, "index\tvaluelen\tvalue\t\trvaluelen");
- report(out_hnd, "\ttype\tdatalen\tdata\trdatalen\n");
- break;
- case ACTION_ENUMERATE:
- report(out_hnd, "[%d]", idx);
- report(out_hnd, "\t[%d]", valuelen);
- unistr_to_ascii(buffer, value, sizeof(buffer)-1);
- report(out_hnd, "\t[%s]", buffer);
- report(out_hnd, "\t[%d]", rvaluelen);
- report(out_hnd, "\t\t[%d]", type);
- report(out_hnd, "\t[%d]", datalen);
-/* report(out_hnd, "\t[%s]", data);*/
- report(out_hnd, "\t[%d]\n", rdatalen);
- break;
- case ACTION_FOOTER:
- report(out_hnd, "\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 **)ctr);
- break;
- }
- case 2:
- {
- display_job_info_2_ctr(out_hnd, action,
- count, (JOB_INFO_2 **)ctr);
- break;
- }
- default:
- {
- report(out_hnd, "display_job_info_ctr: Unknown Info Level\n");
- break;
- }
- }
-}
-
-/****************************************************************************
-printer info level 0 display function
-****************************************************************************/
-static void display_print_driver_1(FILE *out_hnd, DRIVER_INFO_1 *i1)
-{
- fstring name;
- if (i1 == NULL)
- return;
-
- unistr_to_ascii(name, i1->name.buffer, sizeof(name)-1);
-
- report(out_hnd, "\tname:[%s]\n", name);
-}
-
-/****************************************************************************
-printer info level 1 display function
-****************************************************************************/
-static void display_print_driver_2(FILE *out_hnd, DRIVER_INFO_2 *i1)
-{
- fstring name;
- fstring architecture;
- fstring driverpath;
- fstring datafile;
- fstring configfile;
- if (i1 == NULL)
- return;
-
- unistr_to_ascii(name, i1->name.buffer, sizeof(name)-1);
- unistr_to_ascii(architecture, i1->architecture.buffer, sizeof(architecture)-1);
- unistr_to_ascii(driverpath, i1->driverpath.buffer, sizeof(driverpath)-1);
- unistr_to_ascii(datafile, i1->datafile.buffer, sizeof(datafile)-1);
- unistr_to_ascii(configfile, i1->configfile.buffer, sizeof(configfile)-1);
-
- report(out_hnd, "\tversion:[%x]\n", i1->version);
- report(out_hnd, "\tname:[%s]\n", name);
- report(out_hnd, "\tarchitecture:[%s]\n", architecture);
- report(out_hnd, "\tdriverpath:[%s]\n", driverpath);
- report(out_hnd, "\tdatafile:[%s]\n", datafile);
- report(out_hnd, "\tconfigfile:[%s]\n", configfile);
-}
-
-/****************************************************************************
-printer info level 2 display function
-****************************************************************************/
-static void display_print_driver_3(FILE *out_hnd, DRIVER_INFO_3 *i1)
-{
- fstring name;
- fstring architecture;
- fstring driverpath;
- fstring datafile;
- fstring configfile;
- fstring helpfile;
- fstring dependentfiles;
- fstring monitorname;
- fstring defaultdatatype;
-
- int length=0;
- BOOL valid = True;
-
- if (i1 == NULL)
- return;
-
- unistr_to_ascii(name, i1->name.buffer, sizeof(name)-1);
- unistr_to_ascii(architecture, i1->architecture.buffer, sizeof(architecture)-1);
- unistr_to_ascii(driverpath, i1->driverpath.buffer, sizeof(driverpath)-1);
- unistr_to_ascii(datafile, i1->datafile.buffer, sizeof(datafile)-1);
- unistr_to_ascii(configfile, i1->configfile.buffer, sizeof(configfile)-1);
- unistr_to_ascii(helpfile, i1->helpfile.buffer, sizeof(helpfile)-1);
-
- unistr_to_ascii(monitorname, i1->monitorname.buffer, sizeof(monitorname)-1);
- unistr_to_ascii(defaultdatatype, i1->defaultdatatype.buffer, sizeof(defaultdatatype)-1);
-
- report(out_hnd, "\tversion:[%x]\n", i1->version);
- report(out_hnd, "\tname:[%s]\n",name );
- report(out_hnd, "\tarchitecture:[%s]\n", architecture);
- report(out_hnd, "\tdriverpath:[%s]\n", driverpath);
- report(out_hnd, "\tdatafile:[%s]\n", datafile);
- report(out_hnd, "\tconfigfile:[%s]\n", configfile);
- report(out_hnd, "\thelpfile:[%s]\n\n", helpfile);
-
- while (valid)
- {
- unistr_to_ascii(dependentfiles, i1->dependentfiles+length, sizeof(dependentfiles)-1);
- length+=strlen(dependentfiles)+1;
-
- if (strlen(dependentfiles) > 0)
- {
- report(out_hnd, "\tdependentfiles:[%s]\n", dependentfiles);
- }
- else
- {
- valid = False;
- }
- }
-
- report(out_hnd, "\n\tmonitorname:[%s]\n", monitorname);
- report(out_hnd, "\tdefaultdatatype:[%s]\n", defaultdatatype);
-
-}
-
-/****************************************************************************
-connection info level 1 container display function
-****************************************************************************/
-static void display_printer_driver_1_ctr(FILE *out_hnd, enum action_type action, uint32 count, PRINTER_DRIVER_CTR ctr)
-{
- int i;
- DRIVER_INFO_1 *in;
-
- switch (action)
- {
- case ACTION_HEADER:
- report(out_hnd, "Printer driver Level 1:\n");
- break;
- case ACTION_ENUMERATE:
- for (i = 0; i < count; i++) {
- in=ctr.info1;
- display_print_driver_1(out_hnd, &(in[i]) );
- }
- break;
- case ACTION_FOOTER:
- report(out_hnd, "\n");
- break;
- }
-}
-
-/****************************************************************************
-connection info level 2 container display function
-****************************************************************************/
-static void display_printer_driver_2_ctr(FILE *out_hnd, enum action_type action, uint32 count, PRINTER_DRIVER_CTR ctr)
-{
- int i;
- DRIVER_INFO_2 *in;
-
- switch (action)
- {
- case ACTION_HEADER:
- report(out_hnd, "Printer driver Level 2:\n");
- break;
- case ACTION_ENUMERATE:
- for (i = 0; i < count; i++) {
- in=ctr.info2;
- display_print_driver_2(out_hnd, &(in[i]) );
- }
- break;
- case ACTION_FOOTER:
- report(out_hnd, "\n");
- break;
- }
-}
-
-/****************************************************************************
-connection info level 3 container display function
-****************************************************************************/
-static void display_printer_driver_3_ctr(FILE *out_hnd, enum action_type action, uint32 count, PRINTER_DRIVER_CTR ctr)
-{
- int i;
- DRIVER_INFO_3 *in;
-
- switch (action)
- {
- case ACTION_HEADER:
- report(out_hnd, "Printer driver Level 3:\n");
- break;
- case ACTION_ENUMERATE:
- for (i = 0; i < count; i++) {
- in=ctr.info3;
- display_print_driver_3(out_hnd, &(in[i]) );
- }
- break;
- case ACTION_FOOTER:
- report(out_hnd, "\n");
- break;
- }
-}
-
-/****************************************************************************
-connection info container display function
-****************************************************************************/
-void display_printer_driver_ctr(FILE *out_hnd, enum action_type action, uint32 level,
- uint32 count, PRINTER_DRIVER_CTR ctr)
-{
- switch (level) {
- case 1:
- display_printer_driver_1_ctr(out_hnd, action, count, ctr);
- break;
- case 2:
- display_printer_driver_2_ctr(out_hnd, action, count, ctr);
- break;
- case 3:
- display_printer_driver_3_ctr(out_hnd, action, count, ctr);
- break;
- default:
- report(out_hnd, "display_printer_driver_ctr: Unknown Info Level\n");
- break;
- }
-}
-
-
-/****************************************************************************
-printer info level 1 display function
-****************************************************************************/
-static void display_printdriverdir_info_1(FILE *out_hnd, DRIVER_DIRECTORY_1 *i1)
-{
- fstring name;
- if (i1 == NULL)
- return;
-
- unistr_to_ascii(name, i1->name.buffer, sizeof(name)-1);
-
- report(out_hnd, "\tname:[%s]\n", name);
-}
-
-/****************************************************************************
-connection info level 1 container display function
-****************************************************************************/
-static void display_printerdriverdir_info_1_ctr(FILE *out_hnd, enum action_type action, DRIVER_DIRECTORY_CTR ctr)
-{
-
- switch (action)
- {
- case ACTION_HEADER:
- report(out_hnd, "Printer driver dir Info Level 1:\n");
- break;
- case ACTION_ENUMERATE:
- display_printdriverdir_info_1(out_hnd, &(ctr.driver.info_1) );
- break;
- case ACTION_FOOTER:
- report(out_hnd, "\n");
- break;
- }
-}
-
-/****************************************************************************
-connection info container display function
-****************************************************************************/
-void display_printerdriverdir_info_ctr(FILE *out_hnd, enum action_type action, uint32 level,
- DRIVER_DIRECTORY_CTR ctr)
-{
- switch (level) {
- case 1:
- display_printerdriverdir_info_1_ctr(out_hnd, action, ctr);
- break;
- default:
- report(out_hnd, "display_printerdriverdir_info_ctr: Unknown Info Level\n");
- break;
- }
-}