summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/param/loadparm.c4
-rw-r--r--source3/printing/nt_printing.c12
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c44
3 files changed, 43 insertions, 17 deletions
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 726ae5fe56..053626c730 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -413,6 +413,7 @@ typedef struct
BOOL bMSDfsRoot;
BOOL bUseClientDriver;
BOOL bDefaultDevmode;
+ BOOL bForcePrintername;
BOOL bNTAclSupport;
BOOL bForceUnknownAclUser;
BOOL bUseSendfile;
@@ -537,6 +538,7 @@ static service sDefault = {
False, /* bMSDfsRoot */
False, /* bUseClientDriver */
False, /* bDefaultDevmode */
+ False, /* bForcePrintername */
True, /* bNTAclSupport */
False, /* bForceUnknownAclUser */
True, /* bUseSendfile */
@@ -983,6 +985,7 @@ static struct parm_struct parm_table[] = {
{"printer", P_STRING, P_LOCAL, &sDefault.szPrintername, NULL, NULL, FLAG_HIDE},
{"use client driver", P_BOOL, P_LOCAL, &sDefault.bUseClientDriver, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
{"default devmode", P_BOOL, P_LOCAL, &sDefault.bDefaultDevmode, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
+ {"force printername", P_BOOL, P_LOCAL, &sDefault.bForcePrintername, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
{N_("Filename Handling"), P_SEP, P_SEPARATOR},
{"mangling method", P_STRING, P_GLOBAL, &Globals.szManglingMethod, NULL, NULL, FLAG_ADVANCED},
@@ -1885,6 +1888,7 @@ FN_LOCAL_BOOL(lp_inherit_perms, bInheritPerms)
FN_LOCAL_BOOL(lp_inherit_acls, bInheritACLS)
FN_LOCAL_BOOL(lp_use_client_driver, bUseClientDriver)
FN_LOCAL_BOOL(lp_default_devmode, bDefaultDevmode)
+FN_LOCAL_BOOL(lp_force_printername, bForcePrintername)
FN_LOCAL_BOOL(lp_nt_acl_support, bNTAclSupport)
FN_LOCAL_BOOL(lp_force_unknown_acl_user, bForceUnknownAclUser)
FN_LOCAL_BOOL(lp_ea_support, bEASupport)
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 14c0417f77..a69433df37 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -3357,7 +3357,8 @@ static WERROR get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 **info_ptr, const char *se
{
pstring key;
NT_PRINTER_INFO_LEVEL_2 info;
- int len = 0;
+ int len = 0;
+ int snum = lp_servicenumber(sharename);
TDB_DATA kbuf, dbuf;
fstring printername;
char adevice[MAXDEVICENAME];
@@ -3403,7 +3404,12 @@ static WERROR get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 **info_ptr, const char *se
/* Restore the stripped strings. */
slprintf(info.servername, sizeof(info.servername)-1, "\\\\%s", servername);
- slprintf(printername, sizeof(printername)-1, "\\\\%s\\%s", servername, info.printername);
+
+ if ( lp_force_printername(snum) )
+ slprintf(printername, sizeof(printername)-1, "\\\\%s\\%s", servername, sharename );
+ else
+ slprintf(printername, sizeof(printername)-1, "\\\\%s\\%s", servername, info.printername);
+
fstrcpy(info.printername, printername);
len += unpack_devicemode(&info.devmode,dbuf.dptr+len, dbuf.dsize-len);
@@ -3416,7 +3422,7 @@ static WERROR get_a_printer_2(NT_PRINTER_INFO_LEVEL_2 **info_ptr, const char *se
* See comments in get_a_printer_2_default()
*/
- if (lp_default_devmode(lp_servicenumber(sharename)) && !info.devmode) {
+ if (lp_default_devmode(snum) && !info.devmode) {
DEBUG(8,("get_a_printer_2: Constructing a default device mode for [%s]\n",
printername));
info.devmode = construct_nt_devicemode(printername);
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 2d230b07bb..fad5555cea 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -529,12 +529,20 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename)
}
}
+
/* do another loop to look for printernames */
for (snum=0; !found && snum<n_services; snum++) {
- if ( !(lp_snum_ok(snum) && lp_print_ok(snum) ) )
+ /* no point in checking if this is not a printer or
+ we aren't allowing printername != sharename */
+
+ if ( !(lp_snum_ok(snum)
+ && lp_print_ok(snum)
+ && !lp_force_printername(snum)) )
+ {
continue;
+ }
fstrcpy(sname, lp_servicename(snum));
@@ -555,16 +563,16 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename)
}
printername++;
-
+
if ( strequal(printername, aprinter) ) {
found = True;
}
DEBUGADD(10, ("printername: %s\n", printername));
- free_a_printer( &printer, 2);
+ free_a_printer( &printer, 2);
}
-
+
if ( !found ) {
DEBUGADD(4,("Printer not found\n"));
return False;
@@ -5955,18 +5963,26 @@ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum)
slprintf(info->servername, sizeof(info->servername)-1, "\\\\%s", global_myname());
fstrcpy(info->sharename, lp_servicename(snum));
- /* make sure printername is in \\server\printername format */
+ /* check to see if we allow printername != sharename */
+
+ if ( lp_force_printername(snum) ) {
+ slprintf(info->printername, sizeof(info->printername)-1, "\\\\%s\\%s",
+ global_myname(), info->sharename );
+ } else {
+
+ /* make sure printername is in \\server\printername format */
- fstrcpy( printername, info->printername );
- p = printername;
- if ( printername[0] == '\\' && printername[1] == '\\' ) {
- if ( (p = strchr_m( &printername[2], '\\' )) != NULL )
- p++;
+ fstrcpy( printername, info->printername );
+ p = printername;
+ if ( printername[0] == '\\' && printername[1] == '\\' ) {
+ if ( (p = strchr_m( &printername[2], '\\' )) != NULL )
+ p++;
+ }
+
+ slprintf(info->printername, sizeof(info->printername)-1, "\\\\%s\\%s",
+ global_myname(), p );
}
-
- slprintf(info->printername, sizeof(info->printername)-1, "\\\\%s\\%s",
- global_myname(), p );
-
+
info->attributes |= PRINTER_ATTRIBUTE_SAMBA;
info->attributes &= ~PRINTER_ATTRIBUTE_NOT_SAMBA;