summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2009-09-23 20:46:08 +0200
committerGünther Deschner <gd@samba.org>2009-09-30 00:29:49 +0200
commit2c11b73391551723e4ada8664b1ba77873420217 (patch)
tree9cd85bb729c6aa7e2801ebbcd9acbed39f7e8054
parentfcee9d2c97a673347baf58f749f35785a896e468 (diff)
downloadsamba-2c11b73391551723e4ada8664b1ba77873420217.tar.gz
samba-2c11b73391551723e4ada8664b1ba77873420217.tar.bz2
samba-2c11b73391551723e4ada8664b1ba77873420217.zip
s3-registry: use push_reg_sz().
Guenther
-rw-r--r--source3/printing/nt_printing.c24
-rw-r--r--source3/registry/reg_backend_db.c8
-rw-r--r--source3/registry/reg_backend_printing.c79
-rw-r--r--source3/registry/reg_eventlog.c40
-rw-r--r--source3/registry/reg_perfcount.c10
-rw-r--r--source3/registry/reg_util.c16
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c32
-rw-r--r--source3/services/services_db.c30
-rw-r--r--source3/utils/net_rpc_printer.c17
9 files changed, 123 insertions, 133 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index b75e30bb3e..f7591c19f5 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -3167,7 +3167,7 @@ static void store_printer_guid(NT_PRINTER_INFO_LEVEL_2 *info2,
{
int i;
struct regval_ctr *ctr=NULL;
- UNISTR2 unistr_guid;
+ DATA_BLOB unistr_guid;
/* find the DsSpooler key */
if ((i = lookup_printerkey(info2->data, SPOOL_DSSPOOLER_KEY)) < 0)
@@ -3179,14 +3179,11 @@ static void store_printer_guid(NT_PRINTER_INFO_LEVEL_2 *info2,
/* We used to store this as a REG_BINARY but that causes
Vista to whine */
- ZERO_STRUCT( unistr_guid );
-
- init_unistr2( &unistr_guid, GUID_string(talloc_tos(), &guid),
- UNI_STR_TERMINATE );
+ push_reg_sz(talloc_tos(), &unistr_guid, GUID_string(talloc_tos(), &guid));
regval_ctr_addvalue(ctr, "objectGUID", REG_SZ,
- (char *)unistr_guid.buffer,
- unistr_guid.uni_max_len*2);
+ (char *)unistr_guid.data,
+ unistr_guid.length);
}
@@ -3784,22 +3781,19 @@ static int unpack_values(NT_PRINTER_DATA *printer_data, const uint8 *buf, int bu
strequal( valuename, "objectGUID" ) )
{
struct GUID guid;
- UNISTR2 unistr_guid;
-
- ZERO_STRUCT( unistr_guid );
+ DATA_BLOB unistr_guid;
/* convert the GUID to a UNICODE string */
memcpy( &guid, data_p, sizeof(struct GUID) );
- init_unistr2( &unistr_guid,
- GUID_string(talloc_tos(), &guid),
- UNI_STR_TERMINATE );
+ push_reg_sz(&talloc_tos, &unistr_guid,
+ GUID_string(talloc_tos(), &guid));
regval_ctr_addvalue( printer_data->keys[key_index].values,
valuename, REG_SZ,
- (const char *)unistr_guid.buffer,
- unistr_guid.uni_str_len*2 );
+ (const char *)unistr_guid.data,
+ unistr_guid.length);
} else {
/* add the value */
diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c
index dec43ae741..b9ff5dc7fc 100644
--- a/source3/registry/reg_backend_db.c
+++ b/source3/registry/reg_backend_db.c
@@ -250,7 +250,7 @@ WERROR init_registry_key(const char *add_path)
static void regdb_ctr_add_value(struct regval_ctr *ctr,
struct builtin_regkey_value *value)
{
- UNISTR2 data;
+ DATA_BLOB data;
switch(value->type) {
case REG_DWORD:
@@ -260,10 +260,10 @@ static void regdb_ctr_add_value(struct regval_ctr *ctr,
break;
case REG_SZ:
- init_unistr2(&data, value->data.string, UNI_STR_TERMINATE);
+ push_reg_sz(talloc_tos(), &data, value->data.string);
regval_ctr_addvalue(ctr, value->valuename, REG_SZ,
- (char*)data.buffer,
- data.uni_str_len*sizeof(uint16));
+ (char*)data.data,
+ data.length);
break;
default:
diff --git a/source3/registry/reg_backend_printing.c b/source3/registry/reg_backend_printing.c
index 8c6f673ace..2dc5d84215 100644
--- a/source3/registry/reg_backend_printing.c
+++ b/source3/registry/reg_backend_printing.c
@@ -386,7 +386,7 @@ static bool key_printers_store_keys( const char *key, struct regsubkey_ctr *subk
static void fill_in_printer_values(NT_PRINTER_INFO_LEVEL_2 *info2, struct regval_ctr *values)
{
struct spoolss_DeviceMode *devmode;
- UNISTR2 data;
+ DATA_BLOB data;
char *p;
uint32 printer_status = PRINTER_STATUS_OK;
@@ -406,35 +406,36 @@ static void fill_in_printer_values(NT_PRINTER_INFO_LEVEL_2 *info2, struct regval
p = info2->printername;
else
p++;
- init_unistr2( &data, p, UNI_STR_TERMINATE);
- regval_ctr_addvalue( values, "Name", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) );
- init_unistr2( &data, info2->location, UNI_STR_TERMINATE);
- regval_ctr_addvalue( values, "Location", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) );
+ push_reg_sz(talloc_tos(), &data, p);
+ regval_ctr_addvalue( values, "Name", REG_SZ, (char*)data.data, data.length);
- init_unistr2( &data, info2->comment, UNI_STR_TERMINATE);
- regval_ctr_addvalue( values, "Description", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) );
+ push_reg_sz(talloc_tos(), &data, info2->location);
+ regval_ctr_addvalue( values, "Location", REG_SZ, (char*)data.data, data.length);
- init_unistr2( &data, info2->parameters, UNI_STR_TERMINATE);
- regval_ctr_addvalue( values, "Parameters", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) );
+ push_reg_sz(talloc_tos(), &data, info2->comment);
+ regval_ctr_addvalue( values, "Description", REG_SZ, (char*)data.data, data.length);
- init_unistr2( &data, info2->portname, UNI_STR_TERMINATE);
- regval_ctr_addvalue( values, "Port", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) );
+ push_reg_sz(talloc_tos(), &data, info2->parameters);
+ regval_ctr_addvalue( values, "Parameters", REG_SZ, (char*)data.data, data.length);
- init_unistr2( &data, info2->sharename, UNI_STR_TERMINATE);
- regval_ctr_addvalue( values, "Share Name", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) );
+ push_reg_sz(talloc_tos(), &data, info2->portname);
+ regval_ctr_addvalue( values, "Port", REG_SZ, (char*)data.data, data.length);
- init_unistr2( &data, info2->drivername, UNI_STR_TERMINATE);
- regval_ctr_addvalue( values, "Printer Driver", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) );
+ push_reg_sz(talloc_tos(), &data, info2->sharename);
+ regval_ctr_addvalue( values, "Share Name", REG_SZ, (char*)data.data, data.length);
- init_unistr2( &data, info2->sepfile, UNI_STR_TERMINATE);
- regval_ctr_addvalue( values, "Separator File", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) );
+ push_reg_sz(talloc_tos(), &data, info2->drivername);
+ regval_ctr_addvalue( values, "Printer Driver", REG_SZ, (char*)data.data, data.length);
- init_unistr2( &data, "WinPrint", UNI_STR_TERMINATE);
- regval_ctr_addvalue( values, "Print Processor", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) );
+ push_reg_sz(talloc_tos(), &data, info2->sepfile);
+ regval_ctr_addvalue( values, "Separator File", REG_SZ, (char*)data.data, data.length);
- init_unistr2( &data, "RAW", UNI_STR_TERMINATE);
- regval_ctr_addvalue( values, "Datatype", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) );
+ push_reg_sz(talloc_tos(), &data, "WinPrint");
+ regval_ctr_addvalue( values, "Print Processor", REG_SZ, (char*)data.data, data.length);
+
+ push_reg_sz(talloc_tos(), &data, "RAW");
+ regval_ctr_addvalue( values, "Datatype", REG_SZ, (char*)data.data, data.length);
/* stream the device mode */
@@ -894,31 +895,31 @@ static void fill_in_driver_values(NT_PRINTER_DRIVER_INFO_LEVEL_3 *info3, struct
int buffer_size = 0;
int i, length;
const char *filename;
- UNISTR2 data;
+ DATA_BLOB data;
filename = dos_basename( info3->driverpath );
- init_unistr2( &data, filename, UNI_STR_TERMINATE);
- regval_ctr_addvalue( values, "Driver", REG_SZ, (char*)data.buffer,
- data.uni_str_len*sizeof(uint16) );
+ push_reg_sz(talloc_tos(), &data, filename);
+ regval_ctr_addvalue( values, "Driver", REG_SZ,
+ (char *)data.data, data.length);
filename = dos_basename( info3->configfile );
- init_unistr2( &data, filename, UNI_STR_TERMINATE);
- regval_ctr_addvalue( values, "Configuration File", REG_SZ, (char*)data.buffer,
- data.uni_str_len*sizeof(uint16) );
+ push_reg_sz(talloc_tos(), &data, filename);
+ regval_ctr_addvalue( values, "Configuration File", REG_SZ,
+ (char *)data.data, data.length);
filename = dos_basename( info3->datafile );
- init_unistr2( &data, filename, UNI_STR_TERMINATE);
- regval_ctr_addvalue( values, "Data File", REG_SZ, (char*)data.buffer,
- data.uni_str_len*sizeof(uint16) );
+ push_reg_sz(talloc_tos(), &data, filename);
+ regval_ctr_addvalue( values, "Data File", REG_SZ,
+ (char *)data.data, data.length);
filename = dos_basename( info3->helpfile );
- init_unistr2( &data, filename, UNI_STR_TERMINATE);
- regval_ctr_addvalue( values, "Help File", REG_SZ, (char*)data.buffer,
- data.uni_str_len*sizeof(uint16) );
+ push_reg_sz(talloc_tos(), &data, filename);
+ regval_ctr_addvalue( values, "Help File", REG_SZ,
+ (char *)data.data, data.length);
- init_unistr2( &data, info3->defaultdatatype, UNI_STR_TERMINATE);
- regval_ctr_addvalue( values, "Data Type", REG_SZ, (char*)data.buffer,
- data.uni_str_len*sizeof(uint16) );
+ push_reg_sz(talloc_tos(), &data, info3->defaultdatatype);
+ regval_ctr_addvalue( values, "Data Type", REG_SZ,
+ (char *)data.data, data.length);
regval_ctr_addvalue( values, "Version", REG_DWORD, (char*)&info3->cversion,
sizeof(info3->cversion) );
@@ -940,8 +941,8 @@ static void fill_in_driver_values(NT_PRINTER_DRIVER_INFO_LEVEL_3 *info3, struct
break;
}
- init_unistr2( &data, filename, UNI_STR_TERMINATE);
- memcpy( buffer+buffer_size, (char*)data.buffer, data.uni_str_len*sizeof(uint16) );
+ push_reg_sz(talloc_tos(), &data, filename);
+ memcpy( buffer+buffer_size, (char*)data.data, data.length);
buffer_size += (length + 1)*sizeof(uint16);
}
diff --git a/source3/registry/reg_eventlog.c b/source3/registry/reg_eventlog.c
index 45ade52102..c0d5b95b0b 100644
--- a/source3/registry/reg_eventlog.c
+++ b/source3/registry/reg_eventlog.c
@@ -40,7 +40,7 @@ bool eventlog_init_keys(void)
uint32 uiMaxSize;
uint32 uiRetention;
uint32 uiCategoryCount;
- UNISTR2 data;
+ DATA_BLOB data;
TALLOC_CTX *ctx = talloc_tos();
WERROR werr;
@@ -114,18 +114,16 @@ bool eventlog_init_keys(void)
regval_ctr_addvalue(values, "Retention", REG_DWORD,
(char *)&uiRetention,
sizeof(uint32));
- init_unistr2(&data, *elogs, UNI_STR_TERMINATE);
+ push_reg_sz(talloc_tos(), &data, *elogs);
regval_ctr_addvalue(values, "PrimaryModule", REG_SZ,
- (char *)data.buffer,
- data.uni_str_len *
- sizeof(uint16));
- init_unistr2(&data, *elogs, UNI_STR_TERMINATE);
+ (char *)data.data,
+ data.length);
+ push_reg_sz(talloc_tos(), &data, *elogs);
regval_ctr_addvalue(values, "Sources", REG_MULTI_SZ,
- (char *)data.buffer,
- data.uni_str_len *
- sizeof(uint16));
+ (char *)data.data,
+ data.length);
evtfilepath = talloc_asprintf(ctx,
"%%SystemRoot%%\\system32\\config\\%s.tdb",
@@ -133,9 +131,9 @@ bool eventlog_init_keys(void)
if (!evtfilepath) {
TALLOC_FREE(values);
}
- init_unistr2(&data, evtfilepath, UNI_STR_TERMINATE);
- regval_ctr_addvalue(values, "File", REG_EXPAND_SZ, (char *)data.buffer,
- data.uni_str_len * sizeof(uint16));
+ push_reg_sz(talloc_tos(), &data, evtfilepath);
+ regval_ctr_addvalue(values, "File", REG_EXPAND_SZ, (char *)data.data,
+ data.length);
regdb_store_values(evtlogpath, values);
}
@@ -166,15 +164,13 @@ bool eventlog_init_keys(void)
REG_DWORD,
( char * ) &uiCategoryCount,
sizeof( uint32 ) );
- init_unistr2( &data,
- "%SystemRoot%\\system32\\eventlog.dll",
- UNI_STR_TERMINATE );
+ push_reg_sz(talloc_tos(), &data,
+ "%SystemRoot%\\system32\\eventlog.dll");
regval_ctr_addvalue( values, "CategoryMessageFile",
REG_EXPAND_SZ,
- ( char * ) data.buffer,
- data.uni_str_len *
- sizeof( uint16 ) );
+ ( char * ) data.data,
+ data.length);
regdb_store_values( evtlogpath, values );
}
TALLOC_FREE(values);
@@ -203,7 +199,7 @@ bool eventlog_add_source( const char *eventlog, const char *sourcename,
struct regsubkey_ctr *subkeys;
struct regval_ctr *values;
struct regval_blob *rval;
- UNISTR2 data;
+ DATA_BLOB data;
uint16 *msz_wp;
int mbytes, ii;
bool already_in;
@@ -373,11 +369,11 @@ bool eventlog_add_source( const char *eventlog, const char *sourcename,
regdb_fetch_values( evtlogpath, values );
- init_unistr2( &data, messagefile, UNI_STR_TERMINATE );
+ push_reg_sz(talloc_tos(), &data, messagefile);
regval_ctr_addvalue( values, "EventMessageFile", REG_SZ,
- ( char * ) data.buffer,
- data.uni_str_len * sizeof( uint16 ) );
+ ( char * ) data.data,
+ data.length);
regdb_store_values( evtlogpath, values );
TALLOC_FREE(values);
diff --git a/source3/registry/reg_perfcount.c b/source3/registry/reg_perfcount.c
index 14716b2f53..ea4ccbf58f 100644
--- a/source3/registry/reg_perfcount.c
+++ b/source3/registry/reg_perfcount.c
@@ -161,7 +161,7 @@ static uint32 _reg_perfcount_multi_sz_from_tdb(TDB_CONTEXT *tdb,
char temp[256];
char *buf1 = *retbuf;
uint32 working_size = 0;
- UNISTR2 name_index, name;
+ DATA_BLOB name_index, name;
memset(temp, 0, sizeof(temp));
snprintf(temp, sizeof(temp), "%d", keyval);
@@ -182,8 +182,8 @@ static uint32 _reg_perfcount_multi_sz_from_tdb(TDB_CONTEXT *tdb,
buffer_size = 0;
return buffer_size;
}
- init_unistr2(&name_index, (const char *)kbuf.dptr, UNI_STR_TERMINATE);
- memcpy(buf1+buffer_size, (char *)name_index.buffer, working_size);
+ push_reg_sz(talloc_tos(), &name_index, (const char *)kbuf.dptr);
+ memcpy(buf1+buffer_size, (char *)name_index.data, working_size);
buffer_size += working_size;
/* Now encode the actual name */
working_size = (dbuf.dsize + 1)*sizeof(uint16);
@@ -195,8 +195,8 @@ static uint32 _reg_perfcount_multi_sz_from_tdb(TDB_CONTEXT *tdb,
memset(temp, 0, sizeof(temp));
memcpy(temp, dbuf.dptr, dbuf.dsize);
SAFE_FREE(dbuf.dptr);
- init_unistr2(&name, temp, UNI_STR_TERMINATE);
- memcpy(buf1+buffer_size, (char *)name.buffer, working_size);
+ push_reg_sz(talloc_tos(), &name, temp);
+ memcpy(buf1+buffer_size, (char *)name.data, working_size);
buffer_size += working_size;
*retbuf = buf1;
diff --git a/source3/registry/reg_util.c b/source3/registry/reg_util.c
index 714a39f307..3b0885db82 100644
--- a/source3/registry/reg_util.c
+++ b/source3/registry/reg_util.c
@@ -221,7 +221,7 @@ size_t regval_build_multi_sz( char **values, uint16 **buffer )
int i;
size_t buf_size = 0;
uint16 *buf, *b;
- UNISTR2 sz;
+ DATA_BLOB sz;
if ( !values || !buffer )
return 0;
@@ -234,14 +234,14 @@ size_t regval_build_multi_sz( char **values, uint16 **buffer )
}
for ( i=0; values[i]; i++ ) {
- ZERO_STRUCT( sz );
+
/* DEBUG(0,("regval_build_multi_sz: building [%s]\n",values[i])); */
- init_unistr2( &sz, values[i], UNI_STR_TERMINATE );
+ push_reg_sz(talloc_tos(), &sz, values[i]);
/* Alloc some more memory. Always add one one to account for the
double NULL termination */
- b = TALLOC_REALLOC_ARRAY( NULL, buf, uint16, buf_size+sz.uni_str_len+1 );
+ b = TALLOC_REALLOC_ARRAY( NULL, buf, uint16, buf_size+sz.length/2+1 );
if ( !b ) {
DEBUG(0,("regval_build_multi_sz: talloc() reallocation error!\n"));
TALLOC_FREE( buffer );
@@ -250,12 +250,12 @@ size_t regval_build_multi_sz( char **values, uint16 **buffer )
buf = b;
/* copy the unistring2 buffer and increment the size */
- /* dump_data(1,sz.buffer,sz.uni_str_len*2); */
- memcpy( buf+buf_size, sz.buffer, sz.uni_str_len*2 );
- buf_size += sz.uni_str_len;
+ /* dump_data(1,sz.data,sz.length); */
+ memcpy( buf+buf_size, sz.data, sz.length);
+ buf_size += sz.length;
/* cleanup rather than leaving memory hanging around */
- TALLOC_FREE( sz.buffer );
+ TALLOC_FREE( sz.data );
}
buf[buf_size++] = 0x0;
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index a81b5772c0..682a59b5a8 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -6074,7 +6074,7 @@ static WERROR update_printer(pipes_struct *p, struct policy_handle *handle,
NT_PRINTER_INFO_LEVEL *printer = NULL, *old_printer = NULL;
Printer_entry *Printer = find_printer_index_by_hnd(p, handle);
WERROR result;
- UNISTR2 buffer;
+ DATA_BLOB buffer;
fstring asc_buffer;
DEBUG(8,("update_printer\n"));
@@ -6184,17 +6184,17 @@ static WERROR update_printer(pipes_struct *p, struct policy_handle *handle,
*/
if (!strequal(printer->info_2->comment, old_printer->info_2->comment)) {
- init_unistr2( &buffer, printer->info_2->comment, UNI_STR_TERMINATE);
+ push_reg_sz(talloc_tos(), &buffer, printer->info_2->comment);
set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "description",
- REG_SZ, (uint8_t *)buffer.buffer, buffer.uni_str_len*2 );
+ REG_SZ, buffer.data, buffer.length);
notify_printer_comment(snum, printer->info_2->comment);
}
if (!strequal(printer->info_2->sharename, old_printer->info_2->sharename)) {
- init_unistr2( &buffer, printer->info_2->sharename, UNI_STR_TERMINATE);
+ push_reg_sz(talloc_tos(), &buffer, printer->info_2->sharename);
set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "shareName",
- REG_SZ, (uint8_t *)buffer.buffer, buffer.uni_str_len*2 );
+ REG_SZ, buffer.data, buffer.length);
notify_printer_sharename(snum, printer->info_2->sharename);
}
@@ -6208,25 +6208,25 @@ static WERROR update_printer(pipes_struct *p, struct policy_handle *handle,
pname = printer->info_2->printername;
- init_unistr2( &buffer, pname, UNI_STR_TERMINATE);
+ push_reg_sz(talloc_tos(), &buffer, pname);
set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "printerName",
- REG_SZ, (uint8_t *)buffer.buffer, buffer.uni_str_len*2 );
+ REG_SZ, buffer.data, buffer.length);
notify_printer_printername( snum, pname );
}
if (!strequal(printer->info_2->portname, old_printer->info_2->portname)) {
- init_unistr2( &buffer, printer->info_2->portname, UNI_STR_TERMINATE);
+ push_reg_sz(talloc_tos(), &buffer, printer->info_2->portname);
set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "portName",
- REG_SZ, (uint8_t *)buffer.buffer, buffer.uni_str_len*2 );
+ REG_SZ, buffer.data, buffer.length);
notify_printer_port(snum, printer->info_2->portname);
}
if (!strequal(printer->info_2->location, old_printer->info_2->location)) {
- init_unistr2( &buffer, printer->info_2->location, UNI_STR_TERMINATE);
+ push_reg_sz(talloc_tos(), &buffer, printer->info_2->location);
set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "location",
- REG_SZ, (uint8_t *)buffer.buffer, buffer.uni_str_len*2 );
+ REG_SZ, buffer.data, buffer.length);
notify_printer_location(snum, printer->info_2->location);
}
@@ -6234,17 +6234,17 @@ static WERROR update_printer(pipes_struct *p, struct policy_handle *handle,
/* here we need to update some more DsSpooler keys */
/* uNCName, serverName, shortServerName */
- init_unistr2( &buffer, global_myname(), UNI_STR_TERMINATE);
+ push_reg_sz(talloc_tos(), &buffer, global_myname());
set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "serverName",
- REG_SZ, (uint8_t *)buffer.buffer, buffer.uni_str_len*2 );
+ REG_SZ, buffer.data, buffer.length);
set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "shortServerName",
- REG_SZ, (uint8_t *)buffer.buffer, buffer.uni_str_len*2 );
+ REG_SZ, buffer.data, buffer.length);
slprintf( asc_buffer, sizeof(asc_buffer)-1, "\\\\%s\\%s",
global_myname(), printer->info_2->sharename );
- init_unistr2( &buffer, asc_buffer, UNI_STR_TERMINATE);
+ push_reg_sz(talloc_tos(), &buffer, asc_buffer);
set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "uNCName",
- REG_SZ, (uint8_t *)buffer.buffer, buffer.uni_str_len*2 );
+ REG_SZ, buffer.data, buffer.length);
/* Update printer info */
result = mod_a_printer(printer, 2);
diff --git a/source3/services/services_db.c b/source3/services/services_db.c
index 85ea1f8cd4..1aeade8b98 100644
--- a/source3/services/services_db.c
+++ b/source3/services/services_db.c
@@ -250,7 +250,7 @@ static bool read_init_file( const char *servicename, struct rcinit_file_informat
static void fill_service_values(const char *name, struct regval_ctr *values)
{
- UNISTR2 data, dname, ipath, description;
+ DATA_BLOB data, dname, ipath, description;
uint32 dword;
int i;
@@ -268,8 +268,8 @@ static void fill_service_values(const char *name, struct regval_ctr *values)
/* everything runs as LocalSystem */
- init_unistr2( &data, "LocalSystem", UNI_STR_TERMINATE );
- regval_ctr_addvalue( values, "ObjectName", REG_SZ, (char*)data.buffer, data.uni_str_len*2);
+ push_reg_sz(talloc_tos(), &data, "LocalSystem");
+ regval_ctr_addvalue( values, "ObjectName", REG_SZ, (char *)data.data, data.length);
/* special considerations for internal services and the DisplayName value */
@@ -279,13 +279,13 @@ static void fill_service_values(const char *name, struct regval_ctr *values)
if (asprintf(&pstr, "%s/%s/%s",
get_dyn_MODULESDIR(), SVCCTL_SCRIPT_DIR,
builtin_svcs[i].daemon) > 0) {
- init_unistr2( &ipath, pstr, UNI_STR_TERMINATE );
+ push_reg_sz(talloc_tos(), &ipath, pstr);
SAFE_FREE(pstr);
} else {
- init_unistr2( &ipath, "", UNI_STR_TERMINATE );
+ push_reg_sz(talloc_tos(), &ipath, "");
}
- init_unistr2( &description, builtin_svcs[i].description, UNI_STR_TERMINATE );
- init_unistr2( &dname, builtin_svcs[i].dispname, UNI_STR_TERMINATE );
+ push_reg_sz(talloc_tos(), &description, builtin_svcs[i].description);
+ push_reg_sz(talloc_tos(), &dname, builtin_svcs[i].dispname);
break;
}
}
@@ -299,32 +299,32 @@ static void fill_service_values(const char *name, struct regval_ctr *values)
if (asprintf(&pstr, "%s/%s/%s",get_dyn_MODULESDIR(),
SVCCTL_SCRIPT_DIR, name) > 0) {
- init_unistr2( &ipath, pstr, UNI_STR_TERMINATE );
+ push_reg_sz(talloc_tos(), &ipath, pstr);
SAFE_FREE(pstr);
} else {
- init_unistr2( &ipath, "", UNI_STR_TERMINATE );
+ push_reg_sz(talloc_tos(), &ipath, "");
}
/* lookup common unix display names */
dispname = get_common_service_dispname(name);
- init_unistr2( &dname, dispname ? dispname : "", UNI_STR_TERMINATE );
+ push_reg_sz(talloc_tos(), &dname, dispname ? dispname : "");
SAFE_FREE(dispname);
/* get info from init file itself */
if ( read_init_file( name, &init_info ) ) {
- init_unistr2( &description, init_info->description, UNI_STR_TERMINATE );
+ push_reg_sz(talloc_tos(), &description, init_info->description);
TALLOC_FREE( init_info );
}
else {
- init_unistr2( &description, "External Unix Service", UNI_STR_TERMINATE );
+ push_reg_sz(talloc_tos(), &description, "External Unix Service");
}
}
/* add the new values */
- regval_ctr_addvalue( values, "DisplayName", REG_SZ, (char*)dname.buffer, dname.uni_str_len*2);
- regval_ctr_addvalue( values, "ImagePath", REG_SZ, (char*)ipath.buffer, ipath.uni_str_len*2);
- regval_ctr_addvalue( values, "Description", REG_SZ, (char*)description.buffer, description.uni_str_len*2);
+ regval_ctr_addvalue( values, "DisplayName", REG_SZ, (char*)dname.data, dname.length);
+ regval_ctr_addvalue( values, "ImagePath", REG_SZ, (char*)ipath.data, ipath.length);
+ regval_ctr_addvalue( values, "Description", REG_SZ, (char*)description.data, description.length);
return;
}
diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c
index ea7465e33a..c3924efc6a 100644
--- a/source3/utils/net_rpc_printer.c
+++ b/source3/utils/net_rpc_printer.c
@@ -2418,7 +2418,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
for (j=0; j < count; j++) {
struct regval_blob value;
- UNISTR2 data;
+ DATA_BLOB blob;
/* although samba replies with sane data in most cases we
should try to avoid writing wrong registry data */
@@ -2432,7 +2432,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
if (strequal(info[j].value_name, SPOOL_REG_PORTNAME)) {
/* although windows uses a multi-sz, we use a sz */
- init_unistr2(&data, SAMBA_PRINTER_PORT_NAME, UNI_STR_TERMINATE);
+ push_reg_sz(mem_ctx, &blob, SAMBA_PRINTER_PORT_NAME);
fstrcpy(value.valuename, SPOOL_REG_PORTNAME);
}
@@ -2442,7 +2442,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
nt_status = NT_STATUS_NO_MEMORY;
goto done;
}
- init_unistr2(&data, unc_name, UNI_STR_TERMINATE);
+ push_reg_sz(mem_ctx, &blob, unc_name);
fstrcpy(value.valuename, SPOOL_REG_UNCNAME);
}
@@ -2456,27 +2456,27 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
nt_status = NT_STATUS_NO_MEMORY;
goto done;
}
- init_unistr2(&data, url, UNI_STR_TERMINATE);
+ push_reg_sz(mem_ctx, &blob, url);
fstrcpy(value.valuename, SPOOL_REG_URL);
#endif
}
if (strequal(info[j].value_name, SPOOL_REG_SERVERNAME)) {
- init_unistr2(&data, longname, UNI_STR_TERMINATE);
+ push_reg_sz(mem_ctx, &blob, longname);
fstrcpy(value.valuename, SPOOL_REG_SERVERNAME);
}
if (strequal(info[j].value_name, SPOOL_REG_SHORTSERVERNAME)) {
- init_unistr2(&data, global_myname(), UNI_STR_TERMINATE);
+ push_reg_sz(mem_ctx, &blob, global_myname());
fstrcpy(value.valuename, SPOOL_REG_SHORTSERVERNAME);
}
value.type = REG_SZ;
- value.size = data.uni_str_len * 2;
+ value.size = blob.length;
if (value.size) {
- value.data_p = (uint8_t *)TALLOC_MEMDUP(mem_ctx, data.buffer, value.size);
+ value.data_p = blob.data;
} else {
value.data_p = NULL;
}
@@ -2492,7 +2492,6 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
} else {
struct regval_blob v;
- DATA_BLOB blob;
result = push_spoolss_PrinterData(mem_ctx, &blob,
info[j].type,