1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-12 09:18:10 +03:00

s3-spoolss: Migrated spoolss_Forms to use the winreg changeid function.

Signed-off-by: Jim McDonough <jmcd@samba.org>
This commit is contained in:
Andreas Schneider 2010-04-15 15:20:42 +02:00 committed by Simo Sorce
parent 67bdaa5616
commit 2a5dba5555

View File

@ -7586,7 +7586,6 @@ WERROR _spoolss_AddForm(pipes_struct *p,
struct spoolss_AddFormInfo1 *form = r->in.info.info1; struct spoolss_AddFormInfo1 *form = r->in.info.info1;
int snum = -1; int snum = -1;
WERROR status = WERR_OK; WERROR status = WERR_OK;
NT_PRINTER_INFO_LEVEL *printer = NULL;
SE_PRIV se_printop = SE_PRINT_OPERATOR; SE_PRIV se_printop = SE_PRINT_OPERATOR;
Printer_entry *Printer = find_printer_index_by_hnd(p, r->in.handle); Printer_entry *Printer = find_printer_index_by_hnd(p, r->in.handle);
@ -7599,19 +7598,6 @@ WERROR _spoolss_AddForm(pipes_struct *p,
return WERR_BADFID; return WERR_BADFID;
} }
/* forms can be added on printer or on the print server handle */
if ( Printer->printer_type == SPLHND_PRINTER )
{
if (!get_printer_snum(p, r->in.handle, &snum, NULL))
return WERR_BADFID;
status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum));
if (!W_ERROR_IS_OK(status))
goto done;
}
/* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege, /* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege,
and not a printer admin, then fail */ and not a printer admin, then fail */
@ -7623,8 +7609,7 @@ WERROR _spoolss_AddForm(pipes_struct *p,
p->server_info->ptok, p->server_info->ptok,
lp_printer_admin(snum))) { lp_printer_admin(snum))) {
DEBUG(2,("_spoolss_Addform: denied by insufficient permissions.\n")); DEBUG(2,("_spoolss_Addform: denied by insufficient permissions.\n"));
status = WERR_ACCESS_DENIED; return WERR_ACCESS_DENIED;
goto done;
} }
switch (form->flags) { switch (form->flags) {
@ -7633,25 +7618,29 @@ WERROR _spoolss_AddForm(pipes_struct *p,
case SPOOLSS_FORM_PRINTER: case SPOOLSS_FORM_PRINTER:
break; break;
default: default:
status = WERR_INVALID_PARAM; return WERR_INVALID_PARAM;
goto done;
} }
status = winreg_printer_addform1(p->mem_ctx, p->server_info, form); status = winreg_printer_addform1(p->mem_ctx, p->server_info, form);
if (!W_ERROR_IS_OK(status)) { if (!W_ERROR_IS_OK(status)) {
goto done; return status;
} }
/* /*
* ChangeID must always be set if this is a printer * ChangeID must always be set if this is a printer
*/ */
if (Printer->printer_type == SPLHND_PRINTER) {
if (!get_printer_snum(p, r->in.handle, &snum, NULL)) {
return WERR_BADFID;
}
if ( Printer->printer_type == SPLHND_PRINTER ) status = winreg_printer_update_changeid(p->mem_ctx,
status = mod_a_printer(printer, 2); p->server_info,
lp_const_servicename(snum));
done: if (!W_ERROR_IS_OK(status)) {
if ( printer ) return status;
free_a_printer(&printer, 2); }
}
return status; return status;
} }
@ -7667,7 +7656,6 @@ WERROR _spoolss_DeleteForm(pipes_struct *p,
Printer_entry *Printer = find_printer_index_by_hnd(p, r->in.handle); Printer_entry *Printer = find_printer_index_by_hnd(p, r->in.handle);
int snum = -1; int snum = -1;
WERROR status = WERR_OK; WERROR status = WERR_OK;
NT_PRINTER_INFO_LEVEL *printer = NULL;
SE_PRIV se_printop = SE_PRINT_OPERATOR; SE_PRIV se_printop = SE_PRINT_OPERATOR;
DEBUG(5,("_spoolss_DeleteForm\n")); DEBUG(5,("_spoolss_DeleteForm\n"));
@ -7678,18 +7666,6 @@ WERROR _spoolss_DeleteForm(pipes_struct *p,
return WERR_BADFID; return WERR_BADFID;
} }
/* forms can be deleted on printer of on the print server handle */
if ( Printer->printer_type == SPLHND_PRINTER )
{
if (!get_printer_snum(p, r->in.handle, &snum, NULL))
return WERR_BADFID;
status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum));
if (!W_ERROR_IS_OK(status))
goto done;
}
if ((p->server_info->utok.uid != sec_initial_uid()) && if ((p->server_info->utok.uid != sec_initial_uid()) &&
!user_has_privileges(p->server_info->ptok, &se_printop) && !user_has_privileges(p->server_info->ptok, &se_printop) &&
!token_contains_name_in_list(uidtoname(p->server_info->utok.uid), !token_contains_name_in_list(uidtoname(p->server_info->utok.uid),
@ -7705,19 +7681,24 @@ WERROR _spoolss_DeleteForm(pipes_struct *p,
p->server_info, p->server_info,
form_name); form_name);
if (!W_ERROR_IS_OK(status)) { if (!W_ERROR_IS_OK(status)) {
goto done; return status;
} }
/* /*
* ChangeID must always be set if this is a printer * ChangeID must always be set if this is a printer
*/ */
if (Printer->printer_type == SPLHND_PRINTER) {
if (!get_printer_snum(p, r->in.handle, &snum, NULL)) {
return WERR_BADFID;
}
if ( Printer->printer_type == SPLHND_PRINTER ) status = winreg_printer_update_changeid(p->mem_ctx,
status = mod_a_printer(printer, 2); p->server_info,
lp_const_servicename(snum));
done: if (!W_ERROR_IS_OK(status)) {
if ( printer ) return status;
free_a_printer(&printer, 2); }
}
return status; return status;
} }
@ -7733,7 +7714,6 @@ WERROR _spoolss_SetForm(pipes_struct *p,
const char *form_name = r->in.form_name; const char *form_name = r->in.form_name;
int snum = -1; int snum = -1;
WERROR status = WERR_OK; WERROR status = WERR_OK;
NT_PRINTER_INFO_LEVEL *printer = NULL;
SE_PRIV se_printop = SE_PRINT_OPERATOR; SE_PRIV se_printop = SE_PRINT_OPERATOR;
Printer_entry *Printer = find_printer_index_by_hnd(p, r->in.handle); Printer_entry *Printer = find_printer_index_by_hnd(p, r->in.handle);
@ -7746,18 +7726,6 @@ WERROR _spoolss_SetForm(pipes_struct *p,
return WERR_BADFID; return WERR_BADFID;
} }
/* forms can be modified on printer of on the print server handle */
if ( Printer->printer_type == SPLHND_PRINTER )
{
if (!get_printer_snum(p, r->in.handle, &snum, NULL))
return WERR_BADFID;
status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum));
if (!W_ERROR_IS_OK(status))
goto done;
}
/* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege, /* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege,
and not a printer admin, then fail */ and not a printer admin, then fail */
@ -7769,8 +7737,7 @@ WERROR _spoolss_SetForm(pipes_struct *p,
p->server_info->ptok, p->server_info->ptok,
lp_printer_admin(snum))) { lp_printer_admin(snum))) {
DEBUG(2,("_spoolss_Setform: denied by insufficient permissions.\n")); DEBUG(2,("_spoolss_Setform: denied by insufficient permissions.\n"));
status = WERR_ACCESS_DENIED; return WERR_ACCESS_DENIED;
goto done;
} }
status = winreg_printer_setform1(p->mem_ctx, status = winreg_printer_setform1(p->mem_ctx,
@ -7778,20 +7745,24 @@ WERROR _spoolss_SetForm(pipes_struct *p,
form_name, form_name,
form); form);
if (!W_ERROR_IS_OK(status)) { if (!W_ERROR_IS_OK(status)) {
goto done; return status;
} }
/* /*
* ChangeID must always be set if this is a printer * ChangeID must always be set if this is a printer
*/ */
if (Printer->printer_type == SPLHND_PRINTER) {
if (!get_printer_snum(p, r->in.handle, &snum, NULL)) {
return WERR_BADFID;
}
if ( Printer->printer_type == SPLHND_PRINTER ) status = winreg_printer_update_changeid(p->mem_ctx,
status = mod_a_printer(printer, 2); p->server_info,
lp_const_servicename(snum));
if (!W_ERROR_IS_OK(status)) {
done: return status;
if ( printer ) }
free_a_printer(&printer, 2); }
return status; return status;
} }