diff options
-rw-r--r-- | source3/include/rpc_reg.h | 18 | ||||
-rw-r--r-- | source3/registry/reg_frontend.c | 33 | ||||
-rw-r--r-- | source3/registry/reg_printing.c | 178 | ||||
-rw-r--r-- | source3/rpc_server/srv_spoolss_nt.c | 2 | ||||
-rw-r--r-- | source3/script/mkproto.awk | 2 |
5 files changed, 195 insertions, 38 deletions
diff --git a/source3/include/rpc_reg.h b/source3/include/rpc_reg.h index e2347c328b..41d3325015 100644 --- a/source3/include/rpc_reg.h +++ b/source3/include/rpc_reg.h @@ -1,9 +1,10 @@ /* Unix SMB/CIFS implementation. SMB parameters and setup - Copyright (C) Andrew Tridgell 1992-1997 - Copyright (C) Luke Kenneth Casson Leighton 1996-1997 - Copyright (C) Paul Ashton 1997 + Copyright (C) Andrew Tridgell 1992-1997. + Copyright (C) Luke Kenneth Casson Leighton 1996-1997. + Copyright (C) Paul Ashton 1997. + Copyright (C) Gerald Carter 2002. 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 @@ -94,16 +95,7 @@ typedef struct { fstring valuename; uint16 type; uint32 size; /* in bytes */ - void *data_p; -#if 0 - union { - char *string; - uint32 *dword; - uint8 *binary; - void *void_ptr; /* for casting only */ - } data; -#endif - + uint8 *data_p; } REGISTRY_VALUE; /* container for regostry values */ diff --git a/source3/registry/reg_frontend.c b/source3/registry/reg_frontend.c index db612709d1..c0788c1b75 100644 --- a/source3/registry/reg_frontend.c +++ b/source3/registry/reg_frontend.c @@ -202,7 +202,19 @@ REGISTRY_VALUE* regval_ctr_specific_value( REGVAL_CTR *ctr, uint32 idx ) } /*********************************************************************** - Ad a new regostry value to the array + Retrive the TALLOC_CTX associated with a REGISTRY_VALUE + **********************************************************************/ + +TALLOC_CTX* regval_ctr_getctx( REGVAL_CTR *val ) +{ + if ( !val ) + return NULL; + + return val->ctx; +} + +/*********************************************************************** + Add a new regostry value to the array **********************************************************************/ int regval_ctr_addvalue( REGVAL_CTR *ctr, char *name, uint16 type, @@ -235,25 +247,6 @@ int regval_ctr_addvalue( REGVAL_CTR *ctr, char *name, uint16 type, ctr->values[ctr->num_values]->type = type; ctr->values[ctr->num_values]->data_p = talloc_memdup( ctr->ctx, data_p, size ); ctr->values[ctr->num_values]->size = size; -#if 0 - switch ( type ) - { - case REG_SZ: - ctr->values[ctr->num_values]->data.string = talloc_strdup( ctr->ctx, data_p ); - break; - case REG_MULTI_SZ: - ctr->values[ctr->num_values]->data.string = talloc_memdup( ctr->ctx, data_p, size ); - break; - case REG_DWORD: - ctr->values[ctr->num_values]->data.dword = *(uint32*)data_p; - break; - case REG_BINARY: - ctr->values[ctr->num_values]->data.binary = talloc_memdup( ctr->ctx, data_p, size ); - break; - - } -#endif - ctr->num_values++; } diff --git a/source3/registry/reg_printing.c b/source3/registry/reg_printing.c index d8e0f18953..145b8230c9 100644 --- a/source3/registry/reg_printing.c +++ b/source3/registry/reg_printing.c @@ -453,6 +453,11 @@ static int print_subpath_printers( char *key, REGSUBKEY_CTR *subkeys ) int n_services = lp_numservices(); int snum; fstring sname; + int num_subkeys = 0; + char *keystr, *key2 = NULL; + char *base, *new_path; + NT_PRINTER_INFO_LEVEL *printer = NULL; + DEBUG(10,("print_subpath_printers: key=>[%s]\n", key ? key : "NULL" )); @@ -468,13 +473,178 @@ static int print_subpath_printers( char *key, REGSUBKEY_CTR *subkeys ) regsubkey_ctr_addkey( subkeys, sname ); } + + num_subkeys = regsubkey_ctr_numkeys( subkeys ); + goto done; + } + + /* get information for a specific printer */ + + key2 = strdup( key ); + keystr = key2; + reg_split_path( keystr, &base, &new_path ); + + + if ( !new_path ) { + /* sanity check on the printer name */ + if ( !W_ERROR_IS_OK( get_a_printer(&printer, 2, base) ) ) + goto done; + + free_a_printer( &printer, 2 ); + + regsubkey_ctr_addkey( subkeys, "PrinterDriverData" ); + } + + /* no other subkeys below here */ + +done: + SAFE_FREE( key2 ); + return num_subkeys; +} + +/********************************************************************** + handle enumeration of values below KEY_PRINTING\Printers + *********************************************************************/ + +static int print_subpath_values_printers( char *key, REGVAL_CTR *val ) +{ + int num_values = 0; + char *keystr, *key2 = NULL; + char *base, *new_path; + NT_PRINTER_INFO_LEVEL *printer = NULL; + NT_PRINTER_INFO_LEVEL_2 *info2; + DEVICEMODE *devmode; + prs_struct prs; + uint32 offset; + int snum; + int i; + fstring valuename; + uint8 *data; + uint32 type, data_len; + fstring printername; + + /* + * There are tw cases to deal with here + * (1) enumeration of printer_info_2 values + * (2) enumeration of the PrinterDriverData subney + */ + + if ( !key ) { + /* top level key has no values */ + goto done; + } + + key2 = strdup( key ); + keystr = key2; + reg_split_path( keystr, &base, &new_path ); + + fstrcpy( printername, base ); + + if ( !new_path ) + { + /* we are dealing with the printer itself */ + + if ( !W_ERROR_IS_OK( get_a_printer(&printer, 2, printername) ) ) + goto done; + + info2 = printer->info_2; + + + regval_ctr_addvalue( val, "Attributes", REG_DWORD, (char*)&info2->attributes, sizeof(info2->attributes) ); + regval_ctr_addvalue( val, "Priority", REG_DWORD, (char*)&info2->priority, sizeof(info2->attributes) ); + regval_ctr_addvalue( val, "ChangeID", REG_DWORD, (char*)&info2->changeid, sizeof(info2->changeid) ); + regval_ctr_addvalue( val, "Default Priority", REG_DWORD, (char*)&info2->default_priority, sizeof(info2->default_priority) ); + regval_ctr_addvalue( val, "Status", REG_DWORD, (char*)&info2->status, sizeof(info2->status) ); + regval_ctr_addvalue( val, "StartTime", REG_DWORD, (char*)&info2->starttime, sizeof(info2->starttime) ); + regval_ctr_addvalue( val, "UntilTime", REG_DWORD, (char*)&info2->untiltime, sizeof(info2->untiltime) ); + regval_ctr_addvalue( val, "cjobs", REG_DWORD, (char*)&info2->cjobs, sizeof(info2->cjobs) ); + regval_ctr_addvalue( val, "AveragePPM", REG_DWORD, (char*)&info2->averageppm, sizeof(info2->averageppm) ); + + regval_ctr_addvalue( val, "Name", REG_SZ, info2->printername, sizeof(info2->printername)+1 ); + regval_ctr_addvalue( val, "Location", REG_SZ, info2->location, sizeof(info2->location)+1 ); + regval_ctr_addvalue( val, "Comment", REG_SZ, info2->comment, sizeof(info2->comment)+1 ); + regval_ctr_addvalue( val, "Parameters", REG_SZ, info2->parameters, sizeof(info2->parameters)+1 ); + regval_ctr_addvalue( val, "Port", REG_SZ, info2->portname, sizeof(info2->portname)+1 ); + regval_ctr_addvalue( val, "Server", REG_SZ, info2->servername, sizeof(info2->servername)+1 ); + regval_ctr_addvalue( val, "Share", REG_SZ, info2->sharename, sizeof(info2->sharename)+1 ); + regval_ctr_addvalue( val, "Driver", REG_SZ, info2->drivername, sizeof(info2->drivername)+1 ); + regval_ctr_addvalue( val, "Separator File", REG_SZ, info2->sepfile, sizeof(info2->sepfile)+1 ); + regval_ctr_addvalue( val, "Print Processor", REG_SZ, info2->printprocessor, sizeof(info2->printprocessor)+1 ); + + + /* use a prs_struct for converting the devmode and security + descriptor to REG_BIARY */ + + prs_init( &prs, MAX_PDU_FRAG_LEN, regval_ctr_getctx(val), MARSHALL); + + /* stream the device mode */ + + snum = lp_servicenumber(info2->sharename); + if ( (devmode = construct_dev_mode( snum )) != NULL ) + { + if ( spoolss_io_devmode( "devmode", &prs, 0, devmode ) ) { + + offset = prs_offset( &prs ); + + regval_ctr_addvalue( val, "Default Devmode", REG_BINARY, prs_data_p(&prs), offset ); + } + + + } + + prs_mem_clear( &prs ); + prs_set_offset( &prs, 0 ); + + if ( info2->secdesc_buf && info2->secdesc_buf->len ) + { + if ( sec_io_desc("sec_desc", &info2->secdesc_buf->sec, &prs, 0 ) ) { + + offset = prs_offset( &prs ); + + regval_ctr_addvalue( val, "Security", REG_BINARY, prs_data_p(&prs), offset ); + } + } + + + prs_mem_free( &prs ); + free_a_printer( &printer, 2 ); + + num_values = regval_ctr_numvals( val ); + goto done; + } - else + + + keystr = new_path; + reg_split_path( keystr, &base, &new_path ); + + /* here should be no more path components here */ + + if ( new_path || strcmp(base, "PrinterDriverData") ) + goto done; + + /* now enumerate the PrinterDriverData key */ + if ( !W_ERROR_IS_OK( get_a_printer(&printer, 2, printername) ) ) + goto done; + + info2 = printer->info_2; + + + /* iterate over all printer data and fill the regval container */ + + for ( i=0; get_specific_param_by_index(*printer, 2, i, valuename, &data, &type, &data_len); i++ ) { - /* get information for a specific printer */ + regval_ctr_addvalue( val, valuename, type, data, data_len ); } + + free_a_printer( &printer, 2 ); + + num_values = regval_ctr_numvals( val ); + +done: + SAFE_FREE( key2 ); - return regsubkey_ctr_numkeys( subkeys ); + return num_values; } /********************************************************************** @@ -529,6 +699,8 @@ static int handle_printing_subpath( char *key, REGSUBKEY_CTR *subkeys, REGVAL_CT case KEY_INDEX_PRINTER: if ( subkeys ) print_subpath_printers( p, subkeys ); + if ( val ) + print_subpath_values_printers( p, val ); break; /* default case for top level key that has no handler */ diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index bc58655f71..46aebbe3a3 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3374,7 +3374,7 @@ static void free_dev_mode(DEVICEMODE *dev) Create a DEVMODE struct. Returns malloced memory. ****************************************************************************/ -static DEVICEMODE *construct_dev_mode(int snum) +DEVICEMODE *construct_dev_mode(int snum) { char adevice[32]; char aform[32]; diff --git a/source3/script/mkproto.awk b/source3/script/mkproto.awk index b71d50e95a..196715d6b1 100644 --- a/source3/script/mkproto.awk +++ b/source3/script/mkproto.awk @@ -142,7 +142,7 @@ END { gotstart = 1; } - if( $0 ~ /^SAM_ACCT_INFO_NODE|^SMB_ACL_T|^ADS_MODLIST|^PyObject|^SORTED_TREE|^REGISTRY_HOOK|^REGISTRY_VALUE/ ) { + if( $0 ~ /^SAM_ACCT_INFO_NODE|^SMB_ACL_T|^ADS_MODLIST|^PyObject|^SORTED_TREE|^REGISTRY_HOOK|^REGISTRY_VALUE|^DEVICEMODE/ ) { gotstart = 1; } |