示例#1
0
static int key_printers_fetch_values( const char *key, REGVAL_CTR *values )
{
	int 		num_values;
	char		*printers_key;
	char		*printername, *printerdatakey;
	NT_PRINTER_INFO_LEVEL 	*printer = NULL;
	NT_PRINTER_DATA	*p_data;
	int		i, key_index;
	
	printers_key = strip_printers_prefix( key );	
	
	/* top level key values stored in the registry has no values */
	
	if ( !printers_key ) {
		/* normalize to the 'HKLM\SOFTWARE\...\Print\Printers' ket */
		return regdb_fetch_values( KEY_WINNT_PRINTERS, values );
	}
	
	/* lookup the printer object */
	
	if (!reg_split_path( printers_key, &printername, &printerdatakey )) {
		return -1;
	}
	
	if ( !W_ERROR_IS_OK( get_a_printer(NULL, &printer, 2, printername) ) )
		goto done;
		
	if ( !printerdatakey ) {
		fill_in_printer_values( printer->info_2, values );
		goto done;
	}
		
	/* iterate over all printer data keys and fill the regval container */
	
	p_data = printer->info_2->data;
	if ( (key_index = lookup_printerkey( p_data, printerdatakey )) == -1  ) {
		/* failure....should never happen if the client has a valid open handle first */
		DEBUG(10,("key_printers_fetch_values: Unknown keyname [%s]\n", printerdatakey));
		if ( printer )
			free_a_printer( &printer, 2 );
		return -1;
	}
	
	num_values = regval_ctr_numvals( p_data->keys[key_index].values );	
	for ( i=0; i<num_values; i++ )
		regval_ctr_copyvalue( values, regval_ctr_specific_value(p_data->keys[key_index].values, i) );
			

done:
	if ( printer )
		free_a_printer( &printer, 2 );
		
	return regval_ctr_numvals( values );
}
示例#2
0
static int key_forms_fetch_values( const char *key, REGVAL_CTR *values )
{
	uint32 		data[8];
	int		i, num_values, form_index = 1;
	nt_forms_struct *forms_list = NULL;
	nt_forms_struct *form;
		
	DEBUG(10,("print_values_forms: key=>[%s]\n", key ? key : "NULL" ));
	
	num_values = get_ntforms( &forms_list );
		
	DEBUG(10,("hive_forms_fetch_values: [%d] user defined forms returned\n",
		num_values));

	/* handle user defined forms */
				
	for ( i=0; i<num_values; i++ ) {
		form = &forms_list[i];
			
		data[0] = form->width;
		data[1] = form->length;
		data[2] = form->left;
		data[3] = form->top;
		data[4] = form->right;
		data[5] = form->bottom;
		data[6] = form_index++;
		data[7] = form->flag;
			
		regval_ctr_addvalue( values, form->name, REG_BINARY, (char*)data, sizeof(data) );	
	}
		
	SAFE_FREE( forms_list );
	forms_list = NULL;
		
	/* handle built-on forms */
		
	num_values = get_builtin_ntforms( &forms_list );
		
	DEBUG(10,("print_subpath_values_forms: [%d] built-in forms returned\n",
		num_values));
			
	for ( i=0; i<num_values; i++ ) {
		form = &forms_list[i];
			
		data[0] = form->width;
		data[1] = form->length;
		data[2] = form->left;
		data[3] = form->top;
		data[4] = form->right;
		data[5] = form->bottom;
		data[6] = form_index++;
		data[7] = form->flag;
					
		regval_ctr_addvalue( values, form->name, REG_BINARY, (char*)data, sizeof(data) );
	}
		
	SAFE_FREE( forms_list );
	
	return regval_ctr_numvals( values );
}
static int hkpt_params_fetch_values(const char *key, REGVAL_CTR *regvals)
{
	uint32 base_index;
	uint32 buffer_size;
	char *buffer = NULL;

	/* This is ALMOST the same as perflib_009_params, but HKPT has
	   a "Counters" entry instead of a "Counter" key. <Grrrr> */

	base_index = reg_perfcount_get_base_index();
	buffer_size = reg_perfcount_get_counter_names(base_index, &buffer);
	regval_ctr_addvalue(regvals, "Counters", REG_MULTI_SZ, buffer,
			    buffer_size);

	if(buffer_size > 0) {
		SAFE_FREE(buffer);
	}

	buffer_size = reg_perfcount_get_counter_help(base_index, &buffer);
	regval_ctr_addvalue(regvals, "Help", REG_MULTI_SZ, buffer, buffer_size);
	if(buffer_size > 0) {
		SAFE_FREE(buffer);
	}

	return regval_ctr_numvals( regvals );
}
示例#4
0
文件: reg_db.c 项目: AllardJ/Tomato
static int regdb_pack_values(REGVAL_CTR *values, char *buf, int buflen)
{
	int 		len = 0;
	int 		i;
	REGISTRY_VALUE	*val;
	int		num_values;

	if ( !values )
		return 0;

	num_values = regval_ctr_numvals( values );

	/* pack the number of values first */
	
	len += tdb_pack( buf+len, buflen-len, "d", num_values );
	
	/* loop over all values */
		
	for ( i=0; i<num_values; i++ ) {			
		val = regval_ctr_specific_value( values, i );
		len += tdb_pack(buf+len, buflen-len, "fdB",
				regval_name(val),
				regval_type(val),
				regval_size(val),
				regval_data_p(val) );
	}

	return len;
}
static int prod_options_fetch_values(const char *key, REGVAL_CTR *regvals)
{
	const char *value_ascii = "";
	fstring value;
	int value_length;

	switch (lp_server_role()) {
		case ROLE_DOMAIN_PDC:
		case ROLE_DOMAIN_BDC:
			value_ascii = "LanmanNT";
			break;
		case ROLE_STANDALONE:
			value_ascii = "ServerNT";
			break;
		case ROLE_DOMAIN_MEMBER:
			value_ascii = "WinNT";
			break;
	}

	value_length = push_ucs2(value, value, value_ascii, sizeof(value),
				 STR_TERMINATE|STR_NOALIGN );
	regval_ctr_addvalue(regvals, "ProductType", REG_SZ, value,
			    value_length);

	return regval_ctr_numvals( regvals );
}
示例#6
0
static BOOL key_printers_store_values( const char *key, REGVAL_CTR *values )
{
	char *printers_key;
	char *printername, *keyname;
	NT_PRINTER_INFO_LEVEL   *printer = NULL;
	WERROR result;
	
	printers_key = strip_printers_prefix( key );
	
	/* values in the top level key get stored in the registry */

	if ( !printers_key ) {
		/* normalize on the 'HKLM\SOFTWARE\....\Print\Printers' key */
		return regdb_store_values( KEY_WINNT_PRINTERS, values );
	}
	
	if (!reg_split_path( printers_key, &printername, &keyname )) {
		return False;
	}

	if ( !W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, printername) ) )
		return False;

	/* deal with setting values directly under the printername */

	if ( !keyname ) {
		convert_values_to_printer_info_2( printer->info_2, values );
	}
	else {
		int num_values = regval_ctr_numvals( values );
		int i;
		REGISTRY_VALUE *val;
		
		delete_printer_key( printer->info_2->data, keyname );
		
		/* deal with any subkeys */
		for ( i=0; i<num_values; i++ ) {
			val = regval_ctr_specific_value( values, i );
			result = set_printer_dataex( printer, keyname, 
				regval_name( val ),
				regval_type( val ),
				regval_data_p( val ),
				regval_size( val ) );
			if ( !W_ERROR_IS_OK(result) ) {
				DEBUG(0,("key_printers_store_values: failed to set printer data [%s]!\n",
					keyname));
				free_a_printer( &printer, 2 );
				return False;
			}
		}
	}

	result = mod_a_printer( printer, 2 );

	free_a_printer( &printer, 2 );

	return W_ERROR_IS_OK(result);
}
示例#7
0
static int perflib_params(struct regval_ctr *regvals)
{
	int base_index = -1;
	int last_counter = -1;
	int last_help = -1;
	int version = 0x00010001;
	
	base_index = reg_perfcount_get_base_index();
	regval_ctr_addvalue(regvals, "Base Index", REG_DWORD, (uint8_t *)&base_index, sizeof(base_index));
	last_counter = reg_perfcount_get_last_counter(base_index);
	regval_ctr_addvalue(regvals, "Last Counter", REG_DWORD, (uint8_t *)&last_counter, sizeof(last_counter));
	last_help = reg_perfcount_get_last_help(last_counter);
	regval_ctr_addvalue(regvals, "Last Help", REG_DWORD, (uint8_t *)&last_help, sizeof(last_help));
	regval_ctr_addvalue(regvals, "Version", REG_DWORD, (uint8_t *)&version, sizeof(version));

	return regval_ctr_numvals( regvals );
}
示例#8
0
static int perflib_009_params(struct regval_ctr *regvals)
{
	int base_index;
	int buffer_size;
	char *buffer = NULL;

	base_index = reg_perfcount_get_base_index();
	buffer_size = reg_perfcount_get_counter_names(base_index, &buffer);
	regval_ctr_addvalue(regvals, "Counter", REG_MULTI_SZ, (uint8_t *)buffer, buffer_size);
	if(buffer_size > 0)
		SAFE_FREE(buffer);
	buffer_size = reg_perfcount_get_counter_help(base_index, &buffer);
	regval_ctr_addvalue(regvals, "Help", REG_MULTI_SZ, (uint8_t *)buffer, buffer_size);
	if(buffer_size > 0)
		SAFE_FREE(buffer);
	
	return regval_ctr_numvals( regvals );
}
static int prod_options_fetch_values(const char *key, struct regval_ctr *regvals)
{
	const char *value_ascii = "";

	switch (lp_server_role()) {
		case ROLE_DOMAIN_PDC:
		case ROLE_DOMAIN_BDC:
			value_ascii = "LanmanNT";
			break;
		case ROLE_STANDALONE:
			value_ascii = "ServerNT";
			break;
		case ROLE_DOMAIN_MEMBER:
			value_ascii = "WinNT";
			break;
	}

	regval_ctr_addvalue_sz(regvals, "ProductType", value_ascii);

	return regval_ctr_numvals( regvals );
}
示例#10
0
文件: reg_db.c 项目: AllardJ/Tomato
int regdb_fetch_values( const char* key, REGVAL_CTR *values )
{
	TDB_DATA data;
	pstring keystr;

	DEBUG(10,("regdb_fetch_values: Looking for value of key [%s] \n", key));
	
	pstr_sprintf( keystr, "%s/%s", VALUE_PREFIX, key );
	normalize_reg_path( keystr );
	
	data = tdb_fetch_bystring( tdb_reg, keystr );
	
	if ( !data.dptr ) {
		/* all keys have zero values by default */
		return 0;
	}
	
	regdb_unpack_values( values, data.dptr, data.dsize );
	
	SAFE_FREE( data.dptr );
	
	return regval_ctr_numvals(values);
}
示例#11
0
static int driver_arch_fetch_values( char *key, REGVAL_CTR *values )
{
	char 		*keystr, *base, *subkeypath;
	fstring		arch_environment;
	fstring		driver;
	int		version;
	NT_PRINTER_DRIVER_INFO_LEVEL	driver_ctr;
	WERROR		w_result;

	if (!reg_split_path( key, &base, &subkeypath )) {
		return -1;
	}
	
	/* no values in 'Environments\Drivers\Windows NT x86' */
	
	if ( !subkeypath ) 
		return 0;
		
	/* We have the Architecture string and some subkey name:
	   Currently we only support
	   * Drivers
	   * Print Processors
	   Anything else is an error.
	   */

	fstrcpy( arch_environment, base );
	
	keystr = subkeypath;
	if (!reg_split_path( keystr, &base, &subkeypath )) {
		return -1;
	}

	if ( strequal(base, "Print Processors") )
		return 0;

	/* only Drivers key can be left */
		
	if ( !strequal(base, "Drivers") )
		return -1;
			
	if ( !subkeypath )
		return 0;
	
	/* We know that we have Architechure\Drivers with some subkey name
	   The subkey name has to be Version-XX */
	
	keystr = subkeypath;
	if (!reg_split_path( keystr, &base, &subkeypath )) {
		return -1;
	}

	if ( !subkeypath )
		return 0;
		
	version = atoi(&base[strlen(base)-1]);

	/* BEGIN PRINTER DRIVER NAME BLOCK */
	
	keystr = subkeypath;
	if (!reg_split_path( keystr, &base, &subkeypath )) {
		return -1;
	}
	
	/* don't go any deeper for now */
	
	fstrcpy( driver, base );
	
	w_result = get_a_printer_driver( &driver_ctr, 3, driver, arch_environment, version );

	if ( !W_ERROR_IS_OK(w_result) )
		return -1;
		
	fill_in_driver_values( driver_ctr.info_3, values ); 
	
	free_a_printer_driver( driver_ctr, 3 );

	/* END PRINTER DRIVER NAME BLOCK */

						
	DEBUG(8,("key_driver_fetch_values: Exit\n"));
	
	return regval_ctr_numvals( values );
}
示例#12
0
static void convert_values_to_printer_info_2( NT_PRINTER_INFO_LEVEL_2 *printer2, REGVAL_CTR *values )
{
	int num_values = regval_ctr_numvals( values );
	uint32 value_index;
	REGISTRY_VALUE *val;
	int i;
	
	for ( i=0; i<num_values; i++ ) {
		val = regval_ctr_specific_value( values, i );
		value_index = find_valuename_index( regval_name( val ) );
		
		switch( value_index ) {
			case REG_IDX_ATTRIBUTES:
				printer2->attributes = (uint32)(*regval_data_p(val));
				break;
			case REG_IDX_PRIORITY:
				printer2->priority = (uint32)(*regval_data_p(val));
				break;
			case REG_IDX_DEFAULT_PRIORITY:
				printer2->default_priority = (uint32)(*regval_data_p(val));
				break;
			case REG_IDX_CHANGEID:
				printer2->changeid = (uint32)(*regval_data_p(val));
				break;
			case REG_IDX_STARTTIME:
				printer2->starttime = (uint32)(*regval_data_p(val));
				break;
			case REG_IDX_UNTILTIME:
				printer2->untiltime = (uint32)(*regval_data_p(val));
				break;
			case REG_IDX_NAME:
				rpcstr_pull( printer2->printername, regval_data_p(val), sizeof(fstring), regval_size(val), 0 );
				break;
			case REG_IDX_LOCATION:
				rpcstr_pull( printer2->location, regval_data_p(val), sizeof(fstring), regval_size(val), 0 );
				break;
			case REG_IDX_DESCRIPTION:
				rpcstr_pull( printer2->comment, regval_data_p(val), sizeof(fstring), regval_size(val), 0 );
				break;
			case REG_IDX_PARAMETERS:
				rpcstr_pull( printer2->parameters, regval_data_p(val), sizeof(fstring), regval_size(val), 0 );
				break;
			case REG_IDX_PORT:
				rpcstr_pull( printer2->portname, regval_data_p(val), sizeof(fstring), regval_size(val), 0 );
				break;
			case REG_IDX_SHARENAME:
				rpcstr_pull( printer2->sharename, regval_data_p(val), sizeof(fstring), regval_size(val), 0 );
				break;
			case REG_IDX_DRIVER:
				rpcstr_pull( printer2->drivername, regval_data_p(val), sizeof(fstring), regval_size(val), 0 );
				break;
			case REG_IDX_SEP_FILE:
				rpcstr_pull( printer2->sepfile, regval_data_p(val), sizeof(fstring), regval_size(val), 0 );
				break;
			case REG_IDX_PRINTPROC:
				rpcstr_pull( printer2->printprocessor, regval_data_p(val), sizeof(fstring), regval_size(val), 0 );
				break;
			case REG_IDX_DATATYPE:
				rpcstr_pull( printer2->datatype, regval_data_p(val), sizeof(fstring), regval_size(val), 0 );
				break;
			case REG_IDX_DEVMODE:
				break;
			case REG_IDX_SECDESC:
				break;		
			default:
				/* unsupported value...throw away */
				DEBUG(8,("convert_values_to_printer_info_2: Unsupported registry value [%s]\n", 
					regval_name( val ) ));
		}
	}
	
	return;
}	
示例#13
0
WERROR get_remote_printer_publishing_data(struct rpc_pipe_client *cli,
        TALLOC_CTX *mem_ctx,
        ADS_MODLIST *mods,
        const char *printer)
{
    WERROR result;
    char *printername, *servername;
    REGVAL_CTR *dsdriver_ctr, *dsspooler_ctr;
    uint32 i;
    POLICY_HND pol;

    asprintf(&servername, "\\\\%s", cli->cli->desthost);
    asprintf(&printername, "%s\\%s", servername, printer);
    if (!servername || !printername) {
        DEBUG(3, ("Insufficient memory\n"));
        return WERR_NOMEM;
    }

    result = rpccli_spoolss_open_printer_ex(cli, mem_ctx, printername,
                                            "", MAXIMUM_ALLOWED_ACCESS,
                                            servername, cli->cli->user_name, &pol);
    if (!W_ERROR_IS_OK(result)) {
        DEBUG(3, ("Unable to open printer %s, error is %s.\n",
                  printername, dos_errstr(result)));
        SAFE_FREE(printername);
        return result;
    }

    if ( !(dsdriver_ctr = TALLOC_ZERO_P( mem_ctx, REGVAL_CTR )) ) {
        SAFE_FREE(printername);
        return WERR_NOMEM;
    }

    result = rpccli_spoolss_enumprinterdataex(cli, mem_ctx, &pol, SPOOL_DSDRIVER_KEY, dsdriver_ctr);

    if (!W_ERROR_IS_OK(result)) {
        DEBUG(3, ("Unable to do enumdataex on %s, error is %s.\n",
                  printername, dos_errstr(result)));
    } else {
        uint32 num_values = regval_ctr_numvals( dsdriver_ctr );

        /* Have the data we need now, so start building */
        for (i=0; i < num_values; i++) {
            map_regval_to_ads(mem_ctx, mods, dsdriver_ctr->values[i]);
        }
    }

    if ( !(dsspooler_ctr = TALLOC_ZERO_P( mem_ctx, REGVAL_CTR )) ) {
        SAFE_FREE(printername);
        return WERR_NOMEM;
    }

    result = rpccli_spoolss_enumprinterdataex(cli, mem_ctx, &pol, SPOOL_DSSPOOLER_KEY, dsspooler_ctr);

    if (!W_ERROR_IS_OK(result)) {
        DEBUG(3, ("Unable to do enumdataex on %s, error is %s.\n",
                  printername, dos_errstr(result)));
    } else {
        uint32 num_values = regval_ctr_numvals( dsspooler_ctr );

        for (i=0; i<num_values; i++) {
            map_regval_to_ads(mem_ctx, mods, dsspooler_ctr->values[i]);
        }
    }

    ads_mod_str(mem_ctx, mods, SPOOL_REG_PRINTERNAME, printer);

    TALLOC_FREE( dsdriver_ctr );
    TALLOC_FREE( dsspooler_ctr );

    rpccli_spoolss_close_printer(cli, mem_ctx, &pol);
    SAFE_FREE(printername);

    return result;
}