summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h2
-rw-r--r--source3/param/loadparm.c19
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c62
3 files changed, 67 insertions, 16 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index be901b3cf3..deb0ea2704 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1398,7 +1398,6 @@ char *lp_lppausecommand(int );
char *lp_lpresumecommand(int );
char *lp_queuepausecommand(int );
char *lp_queueresumecommand(int );
-char *lp_printername(int );
char *lp_driverfile(int );
char *lp_printerdriver(int );
char *lp_hostsallow(int );
@@ -1507,6 +1506,7 @@ int lp_security_mask(int snum);
int lp_force_security_mode(int snum);
int lp_dir_security_mask(int snum);
int lp_force_dir_security_mode(int snum);
+char *lp_printername(int snum);
/*The following definitions come from param/params.c */
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 0bcb63984b..57db8f0e87 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -1476,7 +1476,7 @@ FN_LOCAL_STRING(lp_lppausecommand, szLppausecommand)
FN_LOCAL_STRING(lp_lpresumecommand, szLpresumecommand)
FN_LOCAL_STRING(lp_queuepausecommand, szQueuepausecommand)
FN_LOCAL_STRING(lp_queueresumecommand, szQueueresumecommand)
-FN_LOCAL_STRING(lp_printername, szPrintername)
+static FN_LOCAL_STRING(_lp_printername, szPrintername)
FN_LOCAL_STRING(lp_driverfile, szDriverFile)
FN_LOCAL_STRING(lp_printerdriver, szPrinterDriver)
FN_LOCAL_STRING(lp_hostsallow, szHostsallow)
@@ -1958,14 +1958,17 @@ static BOOL service_ok(int iService)
/* The [printers] entry MUST be printable. I'm all for flexibility, but */
/* I can't see why you'd want a non-printable printer service... */
- if (strwicmp(iSERVICE(iService).szService, PRINTERS_NAME) == 0)
- if (!iSERVICE(iService).bPrint_ok)
- {
+ if (strwicmp(iSERVICE(iService).szService, PRINTERS_NAME) == 0) {
+ if (!iSERVICE(iService).bPrint_ok) {
DEBUG(0,
("WARNING: [%s] service MUST be printable!\n",
iSERVICE(iService).szService));
iSERVICE(iService).bPrint_ok = True;
}
+ /* [printers] service must also be non-browsable. */
+ if (iSERVICE(iService).bBrowseable)
+ iSERVICE(iService).bBrowseable = False;
+ }
if (iSERVICE(iService).szPath[0] == '\0' &&
strwicmp(iSERVICE(iService).szService, HOMES_NAME) != 0)
@@ -3472,3 +3475,11 @@ int lp_force_dir_security_mode(int snum)
return val;
}
+char *lp_printername(int snum)
+{
+ char *ret = _lp_printername(snum);
+ if (ret == NULL || (ret != NULL && *ret == '\0'))
+ ret = lp_servicename(snum);
+
+ return ret;
+}
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index dc4932fdfc..b8b25a1ecb 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -3653,16 +3653,16 @@ uint32 _new_spoolss_enumforms( const POLICY_HND *handle, uint32 level,
****************************************************************************/
static void fill_port_1(PORT_INFO_1 *port, char *name)
{
- init_unistr(&(port->port_name), name);
+ init_unistr(&port->port_name, name);
}
/****************************************************************************
****************************************************************************/
static void fill_port_2(PORT_INFO_2 *port, char *name)
{
- init_unistr(&(port->port_name), name);
- init_unistr(&(port->monitor_name), "Moniteur Local");
- init_unistr(&(port->description), "Local Port");
+ init_unistr(&port->port_name, name);
+ init_unistr(&port->monitor_name, "Local Monitor");
+ init_unistr(&port->description, "Local Port");
#define PORT_TYPE_WRITE 1
port->port_type=PORT_TYPE_WRITE;
port->reserved=0x0;
@@ -3688,16 +3688,36 @@ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need
for (snum=0; snum<n_services; snum++) {
if ( lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) {
+ /*
+ * Ensure this port name is unique.
+ */
+ int j;
+
+ DEBUG(10,("enumports_level_1: port name %s\n", PRINTERNAME(snum)));
+
+ for(j = 0; j < i; j++) {
+ fstring port_name;
+ unistr_to_dos(port_name, (const char *)&ports[j].port_name.buffer[0], sizeof(port_name));
+
+ if (strequal(port_name, PRINTERNAME(snum)))
+ break;
+ }
+
+ if (j < i)
+ continue;
+
DEBUGADD(6,("Filling port number [%d]\n", i));
- fill_port_1(&(ports[i]), lp_servicename(snum));
+ fill_port_1(&ports[i], PRINTERNAME(snum));
i++;
}
}
+ *returned = i;
+
/* check the required size. */
for (i=0; i<*returned; i++) {
DEBUGADD(6,("adding port [%d]'s size\n", i));
- *needed += spoolss_size_port_info_1(&(ports[i]));
+ *needed += spoolss_size_port_info_1(&ports[i]);
}
if (!alloc_buffer_size(buffer, *needed)) {
@@ -3708,7 +3728,7 @@ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need
/* fill the buffer with the ports structures */
for (i=0; i<*returned; i++) {
DEBUGADD(6,("adding port [%d] to buffer\n", i));
- new_smb_io_port_1("", buffer, &(ports[i]), 0);
+ new_smb_io_port_1("", buffer, &ports[i], 0);
}
safe_free(ports);
@@ -3721,10 +3741,10 @@ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need
return NT_STATUS_NO_PROBLEMO;
}
-
/****************************************************************************
enumports level 2.
****************************************************************************/
+
static uint32 enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned)
{
int n_services=lp_numservices();
@@ -3742,16 +3762,36 @@ static uint32 enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need
for (snum=0; snum<n_services; snum++) {
if ( lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) {
+ /*
+ * Ensure this port name is unique.
+ */
+ int j;
+
+ DEBUG(10,("enumports_level_2: port name %s\n", PRINTERNAME(snum)));
+
+ for(j = 0; j < i; j++) {
+ fstring port_name;
+ unistr_to_dos(port_name, (const char *)&ports[j].port_name.buffer[0], sizeof(port_name));
+
+ if (strequal(port_name, PRINTERNAME(snum)))
+ break;
+ }
+
+ if (j < i)
+ continue;
+
DEBUGADD(6,("Filling port number [%d]\n", i));
- fill_port_2(&(ports[i]), lp_servicename(snum));
+ fill_port_2(&ports[i], PRINTERNAME(snum));
i++;
}
}
+ *returned = i;
+
/* check the required size. */
for (i=0; i<*returned; i++) {
DEBUGADD(6,("adding port [%d]'s size\n", i));
- *needed += spoolss_size_port_info_2(&(ports[i]));
+ *needed += spoolss_size_port_info_2(&ports[i]);
}
if (!alloc_buffer_size(buffer, *needed)) {
@@ -3762,7 +3802,7 @@ static uint32 enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need
/* fill the buffer with the ports structures */
for (i=0; i<*returned; i++) {
DEBUGADD(6,("adding port [%d] to buffer\n", i));
- new_smb_io_port_2("", buffer, &(ports[i]), 0);
+ new_smb_io_port_2("", buffer, &ports[i], 0);
}
safe_free(ports);