1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00

Remove pstrings.

Jeremy.
This commit is contained in:
Jeremy Allison 2007-12-04 15:45:20 -08:00
parent 063358d87a
commit e3c02796f8

View File

@ -108,7 +108,7 @@ static void display_print_driver_3(DRIVER_INFO_3 *i1)
static void display_reg_value(const char *subkey, REGISTRY_VALUE value) static void display_reg_value(const char *subkey, REGISTRY_VALUE value)
{ {
pstring text; char *text;
switch(value.type) { switch(value.type) {
case REG_DWORD: case REG_DWORD:
@ -117,8 +117,14 @@ static void display_reg_value(const char *subkey, REGISTRY_VALUE value)
break; break;
case REG_SZ: case REG_SZ:
rpcstr_pull(text, value.data_p, sizeof(text), value.size, rpcstr_pull_talloc(talloc_tos(),
STR_TERMINATE); &text,
value.data_p,
value.size,
STR_TERMINATE);
if (!text) {
break;
}
d_printf("\t[%s:%s]: REG_SZ: %s\n", subkey, value.valuename, text); d_printf("\t[%s:%s]: REG_SZ: %s\n", subkey, value.valuename, text);
break; break;
@ -1033,7 +1039,7 @@ NTSTATUS rpc_printer_list_internals(const DOM_SID *domain_sid,
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
uint32 i, num_printers; uint32 i, num_printers;
uint32 level = 2; uint32 level = 2;
pstring printername, sharename; char *printername, *sharename;
PRINTER_INFO_CTR ctr; PRINTER_INFO_CTR ctr;
printf("listing printers\n"); printf("listing printers\n");
@ -1042,15 +1048,22 @@ NTSTATUS rpc_printer_list_internals(const DOM_SID *domain_sid,
return nt_status; return nt_status;
for (i = 0; i < num_printers; i++) { for (i = 0; i < num_printers; i++) {
/* do some initialization */ /* do some initialization */
rpcstr_pull(printername, ctr.printers_2[i].printername.buffer, rpcstr_pull_talloc(mem_ctx,
sizeof(printername), -1, STR_TERMINATE); &printername,
rpcstr_pull(sharename, ctr.printers_2[i].sharename.buffer, ctr.printers_2[i].printername.buffer,
sizeof(sharename), -1, STR_TERMINATE); -1,
STR_TERMINATE);
rpcstr_pull_talloc(mem_ctx,
&sharename,
ctr.printers_2[i].sharename.buffer,
-1,
STR_TERMINATE);
d_printf("printer %d: %s, shared as: %s\n", if (printername && sharename) {
i+1, printername, sharename); d_printf("printer %d: %s, shared as: %s\n",
i+1, printername, sharename);
}
} }
return NT_STATUS_OK; return NT_STATUS_OK;
@ -1148,7 +1161,7 @@ static NTSTATUS rpc_printer_publish_internals_args(struct rpc_pipe_client *pipe_
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
uint32 i, num_printers; uint32 i, num_printers;
uint32 level = 7; uint32 level = 7;
pstring printername, sharename; char *printername, *sharename;
PRINTER_INFO_CTR ctr, ctr_pub; PRINTER_INFO_CTR ctr, ctr_pub;
POLICY_HND hnd; POLICY_HND hnd;
bool got_hnd = False; bool got_hnd = False;
@ -1159,12 +1172,20 @@ static NTSTATUS rpc_printer_publish_internals_args(struct rpc_pipe_client *pipe_
return nt_status; return nt_status;
for (i = 0; i < num_printers; i++) { for (i = 0; i < num_printers; i++) {
/* do some initialization */ /* do some initialization */
rpcstr_pull(printername, ctr.printers_2[i].printername.buffer, rpcstr_pull_talloc(mem_ctx,
sizeof(printername), -1, STR_TERMINATE); &printername,
rpcstr_pull(sharename, ctr.printers_2[i].sharename.buffer, ctr.printers_2[i].printername.buffer,
sizeof(sharename), -1, STR_TERMINATE); -1,
STR_TERMINATE);
rpcstr_pull_talloc(mem_ctx,
&sharename,
ctr.printers_2[i].sharename.buffer,
-1,
STR_TERMINATE);
if (!printername || !sharename) {
goto done;
}
/* open printer handle */ /* open printer handle */
if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename, if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename,
@ -1274,8 +1295,8 @@ NTSTATUS rpc_printer_publish_list_internals(const DOM_SID *domain_sid,
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
uint32 i, num_printers; uint32 i, num_printers;
uint32 level = 7; uint32 level = 7;
pstring printername, sharename; char *printername, *sharename;
pstring guid; char *guid;
PRINTER_INFO_CTR ctr, ctr_pub; PRINTER_INFO_CTR ctr, ctr_pub;
POLICY_HND hnd; POLICY_HND hnd;
bool got_hnd = False; bool got_hnd = False;
@ -1285,14 +1306,22 @@ NTSTATUS rpc_printer_publish_list_internals(const DOM_SID *domain_sid,
return nt_status; return nt_status;
for (i = 0; i < num_printers; i++) { for (i = 0; i < num_printers; i++) {
ZERO_STRUCT(ctr_pub); ZERO_STRUCT(ctr_pub);
/* do some initialization */ /* do some initialization */
rpcstr_pull(printername, ctr.printers_2[i].printername.buffer, rpcstr_pull_talloc(mem_ctx,
sizeof(printername), -1, STR_TERMINATE); &printername,
rpcstr_pull(sharename, ctr.printers_2[i].sharename.buffer, ctr.printers_2[i].printername.buffer,
sizeof(sharename), -1, STR_TERMINATE); -1,
STR_TERMINATE);
rpcstr_pull_talloc(mem_ctx,
&sharename,
ctr.printers_2[i].sharename.buffer,
-1,
STR_TERMINATE);
if (!printername || !sharename) {
goto done;
}
/* open printer handle */ /* open printer handle */
if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename, if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename,
@ -1305,8 +1334,14 @@ NTSTATUS rpc_printer_publish_list_internals(const DOM_SID *domain_sid,
if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, &ctr_pub)) if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, &ctr_pub))
goto done; goto done;
rpcstr_pull(guid, ctr_pub.printers_7->guid.buffer, sizeof(guid), -1, STR_TERMINATE); rpcstr_pull_talloc(mem_ctx,
&guid,
ctr_pub.printers_7->guid.buffer,
-1,
STR_TERMINATE);
if (!guid) {
goto done;
}
state = ctr_pub.printers_7->action; state = ctr_pub.printers_7->action;
switch (state) { switch (state) {
case SPOOL_DS_PUBLISH: case SPOOL_DS_PUBLISH:
@ -1367,7 +1402,7 @@ NTSTATUS rpc_printer_migrate_security_internals(const DOM_SID *domain_sid,
uint32 i = 0; uint32 i = 0;
uint32 num_printers; uint32 num_printers;
uint32 level = 2; uint32 level = 2;
pstring printername = "", sharename = ""; char *printername, *sharename;
bool got_hnd_src = False; bool got_hnd_src = False;
bool got_hnd_dst = False; bool got_hnd_dst = False;
struct rpc_pipe_client *pipe_hnd_dst = NULL; struct rpc_pipe_client *pipe_hnd_dst = NULL;
@ -1399,12 +1434,22 @@ NTSTATUS rpc_printer_migrate_security_internals(const DOM_SID *domain_sid,
/* do something for all printers */ /* do something for all printers */
for (i = 0; i < num_printers; i++) { for (i = 0; i < num_printers; i++) {
/* do some initialization */ /* do some initialization */
rpcstr_pull(printername, ctr_enum.printers_2[i].printername.buffer, rpcstr_pull_talloc(mem_ctx,
sizeof(printername), -1, STR_TERMINATE); &printername,
rpcstr_pull(sharename, ctr_enum.printers_2[i].sharename.buffer, ctr_enum.printers_2[i].printername.buffer,
sizeof(sharename), -1, STR_TERMINATE); -1,
STR_TERMINATE);
rpcstr_pull_talloc(mem_ctx,
&sharename,
ctr_enum.printers_2[i].sharename.buffer,
-1,
STR_TERMINATE);
if (!printername || !sharename) {
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
}
/* we can reset NT_STATUS here because we do not /* we can reset NT_STATUS here because we do not
get any real NT_STATUS-codes anymore from now on */ get any real NT_STATUS-codes anymore from now on */
nt_status = NT_STATUS_UNSUCCESSFUL; nt_status = NT_STATUS_UNSUCCESSFUL;
@ -1515,7 +1560,7 @@ NTSTATUS rpc_printer_migrate_forms_internals(const DOM_SID *domain_sid,
uint32 i, f; uint32 i, f;
uint32 num_printers; uint32 num_printers;
uint32 level = 1; uint32 level = 1;
pstring printername = "", sharename = ""; char *printername, *sharename;
bool got_hnd_src = False; bool got_hnd_src = False;
bool got_hnd_dst = False; bool got_hnd_dst = False;
struct rpc_pipe_client *pipe_hnd_dst = NULL; struct rpc_pipe_client *pipe_hnd_dst = NULL;
@ -1534,7 +1579,6 @@ NTSTATUS rpc_printer_migrate_forms_internals(const DOM_SID *domain_sid,
if (!NT_STATUS_IS_OK(nt_status)) if (!NT_STATUS_IS_OK(nt_status))
return nt_status; return nt_status;
/* enum src printers */ /* enum src printers */
if (!get_printer_info(pipe_hnd, mem_ctx, 2, argc, argv, &num_printers, &ctr_enum)) { if (!get_printer_info(pipe_hnd, mem_ctx, 2, argc, argv, &num_printers, &ctr_enum)) {
nt_status = NT_STATUS_UNSUCCESSFUL; nt_status = NT_STATUS_UNSUCCESSFUL;
@ -1547,15 +1591,23 @@ NTSTATUS rpc_printer_migrate_forms_internals(const DOM_SID *domain_sid,
goto done; goto done;
} }
/* do something for all printers */ /* do something for all printers */
for (i = 0; i < num_printers; i++) { for (i = 0; i < num_printers; i++) {
/* do some initialization */ /* do some initialization */
rpcstr_pull(printername, ctr_enum.printers_2[i].printername.buffer, rpcstr_pull_talloc(mem_ctx,
sizeof(printername), -1, STR_TERMINATE); &printername,
rpcstr_pull(sharename, ctr_enum.printers_2[i].sharename.buffer, ctr_enum.printers_2[i].printername.buffer,
sizeof(sharename), -1, STR_TERMINATE); -1,
STR_TERMINATE);
rpcstr_pull_talloc(mem_ctx,
&sharename,
ctr_enum.printers_2[i].sharename.buffer,
-1,
STR_TERMINATE);
if (!printername || !sharename) {
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
}
/* we can reset NT_STATUS here because we do not /* we can reset NT_STATUS here because we do not
get any real NT_STATUS-codes anymore from now on */ get any real NT_STATUS-codes anymore from now on */
nt_status = NT_STATUS_UNSUCCESSFUL; nt_status = NT_STATUS_UNSUCCESSFUL;
@ -1690,7 +1742,7 @@ NTSTATUS rpc_printer_migrate_drivers_internals(const DOM_SID *domain_sid,
uint32 i, p; uint32 i, p;
uint32 num_printers; uint32 num_printers;
uint32 level = 3; uint32 level = 3;
pstring printername = "", sharename = ""; char *printername, *sharename;
bool got_hnd_src = False; bool got_hnd_src = False;
bool got_hnd_dst = False; bool got_hnd_dst = False;
bool got_src_driver_share = False; bool got_src_driver_share = False;
@ -1709,7 +1761,6 @@ NTSTATUS rpc_printer_migrate_drivers_internals(const DOM_SID *domain_sid,
ZERO_STRUCT(info_ctr_enum); ZERO_STRUCT(info_ctr_enum);
ZERO_STRUCT(info_ctr_dst); ZERO_STRUCT(info_ctr_dst);
DEBUG(3,("copying printer-drivers\n")); DEBUG(3,("copying printer-drivers\n"));
nt_status = connect_dst_pipe(&cli_dst, &pipe_hnd_dst, PI_SPOOLSS); nt_status = connect_dst_pipe(&cli_dst, &pipe_hnd_dst, PI_SPOOLSS);
@ -1749,12 +1800,22 @@ NTSTATUS rpc_printer_migrate_drivers_internals(const DOM_SID *domain_sid,
/* do something for all printers */ /* do something for all printers */
for (p = 0; p < num_printers; p++) { for (p = 0; p < num_printers; p++) {
/* do some initialization */ /* do some initialization */
rpcstr_pull(printername, info_ctr_enum.printers_2[p].printername.buffer, rpcstr_pull_talloc(mem_ctx,
sizeof(printername), -1, STR_TERMINATE); &printername,
rpcstr_pull(sharename, info_ctr_enum.printers_2[p].sharename.buffer, info_ctr_enum.printers_2[p].printername.buffer,
sizeof(sharename), -1, STR_TERMINATE); -1,
STR_TERMINATE);
rpcstr_pull_talloc(mem_ctx,
&sharename,
info_ctr_enum.printers_2[p].sharename.buffer,
-1,
STR_TERMINATE);
if (!printername || !sharename) {
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
}
/* we can reset NT_STATUS here because we do not /* we can reset NT_STATUS here because we do not
get any real NT_STATUS-codes anymore from now on */ get any real NT_STATUS-codes anymore from now on */
nt_status = NT_STATUS_UNSUCCESSFUL; nt_status = NT_STATUS_UNSUCCESSFUL;
@ -1911,7 +1972,7 @@ NTSTATUS rpc_printer_migrate_printers_internals(const DOM_SID *domain_sid,
PRINTER_INFO_CTR ctr_src, ctr_dst, ctr_enum; PRINTER_INFO_CTR ctr_src, ctr_dst, ctr_enum;
struct cli_state *cli_dst = NULL; struct cli_state *cli_dst = NULL;
POLICY_HND hnd_dst, hnd_src; POLICY_HND hnd_dst, hnd_src;
pstring printername, sharename; char *printername, *sharename;
bool got_hnd_src = False; bool got_hnd_src = False;
bool got_hnd_dst = False; bool got_hnd_dst = False;
struct rpc_pipe_client *pipe_hnd_dst = NULL; struct rpc_pipe_client *pipe_hnd_dst = NULL;
@ -1935,15 +1996,23 @@ NTSTATUS rpc_printer_migrate_printers_internals(const DOM_SID *domain_sid,
goto done; goto done;
} }
/* do something for all printers */ /* do something for all printers */
for (i = 0; i < num_printers; i++) { for (i = 0; i < num_printers; i++) {
/* do some initialization */ /* do some initialization */
rpcstr_pull(printername, ctr_enum.printers_2[i].printername.buffer, rpcstr_pull_talloc(mem_ctx,
sizeof(printername), -1, STR_TERMINATE); &printername,
rpcstr_pull(sharename, ctr_enum.printers_2[i].sharename.buffer, ctr_enum.printers_2[i].printername.buffer,
sizeof(sharename), -1, STR_TERMINATE); -1,
STR_TERMINATE);
rpcstr_pull_talloc(mem_ctx,
&sharename,
ctr_enum.printers_2[i].sharename.buffer,
-1,
STR_TERMINATE);
if (!printername || !sharename) {
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
}
/* we can reset NT_STATUS here because we do not /* we can reset NT_STATUS here because we do not
get any real NT_STATUS-codes anymore from now on */ get any real NT_STATUS-codes anymore from now on */
nt_status = NT_STATUS_UNSUCCESSFUL; nt_status = NT_STATUS_UNSUCCESSFUL;
@ -2061,7 +2130,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(const DOM_SID *domain_sid,
uint32 i = 0, p = 0, j = 0; uint32 i = 0, p = 0, j = 0;
uint32 num_printers, val_needed, data_needed; uint32 num_printers, val_needed, data_needed;
uint32 level = 2; uint32 level = 2;
pstring printername = "", sharename = ""; char *printername, *sharename;
bool got_hnd_src = False; bool got_hnd_src = False;
bool got_hnd_dst = False; bool got_hnd_dst = False;
struct rpc_pipe_client *pipe_hnd_dst = NULL; struct rpc_pipe_client *pipe_hnd_dst = NULL;
@ -2083,7 +2152,6 @@ NTSTATUS rpc_printer_migrate_settings_internals(const DOM_SID *domain_sid,
if (!NT_STATUS_IS_OK(nt_status)) if (!NT_STATUS_IS_OK(nt_status))
return nt_status; return nt_status;
/* enum src printers */ /* enum src printers */
if (!get_printer_info(pipe_hnd, mem_ctx, level, argc, argv, &num_printers, &ctr_enum)) { if (!get_printer_info(pipe_hnd, mem_ctx, level, argc, argv, &num_printers, &ctr_enum)) {
nt_status = NT_STATUS_UNSUCCESSFUL; nt_status = NT_STATUS_UNSUCCESSFUL;
@ -2106,13 +2174,21 @@ NTSTATUS rpc_printer_migrate_settings_internals(const DOM_SID *domain_sid,
/* do something for all printers */ /* do something for all printers */
for (i = 0; i < num_printers; i++) { for (i = 0; i < num_printers; i++) {
/* do some initialization */ /* do some initialization */
rpcstr_pull(printername, ctr_enum.printers_2[i].printername.buffer, rpcstr_pull_talloc(mem_ctx,
sizeof(printername), -1, STR_TERMINATE); &printername,
rpcstr_pull(sharename, ctr_enum.printers_2[i].sharename.buffer, ctr_enum.printers_2[i].printername.buffer,
sizeof(sharename), -1, STR_TERMINATE); -1,
STR_TERMINATE);
rpcstr_pull_talloc(mem_ctx,
&sharename,
ctr_enum.printers_2[i].sharename.buffer,
-1,
STR_TERMINATE);
if (!printername || !sharename) {
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
}
/* we can reset NT_STATUS here because we do not /* we can reset NT_STATUS here because we do not
get any real NT_STATUS-codes anymore from now on */ get any real NT_STATUS-codes anymore from now on */
nt_status = NT_STATUS_UNSUCCESSFUL; nt_status = NT_STATUS_UNSUCCESSFUL;
@ -2257,9 +2333,15 @@ NTSTATUS rpc_printer_migrate_settings_internals(const DOM_SID *domain_sid,
curkey = keylist; curkey = keylist;
while (*curkey != 0) { while (*curkey != 0) {
char *subkey;
pstring subkey; rpcstr_pull_talloc(mem_ctx,
rpcstr_pull(subkey, curkey, sizeof(subkey), -1, STR_TERMINATE); &subkey,
curkey,
-1,
STR_TERMINATE);
if (!subkey) {
return NT_STATUS_NO_MEMORY;
}
curkey += strlen(subkey) + 1; curkey += strlen(subkey) + 1;