diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/registry/reg_frontend.c | 39 | ||||
-rw-r--r-- | source3/registry/reg_printing.c | 67 | ||||
-rw-r--r-- | source3/rpc_server/srv_spoolss_nt.c | 4 |
3 files changed, 69 insertions, 41 deletions
diff --git a/source3/registry/reg_frontend.c b/source3/registry/reg_frontend.c index f31f675997..05bcd989b4 100644 --- a/source3/registry/reg_frontend.c +++ b/source3/registry/reg_frontend.c @@ -253,12 +253,9 @@ int regval_ctr_addvalue( REGVAL_CTR *ctr, char *name, uint16 type, char *data_p, size_t size ) { REGISTRY_VALUE **ppreg; - uint16 len; if ( name ) { - len = strlen( name ); - /* allocate a slot in the array of pointers */ if ( ctr->num_values == 0 ) @@ -286,6 +283,42 @@ int regval_ctr_addvalue( REGVAL_CTR *ctr, char *name, uint16 type, } /*********************************************************************** + Add a new registry value to the array + **********************************************************************/ + +int regval_ctr_copyvalue( REGVAL_CTR *ctr, REGISTRY_VALUE *val ) +{ + REGISTRY_VALUE **ppreg; + + if ( val ) + { + /* allocate a slot in the array of pointers */ + + if ( ctr->num_values == 0 ) + ctr->values = talloc( ctr->ctx, sizeof(REGISTRY_VALUE*) ); + else { + ppreg = talloc_realloc( ctr->ctx, ctr->values, sizeof(REGISTRY_VALUE*)*(ctr->num_values+1) ); + if ( ppreg ) + ctr->values = ppreg; + } + + /* allocate a new value and store the pointer in the arrya */ + + ctr->values[ctr->num_values] = talloc( ctr->ctx, sizeof(REGISTRY_VALUE) ); + + /* init the value */ + + fstrcpy( ctr->values[ctr->num_values]->valuename, val->valuename ); + ctr->values[ctr->num_values]->type = val->type; + ctr->values[ctr->num_values]->data_p = talloc_memdup( ctr->ctx, val->data_p, val->size ); + ctr->values[ctr->num_values]->size = val->size; + ctr->num_values++; + } + + return ctr->num_values; +} + +/*********************************************************************** Delete a single value from the registry container. No need to free memory since it is talloc'd. **********************************************************************/ diff --git a/source3/registry/reg_printing.c b/source3/registry/reg_printing.c index 8ab0abba9b..2bc9d056e4 100644 --- a/source3/registry/reg_printing.c +++ b/source3/registry/reg_printing.c @@ -453,11 +453,12 @@ static int print_subpath_printers( char *key, REGSUBKEY_CTR *subkeys ) int n_services = lp_numservices(); int snum; fstring sname; + int i; int num_subkeys = 0; char *keystr, *key2 = NULL; char *base, *new_path; NT_PRINTER_INFO_LEVEL *printer = NULL; - + fstring *subkey_names = NULL; DEBUG(10,("print_subpath_printers: key=>[%s]\n", key ? key : "NULL" )); @@ -483,22 +484,23 @@ static int print_subpath_printers( char *key, REGSUBKEY_CTR *subkeys ) key2 = strdup( key ); keystr = key2; reg_split_path( keystr, &base, &new_path ); + + if ( !W_ERROR_IS_OK( get_a_printer(&printer, 2, base) ) ) + goto done; + + num_subkeys = get_printer_subkeys( &printer->info_2->data, new_path?new_path:"", &subkey_names ); + for ( i=0; i<num_subkeys; i++ ) + regsubkey_ctr_addkey( subkeys, subkey_names[i] ); - 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, SPOOL_PRINTERDATA_KEY ); - } - + free_a_printer( &printer, 2 ); + /* no other subkeys below here */ done: SAFE_FREE( key2 ); + SAFE_FREE( subkey_names ); + return num_subkeys; } @@ -517,7 +519,9 @@ static int print_subpath_values_printers( char *key, REGVAL_CTR *val ) prs_struct prs; uint32 offset; int snum; - fstring printername; + fstring printername; + NT_PRINTER_DATA *p_data; + int i, key_index; /* * There are tw cases to deal with here @@ -603,43 +607,36 @@ static int print_subpath_values_printers( char *key, REGVAL_CTR *val ) prs_mem_free( &prs ); - free_a_printer( &printer, 2 ); num_values = regval_ctr_numvals( val ); + goto done; } - - - keystr = new_path; - reg_split_path( keystr, &base, &new_path ); - - /* here should be no more path components here */ - - if ( new_path || strcmp(base, SPOOL_PRINTERDATA_KEY) ) - goto done; - /* now enumerate the PrinterDriverData key */ + /* now enumerate the 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 */ -#if 0 /* JERRY */ - for ( i=0; get_specific_param_by_index(*printer, 2, i, valuename, &data, &type, &data_len); i++ ) - { - regval_ctr_addvalue( val, valuename, type, data, data_len ); + p_data = &printer->info_2->data; + if ( (key_index = lookup_printerkey( p_data, new_path )) == -1 ) { + DEBUG(10,("print_subpath_values_printer: Unknown keyname [%s]\n", new_path)); + goto done; } -#endif - - free_a_printer( &printer, 2 ); - - num_values = regval_ctr_numvals( val ); + num_values = regval_ctr_numvals( &p_data->keys[key_index].values ); + + for ( i=0; i<num_values; i++ ) + regval_ctr_copyvalue( val, regval_ctr_specific_value(&p_data->keys[key_index].values, i) ); + + done: + if ( printer ) + free_a_printer( &printer, 2 ); + SAFE_FREE( key2 ); return num_values; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a9c09b9107..1c60e7024e 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7925,7 +7925,6 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, fstring valuename; fstring keyname; char *oid_string; - UNISTR2 uni_oid; DEBUG(4,("_spoolss_setprinterdataex\n")); @@ -7988,9 +7987,8 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, * this is right. --jerry */ - init_unistr2( &uni_oid, oid_string, strlen(oid_string)+1 ); set_printer_dataex( printer, keyname, valuename, - REG_SZ, (void*)uni_oid.buffer, uni_oid.uni_str_len*sizeof(uint16) ); + REG_SZ, (void*)oid_string, strlen(oid_string)+1 ); } free_a_printer(&printer, 2); |