From 017a305fede73b3f61517f38dec2bf706e2648df Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 26 Apr 2010 13:51:33 -0400 Subject: [PATCH] s3-printing: Convert print_time_access_check. use spoolss_PrintInfo2 and winreg calls Signed-off-by: Jim McDonough --- source3/include/proto.h | 3 ++- source3/printing/nt_printing.c | 22 +++++++++++++++------- source3/printing/printing.c | 2 +- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index 02bc54c5b00..4d0536832c5 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -4792,7 +4792,8 @@ void map_printer_permissions(struct security_descriptor *sd); void map_job_permissions(struct security_descriptor *sd); bool print_access_check(struct auth_serversupplied_info *server_info, int snum, int access_type); -bool print_time_access_check(const char *servicename); +bool print_time_access_check(struct auth_serversupplied_info *server_info, + const char *servicename); char* get_server_name( Printer_entry *printer ); /* The following definitions come from printing/pcap.c */ diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index 52ced155f49..a36e40be775 100644 --- a/source3/printing/nt_printing.c +++ b/source3/printing/nt_printing.c @@ -5101,30 +5101,38 @@ bool print_access_check(struct auth_serversupplied_info *server_info, int snum, Check the time parameters allow a print operation. *****************************************************************************/ -bool print_time_access_check(const char *servicename) +bool print_time_access_check(struct auth_serversupplied_info *server_info, + const char *servicename) { - NT_PRINTER_INFO_LEVEL *printer = NULL; + struct spoolss_PrinterInfo2 *pinfo2 = NULL; + WERROR result; bool ok = False; time_t now = time(NULL); struct tm *t; uint32 mins; - if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, servicename))) + result = winreg_get_printer(NULL, server_info, + NULL, servicename, &pinfo2); + if (!W_ERROR_IS_OK(result)) { return False; + } - if (printer->info_2->starttime == 0 && printer->info_2->untiltime == 0) + if (pinfo2->starttime == 0 && pinfo2->untiltime == 0) { ok = True; + } t = gmtime(&now); mins = (uint32)t->tm_hour*60 + (uint32)t->tm_min; - if (mins >= printer->info_2->starttime && mins <= printer->info_2->untiltime) + if (mins >= pinfo2->starttime && mins <= pinfo2->untiltime) { ok = True; + } - free_a_printer(&printer, 2); + TALLOC_FREE(pinfo2); - if (!ok) + if (!ok) { errno = EACCES; + } return ok; } diff --git a/source3/printing/printing.c b/source3/printing/printing.c index e0cca8854e4..5def9cd0d14 100644 --- a/source3/printing/printing.c +++ b/source3/printing/printing.c @@ -2430,7 +2430,7 @@ uint32 print_job_start(struct auth_serversupplied_info *server_info, int snum, return (uint32)-1; } - if (!print_time_access_check(lp_servicename(snum))) { + if (!print_time_access_check(server_info, lp_servicename(snum))) { DEBUG(3, ("print_job_start: job start denied by time check\n")); release_print_db(pdb); return (uint32)-1; -- 2.34.1