8d7e41661dc4633488e93b13363137523ce59977jose borrego/*
8d7e41661dc4633488e93b13363137523ce59977jose borrego * CDDL HEADER START
8d7e41661dc4633488e93b13363137523ce59977jose borrego *
8d7e41661dc4633488e93b13363137523ce59977jose borrego * The contents of this file are subject to the terms of the
8d7e41661dc4633488e93b13363137523ce59977jose borrego * Common Development and Distribution License (the "License").
8d7e41661dc4633488e93b13363137523ce59977jose borrego * You may not use this file except in compliance with the License.
8d7e41661dc4633488e93b13363137523ce59977jose borrego *
8d7e41661dc4633488e93b13363137523ce59977jose borrego * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
8d7e41661dc4633488e93b13363137523ce59977jose borrego * or http://www.opensolaris.org/os/licensing.
8d7e41661dc4633488e93b13363137523ce59977jose borrego * See the License for the specific language governing permissions
8d7e41661dc4633488e93b13363137523ce59977jose borrego * and limitations under the License.
8d7e41661dc4633488e93b13363137523ce59977jose borrego *
8d7e41661dc4633488e93b13363137523ce59977jose borrego * When distributing Covered Code, include this CDDL HEADER in each
8d7e41661dc4633488e93b13363137523ce59977jose borrego * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
8d7e41661dc4633488e93b13363137523ce59977jose borrego * If applicable, add the following below this CDDL HEADER, with the
8d7e41661dc4633488e93b13363137523ce59977jose borrego * fields enclosed by brackets "[]" replaced with your own identifying
8d7e41661dc4633488e93b13363137523ce59977jose borrego * information: Portions Copyright [yyyy] [name of copyright owner]
8d7e41661dc4633488e93b13363137523ce59977jose borrego *
8d7e41661dc4633488e93b13363137523ce59977jose borrego * CDDL HEADER END
8d7e41661dc4633488e93b13363137523ce59977jose borrego */
8d7e41661dc4633488e93b13363137523ce59977jose borrego/*
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
68b2bbf26c7040fea4281dcb58b81e7627e46f34Gordon Ross * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
8d7e41661dc4633488e93b13363137523ce59977jose borrego */
8d7e41661dc4633488e93b13363137523ce59977jose borrego
8d7e41661dc4633488e93b13363137523ce59977jose borrego/*
8d7e41661dc4633488e93b13363137523ce59977jose borrego * Printing and Spooling RPC service.
8d7e41661dc4633488e93b13363137523ce59977jose borrego */
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh#include <sys/types.h>
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh#include <sys/stat.h>
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh#include <sys/utsname.h>
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross#include <sys/atomic.h>
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh#include <unistd.h>
8d7e41661dc4633488e93b13363137523ce59977jose borrego#include <stdlib.h>
8d7e41661dc4633488e93b13363137523ce59977jose borrego#include <strings.h>
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh#include <fcntl.h>
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh#include <errno.h>
8d7e41661dc4633488e93b13363137523ce59977jose borrego#include <smbsrv/libsmb.h>
8d7e41661dc4633488e93b13363137523ce59977jose borrego#include <smbsrv/libmlrpc.h>
8d7e41661dc4633488e93b13363137523ce59977jose borrego#include <smbsrv/libmlsvc.h>
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh#include <smbsrv/smb.h>
8d7e41661dc4633488e93b13363137523ce59977jose borrego#include <smbsrv/ndl/spoolss.ndl>
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh#include <smbsrv/ndl/winreg.ndl>
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh#include <smb/nterror.h>
8d7e41661dc4633488e93b13363137523ce59977jose borrego#include <smbsrv/smbinfo.h>
8d7e41661dc4633488e93b13363137523ce59977jose borrego#include <smbsrv/nmpipes.h>
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh#include <mlsvc.h>
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
86d7016b0051dd58772baafe5b5bcee51d560b05Gordon Ross#ifdef HAVE_CUPS
86d7016b0051dd58772baafe5b5bcee51d560b05Gordon Ross
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh#define SPOOLSS_PRINTER "Postscript"
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshtypedef struct smb_spool {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh list_t sp_list;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh int sp_cnt;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh rwlock_t sp_rwl;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh int sp_initialized;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh} smb_spool_t;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshtypedef struct smb_spooldoc {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh uint32_t sd_magic;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh list_node_t sd_lnd;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_inaddr_t sd_ipaddr;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh int sd_spool_num;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh char sd_username[MAXNAMELEN];
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh char sd_path[MAXPATHLEN];
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh char sd_doc_name[MAXNAMELEN];
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh char sd_printer_name[MAXPATHLEN];
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh int32_t sd_fd;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh ndr_hdid_t sd_handle;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh} smb_spooldoc_t;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshtypedef struct {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh char *name;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh uint32_t value;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh} spoolss_winreg_t;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshtypedef struct {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh uint8_t *sd_buf;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh uint32_t sd_size;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh} spoolss_sd_t;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic uint32_t spoolss_cnt;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic smb_spool_t spoolss_splist;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshvoid (*spoolss_copyfile_callback)(smb_inaddr_t *, char *, char *, char *);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshDECL_FIXUP_STRUCT(spoolss_GetPrinter_result_u);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshDECL_FIXUP_STRUCT(spoolss_GetPrinter_result);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshDECL_FIXUP_STRUCT(spoolss_GetPrinter);
8d7e41661dc4633488e93b13363137523ce59977jose borrego
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshDECL_FIXUP_STRUCT(spoolss_RPC_V2_NOTIFY_INFO_DATA_DATA);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshDECL_FIXUP_STRUCT(spoolss_RPC_V2_NOTIFY_INFO_DATA);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshDECL_FIXUP_STRUCT(spoolss_RPC_V2_NOTIFY_INFO);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshDECL_FIXUP_STRUCT(spoolss_RFNPCNEX);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshuint32_t srvsvc_sd_set_relative(smb_sd_t *, uint8_t *);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshstatic int spoolss_getservername(char *, size_t);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshstatic uint32_t spoolss_make_sd(ndr_xa_t *, spoolss_sd_t *);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshstatic uint32_t spoolss_format_sd(smb_sd_t *);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshstatic int spoolss_find_document(ndr_hdid_t *);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int spoolss_s_OpenPrinter(void *, ndr_xa_t *);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int spoolss_s_ClosePrinter(void *, ndr_xa_t *);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int spoolss_s_AbortPrinter(void *, ndr_xa_t *);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int spoolss_s_ResetPrinter(void *, ndr_xa_t *);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int spoolss_s_GetPrinter(void *, ndr_xa_t *);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int spoolss_s_GetPrinterData(void *, ndr_xa_t *);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int spoolss_s_AddJob(void *, ndr_xa_t *);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int spoolss_s_GetJob(void *, ndr_xa_t *);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int spoolss_s_EnumJobs(void *, ndr_xa_t *);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int spoolss_s_ScheduleJob(void *, ndr_xa_t *);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int spoolss_s_StartDocPrinter(void *, ndr_xa_t *);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int spoolss_s_EndDocPrinter(void *, ndr_xa_t *);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int spoolss_s_StartPagePrinter(void *, ndr_xa_t *);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int spoolss_s_EndPagePrinter(void *, ndr_xa_t *);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int spoolss_s_rfnpcnex(void *, ndr_xa_t *);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int spoolss_s_WritePrinter(void *, ndr_xa_t *);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshstatic int spoolss_s_AddForm(void *, ndr_xa_t *);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshstatic int spoolss_s_DeleteForm(void *, ndr_xa_t *);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int spoolss_s_EnumForms(void *, ndr_xa_t *);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshstatic int spoolss_s_AddMonitor(void *, ndr_xa_t *);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshstatic int spoolss_s_DeleteMonitor(void *, ndr_xa_t *);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshstatic int spoolss_s_DeletePort(void *, ndr_xa_t *);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshstatic int spoolss_s_AddPortEx(void *, ndr_xa_t *);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshstatic int spoolss_s_SetPort(void *, ndr_xa_t *);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int spoolss_s_stub(void *, ndr_xa_t *);
8d7e41661dc4633488e93b13363137523ce59977jose borrego
8d7e41661dc4633488e93b13363137523ce59977jose borregostatic ndr_stub_table_t spoolss_stub_table[] = {
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh { spoolss_s_GetJob, SPOOLSS_OPNUM_GetJob },
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh { spoolss_s_EnumJobs, SPOOLSS_OPNUM_EnumJobs },
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh { spoolss_s_stub, SPOOLSS_OPNUM_DeletePrinter },
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh { spoolss_s_GetPrinter, SPOOLSS_OPNUM_GetPrinter },
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh { spoolss_s_stub, SPOOLSS_OPNUM_GetPrinterDriver },
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh { spoolss_s_stub, SPOOLSS_OPNUM_DeletePrinterDriver },
8d7e41661dc4633488e93b13363137523ce59977jose borrego { spoolss_s_OpenPrinter, SPOOLSS_OPNUM_OpenPrinter },
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh { spoolss_s_StartDocPrinter, SPOOLSS_OPNUM_StartDocPrinter },
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh { spoolss_s_WritePrinter, SPOOLSS_OPNUM_WritePrinter },
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh { spoolss_s_EndDocPrinter, SPOOLSS_OPNUM_EndDocPrinter },
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh { spoolss_s_StartPagePrinter, SPOOLSS_OPNUM_StartPagePrinter },
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh { spoolss_s_EndPagePrinter, SPOOLSS_OPNUM_EndPagePrinter },
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh { spoolss_s_AbortPrinter, SPOOLSS_OPNUM_AbortPrinter },
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh { spoolss_s_ResetPrinter, SPOOLSS_OPNUM_ResetPrinter },
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh { spoolss_s_AddJob, SPOOLSS_OPNUM_AddJob },
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh { spoolss_s_ScheduleJob, SPOOLSS_OPNUM_ScheduleJob },
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh { spoolss_s_GetPrinterData, SPOOLSS_OPNUM_GetPrinterData },
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh { spoolss_s_ClosePrinter, SPOOLSS_OPNUM_ClosePrinter },
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh { spoolss_s_AddForm, SPOOLSS_OPNUM_AddForm },
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh { spoolss_s_DeleteForm, SPOOLSS_OPNUM_DeleteForm },
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh { spoolss_s_EnumForms, SPOOLSS_OPNUM_EnumForms },
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh { spoolss_s_AddMonitor, SPOOLSS_OPNUM_AddMonitor },
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh { spoolss_s_DeleteMonitor, SPOOLSS_OPNUM_DeleteMonitor },
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh { spoolss_s_DeletePort, SPOOLSS_OPNUM_DeletePort },
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh { spoolss_s_AddPortEx, SPOOLSS_OPNUM_AddPortEx },
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh { spoolss_s_SetPort, SPOOLSS_OPNUM_SetPort },
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh { spoolss_s_stub, SPOOLSS_OPNUM_GetPrinterDriver2 },
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh { spoolss_s_stub, SPOOLSS_OPNUM_FCPN },
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh { spoolss_s_stub, SPOOLSS_OPNUM_ReplyOpenPrinter },
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh { spoolss_s_stub, SPOOLSS_OPNUM_ReplyClosePrinter },
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh { spoolss_s_stub, SPOOLSS_OPNUM_RFFPCNEX },
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh { spoolss_s_rfnpcnex, SPOOLSS_OPNUM_RFNPCNEX },
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh { spoolss_s_stub, SPOOLSS_OPNUM_RRPCN },
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh { spoolss_s_OpenPrinter, SPOOLSS_OPNUM_OpenPrinterEx },
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh { spoolss_s_stub, SPOOLSS_OPNUM_EnumPrinterData },
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh { spoolss_s_stub, SPOOLSS_OPNUM_EnumPrinterDataEx },
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh { spoolss_s_stub, SPOOLSS_OPNUM_EnumPrinterKey },
8d7e41661dc4633488e93b13363137523ce59977jose borrego {0}
8d7e41661dc4633488e93b13363137523ce59977jose borrego};
8d7e41661dc4633488e93b13363137523ce59977jose borrego
8d7e41661dc4633488e93b13363137523ce59977jose borregostatic ndr_service_t spoolss_service = {
8d7e41661dc4633488e93b13363137523ce59977jose borrego "SPOOLSS", /* name */
8d7e41661dc4633488e93b13363137523ce59977jose borrego "Print Spool Service", /* desc */
8d7e41661dc4633488e93b13363137523ce59977jose borrego "\\spoolss", /* endpoint */
8d7e41661dc4633488e93b13363137523ce59977jose borrego PIPE_SPOOLSS, /* sec_addr_port */
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh "12345678-1234-abcd-ef00-0123456789ab", 1, /* abstract */
8d7e41661dc4633488e93b13363137523ce59977jose borrego NDR_TRANSFER_SYNTAX_UUID, 2, /* transfer */
8d7e41661dc4633488e93b13363137523ce59977jose borrego 0, /* no bind_instance_size */
8d7e41661dc4633488e93b13363137523ce59977jose borrego 0, /* no bind_req() */
8d7e41661dc4633488e93b13363137523ce59977jose borrego 0, /* no unbind_and_close() */
8d7e41661dc4633488e93b13363137523ce59977jose borrego 0, /* use generic_call_stub() */
8d7e41661dc4633488e93b13363137523ce59977jose borrego &TYPEINFO(spoolss_interface), /* interface ti */
8d7e41661dc4633488e93b13363137523ce59977jose borrego spoolss_stub_table /* stub_table */
8d7e41661dc4633488e93b13363137523ce59977jose borrego};
8d7e41661dc4633488e93b13363137523ce59977jose borrego
8d7e41661dc4633488e93b13363137523ce59977jose borregovoid
8d7e41661dc4633488e93b13363137523ce59977jose borregospoolss_initialize(void)
8d7e41661dc4633488e93b13363137523ce59977jose borrego{
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if (!spoolss_splist.sp_initialized) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh list_create(&spoolss_splist.sp_list,
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh sizeof (smb_spooldoc_t),
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh offsetof(smb_spooldoc_t, sd_lnd));
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh spoolss_splist.sp_initialized = 1;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh }
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh spoolss_copyfile_callback = NULL;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
8d7e41661dc4633488e93b13363137523ce59977jose borrego (void) ndr_svc_register(&spoolss_service);
8d7e41661dc4633488e93b13363137523ce59977jose borrego}
8d7e41661dc4633488e93b13363137523ce59977jose borrego
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshvoid
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshspoolss_finalize(void)
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh{
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh spoolss_copyfile_callback = NULL;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh}
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh/*
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh * Register a copyfile callback that the spoolss service can use to
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh * copy files to the spool directory.
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh *
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh * Set a null pointer to disable the copying of files to the spool
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh * directory.
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh */
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshvoid
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshspoolss_register_copyfile(spoolss_copyfile_t copyfile)
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh{
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh spoolss_copyfile_callback = copyfile;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh}
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshstatic void
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshspoolss_copyfile(smb_inaddr_t *ipaddr, char *username, char *path,
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh char *docname)
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh{
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if (spoolss_copyfile_callback != NULL)
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh (*spoolss_copyfile_callback)(ipaddr, username, path, docname);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh}
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int
8d7e41661dc4633488e93b13363137523ce59977jose borregospoolss_s_OpenPrinter(void *arg, ndr_xa_t *mxa)
8d7e41661dc4633488e93b13363137523ce59977jose borrego{
8d7e41661dc4633488e93b13363137523ce59977jose borrego struct spoolss_OpenPrinter *param = arg;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh char *name = (char *)param->printer_name;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh ndr_hdid_t *id;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if (name != NULL && *name != '\0') {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if (strspn(name, "\\") > 2) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh bzero(&param->handle, sizeof (spoolss_handle_t));
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->status = ERROR_INVALID_PRINTER_NAME;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh return (NDR_DRC_OK);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh }
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_tracef("spoolss_s_OpenPrinter: %s", name);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh }
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if ((id = ndr_hdalloc(mxa, NULL)) == NULL) {
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh bzero(&param->handle, sizeof (spoolss_handle_t));
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->status = ERROR_NOT_ENOUGH_MEMORY;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh return (NDR_DRC_OK);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh }
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh bcopy(id, &param->handle, sizeof (spoolss_handle_t));
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->status = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh return (NDR_DRC_OK);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh}
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh/*ARGSUSED*/
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshspoolss_s_StartPagePrinter(void *arg, ndr_xa_t *mxa)
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh{
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh struct spoolss_StartPagePrinter *param = arg;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->status = ERROR_SUCCESS;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh return (NDR_DRC_OK);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh}
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh/*ARGSUSED*/
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshspoolss_s_EndPagePrinter(void *arg, ndr_xa_t *mxa)
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh{
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh struct spoolss_EndPagePrinter *param = arg;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->status = ERROR_SUCCESS;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh return (NDR_DRC_OK);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh}
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh/*
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh * Windows XP and 2000 use this mechanism to write spool files.
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh * Create a spool file fd to be used by spoolss_s_WritePrinter
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh * and add it to the tail of the spool list.
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh */
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshspoolss_s_StartDocPrinter(void *arg, ndr_xa_t *mxa)
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh{
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh struct spoolss_StartDocPrinter *param = arg;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh ndr_hdid_t *id = (ndr_hdid_t *)&param->handle;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh smb_spooldoc_t *spfile;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh spoolss_DocInfo_t *docinfo;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh char g_path[MAXPATHLEN];
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh smb_share_t si;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh int rc;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh int fd;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh if (ndr_hdlookup(mxa, id) == NULL) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_tracef("spoolss_s_StartDocPrinter: invalid handle");
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->status = ERROR_INVALID_HANDLE;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh return (NDR_DRC_OK);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh }
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh if ((docinfo = param->dinfo.DocInfoContainer) == NULL) {
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->status = ERROR_INVALID_PARAMETER;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh return (NDR_DRC_OK);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh }
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh if ((rc = smb_shr_get(SMB_SHARE_PRINT, &si)) != NERR_Success) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_tracef("spoolss_s_StartDocPrinter: %s error=%d",
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh SMB_SHARE_PRINT, rc);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->status = rc;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh return (NDR_DRC_OK);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh }
8d7e41661dc4633488e93b13363137523ce59977jose borrego
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh if ((spfile = calloc(1, sizeof (smb_spooldoc_t))) == NULL) {
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->status = ERROR_NOT_ENOUGH_MEMORY;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh return (NDR_DRC_OK);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh }
8d7e41661dc4633488e93b13363137523ce59977jose borrego
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh if (docinfo->doc_name != NULL)
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh (void) strlcpy(spfile->sd_doc_name,
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh (char *)docinfo->doc_name, MAXNAMELEN);
8d7e41661dc4633488e93b13363137523ce59977jose borrego else
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh (void) strlcpy(spfile->sd_doc_name, "document", MAXNAMELEN);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh if (docinfo->printer_name != NULL)
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh (void) strlcpy(spfile->sd_printer_name,
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh (char *)docinfo->printer_name, MAXPATHLEN);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh else
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh (void) strlcpy(spfile->sd_printer_name, "printer", MAXPATHLEN);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
68b2bbf26c7040fea4281dcb58b81e7627e46f34Gordon Ross spfile->sd_ipaddr = mxa->pipe->np_user->ui_ipaddr;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh (void) strlcpy((char *)spfile->sd_username,
68b2bbf26c7040fea4281dcb58b81e7627e46f34Gordon Ross mxa->pipe->np_user->ui_account, MAXNAMELEN);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh (void) memcpy(&spfile->sd_handle, &param->handle, sizeof (ndr_hdid_t));
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh /*
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh * write temporary spool file to print$
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh */
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh (void) snprintf(g_path, MAXPATHLEN, "%s/%s%d", si.shr_path,
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh spfile->sd_username, spoolss_cnt);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh atomic_inc_32(&spoolss_cnt);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh fd = open(g_path, O_CREAT | O_RDWR, 0600);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh if (fd == -1) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_tracef("spoolss_s_StartDocPrinter: %s: %s",
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh g_path, strerror(errno));
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->status = ERROR_OPEN_FAILED;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh free(spfile);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh } else {
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh (void) strlcpy((char *)spfile->sd_path, g_path, MAXPATHLEN);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh spfile->sd_fd = (uint16_t)fd;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh /*
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh * Add the document to the spool list.
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh */
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh (void) rw_wrlock(&spoolss_splist.sp_rwl);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh list_insert_tail(&spoolss_splist.sp_list, spfile);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh spoolss_splist.sp_cnt++;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh (void) rw_unlock(&spoolss_splist.sp_rwl);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh /*
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh * JobId isn't used now, but if printQ management is added
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh * this will have to be incremented per job submitted.
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh */
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->JobId = 46;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->status = ERROR_SUCCESS;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh }
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh return (NDR_DRC_OK);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh}
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh/*
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh * Windows XP and 2000 use this mechanism to write spool files
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh * Search the spooldoc list for a matching RPC handle and pass
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh * the spool the file for printing.
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh */
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshspoolss_s_EndDocPrinter(void *arg, ndr_xa_t *mxa)
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh{
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh struct spoolss_EndDocPrinter *param = arg;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh ndr_hdid_t *id = (ndr_hdid_t *)&param->handle;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_spooldoc_t *sp;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if (ndr_hdlookup(mxa, id) == NULL) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_tracef("spoolss_s_EndDocPrinter: invalid handle");
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->status = ERROR_INVALID_HANDLE;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh return (NDR_DRC_OK);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh }
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->status = ERROR_INVALID_HANDLE;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh (void) rw_wrlock(&spoolss_splist.sp_rwl);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh sp = list_head(&spoolss_splist.sp_list);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh while (sp != NULL) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if (!memcmp(id, &(sp->sd_handle), sizeof (ndr_hdid_t))) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh spoolss_copyfile(&sp->sd_ipaddr,
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh sp->sd_username, sp->sd_path, sp->sd_doc_name);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh (void) close(sp->sd_fd);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh list_remove(&spoolss_splist.sp_list, sp);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh free(sp);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->status = ERROR_SUCCESS;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh break;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh }
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh sp = list_next(&spoolss_splist.sp_list, sp);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh }
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh (void) rw_unlock(&spoolss_splist.sp_rwl);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if (param->status != ERROR_SUCCESS)
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_tracef("spoolss_s_EndDocPrinter: document not found");
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh return (NDR_DRC_OK);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh}
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh/*ARGSUSED*/
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshspoolss_s_AbortPrinter(void *arg, ndr_xa_t *mxa)
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh{
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh struct spoolss_AbortPrinter *param = arg;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->status = ERROR_SUCCESS;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh return (NDR_DRC_OK);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh}
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh/*ARGSUSED*/
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshspoolss_s_ResetPrinter(void *arg, ndr_xa_t *mxa)
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh{
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh struct spoolss_AbortPrinter *param = arg;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->status = ERROR_SUCCESS;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh return (NDR_DRC_OK);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh}
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshspoolss_s_ClosePrinter(void *arg, ndr_xa_t *mxa)
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh{
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh struct spoolss_ClosePrinter *param = arg;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh ndr_hdid_t *id = (ndr_hdid_t *)&param->handle;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh ndr_handle_t *hd;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh if ((hd = ndr_hdlookup(mxa, id)) != NULL) {
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh free(hd->nh_data);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh hd->nh_data = NULL;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh }
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh ndr_hdfree(mxa, id);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh bzero(&param->result_handle, sizeof (spoolss_handle_t));
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->status = ERROR_SUCCESS;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh return (NDR_DRC_OK);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh}
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshstatic int
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshspoolss_s_AddForm(void *arg, ndr_xa_t *mxa)
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh{
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh struct spoolss_AddForm *param = arg;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh ndr_hdid_t *id = (ndr_hdid_t *)&param->handle;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if (ndr_hdlookup(mxa, id) == NULL) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh bzero(param, sizeof (struct spoolss_AddForm));
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->status = ERROR_INVALID_HANDLE;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh return (NDR_DRC_OK);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh }
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh bzero(param, sizeof (struct spoolss_AddForm));
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->status = ERROR_SUCCESS;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh return (NDR_DRC_OK);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh}
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshstatic int
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshspoolss_s_DeleteForm(void *arg, ndr_xa_t *mxa)
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh{
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh struct spoolss_DeleteForm *param = arg;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh ndr_hdid_t *id = (ndr_hdid_t *)&param->handle;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if (ndr_hdlookup(mxa, id) == NULL) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh bzero(param, sizeof (struct spoolss_DeleteForm));
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->status = ERROR_INVALID_HANDLE;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh return (NDR_DRC_OK);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh }
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh bzero(param, sizeof (struct spoolss_DeleteForm));
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->status = ERROR_SUCCESS;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh return (NDR_DRC_OK);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh}
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshstatic int
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshspoolss_s_EnumForms(void *arg, ndr_xa_t *mxa)
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh{
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh struct spoolss_EnumForms *param = arg;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh ndr_hdid_t *id = (ndr_hdid_t *)&param->handle;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if (ndr_hdlookup(mxa, id) == NULL) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh bzero(param, sizeof (struct spoolss_EnumForms));
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->status = ERROR_INVALID_HANDLE;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh return (NDR_DRC_OK);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh }
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh bzero(param, sizeof (struct spoolss_EnumForms));
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->status = ERROR_SUCCESS;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->needed = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh return (NDR_DRC_OK);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh}
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh/*ARGSUSED*/
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshstatic int
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshspoolss_s_AddMonitor(void *arg, ndr_xa_t *mxa)
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh{
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh struct spoolss_AddMonitor *param = arg;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->status = ERROR_SUCCESS;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh return (NDR_DRC_OK);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh}
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh/*ARGSUSED*/
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshstatic int
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshspoolss_s_DeleteMonitor(void *arg, ndr_xa_t *mxa)
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh{
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh struct spoolss_DeleteMonitor *param = arg;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->status = ERROR_SUCCESS;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh return (NDR_DRC_OK);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh}
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh/*ARGSUSED*/
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshstatic int
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshspoolss_s_DeletePort(void *arg, ndr_xa_t *mxa)
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh{
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh struct spoolss_DeletePort *param = arg;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->status = ERROR_SUCCESS;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh return (NDR_DRC_OK);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh}
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh/*ARGSUSED*/
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshstatic int
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshspoolss_s_AddPortEx(void *arg, ndr_xa_t *mxa)
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh{
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh struct spoolss_AddPortEx *param = arg;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->status = ERROR_SUCCESS;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh return (NDR_DRC_OK);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh}
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh/*ARGSUSED*/
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshstatic int
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshspoolss_s_SetPort(void *arg, ndr_xa_t *mxa)
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh{
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh struct spoolss_SetPort *param = arg;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->status = ERROR_SUCCESS;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh return (NDR_DRC_OK);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh}
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh/*ARGSUSED*/
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshstatic int
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshspoolss_s_EnumJobs(void *arg, ndr_xa_t *mxa)
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh{
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh struct spoolss_EnumJobs *param = arg;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh DWORD status = ERROR_SUCCESS;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh switch (param->level) {
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh case 1:
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh case 2:
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh case 3:
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh case 4:
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh default:
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh break;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh }
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->status = status;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->needed = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->needed2 = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh return (NDR_DRC_OK);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh}
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh/*ARGSUSED*/
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshspoolss_s_GetJob(void *arg, ndr_xa_t *mxa)
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh{
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh struct spoolss_GetJob *param = arg;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh DWORD status = ERROR_SUCCESS;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh if (param->BufCount == 0)
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->status = ERROR_INSUFFICIENT_BUFFER;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh else
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->status = status;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->needed = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh return (NDR_DRC_OK);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh}
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh/*ARGSUSED*/
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshspoolss_s_ScheduleJob(void *arg, ndr_xa_t *mxa)
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh{
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh struct spoolss_ScheduleJob *param = arg;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh DWORD status = ERROR_SPL_NO_ADDJOB;
8d7e41661dc4633488e93b13363137523ce59977jose borrego
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->status = status;
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
8d7e41661dc4633488e93b13363137523ce59977jose borrego}
8d7e41661dc4633488e93b13363137523ce59977jose borrego
8d7e41661dc4633488e93b13363137523ce59977jose borrego/*ARGSUSED*/
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshspoolss_s_AddJob(void *arg, ndr_xa_t *mxa)
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh{
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh struct spoolss_AddJob *param = arg;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->status = ERROR_SUCCESS;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->needed = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh return (NDR_DRC_OK);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh}
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh/*ARGSUSED*/
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshspoolss_s_rfnpcnex(void *arg, ndr_xa_t *mxa)
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh{
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh struct spoolss_RFNPCNEX *param = arg;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->ppinfo = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->status = ERROR_SUCCESS;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh return (NDR_DRC_OK);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh}
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh/*
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh * Use the RPC context handle to find the fd and write the document content.
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh */
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshspoolss_s_WritePrinter(void *arg, ndr_xa_t *mxa)
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh{
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh struct spoolss_WritePrinter *param = arg;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh int written = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh ndr_hdid_t *id = (ndr_hdid_t *)&param->handle;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh int spfd;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh if (ndr_hdlookup(mxa, id) == NULL) {
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->written = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->status = ERROR_INVALID_HANDLE;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_tracef("spoolss_s_WritePrinter: invalid handle");
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh return (NDR_DRC_OK);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh }
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if ((spfd = spoolss_find_document(id)) < 0) {
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->written = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->status = ERROR_INVALID_HANDLE;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_tracef("spoolss_s_WritePrinter: document not found");
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh return (NDR_DRC_OK);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh }
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh written = write(spfd, param->pBuf, param->BufCount);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh if (written < param->BufCount) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_tracef("spoolss_s_WritePrinter: write failed");
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->written = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->status = ERROR_CANTWRITE;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh return (NDR_DRC_OK);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh }
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->written = written;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->status = ERROR_SUCCESS;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh return (NDR_DRC_OK);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh}
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh/*
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh * Find a document by RPC handle in the spool list and return the fd.
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh */
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshstatic int
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshspoolss_find_document(ndr_hdid_t *handle)
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh{
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_spooldoc_t *sp;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh (void) rw_rdlock(&spoolss_splist.sp_rwl);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh sp = list_head(&spoolss_splist.sp_list);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh while (sp != NULL) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if (!memcmp(handle, &(sp->sd_handle), sizeof (ndr_hdid_t))) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh (void) rw_unlock(&spoolss_splist.sp_rwl);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh return (sp->sd_fd);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh }
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh sp = list_next(&spoolss_splist.sp_list, sp);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh }
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh (void) rw_unlock(&spoolss_splist.sp_rwl);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh return (-1);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh}
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh/*
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh * GetPrinterData is used t obtain values from the registry for a
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh * printer or a print server. See [MS-RPRN] for value descriptions.
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh * The registry returns ERROR_FILE_NOT_FOUND for unknown keys.
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh */
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshspoolss_s_GetPrinterData(void *arg, ndr_xa_t *mxa)
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh{
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh static spoolss_winreg_t reg[] = {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh { "ChangeId", 0x0050acf2 },
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh { "W3SvcInstalled", 0x00000000 },
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh { "BeepEnabled", 0x00000000 },
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh { "EventLog", 0x0000001f },
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh { "NetPopup", 0x00000000 },
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh { "NetPopupToComputer", 0x00000000 },
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh { "MajorVersion", 0x00000003 },
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh { "MinorVersion", 0x00000000 },
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh { "DsPresent", 0x00000000 }
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh };
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh struct spoolss_GetPrinterData *param = arg;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh char *name = (char *)param->pValueName;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh char buf[MAXPATHLEN];
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh static uint8_t reserved_buf[4];
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh spoolss_winreg_t *rp;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_share_t si;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_version_t *osversion;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh struct utsname sysname;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_wchar_t *wcs;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh uint32_t value;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh uint32_t status;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh int wcslen;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh int i;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if (name == NULL || *name == '\0') {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh status = ERROR_FILE_NOT_FOUND;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh goto report_error;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh }
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh for (i = 0; i < sizeof (reg) / sizeof (reg[0]); ++i) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->pType = WINREG_DWORD;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->Needed = sizeof (uint32_t);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh rp = &reg[i];
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if (strcasecmp(name, rp->name) != 0)
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh continue;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if (param->Size < sizeof (uint32_t)) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->Size = 0;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh goto need_more_data;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh }
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if ((param->Buf = NDR_NEW(mxa, uint32_t)) == NULL) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh status = ERROR_NOT_ENOUGH_MEMORY;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh goto report_error;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh }
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh value = rp->value;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if ((strcasecmp(name, "DsPresent") == 0) &&
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh (smb_config_get_secmode() == SMB_SECMODE_DOMAIN))
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh value = 0x00000001;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh bcopy(&value, param->Buf, sizeof (uint32_t));
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->Size = sizeof (uint32_t);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->status = ERROR_SUCCESS;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh return (NDR_DRC_OK);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh }
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if (strcasecmp(name, "OSVersion") == 0) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->pType = WINREG_BINARY;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->Needed = sizeof (smb_version_t);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if (param->Size < sizeof (smb_version_t)) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->Size = sizeof (smb_version_t);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh goto need_more_data;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh }
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if ((osversion = NDR_NEW(mxa, smb_version_t)) == NULL) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh status = ERROR_NOT_ENOUGH_MEMORY;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh goto report_error;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh }
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_config_get_version(osversion);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->Buf = (uint8_t *)osversion;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->status = ERROR_SUCCESS;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh return (NDR_DRC_OK);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh }
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if (strcasecmp(name, "DNSMachineName") == 0) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->pType = WINREG_SZ;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh buf[0] = '\0';
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh (void) smb_getfqhostname(buf, MAXHOSTNAMELEN);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh goto encode_string;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh }
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if (strcasecmp(name, "DefaultSpoolDirectory") == 0) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->pType = WINREG_SZ;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh buf[0] = '\0';
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if (smb_shr_get(SMB_SHARE_PRINT, &si) != NERR_Success) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh status = ERROR_FILE_NOT_FOUND;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh goto report_error;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh }
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh (void) snprintf(buf, MAXPATHLEN, "C:/%s", si.shr_path);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh (void) strcanon(buf, "/\\");
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh (void) strsubst(buf, '/', '\\');
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh goto encode_string;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh }
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if (strcasecmp(name, "Architecture") == 0) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->pType = WINREG_SZ;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if (uname(&sysname) < 0)
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh (void) strlcpy(buf, "Solaris", MAXPATHLEN);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh else
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh (void) snprintf(buf, MAXPATHLEN, "%s %s",
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh sysname.sysname, sysname.machine);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh goto encode_string;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh }
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh status = ERROR_FILE_NOT_FOUND;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshreport_error:
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh bzero(param, sizeof (struct spoolss_GetPrinterData));
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->Buf = reserved_buf;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->status = status;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh return (NDR_DRC_OK);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshencode_string:
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh wcslen = smb_wcequiv_strlen(buf) + sizeof (smb_wchar_t);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if (param->Size < wcslen) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->Needed = wcslen;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh goto need_more_data;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh }
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if ((wcs = NDR_MALLOC(mxa, wcslen)) == NULL) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh status = ERROR_NOT_ENOUGH_MEMORY;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh goto report_error;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh }
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh (void) ndr_mbstowcs(NULL, wcs, buf, wcslen);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->Buf = (uint8_t *)wcs;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->Needed = wcslen;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->status = ERROR_SUCCESS;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh return (NDR_DRC_OK);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshneed_more_data:
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->Size = 0;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->Buf = reserved_buf;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->status = ERROR_MORE_DATA;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh return (NDR_DRC_OK);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh}
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshvoid
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshsmb_rpc_off(char *dst, char *src, uint32_t *offset, uint32_t *outoffset)
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh{
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh int nwchars;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh int bytes;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh bytes = smb_wcequiv_strlen(src) + 2;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh nwchars = strlen(src) + 1;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh *offset -= bytes;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh *outoffset = *offset;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh /*LINTED E_BAD_PTR_CAST_ALIGN*/
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh (void) smb_mbstowcs(((smb_wchar_t *)(dst + *offset)), src, nwchars);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh}
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
8d7e41661dc4633488e93b13363137523ce59977jose borregoint
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshspoolss_s_GetPrinter(void *arg, ndr_xa_t *mxa)
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh{
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh struct spoolss_GetPrinter *param = arg;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh struct spoolss_GetPrinter0 *pinfo0;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh struct spoolss_GetPrinter1 *pinfo1;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh struct spoolss_GetPrinter2 *pinfo2;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh struct spoolss_DeviceMode *devmode2;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh ndr_hdid_t *id = (ndr_hdid_t *)&param->handle;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh spoolss_sd_t secdesc;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh char server[MAXNAMELEN];
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh char printer[MAXNAMELEN];
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh DWORD status = ERROR_SUCCESS;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh char *wname;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh uint32_t offset;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh uint8_t *tmpbuf;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if (ndr_hdlookup(mxa, id) == NULL) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh status = ERROR_INVALID_HANDLE;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh goto error_out;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh }
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if (spoolss_getservername(server, MAXNAMELEN) != 0) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh status = ERROR_INTERNAL_ERROR;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh goto error_out;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh }
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh (void) snprintf(printer, MAXNAMELEN, "%s\\%s", server, SPOOLSS_PRINTER);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh switch (param->switch_value) {
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh case 0:
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh case 1:
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->needed = 460;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh break;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh case 2:
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->needed = 712;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh break;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh default:
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh status = ERROR_INVALID_LEVEL;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh goto error_out;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh }
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if (param->BufCount < param->needed) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->BufCount = 0;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->Buf = NULL;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->status = ERROR_INSUFFICIENT_BUFFER;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh return (NDR_DRC_OK);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh }
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if ((param->Buf = NDR_MALLOC(mxa, param->BufCount)) == NULL) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh status = ERROR_NOT_ENOUGH_MEMORY;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh goto error_out;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh }
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh bzero(param->Buf, param->BufCount);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh wname = (char *)param->Buf;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh offset = param->needed;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh switch (param->switch_value) {
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh case 0:
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh /*LINTED E_BAD_PTR_CAST_ALIGN*/
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh pinfo0 = (struct spoolss_GetPrinter0 *)param->Buf;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_rpc_off(wname, server, &offset, &pinfo0->servername);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_rpc_off(wname, printer, &offset, &pinfo0->printername);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh pinfo0->cjobs = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh pinfo0->total_jobs = 6;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh pinfo0->total_bytes = 1040771;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh pinfo0->time0 = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh pinfo0->time1 = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh pinfo0->time2 = 3;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh pinfo0->time3 = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh pinfo0->global_counter = 2162710;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh pinfo0->total_pages = 21495865;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh pinfo0->version = 10;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh pinfo0->session_counter = 1;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh pinfo0->job_error = 0x6;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh pinfo0->change_id = 0x1;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh pinfo0->status = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh pinfo0->c_setprinter = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh break;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh case 1:
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh /*LINTED E_BAD_PTR_CAST_ALIGN*/
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh pinfo1 = (struct spoolss_GetPrinter1 *)param->Buf;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh pinfo1->flags = PRINTER_ENUM_ICON8;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_rpc_off(wname, printer, &offset, &pinfo1->flags);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_rpc_off(wname, printer, &offset, &pinfo1->description);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_rpc_off(wname, printer, &offset, &pinfo1->comment);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh break;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh case 2:
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh /*LINTED E_BAD_PTR_CAST_ALIGN*/
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh pinfo2 = (struct spoolss_GetPrinter2 *)param->Buf;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_rpc_off(wname, server, &offset, &pinfo2->servername);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_rpc_off(wname, printer, &offset, &pinfo2->printername);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh smb_rpc_off(wname, SPOOLSS_PRINTER, &offset,
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh &pinfo2->sharename);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh smb_rpc_off(wname, "CIFS Printer Port", &offset,
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh &pinfo2->portname);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh smb_rpc_off(wname, "", &offset, &pinfo2->drivername);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh smb_rpc_off(wname, SPOOLSS_PRINTER, &offset,
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh &pinfo2->comment);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh smb_rpc_off(wname, "farside", &offset, &pinfo2->location);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh offset -= sizeof (struct spoolss_DeviceMode);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh pinfo2->devmode = offset;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh /*LINTED E_BAD_PTR_CAST_ALIGN*/
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh devmode2 = (struct spoolss_DeviceMode *)(param->Buf + offset);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh smb_rpc_off(wname, "farside", &offset, &pinfo2->sepfile);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh smb_rpc_off(wname, "winprint", &offset,
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh &pinfo2->printprocessor);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh smb_rpc_off(wname, "RAW", &offset, &pinfo2->datatype);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_rpc_off(wname, "", &offset, &pinfo2->parameters);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh status = spoolss_make_sd(mxa, &secdesc);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if (status == ERROR_SUCCESS) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh offset -= secdesc.sd_size;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh pinfo2->secdesc = offset;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh tmpbuf = (uint8_t *)(param->Buf + offset);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh bcopy(secdesc.sd_buf, tmpbuf, secdesc.sd_size);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh }
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh pinfo2->attributes = 0x00001048;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh pinfo2->status = 0x00000000;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh pinfo2->starttime = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh pinfo2->untiltime = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh pinfo2->cjobs = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh pinfo2->averageppm = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh pinfo2->defaultpriority = 0;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh /*LINTED E_BAD_PTR_CAST_ALIGN*/
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh (void) smb_mbstowcs((smb_wchar_t *)devmode2->devicename,
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh printer, 32);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->specversion = 0x0401;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->driverversion = 1024;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->size = 220;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->driverextra_length = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->fields = 0x00014713;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->orientation = 1;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->papersize = 1;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->paperlength = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->paperwidth = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->scale = 100;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->copies = 1;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->defaultsource = 15;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->printquality = 65532;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->color = 1;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->duplex = 1;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->yresolution = 1;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->ttoption = 1;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->collate = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh /*LINTED E_BAD_PTR_CAST_ALIGN*/
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh (void) smb_mbstowcs((smb_wchar_t *)devmode2->formname,
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh "Letter", 32);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->logpixels = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->bitsperpel = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->pelswidth = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->pelsheight = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->displayflags = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->displayfrequency = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->icmmethod = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->icmintent = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->mediatype = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->dithertype = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->reserved1 = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->reserved2 = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->panningwidth = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh devmode2->panningheight = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh break;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh default:
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh break;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh }
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh param->status = status;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh return (NDR_DRC_OK);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosherror_out:
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_tracef("spoolss_s_GetPrinter: error %u", status);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh bzero(param, sizeof (struct spoolss_GetPrinter));
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh param->status = status;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh return (NDR_DRC_OK);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh}
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshstatic int
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshspoolss_getservername(char *name, size_t namelen)
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh{
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh char hostname[MAXHOSTNAMELEN];
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh char ipstr[INET6_ADDRSTRLEN];
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_inaddr_t ipaddr;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh struct hostent *h;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh const char *p;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh int error;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if (smb_gethostname(hostname, MAXHOSTNAMELEN, 0) != 0) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_tracef("spoolss_s_GetPrinter: gethostname failed");
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh return (-1);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh }
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if ((h = smb_gethostbyname(hostname, &error)) == NULL) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_tracef("spoolss_s_GetPrinter: gethostbyname failed: %d",
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh error);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh return (-1);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh }
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh bcopy(h->h_addr, &ipaddr, h->h_length);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh ipaddr.a_family = h->h_addrtype;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh freehostent(h);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh p = smb_inet_ntop(&ipaddr, ipstr, SMB_IPSTRLEN(ipaddr.a_family));
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if (p == NULL) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_tracef("spoolss_s_GetPrinter: inet_ntop failed");
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh return (-1);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh }
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh (void) snprintf(name, namelen, "\\\\%s", ipstr);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh return (0);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh}
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshstatic uint32_t
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshspoolss_make_sd(ndr_xa_t *mxa, spoolss_sd_t *secdesc)
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh{
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_sd_t sd;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh uint8_t *sd_buf;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh uint32_t sd_len;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh uint32_t status;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh bzero(&sd, sizeof (smb_sd_t));
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if ((status = spoolss_format_sd(&sd)) != ERROR_SUCCESS)
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh return (status);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh sd_len = smb_sd_len(&sd, SMB_ALL_SECINFO);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if ((sd_buf = NDR_MALLOC(mxa, sd_len)) == NULL)
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh return (ERROR_NOT_ENOUGH_MEMORY);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh secdesc->sd_buf = sd_buf;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh secdesc->sd_size = sd_len;
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh status = srvsvc_sd_set_relative(&sd, sd_buf);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh smb_sd_term(&sd);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh return (status);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh}
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic uint32_t
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintoshspoolss_format_sd(smb_sd_t *sd)
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh{
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh smb_fssd_t fs_sd;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh acl_t *acl;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh uint32_t status = ERROR_SUCCESS;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh if (acl_fromtext("everyone@:full_set::allow", &acl) != 0) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_tracef("spoolss_format_sd: NOT_ENOUGH_MEMORY");
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh return (ERROR_NOT_ENOUGH_MEMORY);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh }
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh smb_fssd_init(&fs_sd, SMB_ALL_SECINFO, SMB_FSSD_FLAGS_DIR);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh fs_sd.sd_uid = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh fs_sd.sd_gid = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh fs_sd.sd_zdacl = acl;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh fs_sd.sd_zsacl = NULL;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh status = smb_sd_fromfs(&fs_sd, sd);
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh if (status != NT_STATUS_SUCCESS) {
fd9ee8b58485b20072eeef1310a88ff348d5e7fajoyce mcintosh smb_tracef("spoolss_format_sd: %u", status);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh status = ERROR_ACCESS_DENIED;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh }
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh smb_fssd_term(&fs_sd);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh return (status);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh}
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh/*ARGSUSED*/
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshstatic int
8d7e41661dc4633488e93b13363137523ce59977jose borregospoolss_s_stub(void *arg, ndr_xa_t *mxa)
8d7e41661dc4633488e93b13363137523ce59977jose borrego{
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_FAULT_PARAM_0_UNIMPLEMENTED);
8d7e41661dc4633488e93b13363137523ce59977jose borrego}
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshvoid
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshfixup_spoolss_RFNPCNEX(struct spoolss_RFNPCNEX *val)
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh{
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh unsigned short size1 = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh unsigned short size2 = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh unsigned short size3 = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh struct spoolss_RPC_V2_NOTIFY_INFO *pinfo;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh pinfo = val->ppinfo->pinfo;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh switch (pinfo->aData->Reserved) {
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh case TABLE_STRING:
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh size1 = sizeof (struct STRING_CONTAINER);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh break;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh case TABLE_DWORD:
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh size1 = sizeof (DWORD) * 2;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh break;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh case TABLE_TIME:
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh size1 = sizeof (struct SYSTEMTIME_CONTAINER);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh break;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh case TABLE_DEVMODE:
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh size1 = sizeof (struct spoolssDevmodeContainer);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh break;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh case TABLE_SECURITY_DESCRIPTOR:
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh size1 = sizeof (struct SECURITY_CONTAINER);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh break;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh default:
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh return;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh }
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh size2 = size1 + (2 * sizeof (DWORD));
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh size3 = size2 + sizeof (ndr_request_hdr_t) + sizeof (DWORD);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh FIXUP_PDU_SIZE(spoolss_RPC_V2_NOTIFY_INFO_DATA_DATA, size1);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh FIXUP_PDU_SIZE(spoolss_RPC_V2_NOTIFY_INFO_DATA, size2);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh FIXUP_PDU_SIZE(spoolss_RPC_V2_NOTIFY_INFO, size3);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh FIXUP_PDU_SIZE(spoolss_RFNPCNEX, size3);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh}
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshvoid
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintoshfixup_spoolss_GetPrinter(struct spoolss_GetPrinter *val)
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh{
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh unsigned short size1 = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh unsigned short size2 = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh unsigned short size3 = 0;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh switch (val->switch_value) {
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh CASE_INFO_ENT(spoolss_GetPrinter, 0);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh CASE_INFO_ENT(spoolss_GetPrinter, 1);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh CASE_INFO_ENT(spoolss_GetPrinter, 2);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh CASE_INFO_ENT(spoolss_GetPrinter, 3);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh CASE_INFO_ENT(spoolss_GetPrinter, 4);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh CASE_INFO_ENT(spoolss_GetPrinter, 5);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh CASE_INFO_ENT(spoolss_GetPrinter, 6);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh CASE_INFO_ENT(spoolss_GetPrinter, 7);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh CASE_INFO_ENT(spoolss_GetPrinter, 8);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh default:
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh return;
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh };
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh size2 = size1 + (2 * sizeof (DWORD));
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh size3 = size2 + sizeof (ndr_request_hdr_t) + sizeof (DWORD);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh FIXUP_PDU_SIZE(spoolss_GetPrinter_result_u, size1);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh FIXUP_PDU_SIZE(spoolss_GetPrinter_result, size2);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh FIXUP_PDU_SIZE(spoolss_GetPrinter, size3);
cb174861876aea6950a7ab4ce944aff84b1914cdjoyce mcintosh}
86d7016b0051dd58772baafe5b5bcee51d560b05Gordon Ross
86d7016b0051dd58772baafe5b5bcee51d560b05Gordon Ross#else /* HAVE_CUPS */
86d7016b0051dd58772baafe5b5bcee51d560b05Gordon Ross
86d7016b0051dd58772baafe5b5bcee51d560b05Gordon Ross/*
86d7016b0051dd58772baafe5b5bcee51d560b05Gordon Ross * If not HAVE_CUPS, just provide a few "stubs".
86d7016b0051dd58772baafe5b5bcee51d560b05Gordon Ross */
86d7016b0051dd58772baafe5b5bcee51d560b05Gordon Ross
86d7016b0051dd58772baafe5b5bcee51d560b05Gordon Rossvoid
86d7016b0051dd58772baafe5b5bcee51d560b05Gordon Rossspoolss_initialize(void)
86d7016b0051dd58772baafe5b5bcee51d560b05Gordon Ross{
86d7016b0051dd58772baafe5b5bcee51d560b05Gordon Ross}
86d7016b0051dd58772baafe5b5bcee51d560b05Gordon Ross
86d7016b0051dd58772baafe5b5bcee51d560b05Gordon Rossvoid
86d7016b0051dd58772baafe5b5bcee51d560b05Gordon Rossspoolss_finalize(void)
86d7016b0051dd58772baafe5b5bcee51d560b05Gordon Ross{
86d7016b0051dd58772baafe5b5bcee51d560b05Gordon Ross}
86d7016b0051dd58772baafe5b5bcee51d560b05Gordon Ross
86d7016b0051dd58772baafe5b5bcee51d560b05Gordon Ross/*ARGSUSED*/
86d7016b0051dd58772baafe5b5bcee51d560b05Gordon Rossvoid
86d7016b0051dd58772baafe5b5bcee51d560b05Gordon Rossspoolss_register_copyfile(spoolss_copyfile_t copyfile)
86d7016b0051dd58772baafe5b5bcee51d560b05Gordon Ross{
86d7016b0051dd58772baafe5b5bcee51d560b05Gordon Ross}
86d7016b0051dd58772baafe5b5bcee51d560b05Gordon Ross
86d7016b0051dd58772baafe5b5bcee51d560b05Gordon Ross#endif /* HAVE_CUPS */