summaryrefslogtreecommitdiff
path: root/source3/rpc_server/srv_spoolss_nt.c
diff options
context:
space:
mode:
authorJean-François Micouleau <jfm@samba.org>2000-04-10 21:47:46 +0000
committerJean-François Micouleau <jfm@samba.org>2000-04-10 21:47:46 +0000
commit416fa5377bfca53f21b1fe9c1a71c7ca255abeb2 (patch)
tree099930dccf1efffdfde8e12daee9fb70837b859a /source3/rpc_server/srv_spoolss_nt.c
parent4379d359a8cdcc5b2d4ebf713a0ac32b1c7df4d2 (diff)
downloadsamba-416fa5377bfca53f21b1fe9c1a71c7ca255abeb2.tar.gz
samba-416fa5377bfca53f21b1fe9c1a71c7ca255abeb2.tar.bz2
samba-416fa5377bfca53f21b1fe9c1a71c7ca255abeb2.zip
added checks to open both \\server\printer and \\server\share.
it doesn't work, the getprinter level 0 reply is wrong... J.F. (This used to be commit a7b09e3e11dc66779ee50524ebe1f6687ec744c6)
Diffstat (limited to 'source3/rpc_server/srv_spoolss_nt.c')
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c47
1 files changed, 44 insertions, 3 deletions
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 1d33b1b8bb..3f9e98caa3 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -327,6 +327,7 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername)
aprinter++;
DEBUGADD(5,("searching for [%s] (len=%d)\n", aprinter, strlen(aprinter)));
+
/*
* store the Samba share name in it
* in back we have the long printer name
@@ -361,14 +362,54 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername)
found=True;
}
- if (found==False)
- {
+ /*
+ * if we haven't found a printer with the given printername
+ * then it can be a share name as you can open both \\server\printer and
+ * \\server\share
+ */
+
+ /*
+ * we still check if the printer description file exists as NT won't be happy
+ * if we reply OK in the openprinter call and can't reply in the subsequent RPC calls
+ */
+
+ if (found==False) {
+ DEBUGADD(5,("Printer not found, checking for share now\n"));
+
+ for (snum=0;snum<n_services && found==False;snum++) {
+
+ if ( !(lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) )
+ continue;
+
+ DEBUGADD(5,("share:%s\n",lp_servicename(snum)));
+
+ if (get_a_printer(&printer, 2, lp_servicename(snum))!=0)
+ continue;
+
+ DEBUG(10,("set_printer_hnd_printername: printername [%s], aprinter [%s]\n",
+ printer.info_2->printername, aprinter ));
+
+ if ( strlen(lp_servicename(snum)) != strlen(aprinter) ) {
+ free_a_printer(printer, 2);
+ continue;
+ }
+
+ if ( strncasecmp(lp_servicename(snum), aprinter, strlen(aprinter))) {
+ free_a_printer(printer, 2);
+ continue;
+ }
+
+ found=True;
+ }
+ }
+
+ if (found==False) {
DEBUGADD(4,("Printer not found\n"));
return False;
}
snum--;
- DEBUGADD(4,("Printer found: %s[%x]\n",lp_servicename(snum),snum));
+ DEBUGADD(4,("Printer found: %s -> %s[%x]\n",printer.info_2->printername, lp_servicename(snum),snum));
ZERO_STRUCT(Printer->dev.printername);
strncpy(Printer->dev.printername, lp_servicename(snum), strlen(lp_servicename(snum)));
free_a_printer(printer, 2);