diff options
author | Tim Potter <tpot@samba.org> | 2002-04-15 04:07:13 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 2002-04-15 04:07:13 +0000 |
commit | 1667a821060b8bbc1cef3db473f6967cd02f5886 (patch) | |
tree | 8f8a26c208e1d1df5d28c5a075ed451723a0678a /source3 | |
parent | 36514b65eed055282f2f391d18128536026d9485 (diff) | |
download | samba-1667a821060b8bbc1cef3db473f6967cd02f5886.tar.gz samba-1667a821060b8bbc1cef3db473f6967cd02f5886.tar.bz2 samba-1667a821060b8bbc1cef3db473f6967cd02f5886.zip |
Merge of print server permission handling fixes from HEAD.
Unit tests rock!
(This used to be commit bc673c42045ceb46d9569bc4d88f9c64897fc85a)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/printing/nt_printing.c | 16 | ||||
-rw-r--r-- | source3/rpc_server/srv_spoolss_nt.c | 49 |
2 files changed, 53 insertions, 12 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index 907c3fd8e6..29bc185a6d 100644 --- a/source3/printing/nt_printing.c +++ b/source3/printing/nt_printing.c @@ -56,6 +56,22 @@ STANDARD_MAPPING printer_std_mapping = { PRINTER_ALL_ACCESS }; +/* Map generic permissions to print server object specific permissions */ + +GENERIC_MAPPING printserver_generic_mapping = { + SERVER_READ, + SERVER_WRITE, + SERVER_EXECUTE, + SERVER_ALL_ACCESS +}; + +STANDARD_MAPPING printserver_std_mapping = { + SERVER_READ, + SERVER_WRITE, + SERVER_EXECUTE, + SERVER_ALL_ACCESS +}; + /* We need one default form to support our default printer. Msoft adds the forms it wants and in the ORDER it wants them (note: DEVMODE papersize is an array index). Letter is always first, so (for the current code) additions diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 3bc91c2472..a8552cd14d 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -92,7 +92,8 @@ static uint32 smb_connections=0; /* in printing/nt_printing.c */ -extern STANDARD_MAPPING printer_std_mapping; + +extern STANDARD_MAPPING printer_std_mapping, printserver_std_mapping; #define OUR_HANDLE(hnd) (((hnd)==NULL)?"NULL":(IVAL((hnd)->data5,4)==(uint32)sys_getpid()?"OURS":"OTHER")), \ ((unsigned int)IVAL((hnd)->data5,4)),((unsigned int)sys_getpid()) @@ -959,26 +960,50 @@ Can't find printer handle we created for printer %s\n", name )); get_current_user(&user, p); if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) { - if (printer_default->access_required == 0) { - return WERR_OK; + + /* Printserver handles use global struct... */ + + snum = -1; + + /* Map standard access rights to object specific access + rights */ + + se_map_standard(&printer_default->access_required, + &printserver_std_mapping); + + /* Deny any object specific bits that don't apply to print + servers (i.e printer and job specific bits) */ + + printer_default->access_required &= SPECIFIC_RIGHTS_MASK; + + if (printer_default->access_required & + ~(SERVER_ACCESS_ADMINISTER | SERVER_ACCESS_ENUMERATE)) { + DEBUG(3, ("access DENIED for non-printserver bits")); + close_printer_handle(p, handle); + return WERR_ACCESS_DENIED; } - else if ((printer_default->access_required & SERVER_ACCESS_ADMINISTER ) == SERVER_ACCESS_ADMINISTER) { - /* Printserver handles use global struct... */ - snum = -1; + /* Allow admin access */ + + if (printer_default->access_required & + SERVER_ACCESS_ADMINISTER) { if (!lp_ms_add_printer_wizard()) { close_printer_handle(p, handle); return WERR_ACCESS_DENIED; } - else if (user.uid == 0 || user_in_list(uidtoname(user.uid), lp_printer_admin(snum))) { + + if (user.uid == 0 || + user_in_list(uidtoname(user.uid), + lp_printer_admin(snum))) return WERR_OK; - } - else { - close_printer_handle(p, handle); - return WERR_ACCESS_DENIED; - } + + close_printer_handle(p, handle); + return WERR_ACCESS_DENIED; } + + /* We fall through to return WERR_OK */ + } else { |