struct _counter_printer_0 *prev;
int snum;
- uint32 counter;
+ uint32_t counter;
} counter_printer_0;
static counter_printer_0 *counter_list;
static struct rpc_pipe_client *notify_cli_pipe; /* print notify back-channel pipe handle*/
-static uint32 smb_connections=0;
+static uint32_t smb_connections = 0;
/* in printing/nt_printing.c */
/* Tell the connections db we're no longer interested in
* printer notify messages. */
- register_message_flags( False, FLAG_MSG_PRINT_NOTIFY );
+ register_message_flags(false, FLAG_MSG_PRINT_NOTIFY);
}
smb_connections--;
static int printer_entry_destructor(Printer_entry *Printer)
{
- if (Printer->notify.client_connected==True) {
+ if (Printer->notify.client_connected == true) {
int snum = -1;
if ( Printer->printer_type == SPLHND_SERVER) {
Printer->notify.localmachine[0]='\0';
Printer->notify.printerlocal=0;
TALLOC_FREE(Printer->notify.option);
- Printer->notify.client_connected=False;
+ Printer->notify.client_connected = false;
free_nt_devicemode( &Printer->nt_devmode );
free_a_printer( &Printer->printer_info, 2 );
if (!Printer) {
DEBUG(2,("close_printer_handle: Invalid handle (%s:%u:%u)\n",
OUR_HANDLE(hnd)));
- return False;
+ return false;
}
close_policy_hnd(p, hnd);
- return True;
+ return true;
}
/****************************************************************************
char *command = NULL;
int ret;
SE_PRIV se_printop = SE_PRINT_OPERATOR;
- bool is_print_op = False;
+ bool is_print_op = false;
/* can't fail if we don't try */
return WERR_BADFID; /* What to return here? */
/* go ahead and re-read the services immediately */
- reload_services( False );
+ reload_services(false);
if ( lp_servicenumber( sharename ) < 0 )
return WERR_ACCESS_DENIED;
if (!Printer) {
DEBUG(2,("get_printer_snum: Invalid handle (%s:%u:%u)\n",
OUR_HANDLE(hnd)));
- return False;
+ return false;
}
switch (Printer->printer_type) {
*number = print_queue_snum(Printer->sharename);
return (*number != -1);
case SPLHND_SERVER:
- return False;
+ return false;
default:
- return False;
+ return false;
}
}
Check if it's \\server or \\server\printer
****************************************************************************/
-static bool set_printer_hnd_printertype(Printer_entry *Printer, char *handlename)
+static bool set_printer_hnd_printertype(Printer_entry *Printer, const char *handlename)
{
DEBUG(3,("Setting printer type=%s\n", handlename));
if ( strlen(handlename) < 3 ) {
DEBUGADD(4,("A print server must have at least 1 char ! %s\n", handlename));
- return False;
+ return false;
}
/* it's a print server */
Printer->printer_type = SPLHND_PRINTER;
}
- return True;
+ return true;
}
/****************************************************************************
XcvDataPort() interface.
****************************************************************************/
-static bool set_printer_hnd_name(Printer_entry *Printer, char *handlename)
+static bool set_printer_hnd_name(Printer_entry *Printer, const char *handlename)
{
int snum;
int n_services=lp_numservices();
char *aprinter, *printername;
const char *servername;
fstring sname;
- bool found=False;
+ bool found = false;
NT_PRINTER_INFO_LEVEL *printer = NULL;
WERROR result;
- DEBUG(4,("Setting printer name=%s (len=%lu)\n", handlename, (unsigned long)strlen(handlename)));
+ DEBUG(4,("Setting printer name=%s (len=%lu)\n", handlename,
+ (unsigned long)strlen(handlename)));
- aprinter = handlename;
+ aprinter = CONST_DISCARD(char *, handlename);
if ( *handlename == '\\' ) {
servername = canon_servername(handlename);
if ( (aprinter = strchr_m( servername, '\\' )) != NULL ) {
aprinter++;
}
} else {
- servername = "";
+ servername = global_myname();
}
/* save the servername to fill in replies on this handle */
if ( !is_myname_or_ipaddr( servername ) )
- return False;
+ return false;
fstrcpy( Printer->servername, servername );
if ( Printer->printer_type == SPLHND_SERVER )
- return True;
+ return true;
if ( Printer->printer_type != SPLHND_PRINTER )
- return False;
+ return false;
DEBUGADD(5, ("searching for [%s]\n", aprinter ));
if ( strequal( aprinter, SPL_XCV_MONITOR_TCPMON ) ) {
Printer->printer_type = SPLHND_PORTMON_TCP;
fstrcpy(sname, SPL_XCV_MONITOR_TCPMON);
- found = True;
+ found = true;
}
else if ( strequal( aprinter, SPL_XCV_MONITOR_LOCALMON ) ) {
Printer->printer_type = SPLHND_PORTMON_LOCAL;
fstrcpy(sname, SPL_XCV_MONITOR_LOCALMON);
- found = True;
+ found = true;
}
/* Search all sharenames first as this is easier than pulling
fstrcpy(sname, lp_servicename(snum));
if ( strequal( aprinter, sname ) ) {
- found = True;
+ found = true;
break;
}
if ( strequal(printername, aprinter) ) {
free_a_printer( &printer, 2);
- found = True;
+ found = true;
break;
}
if ( !found ) {
DEBUGADD(4,("Printer not found\n"));
- return False;
+ return false;
}
DEBUGADD(4,("set_printer_hnd_name: Printer found: %s -> %s\n", aprinter, sname));
fstrcpy(Printer->sharename, sname);
- return True;
+ return true;
}
/****************************************************************************
****************************************************************************/
static bool open_printer_hnd(pipes_struct *p, struct policy_handle *hnd,
- char *name, uint32_t access_granted)
+ const char *name, uint32_t access_granted)
{
Printer_entry *new_printer;
if (!create_policy_hnd(p, hnd, new_printer)) {
TALLOC_FREE(new_printer);
- return False;
+ return false;
}
/* Add to the internal list. */
if (!set_printer_hnd_printertype(new_printer, name)) {
close_printer_handle(p, hnd);
- return False;
+ return false;
}
if (!set_printer_hnd_name(new_printer, name)) {
close_printer_handle(p, hnd);
- return False;
+ return false;
}
new_printer->access_granted = access_granted;
DEBUG(5, ("%d printer handles active\n", (int)p->pipe_handles->count ));
- return True;
+ return true;
}
/***************************************************************************
given by (notify_type, notify_field).
**************************************************************************/
-static bool is_monitoring_event_flags(uint32 flags, uint16 notify_type,
- uint16 notify_field)
+static bool is_monitoring_event_flags(uint32_t flags, uint16_t notify_type,
+ uint16_t notify_field)
{
- return True;
+ return true;
}
-static bool is_monitoring_event(Printer_entry *p, uint16 notify_type,
- uint16 notify_field)
+static bool is_monitoring_event(Printer_entry *p, uint16_t notify_type,
+ uint16_t notify_field)
{
struct spoolss_NotifyOption *option = p->notify.option;
- uint32 i, j;
+ uint32_t i, j;
/*
* Flags should always be zero when the change notify
*/
if (!option) {
- return False;
+ return false;
}
if (p->notify.flags)
for (j = 0; j < option->types[i].count; j++) {
if (option->types[i].fields[j].field == notify_field) {
- return True;
+ return true;
}
}
}
DEBUG(10, ("Open handle for \\\\%s\\%s is not monitoring 0x%02x/0x%02x\n",
p->servername, p->sharename, notify_type, notify_field));
- return False;
+ return false;
}
#define SETUP_SPOOLSS_NOTIFY_DATA_INTEGER(_data, _integer) \
/***********************************************************************
**********************************************************************/
-static SPOOLSS_NOTIFY_MSG_GROUP* notify_ctr_getgroup( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx )
+static SPOOLSS_NOTIFY_MSG_GROUP* notify_ctr_getgroup( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32_t idx )
{
if ( !ctr || !ctr->msg_groups )
return NULL;
back registered
**********************************************************************/
-static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx )
+static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32_t idx )
{
Printer_entry *p;
TALLOC_CTX *mem_ctx = notify_ctr_getctx( ctr );
static bool notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, struct timeval *tv, void *buf, size_t len )
{
- uint32 tv_sec, tv_usec;
+ uint32_t tv_sec, tv_usec;
size_t offset = 0;
/* Unpack message */
- offset += tdb_unpack((uint8 *)buf + offset, len - offset, "f",
+ offset += tdb_unpack((uint8_t *)buf + offset, len - offset, "f",
msg->printer);
- offset += tdb_unpack((uint8 *)buf + offset, len - offset, "ddddddd",
+ offset += tdb_unpack((uint8_t *)buf + offset, len - offset, "ddddddd",
&tv_sec, &tv_usec,
&msg->type, &msg->field, &msg->id, &msg->len, &msg->flags);
if (msg->len == 0)
- tdb_unpack((uint8 *)buf + offset, len - offset, "dd",
+ tdb_unpack((uint8_t *)buf + offset, len - offset, "dd",
&msg->notify.value[0], &msg->notify.value[1]);
else
- tdb_unpack((uint8 *)buf + offset, len - offset, "B",
+ tdb_unpack((uint8_t *)buf + offset, len - offset, "B",
&msg->len, &msg->notify.data);
DEBUG(3, ("notify2_unpack_msg: got NOTIFY2 message for printer %s, jobid %u type %d, field 0x%02x, flags 0x%04x\n",
DEBUG(3, ("notify2_unpack_msg: value1 = %d, value2 = %d\n", msg->notify.value[0],
msg->notify.value[1]));
else
- dump_data(3, (uint8 *)msg->notify.data, msg->len);
+ dump_data(3, (uint8_t *)msg->notify.data, msg->len);
- return True;
+ return true;
}
/********************************************************************
/* cleanup */
- DEBUG(10,("receive_notify2_message_list: processed %u messages\n", (uint32)msg_count ));
+ DEBUG(10,("receive_notify2_message_list: processed %u messages\n",
+ (uint32_t)msg_count ));
notify_msg_ctr_destroy( &messages );
driver
********************************************************************/
-static bool srv_spoolss_drv_upgrade_printer(char* drivername)
+static bool srv_spoolss_drv_upgrade_printer(const char *drivername)
{
int len = strlen(drivername);
if (!len)
- return False;
+ return false;
DEBUG(10,("srv_spoolss_drv_upgrade_printer: Sending message about driver upgrade [%s]\n",
drivername));
messaging_send_buf(smbd_messaging_context(), procid_self(),
MSG_PRINTER_DRVUPGRADE,
- (uint8 *)drivername, len+1);
+ (uint8_t *)drivername, len+1);
- return True;
+ return true;
}
/**********************************************************************
int snum;
/* loop through all printers and update the cache where
- client_connected == True */
+ client_connected == true */
while ( printer )
{
if ( (printer->printer_type == SPLHND_PRINTER)
int len = strlen(drivername);
if (!len)
- return False;
+ return false;
DEBUG(10,("srv_spoolss_reset_printerdata: Sending message about resetting printerdata [%s]\n",
drivername));
messaging_send_buf(smbd_messaging_context(), procid_self(),
MSG_PRINTERDATA_INIT_RESET,
- (uint8 *)drivername, len+1);
+ (uint8_t *)drivername, len+1);
- return True;
+ return true;
}
/**********************************************************************
if ((devmode->__driverextra_length != 0) && (devmode->driverextra_data.data != NULL)) {
SAFE_FREE(nt_devmode->nt_dev_private);
nt_devmode->driverextra = devmode->__driverextra_length;
- if((nt_devmode->nt_dev_private=SMB_MALLOC_ARRAY(uint8, nt_devmode->driverextra)) == NULL)
+ if((nt_devmode->nt_dev_private = SMB_MALLOC_ARRAY(uint8_t, nt_devmode->driverextra)) == NULL)
return false;
memcpy(nt_devmode->nt_dev_private, devmode->driverextra_data.data, nt_devmode->driverextra);
}
WERROR _spoolss_OpenPrinterEx(pipes_struct *p,
struct spoolss_OpenPrinterEx *r)
{
- char *name = CONST_DISCARD(char *, r->in.printername);
int snum;
Printer_entry *Printer=NULL;
- if (!name) {
+ if (!r->in.printername) {
return WERR_INVALID_PARAM;
}
/* some sanity check because you can open a printer or a print server */
/* aka: \\server\printer or \\server */
- DEBUGADD(3,("checking name: %s\n",name));
+ DEBUGADD(3,("checking name: %s\n", r->in.printername));
- if (!open_printer_hnd(p, r->out.handle, name, 0)) {
+ if (!open_printer_hnd(p, r->out.handle, r->in.printername, 0)) {
ZERO_STRUCTP(r->out.handle);
return WERR_INVALID_PARAM;
}
Printer = find_printer_index_by_hnd(p, r->out.handle);
if ( !Printer ) {
DEBUG(0,("_spoolss_OpenPrinterEx: logic error. Can't find printer "
- "handle we created for printer %s\n", name ));
+ "handle we created for printer %s\n", r->in.printername));
close_printer_handle(p, r->out.handle);
ZERO_STRUCTP(r->out.handle);
return WERR_INVALID_PARAM;
if (!get_printer_snum(p, handle, &snum, NULL))
return WERR_BADFID;
- Printer->document_started=False;
+ Printer->document_started = false;
print_job_end(snum, Printer->jobid,NORMAL_CLOSE);
/* error codes unhandled so far ... */
result = delete_printer_handle(p, r->in.handle);
- update_c_setprinter(False);
+ update_c_setprinter(false);
return result;
}
* long architecture string
******************************************************************/
-static int get_version_id (char * arch)
+static int get_version_id(const char *arch)
{
int i;
struct table_node archi_table[]= {
WERROR _spoolss_DeletePrinterDriver(pipes_struct *p,
struct spoolss_DeletePrinterDriver *r)
{
- char *driver;
- char *arch;
NT_PRINTER_DRIVER_INFO_LEVEL info;
NT_PRINTER_DRIVER_INFO_LEVEL info_win2k;
int version;
return WERR_ACCESS_DENIED;
}
- driver = CONST_DISCARD(char *, r->in.driver);
- arch = CONST_DISCARD(char *, r->in.architecture);
-
/* check that we have a valid driver name first */
- if ((version=get_version_id(arch)) == -1)
+ if ((version = get_version_id(r->in.architecture)) == -1)
return WERR_INVALID_ENVIRONMENT;
ZERO_STRUCT(info);
ZERO_STRUCT(info_win2k);
- if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version)))
+ if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, r->in.driver,
+ r->in.architecture,
+ version)))
{
/* try for Win2k driver if "Windows NT x86" */
if ( version == 2 ) {
version = 3;
- if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) {
+ if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3,
+ r->in.driver,
+ r->in.architecture,
+ version))) {
status = WERR_UNKNOWN_PRINTER_DRIVER;
goto done;
}
if ( version == 2 )
{
- if (W_ERROR_IS_OK(get_a_printer_driver(&info_win2k, 3, driver, arch, 3)))
+ if (W_ERROR_IS_OK(get_a_printer_driver(&info_win2k, 3,
+ r->in.driver,
+ r->in.architecture, 3)))
{
/* if we get to here, we now have 2 driver info structures to remove */
/* remove the Win2k driver first*/
status_win2k = delete_printer_driver(
- p, info_win2k.info_3, 3, False );
+ p, info_win2k.info_3, 3, false);
free_a_printer_driver( info_win2k, 3 );
/* this should not have failed---if it did, report to client */
}
}
- status = delete_printer_driver(p, info.info_3, version, False);
+ status = delete_printer_driver(p, info.info_3, version, false);
/* if at least one of the deletes succeeded return OK */
WERROR _spoolss_DeletePrinterDriverEx(pipes_struct *p,
struct spoolss_DeletePrinterDriverEx *r)
{
- char *driver;
- char *arch;
NT_PRINTER_DRIVER_INFO_LEVEL info;
NT_PRINTER_DRIVER_INFO_LEVEL info_win2k;
int version;
- uint32_t flags = r->in.delete_flags;
bool delete_files;
WERROR status;
WERROR status_win2k = WERR_ACCESS_DENIED;
return WERR_ACCESS_DENIED;
}
- driver = CONST_DISCARD(char *, r->in.driver);
- arch = CONST_DISCARD(char *, r->in.architecture);
-
/* check that we have a valid driver name first */
- if ((version=get_version_id(arch)) == -1) {
+ if ((version = get_version_id(r->in.architecture)) == -1) {
/* this is what NT returns */
return WERR_INVALID_ENVIRONMENT;
}
- if ( flags & DPD_DELETE_SPECIFIC_VERSION )
+ if (r->in.delete_flags & DPD_DELETE_SPECIFIC_VERSION)
version = r->in.version;
ZERO_STRUCT(info);
ZERO_STRUCT(info_win2k);
- status = get_a_printer_driver(&info, 3, driver, arch, version);
+ status = get_a_printer_driver(&info, 3, r->in.driver,
+ r->in.architecture, version);
if ( !W_ERROR_IS_OK(status) )
{
* then we've failed
*/
- if ( (flags&DPD_DELETE_SPECIFIC_VERSION) || (version !=2) )
+ if ( (r->in.delete_flags & DPD_DELETE_SPECIFIC_VERSION) || (version !=2) )
goto done;
/* try for Win2k driver if "Windows NT x86" */
version = 3;
- if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) {
+ if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, r->in.driver,
+ r->in.architecture,
+ version))) {
status = WERR_UNKNOWN_PRINTER_DRIVER;
goto done;
}
* Refer to MSDN docs on DeletePrinterDriverEx() for details.
*/
- delete_files = flags & (DPD_DELETE_ALL_FILES|DPD_DELETE_UNUSED_FILES);
+ delete_files = r->in.delete_flags & (DPD_DELETE_ALL_FILES|DPD_DELETE_UNUSED_FILES);
/* fail if any files are in use and DPD_DELETE_ALL_FILES is set */
- if ( delete_files && printer_driver_files_in_use(info.info_3) & (flags&DPD_DELETE_ALL_FILES) ) {
+ if ( delete_files && printer_driver_files_in_use(info.info_3) & (r->in.delete_flags & DPD_DELETE_ALL_FILES) ) {
/* no idea of the correct error here */
status = WERR_ACCESS_DENIED;
goto done;
/* also check for W32X86/3 if necessary; maybe we already have? */
- if ( (version == 2) && ((flags&DPD_DELETE_SPECIFIC_VERSION) != DPD_DELETE_SPECIFIC_VERSION) ) {
- if (W_ERROR_IS_OK(get_a_printer_driver(&info_win2k, 3, driver, arch, 3)))
+ if ( (version == 2) && ((r->in.delete_flags & DPD_DELETE_SPECIFIC_VERSION) != DPD_DELETE_SPECIFIC_VERSION) ) {
+ if (W_ERROR_IS_OK(get_a_printer_driver(&info_win2k, 3,
+ r->in.driver,
+ r->in.architecture, 3)))
{
- if ( delete_files && printer_driver_files_in_use(info_win2k.info_3) & (flags&DPD_DELETE_ALL_FILES) ) {
+ if ( delete_files && printer_driver_files_in_use(info_win2k.info_3) & (r->in.delete_flags & DPD_DELETE_ALL_FILES) ) {
/* no idea of the correct error here */
free_a_printer_driver( info_win2k, 3 );
status = WERR_ACCESS_DENIED;
Internal routine for storing printerdata
***************************************************************************/
-WERROR set_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, const char *key, const char *value,
- uint32 type, uint8 *data, int real_len )
+WERROR set_printer_dataex(NT_PRINTER_INFO_LEVEL *printer,
+ const char *key, const char *value,
+ uint32_t type, uint8_t *data, int real_len)
{
/* the registry objects enforce uniqueness based on value name */
}
/* REG_BINARY
- * uint32 size = 0x114
- * uint32 major = 5
- * uint32 minor = [0|1]
- * uint32 build = [2195|2600]
+ * uint32_t size = 0x114
+ * uint32_t major = 5
+ * uint32_t minor = [0|1]
+ * uint32_t build = [2195|2600]
* extra unicode string = e.g. "Service Pack 3"
*/
if (!StrCaseCmp(value, "OSVersion")) {
if ( is_zero_addr((struct sockaddr *)client_ss) ) {
if ( !resolve_name( remote_machine, &rm_addr, 0x20) ) {
DEBUG(2,("spoolss_connect_to_client: Can't resolve address for %s\n", remote_machine));
- return False;
+ return false;
}
if (ismyaddr((struct sockaddr *)&rm_addr)) {
DEBUG(0,("spoolss_connect_to_client: Machine %s is one of our addresses. Cannot add to ourselves.\n", remote_machine));
- return False;
+ return false;
}
} else {
char addr[INET6_ADDRSTRLEN];
if ( !NT_STATUS_IS_OK( ret ) ) {
DEBUG(2,("spoolss_connect_to_client: connection to [%s] failed!\n",
remote_machine ));
- return False;
+ return false;
}
if ( the_cli->protocol != PROTOCOL_NT1 ) {
DEBUG(0,("spoolss_connect_to_client: machine %s didn't negotiate NT protocol.\n", remote_machine));
cli_shutdown(the_cli);
- return False;
+ return false;
}
/*
DEBUG(2,("spoolss_connect_to_client: unable to open the spoolss pipe on machine %s. Error was : %s.\n",
remote_machine, nt_errstr(ret)));
cli_shutdown(the_cli);
- return False;
+ return false;
}
- return True;
+ return true;
}
/***************************************************************************
****************************************************************************/
static bool srv_spoolss_replyopenprinter(int snum, const char *printer,
- uint32 localprinter, uint32 type,
+ uint32_t localprinter, uint32_t type,
struct policy_handle *handle,
struct sockaddr_storage *client_ss)
{
fstrcpy(unix_printer, printer+2); /* the +2 is to strip the leading 2 backslashs */
if ( !spoolss_connect_to_client( ¬ify_cli_pipe, client_ss, unix_printer ))
- return False;
+ return false;
messaging_register(smbd_messaging_context(), NULL,
MSG_PRINTER_NOTIFY2,
receive_notify2_message_list);
/* Tell the connections db we're now interested in printer
* notify messages. */
- register_message_flags( True, FLAG_MSG_PRINT_NOTIFY );
+ register_message_flags(true, FLAG_MSG_PRINT_NOTIFY);
}
/*
&Printer->notify.client_hnd, &client_ss))
return WERR_SERVER_UNAVAILABLE;
- Printer->notify.client_connected=True;
+ Printer->notify.client_connected = true;
return WERR_OK;
}
/* A table describing the various print notification constants and
whether the notification data is a pointer to a variable sized
- buffer, a one value uint32 or a two value uint32. */
+ buffer, a one value uint32_t or a two value uint32_t. */
static const struct s_notify_info_data_table notify_info_data_table[] =
{
notify_info_data_table[i].field == field &&
notify_info_data_table[i].fn != NULL) {
*value = i;
- return True;
+ return true;
}
}
- return False;
+ return false;
}
/****************************************************************************
option_type->count, lp_servicename(snum)));
if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &printer, 2, lp_const_servicename(snum))))
- return False;
+ return false;
for(field_num=0; field_num < option_type->count; field_num++) {
field = option_type->fields[field_num].field;
if (info->notifies == NULL) {
DEBUG(2,("construct_notify_printer_info: failed to enlarge buffer info->data!\n"));
free_a_printer(&printer, 2);
- return False;
+ return false;
}
current_data = &info->notifies[info->count];
}
free_a_printer(&printer, 2);
- return True;
+ return true;
}
/*******************************************************************
info->count + 1);
if (info->notifies == NULL) {
DEBUG(2,("construct_notify_jobs_info: failed to enlarg buffer info->data!\n"));
- return False;
+ return false;
}
current_data=&(info->notifies[info->count]);
info->count++;
}
- return True;
+ return true;
}
/*
int snum;
Printer_entry *Printer = find_printer_index_by_hnd(p, hnd);
int i;
- uint32 id;
+ uint32_t id;
struct spoolss_NotifyOption *option;
struct spoolss_NotifyOptionType option_type;
int count,j;
/* We need to keep track of the change value to send back in
RRPCN replies otherwise our updates are ignored. */
- Printer->notify.fnpcn = True;
+ Printer->notify.fnpcn = true;
if (Printer->notify.client_connected) {
DEBUG(10,("_spoolss_RouterRefreshPrinterChangeNotify: "
break;
}
- Printer->notify.fnpcn = False;
+ Printer->notify.fnpcn = false;
done:
return result;
return WERR_OK;
}
+/********************************************************************
+ * construct_printer_info8
+ * fill a spoolss_PrinterInfo8 struct
+ ********************************************************************/
+
+static WERROR construct_printer_info8(TALLOC_CTX *mem_ctx,
+ const NT_PRINTER_INFO_LEVEL *ntprinter,
+ struct spoolss_DeviceModeInfo *r,
+ int snum)
+{
+ struct spoolss_DeviceMode *devmode;
+ WERROR result;
+
+ if (!ntprinter->info_2->devmode) {
+ r->devmode = NULL;
+ return WERR_OK;
+ }
+
+ devmode = TALLOC_ZERO_P(mem_ctx, struct spoolss_DeviceMode);
+ W_ERROR_HAVE_NO_MEMORY(devmode);
+
+ result = convert_nt_devicemode(mem_ctx, devmode, ntprinter->info_2->devmode);
+ if (!W_ERROR_IS_OK(result)) {
+ TALLOC_FREE(devmode);
+ return result;
+ }
+
+ r->devmode = devmode;
+
+ return WERR_OK;
+}
+
+
/********************************************************************
* construct_printer_info1
* fill a spoolss_PrinterInfo1 struct
struct spoolss_PrinterInfo1 *r,
int snum)
{
- char *chaine = NULL;
r->flags = flags;
+ r->description = talloc_asprintf(mem_ctx, "%s,%s,%s",
+ ntprinter->info_2->printername,
+ ntprinter->info_2->drivername,
+ ntprinter->info_2->location);
+ W_ERROR_HAVE_NO_MEMORY(r->description);
+
if (*ntprinter->info_2->comment == '\0') {
r->comment = talloc_strdup(mem_ctx, lp_comment(snum));
- chaine = talloc_asprintf(mem_ctx,
- "%s,%s,%s", ntprinter->info_2->printername,
- ntprinter->info_2->drivername, lp_comment(snum));
} else {
r->comment = talloc_strdup(mem_ctx, ntprinter->info_2->comment); /* saved comment */
- chaine = talloc_asprintf(mem_ctx,
- "%s,%s,%s", ntprinter->info_2->printername,
- ntprinter->info_2->drivername, ntprinter->info_2->comment);
}
- W_ERROR_HAVE_NO_MEMORY(chaine);
W_ERROR_HAVE_NO_MEMORY(r->comment);
- r->description = talloc_strdup(mem_ctx, chaine);
- W_ERROR_HAVE_NO_MEMORY(r->description);
r->name = talloc_strdup(mem_ctx, ntprinter->info_2->printername);
W_ERROR_HAVE_NO_MEMORY(r->name);
Spoolss_enumprinters.
********************************************************************/
-static WERROR enum_all_printers_info_1(TALLOC_CTX *mem_ctx,
- uint32_t flags,
- union spoolss_PrinterInfo **info_p,
- uint32_t *count)
+static WERROR enum_all_printers_info_level(TALLOC_CTX *mem_ctx,
+ uint32_t level,
+ uint32_t flags,
+ union spoolss_PrinterInfo **info_p,
+ uint32_t *count_p)
{
int snum;
int n_services = lp_numservices();
union spoolss_PrinterInfo *info = NULL;
+ uint32_t count = 0;
WERROR result = WERR_OK;
- DEBUG(4,("enum_all_printers_info_1\n"));
-
- *count = 0;
+ *count_p = 0;
+ *info_p = NULL;
- for (snum=0; snum<n_services; snum++) {
+ for (snum = 0; snum < n_services; snum++) {
NT_PRINTER_INFO_LEVEL *ntprinter = NULL;
- struct spoolss_PrinterInfo1 info1;
if (!snum_is_shared_printer(snum)) {
continue;
}
- DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum));
+ DEBUG(4,("Found a printer in smb.conf: %s[%x]\n",
+ lp_servicename(snum), snum));
- result = get_a_printer(NULL, &ntprinter, 2, lp_const_servicename(snum));
- if (!W_ERROR_IS_OK(result)) {
- continue;
+ info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
+ union spoolss_PrinterInfo,
+ count + 1);
+ if (!info) {
+ result = WERR_NOMEM;
+ goto out;
}
- result = construct_printer_info1(info, ntprinter, flags, &info1, snum);
- free_a_printer(&ntprinter,2);
+ result = get_a_printer(NULL, &ntprinter, 2,
+ lp_const_servicename(snum));
if (!W_ERROR_IS_OK(result)) {
- continue;
+ goto out;
}
- info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
- union spoolss_PrinterInfo,
- *count + 1);
- if (!info) {
- DEBUG(2,("enum_all_printers_info_1: failed to enlarge printers buffer!\n"));
- result = WERR_NOMEM;
+ switch (level) {
+ case 0:
+ result = construct_printer_info0(info, ntprinter,
+ &info[count].info0, snum);
+ break;
+ case 1:
+ result = construct_printer_info1(info, ntprinter, flags,
+ &info[count].info1, snum);
+ break;
+ case 2:
+ result = construct_printer_info2(info, ntprinter,
+ &info[count].info2, snum);
+ break;
+ case 4:
+ result = construct_printer_info4(info, ntprinter,
+ &info[count].info4, snum);
+ break;
+ case 5:
+ result = construct_printer_info5(info, ntprinter,
+ &info[count].info5, snum);
+ break;
+
+ default:
+ result = WERR_UNKNOWN_LEVEL;
+ free_a_printer(&ntprinter, 2);
goto out;
}
- DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1\n", *count));
+ free_a_printer(&ntprinter, 2);
+ if (!W_ERROR_IS_OK(result)) {
+ goto out;
+ }
- info[*count].info1 = info1;
- (*count)++;
+ count++;
}
+ *count_p = count;
+ *info_p = info;
+
out:
if (!W_ERROR_IS_OK(result)) {
TALLOC_FREE(info);
- *count = 0;
return result;
}
return WERR_OK;
}
+/********************************************************************
+ * handle enumeration of printers at level 0
+ ********************************************************************/
+
+static WERROR enumprinters_level0(TALLOC_CTX *mem_ctx,
+ uint32_t flags,
+ const char *servername,
+ union spoolss_PrinterInfo **info,
+ uint32_t *count)
+{
+ DEBUG(4,("enum_all_printers_info_0\n"));
+
+ return enum_all_printers_info_level(mem_ctx, 0, flags, info, count);
+}
+
+
+/********************************************************************
+********************************************************************/
+
+static WERROR enum_all_printers_info_1(TALLOC_CTX *mem_ctx,
+ uint32_t flags,
+ union spoolss_PrinterInfo **info,
+ uint32_t *count)
+{
+ DEBUG(4,("enum_all_printers_info_1\n"));
+
+ return enum_all_printers_info_level(mem_ctx, 1, flags, info, count);
+}
+
/********************************************************************
enum_all_printers_info_1_local.
*********************************************************************/
********************************************************************/
static WERROR enum_all_printers_info_2(TALLOC_CTX *mem_ctx,
- union spoolss_PrinterInfo **info_p,
+ union spoolss_PrinterInfo **info,
uint32_t *count)
{
- int snum;
- int n_services = lp_numservices();
- union spoolss_PrinterInfo *info = NULL;
- WERROR result = WERR_OK;
-
- *count = 0;
-
- for (snum=0; snum<n_services; snum++) {
-
- struct spoolss_PrinterInfo2 info2;
- NT_PRINTER_INFO_LEVEL *ntprinter = NULL;
-
- if (!snum_is_shared_printer(snum)) {
- continue;
- }
-
- DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum));
-
- result = get_a_printer(NULL, &ntprinter, 2, lp_const_servicename(snum));
- if (!W_ERROR_IS_OK(result)) {
- continue;
- }
-
- result = construct_printer_info2(info, ntprinter, &info2, snum);
- free_a_printer(&ntprinter, 2);
- if (!W_ERROR_IS_OK(result)) {
- continue;
- }
-
- info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
- union spoolss_PrinterInfo,
- *count + 1);
- if (!info) {
- DEBUG(2,("enum_all_printers_info_2: failed to enlarge printers buffer!\n"));
- result = WERR_NOMEM;
- goto out;
- }
-
- DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_2\n", *count + 1));
-
- info[*count].info2 = info2;
+ DEBUG(4,("enum_all_printers_info_2\n"));
- (*count)++;
- }
-
- out:
- if (!W_ERROR_IS_OK(result)) {
- TALLOC_FREE(info);
- *count = 0;
- return result;
- }
-
- *info_p = info;
-
- return WERR_OK;
+ return enum_all_printers_info_level(mem_ctx, 2, 0, info, count);
}
/********************************************************************
return WERR_OK;
}
+/********************************************************************
+ * handle enumeration of printers at level 4
+ ********************************************************************/
+
+static WERROR enumprinters_level4(TALLOC_CTX *mem_ctx,
+ uint32_t flags,
+ const char *servername,
+ union spoolss_PrinterInfo **info,
+ uint32_t *count)
+{
+ DEBUG(4,("enum_all_printers_info_4\n"));
+
+ return enum_all_printers_info_level(mem_ctx, 4, flags, info, count);
+}
+
+
/********************************************************************
* handle enumeration of printers at level 5
********************************************************************/
union spoolss_PrinterInfo **info,
uint32_t *count)
{
-/* return enum_all_printers_info_5(mem_ctx, info, offered, needed, count);*/
- return WERR_OK;
+ DEBUG(4,("enum_all_printers_info_5\n"));
+
+ return enum_all_printers_info_level(mem_ctx, 5, flags, info, count);
}
/****************************************************************
W_ERROR_HAVE_NO_MEMORY(name);
switch (r->in.level) {
+ case 0:
+ result = enumprinters_level0(p->mem_ctx, r->in.flags, name,
+ r->out.info, r->out.count);
+ break;
case 1:
result = enumprinters_level1(p->mem_ctx, r->in.flags, name,
r->out.info, r->out.count);
result = enumprinters_level2(p->mem_ctx, r->in.flags, name,
r->out.info, r->out.count);
break;
+ case 4:
+ result = enumprinters_level4(p->mem_ctx, r->in.flags, name,
+ r->out.info, r->out.count);
+ break;
case 5:
result = enumprinters_level5(p->mem_ctx, r->in.flags, name,
r->out.info, r->out.count);
break;
- case 3:
- case 4:
- result = WERR_OK; /* ??? */
- break;
default:
return WERR_UNKNOWN_LEVEL;
}
result = construct_printer_info7(p->mem_ctx, Printer,
&r->out.info->info7, snum);
break;
+ case 8:
+ result = construct_printer_info8(p->mem_ctx, ntprinter,
+ &r->out.info->info8, snum);
+ break;
default:
result = WERR_UNKNOWN_LEVEL;
break;
} else {
r->help_file = talloc_strdup(mem_ctx, "");
}
- W_ERROR_HAVE_NO_MEMORY(r->config_file);
+ W_ERROR_HAVE_NO_MEMORY(r->help_file);
r->monitor_name = talloc_strdup(mem_ctx, driver->info_3->monitorname);
W_ERROR_HAVE_NO_MEMORY(r->monitor_name);
}
/********************************************************************
- * fill a spoolss_DriverInfo6 struct
+ * fill a spoolss_DriverInfo4 struct
********************************************************************/
-static WERROR fill_printer_driver_info6(TALLOC_CTX *mem_ctx,
- struct spoolss_DriverInfo6 *r,
+static WERROR fill_printer_driver_info4(TALLOC_CTX *mem_ctx,
+ struct spoolss_DriverInfo4 *r,
const NT_PRINTER_DRIVER_INFO_LEVEL *driver,
const char *servername)
{
} else {
r->help_file = talloc_strdup(mem_ctx, "");
}
- W_ERROR_HAVE_NO_MEMORY(r->config_file);
+ W_ERROR_HAVE_NO_MEMORY(r->help_file);
+
+ r->dependent_files = string_array_from_driver_info(mem_ctx,
+ driver->info_3->dependentfiles,
+ cservername);
+
r->monitor_name = talloc_strdup(mem_ctx, driver->info_3->monitorname);
W_ERROR_HAVE_NO_MEMORY(r->monitor_name);
r->default_datatype = talloc_strdup(mem_ctx, driver->info_3->defaultdatatype);
W_ERROR_HAVE_NO_MEMORY(r->default_datatype);
- r->dependent_files = string_array_from_driver_info(mem_ctx,
- driver->info_3->dependentfiles,
- cservername);
r->previous_names = string_array_from_driver_info(mem_ctx,
NULL,
cservername);
- r->driver_date = 0;
- r->driver_version = 0;
-
- r->manufacturer_name = talloc_strdup(mem_ctx, "");
- W_ERROR_HAVE_NO_MEMORY(r->manufacturer_name);
- r->manufacturer_url = talloc_strdup(mem_ctx, "");
- W_ERROR_HAVE_NO_MEMORY(r->manufacturer_url);
- r->hardware_id = talloc_strdup(mem_ctx, "");
- W_ERROR_HAVE_NO_MEMORY(r->hardware_id);
- r->provider = talloc_strdup(mem_ctx, "");
- W_ERROR_HAVE_NO_MEMORY(r->provider);
-
return WERR_OK;
}
/********************************************************************
- * construct_printer_driver_info_1
+ * fill a spoolss_DriverInfo5 struct
********************************************************************/
-static WERROR construct_printer_driver_info_1(TALLOC_CTX *mem_ctx,
- struct spoolss_DriverInfo1 *r,
- int snum,
- const char *servername,
- const char *architecture,
- uint32_t version)
+static WERROR fill_printer_driver_info5(TALLOC_CTX *mem_ctx,
+ struct spoolss_DriverInfo5 *r,
+ const NT_PRINTER_DRIVER_INFO_LEVEL *driver,
+ const char *servername)
{
- NT_PRINTER_INFO_LEVEL *printer = NULL;
- NT_PRINTER_DRIVER_INFO_LEVEL driver;
- WERROR result;
+ const char *cservername = canon_servername(servername);
- ZERO_STRUCT(driver);
+ r->version = driver->info_3->cversion;
- if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, lp_const_servicename(snum))))
- return WERR_INVALID_PRINTER_NAME;
+ r->driver_name = talloc_strdup(mem_ctx, driver->info_3->name);
+ W_ERROR_HAVE_NO_MEMORY(r->driver_name);
+ r->architecture = talloc_strdup(mem_ctx, driver->info_3->environment);
+ W_ERROR_HAVE_NO_MEMORY(r->architecture);
- if (!W_ERROR_IS_OK(get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version))) {
- free_a_printer(&printer, 2);
- return WERR_UNKNOWN_PRINTER_DRIVER;
+ if (strlen(driver->info_3->driverpath)) {
+ r->driver_path = talloc_asprintf(mem_ctx, "\\\\%s%s",
+ cservername, driver->info_3->driverpath);
+ } else {
+ r->driver_path = talloc_strdup(mem_ctx, "");
}
+ W_ERROR_HAVE_NO_MEMORY(r->driver_path);
+
+ if (strlen(driver->info_3->datafile)) {
+ r->data_file = talloc_asprintf(mem_ctx, "\\\\%s%s",
+ cservername, driver->info_3->datafile);
+ } else {
+ r->data_file = talloc_strdup(mem_ctx, "");
+ }
+ W_ERROR_HAVE_NO_MEMORY(r->data_file);
+
+ if (strlen(driver->info_3->configfile)) {
+ r->config_file = talloc_asprintf(mem_ctx, "\\\\%s%s",
+ cservername, driver->info_3->configfile);
+ } else {
+ r->config_file = talloc_strdup(mem_ctx, "");
+ }
+ W_ERROR_HAVE_NO_MEMORY(r->config_file);
+
+ r->driver_attributes = 0;
+ r->config_version = 0;
+ r->driver_version = 0;
+
+ return WERR_OK;
+}
+/********************************************************************
+ * fill a spoolss_DriverInfo6 struct
+ ********************************************************************/
+
+static WERROR fill_printer_driver_info6(TALLOC_CTX *mem_ctx,
+ struct spoolss_DriverInfo6 *r,
+ const NT_PRINTER_DRIVER_INFO_LEVEL *driver,
+ const char *servername)
+{
+ const char *cservername = canon_servername(servername);
+
+ r->version = driver->info_3->cversion;
+
+ r->driver_name = talloc_strdup(mem_ctx, driver->info_3->name);
+ W_ERROR_HAVE_NO_MEMORY(r->driver_name);
+ r->architecture = talloc_strdup(mem_ctx, driver->info_3->environment);
+ W_ERROR_HAVE_NO_MEMORY(r->architecture);
+
+ if (strlen(driver->info_3->driverpath)) {
+ r->driver_path = talloc_asprintf(mem_ctx, "\\\\%s%s",
+ cservername, driver->info_3->driverpath);
+ } else {
+ r->driver_path = talloc_strdup(mem_ctx, "");
+ }
+ W_ERROR_HAVE_NO_MEMORY(r->driver_path);
+
+ if (strlen(driver->info_3->datafile)) {
+ r->data_file = talloc_asprintf(mem_ctx, "\\\\%s%s",
+ cservername, driver->info_3->datafile);
+ } else {
+ r->data_file = talloc_strdup(mem_ctx, "");
+ }
+ W_ERROR_HAVE_NO_MEMORY(r->data_file);
+
+ if (strlen(driver->info_3->configfile)) {
+ r->config_file = talloc_asprintf(mem_ctx, "\\\\%s%s",
+ cservername, driver->info_3->configfile);
+ } else {
+ r->config_file = talloc_strdup(mem_ctx, "");
+ }
+ W_ERROR_HAVE_NO_MEMORY(r->config_file);
+
+ if (strlen(driver->info_3->helpfile)) {
+ r->help_file = talloc_asprintf(mem_ctx, "\\\\%s%s",
+ cservername, driver->info_3->helpfile);
+ } else {
+ r->help_file = talloc_strdup(mem_ctx, "");
+ }
+ W_ERROR_HAVE_NO_MEMORY(r->help_file);
+
+ r->monitor_name = talloc_strdup(mem_ctx, driver->info_3->monitorname);
+ W_ERROR_HAVE_NO_MEMORY(r->monitor_name);
+ r->default_datatype = talloc_strdup(mem_ctx, driver->info_3->defaultdatatype);
+ W_ERROR_HAVE_NO_MEMORY(r->default_datatype);
+
+ r->dependent_files = string_array_from_driver_info(mem_ctx,
+ driver->info_3->dependentfiles,
+ cservername);
+ r->previous_names = string_array_from_driver_info(mem_ctx,
+ NULL,
+ cservername);
+
+ r->driver_date = 0;
+ r->driver_version = 0;
+
+ r->manufacturer_name = talloc_strdup(mem_ctx, "");
+ W_ERROR_HAVE_NO_MEMORY(r->manufacturer_name);
+ r->manufacturer_url = talloc_strdup(mem_ctx, "");
+ W_ERROR_HAVE_NO_MEMORY(r->manufacturer_url);
+ r->hardware_id = talloc_strdup(mem_ctx, "");
+ W_ERROR_HAVE_NO_MEMORY(r->hardware_id);
+ r->provider = talloc_strdup(mem_ctx, "");
+ W_ERROR_HAVE_NO_MEMORY(r->provider);
+
+ return WERR_OK;
+}
+
+/********************************************************************
+ ********************************************************************/
+
+static WERROR fill_spoolss_DriverFileInfo(TALLOC_CTX *mem_ctx,
+ struct spoolss_DriverFileInfo *r,
+ const char *cservername,
+ const char *file_name,
+ enum spoolss_DriverFileType file_type,
+ uint32_t file_version)
+{
+ r->file_name = talloc_asprintf(mem_ctx, "\\\\%s%s",
+ cservername, file_name);
+ W_ERROR_HAVE_NO_MEMORY(r->file_name);
+ r->file_type = file_type;
+ r->file_version = file_version;
+
+ return WERR_OK;
+}
+
+/********************************************************************
+ ********************************************************************/
+
+static WERROR spoolss_DriverFileInfo_from_driver(TALLOC_CTX *mem_ctx,
+ const NT_PRINTER_DRIVER_INFO_LEVEL *driver,
+ const char *cservername,
+ struct spoolss_DriverFileInfo **info_p,
+ uint32_t *count_p)
+{
+ struct spoolss_DriverFileInfo *info = NULL;
+ uint32_t count = 0;
+ WERROR result;
+ uint32_t i;
+
+ *info_p = NULL;
+ *count_p = 0;
+
+ if (strlen(driver->info_3->driverpath)) {
+ info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
+ struct spoolss_DriverFileInfo,
+ count + 1);
+ W_ERROR_HAVE_NO_MEMORY(info);
+ result = fill_spoolss_DriverFileInfo(info,
+ &info[count],
+ cservername,
+ driver->info_3->driverpath,
+ SPOOLSS_DRIVER_FILE_TYPE_RENDERING,
+ 0);
+ W_ERROR_NOT_OK_RETURN(result);
+ count++;
+ }
+
+ if (strlen(driver->info_3->configfile)) {
+ info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
+ struct spoolss_DriverFileInfo,
+ count + 1);
+ W_ERROR_HAVE_NO_MEMORY(info);
+ result = fill_spoolss_DriverFileInfo(info,
+ &info[count],
+ cservername,
+ driver->info_3->configfile,
+ SPOOLSS_DRIVER_FILE_TYPE_CONFIGURATION,
+ 0);
+ W_ERROR_NOT_OK_RETURN(result);
+ count++;
+ }
+
+ if (strlen(driver->info_3->datafile)) {
+ info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
+ struct spoolss_DriverFileInfo,
+ count + 1);
+ W_ERROR_HAVE_NO_MEMORY(info);
+ result = fill_spoolss_DriverFileInfo(info,
+ &info[count],
+ cservername,
+ driver->info_3->datafile,
+ SPOOLSS_DRIVER_FILE_TYPE_DATA,
+ 0);
+ W_ERROR_NOT_OK_RETURN(result);
+ count++;
+ }
+
+ if (strlen(driver->info_3->helpfile)) {
+ info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
+ struct spoolss_DriverFileInfo,
+ count + 1);
+ W_ERROR_HAVE_NO_MEMORY(info);
+ result = fill_spoolss_DriverFileInfo(info,
+ &info[count],
+ cservername,
+ driver->info_3->helpfile,
+ SPOOLSS_DRIVER_FILE_TYPE_HELP,
+ 0);
+ W_ERROR_NOT_OK_RETURN(result);
+ count++;
+ }
+
+ for (i=0; driver->info_3->dependentfiles[i][0] != '\0'; i++) {
+ info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
+ struct spoolss_DriverFileInfo,
+ count + 1);
+ W_ERROR_HAVE_NO_MEMORY(info);
+ result = fill_spoolss_DriverFileInfo(info,
+ &info[count],
+ cservername,
+ driver->info_3->dependentfiles[i],
+ SPOOLSS_DRIVER_FILE_TYPE_OTHER,
+ 0);
+ W_ERROR_NOT_OK_RETURN(result);
+ count++;
+ }
+
+ *info_p = info;
+ *count_p = count;
+
+ return WERR_OK;
+}
+
+/********************************************************************
+ * fill a spoolss_DriverInfo101 sttruct
+ ********************************************************************/
+
+static WERROR fill_printer_driver_info101(TALLOC_CTX *mem_ctx,
+ struct spoolss_DriverInfo101 *r,
+ const NT_PRINTER_DRIVER_INFO_LEVEL *driver,
+ const char *servername)
+{
+ const char *cservername = canon_servername(servername);
+ WERROR result;
+
+ r->version = driver->info_3->cversion;
+
+ r->driver_name = talloc_strdup(mem_ctx, driver->info_3->name);
+ W_ERROR_HAVE_NO_MEMORY(r->driver_name);
+ r->architecture = talloc_strdup(mem_ctx, driver->info_3->environment);
+ W_ERROR_HAVE_NO_MEMORY(r->architecture);
+
+ result = spoolss_DriverFileInfo_from_driver(mem_ctx, driver,
+ cservername,
+ &r->file_info,
+ &r->file_count);
+ if (!W_ERROR_IS_OK(result)) {
+ return result;
+ }
+
+ r->monitor_name = talloc_strdup(mem_ctx, driver->info_3->monitorname);
+ W_ERROR_HAVE_NO_MEMORY(r->monitor_name);
+
+ r->default_datatype = talloc_strdup(mem_ctx, driver->info_3->defaultdatatype);
+ W_ERROR_HAVE_NO_MEMORY(r->default_datatype);
+
+ r->previous_names = string_array_from_driver_info(mem_ctx,
+ NULL,
+ cservername);
+ r->driver_date = 0;
+ r->driver_version = 0;
+
+ r->manufacturer_name = talloc_strdup(mem_ctx, "");
+ W_ERROR_HAVE_NO_MEMORY(r->manufacturer_name);
+ r->manufacturer_url = talloc_strdup(mem_ctx, "");
+ W_ERROR_HAVE_NO_MEMORY(r->manufacturer_url);
+ r->hardware_id = talloc_strdup(mem_ctx, "");
+ W_ERROR_HAVE_NO_MEMORY(r->hardware_id);
+ r->provider = talloc_strdup(mem_ctx, "");
+ W_ERROR_HAVE_NO_MEMORY(r->provider);
+
+ return WERR_OK;
+}
+
+/********************************************************************
+ * construct_printer_driver_info_1
+ ********************************************************************/
+
+static WERROR construct_printer_driver_info_1(TALLOC_CTX *mem_ctx,
+ struct spoolss_DriverInfo1 *r,
+ int snum,
+ const char *servername,
+ const char *architecture,
+ uint32_t version)
+{
+ NT_PRINTER_INFO_LEVEL *printer = NULL;
+ NT_PRINTER_DRIVER_INFO_LEVEL driver;
+ WERROR result;
+
+ ZERO_STRUCT(driver);
+
+ if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, lp_const_servicename(snum))))
+ return WERR_INVALID_PRINTER_NAME;
+
+ if (!W_ERROR_IS_OK(get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version))) {
+ free_a_printer(&printer, 2);
+ return WERR_UNKNOWN_PRINTER_DRIVER;
+ }
+
+ result = fill_printer_driver_info1(mem_ctx, r, &driver, servername, architecture);
+
+ free_a_printer(&printer,2);
- result = fill_printer_driver_info1(mem_ctx, r, &driver, servername, architecture);
-
- free_a_printer(&printer,2);
-
return result;
}
return status;
}
+/********************************************************************
+ * construct_printer_info_101
+ * fill a printer_info_101 struct
+ ********************************************************************/
+
+static WERROR construct_printer_driver_info_101(TALLOC_CTX *mem_ctx,
+ struct spoolss_DriverInfo101 *r,
+ int snum,
+ const char *servername,
+ const char *architecture,
+ uint32_t version)
+{
+ NT_PRINTER_INFO_LEVEL *printer = NULL;
+ NT_PRINTER_DRIVER_INFO_LEVEL driver;
+ WERROR result;
+
+ ZERO_STRUCT(driver);
+
+ result = get_a_printer(NULL, &printer, 2, lp_const_servicename(snum));
+
+ DEBUG(8,("construct_printer_driver_info_101: status: %s\n",
+ win_errstr(result)));
+
+ if (!W_ERROR_IS_OK(result)) {
+ return WERR_INVALID_PRINTER_NAME;
+ }
+
+ result = get_a_printer_driver(&driver, 3, printer->info_2->drivername,
+ architecture, version);
+
+ DEBUG(8,("construct_printer_driver_info_101: status: %s\n",
+ win_errstr(result)));
+
+ if (!W_ERROR_IS_OK(result)) {
+ /*
+ * Is this a W2k client ?
+ */
+
+ if (version < 3) {
+ free_a_printer(&printer, 2);
+ return WERR_UNKNOWN_PRINTER_DRIVER;
+ }
+
+ /* Yes - try again with a WinNT driver. */
+ version = 2;
+ result = get_a_printer_driver(&driver, 3, printer->info_2->drivername,
+ architecture, version);
+ DEBUG(8,("construct_printer_driver_info_6: status: %s\n",
+ win_errstr(result)));
+ if (!W_ERROR_IS_OK(result)) {
+ free_a_printer(&printer, 2);
+ return WERR_UNKNOWN_PRINTER_DRIVER;
+ }
+ }
+
+ result = fill_printer_driver_info101(mem_ctx, r, &driver, servername);
+
+ free_a_printer(&printer, 2);
+ free_a_printer_driver(driver, 3);
+
+ return result;
+}
+
/****************************************************************
_spoolss_GetPrinterDriver2
****************************************************************/
r->in.architecture,
r->in.client_major_version);
break;
- default:
-#if 0 /* JERRY */
case 101:
- /* apparently this call is the equivalent of
- EnumPrinterDataEx() for the DsDriver key */
+ result = construct_printer_driver_info_101(p->mem_ctx,
+ &r->out.info->info101,
+ snum,
+ servername,
+ r->in.architecture,
+ r->in.client_major_version);
break;
-#endif
+ default:
result = WERR_UNKNOWN_LEVEL;
break;
}
return WERR_BADFID;
}
- Printer->page_started=True;
+ Printer->page_started = true;
return WERR_OK;
}
if (!get_printer_snum(p, r->in.handle, &snum, NULL))
return WERR_BADFID;
- Printer->page_started=False;
+ Printer->page_started = false;
print_job_endpage(snum, Printer->jobid);
return WERR_OK;
WERROR _spoolss_StartDocPrinter(pipes_struct *p,
struct spoolss_StartDocPrinter *r)
{
- uint32_t *jobid = r->out.job_id;
struct spoolss_DocumentInfo1 *info_1;
int snum;
Printer_entry *Printer = find_printer_index_by_hnd(p, r->in.handle);
if (info_1->datatype) {
if (strcmp(info_1->datatype, "RAW") != 0) {
- (*jobid)=0;
+ *r->out.job_id = 0;
return WERR_INVALID_DATATYPE;
}
}
return map_werror_from_unix(errno);
}
- Printer->document_started=True;
- (*jobid) = Printer->jobid;
+ Printer->document_started = true;
+ *r->out.job_id = Printer->jobid;
return WERR_OK;
}
WERROR _spoolss_WritePrinter(pipes_struct *p,
struct spoolss_WritePrinter *r)
{
- uint32 buffer_size = r->in._data_size;
- uint8 *buffer = r->in.data.data;
- uint32 *buffer_written = &r->in._data_size;
+ uint32_t buffer_written;
int snum;
Printer_entry *Printer = find_printer_index_by_hnd(p, r->in.handle);
if (!get_printer_snum(p, r->in.handle, &snum, NULL))
return WERR_BADFID;
- (*buffer_written) = (uint32)print_job_write(snum, Printer->jobid, (const char *)buffer,
- (SMB_OFF_T)-1, (size_t)buffer_size);
- if (*buffer_written == (uint32)-1) {
+ buffer_written = (uint32_t)print_job_write(snum, Printer->jobid,
+ (const char *)r->in.data.data,
+ (SMB_OFF_T)-1,
+ (size_t)r->in._data_size);
+ if (buffer_written == (uint32_t)-1) {
*r->out.num_written = 0;
if (errno == ENOSPC)
return WERR_NO_SPOOL_SPACE;
- return True;
+ return true;
}
/****************************************************************************
char *command = NULL;
int ret;
SE_PRIV se_printop = SE_PRINT_OPERATOR;
- bool is_print_op = False;
+ bool is_print_op = false;
if ( !*cmd ) {
return WERR_ACCESS_DENIED;
int ret;
int fd;
SE_PRIV se_printop = SE_PRINT_OPERATOR;
- bool is_print_op = False;
+ bool is_print_op = false;
char *remote_machine = talloc_strdup(ctx, "%m");
if (!remote_machine) {
if ( ret != 0 ) {
if (fd != -1)
close(fd);
- return False;
+ return false;
}
/* reload our services immediately */
- reload_services( False );
+ reload_services(false);
numlines = 0;
/* Get lines and convert them back to dos-codepage */
}
TALLOC_FREE(qlines);
- return True;
+ return true;
}
if (!strequal(printer->info_2->comment, old_printer->info_2->comment)) {
init_unistr2( &buffer, printer->info_2->comment, UNI_STR_TERMINATE);
set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "description",
- REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 );
+ REG_SZ, (uint8_t *)buffer.buffer, buffer.uni_str_len*2 );
notify_printer_comment(snum, printer->info_2->comment);
}
if (!strequal(printer->info_2->sharename, old_printer->info_2->sharename)) {
init_unistr2( &buffer, printer->info_2->sharename, UNI_STR_TERMINATE);
set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "shareName",
- REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 );
+ REG_SZ, (uint8_t *)buffer.buffer, buffer.uni_str_len*2 );
notify_printer_sharename(snum, printer->info_2->sharename);
}
init_unistr2( &buffer, pname, UNI_STR_TERMINATE);
set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "printerName",
- REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 );
+ REG_SZ, (uint8_t *)buffer.buffer, buffer.uni_str_len*2 );
notify_printer_printername( snum, pname );
}
if (!strequal(printer->info_2->portname, old_printer->info_2->portname)) {
init_unistr2( &buffer, printer->info_2->portname, UNI_STR_TERMINATE);
set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "portName",
- REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 );
+ REG_SZ, (uint8_t *)buffer.buffer, buffer.uni_str_len*2 );
notify_printer_port(snum, printer->info_2->portname);
}
if (!strequal(printer->info_2->location, old_printer->info_2->location)) {
init_unistr2( &buffer, printer->info_2->location, UNI_STR_TERMINATE);
set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "location",
- REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 );
+ REG_SZ, (uint8_t *)buffer.buffer, buffer.uni_str_len*2 );
notify_printer_location(snum, printer->info_2->location);
}
init_unistr2( &buffer, global_myname(), UNI_STR_TERMINATE);
set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "serverName",
- REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 );
+ REG_SZ, (uint8_t *)buffer.buffer, buffer.uni_str_len*2 );
set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "shortServerName",
- REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 );
+ REG_SZ, (uint8_t *)buffer.buffer, buffer.uni_str_len*2 );
slprintf( asc_buffer, sizeof(asc_buffer)-1, "\\\\%s\\%s",
global_myname(), printer->info_2->sharename );
init_unistr2( &buffer, asc_buffer, UNI_STR_TERMINATE);
set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "uNCName",
- REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 );
+ REG_SZ, (uint8_t *)buffer.buffer, buffer.uni_str_len*2 );
/* Update printer info */
result = mod_a_printer(printer, 2);
return WERR_BADFID;
}
- if (Printer->notify.client_connected==True) {
+ if (Printer->notify.client_connected == true) {
int snum = -1;
if ( Printer->printer_type == SPLHND_SERVER)
Printer->notify.localmachine[0]='\0';
Printer->notify.printerlocal=0;
TALLOC_FREE(Printer->notify.option);
- Printer->notify.client_connected=False;
+ Printer->notify.client_connected = false;
return WERR_OK;
}
WERROR _spoolss_SetJob(pipes_struct *p,
struct spoolss_SetJob *r)
{
- uint32 jobid = r->in.job_id;
- uint32 command = r->in.command;
-
int snum;
WERROR errcode = WERR_BADFUNC;
return WERR_BADFID;
}
- if (!print_job_exists(lp_const_servicename(snum), jobid)) {
+ if (!print_job_exists(lp_const_servicename(snum), r->in.job_id)) {
return WERR_INVALID_PRINTER_NAME;
}
- switch (command) {
+ switch (r->in.command) {
case SPOOLSS_JOB_CONTROL_CANCEL:
case SPOOLSS_JOB_CONTROL_DELETE:
- if (print_job_delete(p->server_info, snum, jobid, &errcode)) {
+ if (print_job_delete(p->server_info, snum, r->in.job_id, &errcode)) {
errcode = WERR_OK;
}
break;
case SPOOLSS_JOB_CONTROL_PAUSE:
- if (print_job_pause(p->server_info, snum, jobid, &errcode)) {
+ if (print_job_pause(p->server_info, snum, r->in.job_id, &errcode)) {
errcode = WERR_OK;
}
break;
case SPOOLSS_JOB_CONTROL_RESTART:
case SPOOLSS_JOB_CONTROL_RESUME:
- if (print_job_resume(p->server_info, snum, jobid, &errcode)) {
+ if (print_job_resume(p->server_info, snum, r->in.job_id, &errcode)) {
errcode = WERR_OK;
}
break;
}
/****************************************************************************
- Enumerates all printer drivers at level 1.
+ Enumerates all printer drivers by level.
****************************************************************************/
-static WERROR enumprinterdrivers_level1(TALLOC_CTX *mem_ctx,
- const char *servername,
- const char *architecture,
- union spoolss_DriverInfo **info_p,
- uint32_t *count)
+static WERROR enumprinterdrivers_level(TALLOC_CTX *mem_ctx,
+ const char *servername,
+ const char *architecture,
+ uint32_t level,
+ union spoolss_DriverInfo **info_p,
+ uint32_t *count_p)
{
int i;
int ndrivers;
fstring *list = NULL;
NT_PRINTER_DRIVER_INFO_LEVEL driver;
union spoolss_DriverInfo *info = NULL;
+ uint32_t count = 0;
WERROR result = WERR_OK;
- *count = 0;
+ *count_p = 0;
+ *info_p = NULL;
for (version=0; version<DRIVER_MAX_VERSION; version++) {
list = NULL;
if (ndrivers != 0) {
info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
union spoolss_DriverInfo,
- *count + ndrivers);
+ count + ndrivers);
if (!info) {
DEBUG(0,("enumprinterdrivers_level1: "
"failed to enlarge driver info buffer!\n"));
if (!W_ERROR_IS_OK(result)) {
goto out;
}
- result = fill_printer_driver_info1(info, &info[*count+i].info1,
- &driver, servername,
- architecture);
+
+ switch (level) {
+ case 1:
+ result = fill_printer_driver_info1(info, &info[count+i].info1,
+ &driver, servername,
+ architecture);
+ break;
+ case 2:
+ result = fill_printer_driver_info2(info, &info[count+i].info2,
+ &driver, servername);
+ break;
+ case 3:
+ result = fill_printer_driver_info3(info, &info[count+i].info3,
+ &driver, servername);
+ break;
+ case 4:
+ result = fill_printer_driver_info4(info, &info[count+i].info4,
+ &driver, servername);
+ break;
+ case 5:
+ result = fill_printer_driver_info5(info, &info[count+i].info5,
+ &driver, servername);
+ break;
+ case 6:
+ result = fill_printer_driver_info6(info, &info[count+i].info6,
+ &driver, servername);
+ break;
+ default:
+ result = WERR_UNKNOWN_LEVEL;
+ break;
+ }
+
if (!W_ERROR_IS_OK(result)) {
free_a_printer_driver(driver, 3);
goto out;
free_a_printer_driver(driver, 3);
}
- *count += ndrivers;
+ count += ndrivers;
SAFE_FREE(list);
}
if (!W_ERROR_IS_OK(result)) {
TALLOC_FREE(info);
- *count = 0;
return result;
}
*info_p = info;
+ *count_p = count;
return WERR_OK;
}
/****************************************************************************
- Enumerates all printer drivers at level 2.
+ Enumerates all printer drivers at level 1.
****************************************************************************/
-static WERROR enumprinterdrivers_level2(TALLOC_CTX *mem_ctx,
+static WERROR enumprinterdrivers_level1(TALLOC_CTX *mem_ctx,
const char *servername,
const char *architecture,
union spoolss_DriverInfo **info_p,
uint32_t *count)
{
- int i;
- int ndrivers;
- uint32_t version;
- fstring *list = NULL;
- NT_PRINTER_DRIVER_INFO_LEVEL driver;
- union spoolss_DriverInfo *info = NULL;
- WERROR result = WERR_OK;
-
- *count = 0;
-
- for (version=0; version<DRIVER_MAX_VERSION; version++) {
- list = NULL;
- ndrivers = get_ntdrivers(&list, architecture, version);
- DEBUGADD(4,("we have:[%d] drivers in environment [%s] and version [%d]\n",
- ndrivers, architecture, version));
-
- if (ndrivers == -1) {
- result = WERR_NOMEM;
- goto out;
- }
-
- if (ndrivers != 0) {
- info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
- union spoolss_DriverInfo,
- *count + ndrivers);
- if (!info) {
- DEBUG(0,("enumprinterdrivers_level2: "
- "failed to enlarge driver info buffer!\n"));
- result = WERR_NOMEM;
- goto out;
- }
- }
-
- for (i=0; i<ndrivers; i++) {
- DEBUGADD(5,("\tdriver: [%s]\n", list[i]));
- ZERO_STRUCT(driver);
- result = get_a_printer_driver(&driver, 3, list[i],
- architecture, version);
- if (!W_ERROR_IS_OK(result)) {
- goto out;
- }
- result = fill_printer_driver_info2(info, &info[*count+i].info2,
- &driver, servername);
- if (!W_ERROR_IS_OK(result)) {
- free_a_printer_driver(driver, 3);
- goto out;
- }
- free_a_printer_driver(driver, 3);
- }
-
- *count += ndrivers;
- SAFE_FREE(list);
- }
-
- out:
- SAFE_FREE(list);
-
- if (!W_ERROR_IS_OK(result)) {
- TALLOC_FREE(info);
- *count = 0;
- return result;
- }
+ return enumprinterdrivers_level(mem_ctx, servername, architecture, 1,
+ info_p, count);
+}
- *info_p = info;
+/****************************************************************************
+ Enumerates all printer drivers at level 2.
+****************************************************************************/
- return WERR_OK;
+static WERROR enumprinterdrivers_level2(TALLOC_CTX *mem_ctx,
+ const char *servername,
+ const char *architecture,
+ union spoolss_DriverInfo **info_p,
+ uint32_t *count)
+{
+ return enumprinterdrivers_level(mem_ctx, servername, architecture, 2,
+ info_p, count);
}
/****************************************************************************
union spoolss_DriverInfo **info_p,
uint32_t *count)
{
- int i;
- int ndrivers;
- uint32_t version;
- fstring *list = NULL;
- union spoolss_DriverInfo *info = NULL;
- NT_PRINTER_DRIVER_INFO_LEVEL driver;
- WERROR result = WERR_OK;
-
- *count = 0;
-
- for (version=0; version<DRIVER_MAX_VERSION; version++) {
- list = NULL;
- ndrivers = get_ntdrivers(&list, architecture, version);
- DEBUGADD(4,("we have:[%d] drivers in environment [%s] and version [%d]\n",
- ndrivers, architecture, version));
-
- if (ndrivers == -1) {
- result = WERR_NOMEM;
- goto out;
- }
-
- if (ndrivers != 0) {
- info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
- union spoolss_DriverInfo,
- *count + ndrivers);
- if (!info) {
- DEBUG(0,("enumprinterdrivers_level3: "
- "failed to enlarge driver info buffer!\n"));
- result = WERR_NOMEM;
- goto out;
- }
- }
-
- for (i=0; i<ndrivers; i++) {
- DEBUGADD(5,("\tdriver: [%s]\n", list[i]));
- ZERO_STRUCT(driver);
- result = get_a_printer_driver(&driver, 3, list[i],
- architecture, version);
- if (!W_ERROR_IS_OK(result)) {
- goto out;
- }
- result = fill_printer_driver_info3(info, &info[*count+i].info3,
- &driver, servername);
- if (!W_ERROR_IS_OK(result)) {
- free_a_printer_driver(driver, 3);
- goto out;
- }
+ return enumprinterdrivers_level(mem_ctx, servername, architecture, 3,
+ info_p, count);
+}
- free_a_printer_driver(driver, 3);
- }
+/****************************************************************************
+ Enumerates all printer drivers at level 4.
+****************************************************************************/
- *count += ndrivers;
- SAFE_FREE(list);
- }
+static WERROR enumprinterdrivers_level4(TALLOC_CTX *mem_ctx,
+ const char *servername,
+ const char *architecture,
+ union spoolss_DriverInfo **info_p,
+ uint32_t *count)
+{
+ return enumprinterdrivers_level(mem_ctx, servername, architecture, 4,
+ info_p, count);
+}
- out:
- SAFE_FREE(list);
+/****************************************************************************
+ Enumerates all printer drivers at level 5.
+****************************************************************************/
- if (!W_ERROR_IS_OK(result)) {
- TALLOC_FREE(info);
- *count = 0;
- return result;
- }
+static WERROR enumprinterdrivers_level5(TALLOC_CTX *mem_ctx,
+ const char *servername,
+ const char *architecture,
+ union spoolss_DriverInfo **info_p,
+ uint32_t *count)
+{
+ return enumprinterdrivers_level(mem_ctx, servername, architecture, 5,
+ info_p, count);
+}
- *info_p = info;
+/****************************************************************************
+ Enumerates all printer drivers at level 6.
+****************************************************************************/
- return WERR_OK;
+static WERROR enumprinterdrivers_level6(TALLOC_CTX *mem_ctx,
+ const char *servername,
+ const char *architecture,
+ union spoolss_DriverInfo **info_p,
+ uint32_t *count)
+{
+ return enumprinterdrivers_level(mem_ctx, servername, architecture, 6,
+ info_p, count);
}
+
/****************************************************************
_spoolss_EnumPrinterDrivers
****************************************************************/
r->in.environment,
r->out.info, r->out.count);
break;
+ case 4:
+ result = enumprinterdrivers_level4(p->mem_ctx, cservername,
+ r->in.environment,
+ r->out.info, r->out.count);
+ break;
+ case 5:
+ result = enumprinterdrivers_level5(p->mem_ctx, cservername,
+ r->in.environment,
+ r->out.info, r->out.count);
+ break;
+ case 6:
+ result = enumprinterdrivers_level6(p->mem_ctx, cservername,
+ r->in.environment,
+ r->out.info, r->out.count);
+ break;
default:
return WERR_UNKNOWN_LEVEL;
}
return WERR_ACCESS_DENIED;
}
- update_c_setprinter(False);
+ update_c_setprinter(false);
free_a_printer(&printer,2);
return WERR_OK;
struct spoolss_AddDriverInfoCtr *info = r->in.info_ctr;
WERROR err = WERR_OK;
NT_PRINTER_DRIVER_INFO_LEVEL driver;
- fstring driver_name;
- uint32 version;
+ const char *driver_name = NULL;
+ uint32_t version;
const char *fn;
switch (p->hdr_req.opnum) {
switch(level) {
case 3:
- fstrcpy(driver_name,
- driver.info_3->name ? driver.info_3->name : "");
+ driver_name = driver.info_3->name ? driver.info_3->name : "";
break;
case 6:
- fstrcpy(driver_name,
- driver.info_6->name ? driver.info_6->name : "");
+ driver_name = driver.info_6->name ? driver.info_6->name : "";
break;
}
int snum;
WERROR status = WERR_OK;
NT_PRINTER_INFO_LEVEL *printer = NULL;
+ SE_PRIV se_printop = SE_PRINT_OPERATOR;
int count=0;
nt_forms_struct *list=NULL;
goto done;
}
- if ( !(Printer->access_granted & (PRINTER_ACCESS_ADMINISTER|SERVER_ACCESS_ADMINISTER)) ) {
- DEBUG(2,("_spoolss_addform: denied by handle permissions.\n"));
- status = WERR_ACCESS_DENIED;
- goto done;
+ /* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege,
+ and not a printer admin, then fail */
+
+ if ((p->server_info->utok.uid != 0) &&
+ !user_has_privileges(p->server_info->ptok, &se_printop) &&
+ !token_contains_name_in_list(uidtoname(p->server_info->utok.uid),
+ NULL, NULL,
+ p->server_info->ptok,
+ lp_printer_admin(snum))) {
+ DEBUG(2,("_spoolss_Addform: denied by insufficient permissions.\n"));
+ return WERR_ACCESS_DENIED;
}
/* can't add if builtin */
int snum;
WERROR status = WERR_OK;
NT_PRINTER_INFO_LEVEL *printer = NULL;
+ SE_PRIV se_printop = SE_PRINT_OPERATOR;
DEBUG(5,("_spoolss_DeleteForm\n"));
goto done;
}
- if ( !(Printer->access_granted & (PRINTER_ACCESS_ADMINISTER|SERVER_ACCESS_ADMINISTER)) ) {
- DEBUG(2,("_spoolss_DeleteForm: denied by handle permissions.\n"));
- status = WERR_ACCESS_DENIED;
- goto done;
+ if ((p->server_info->utok.uid != 0) &&
+ !user_has_privileges(p->server_info->ptok, &se_printop) &&
+ !token_contains_name_in_list(uidtoname(p->server_info->utok.uid),
+ NULL, NULL,
+ p->server_info->ptok,
+ lp_printer_admin(snum))) {
+ DEBUG(2,("_spoolss_DeleteForm: denied by insufficient permissions.\n"));
+ return WERR_ACCESS_DENIED;
}
+
/* can't delete if builtin */
if (get_a_builtin_ntform_by_string(form_name,&tmpForm)) {
int snum;
WERROR status = WERR_OK;
NT_PRINTER_INFO_LEVEL *printer = NULL;
+ SE_PRIV se_printop = SE_PRINT_OPERATOR;
int count=0;
nt_forms_struct *list=NULL;
goto done;
}
- if ( !(Printer->access_granted & (PRINTER_ACCESS_ADMINISTER|SERVER_ACCESS_ADMINISTER)) ) {
- DEBUG(2,("_spoolss_SetForm: denied by handle permissions\n"));
- status = WERR_ACCESS_DENIED;
- goto done;
+ /* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege,
+ and not a printer admin, then fail */
+
+ if ((p->server_info->utok.uid != 0) &&
+ !user_has_privileges(p->server_info->ptok, &se_printop) &&
+ !token_contains_name_in_list(uidtoname(p->server_info->utok.uid),
+ NULL, NULL,
+ p->server_info->ptok,
+ lp_printer_admin(snum))) {
+ DEBUG(2,("_spoolss_Setform: denied by insufficient permissions.\n"));
+ return WERR_ACCESS_DENIED;
}
/* can't set if builtin */
return WERR_OK;
}
+/****************************************************************
+ _spoolss_AddPort
+****************************************************************/
+
+WERROR _spoolss_AddPort(pipes_struct *p,
+ struct spoolss_AddPort *r)
+{
+ /* do what w2k3 does */
+
+ return WERR_NOT_SUPPORTED;
+}
+
/****************************************************************
_spoolss_AddPrinter
****************************************************************/
return WERR_NOT_SUPPORTED;
}
-/****************************************************************
- _spoolss_AddPort
-****************************************************************/
-
-WERROR _spoolss_AddPort(pipes_struct *p,
- struct spoolss_AddPort *r)
-{
- p->rng_fault_state = true;
- return WERR_NOT_SUPPORTED;
-}
-
/****************************************************************
_spoolss_ConfigurePort
****************************************************************/