Printers missing after 3.0.9 - 3.0.12 upgrade

psz at maths.usyd.edu.au psz at maths.usyd.edu.au
Wed Apr 6 19:49:40 GMT 2005


Yesterday I wrote about my troubles with missing printers. Seems that Samba
mis-parses the printcap file, and (on purpose!?) skips (disallows) printer
aliases.

The following patch seems to solve the problem.

Cheers,

Paul Szabo   psz at maths.usyd.edu.au   http://www.maths.usyd.edu.au/u/psz/
School of Mathematics and Statistics   University of Sydney    Australia


*** printing/pcap.c.orig	Sat Mar 12 00:47:03 2005
--- printing/pcap.c	Thu Apr  7 05:20:59 2005
***************
*** 165,170 ****
--- 165,182 ----
  		 * now find the most likely printer name and comment 
  		 * this is pure guesswork, but it's better than nothing
  		 */
+ /* PSz  7 Apr 05 */
+ /*
+  * Pure bogosity I say...
+  * I need all my printers: all aliases please.
+  * Reading line-by-line you may not see a comment: not always like
+  *   lp|My printer:stuff:
+  * but could be
+  *   lp1|lp2|
+  *   lp3|No comment
+  *   :stuff
+  * instead.
+  */
  		for (*name = *comment = 0, p = pcap_line; p != NULL; p = q) {
  			BOOL has_punctuation;
  
***************
*** 175,209 ****
  			                   strchr_m(p, '\t') ||
  			                   strchr_m(p, '(') ||
  			                   strchr_m(p, ')'));
! 
! 			if (strlen(p) > strlen(comment) && has_punctuation) {
! 				pstrcpy(comment, p);
! 				continue;
! 			}
! 
! 			if (strlen(p) <= MAXPRINTERLEN &&
! 			    strlen(p) > strlen(name) && !has_punctuation) {
! 				if (!*comment)
! 					pstrcpy(comment, name);
! 
  				pstrcpy(name, p);
! 				continue;
! 			}
! 
! 			if (!strchr_m(comment, ' ') &&
! 			    strlen(p) > strlen(comment)) {
! 				pstrcpy(comment, p);
! 				continue;
  			}
  		}
  
! 		comment[60] = 0;
! 		name[MAXPRINTERLEN] = 0;
! 
! 		if (*name && !pcap_cache_add(name, comment)) {
! 			x_fclose(pcap_file);
! 			goto done;
! 		}
  	}
  
  	x_fclose(pcap_file);
--- 187,232 ----
  			                   strchr_m(p, '\t') ||
  			                   strchr_m(p, '(') ||
  			                   strchr_m(p, ')'));
! 			if (strlen(p) > 0 && !has_punctuation) {
  				pstrcpy(name, p);
! 				name[MAXPRINTERLEN] = 0;
! 				if (*name && !pcap_cache_add(name, comment)) {
! 					x_fclose(pcap_file);
! 					goto done;
! 				}
  			}
  		}
  
! /*
!  *			if (strlen(p) > strlen(comment) && has_punctuation) {
!  *				pstrcpy(comment, p);
!  *				continue;
!  *			}
!  *
!  *			if (strlen(p) <= MAXPRINTERLEN &&
!  *			    strlen(p) > strlen(name) && !has_punctuation) {
!  *				if (!*comment)
!  *					pstrcpy(comment, name);
!  *
!  *				pstrcpy(name, p);
!  *				continue;
!  *			}
!  *
!  *			if (!strchr_m(comment, ' ') &&
!  *			    strlen(p) > strlen(comment)) {
!  *				pstrcpy(comment, p);
!  *				continue;
!  *			}
!  *		}
!  *
!  *		comment[60] = 0;
!  *		name[MAXPRINTERLEN] = 0;
!  *
!  *		if (*name && !pcap_cache_add(name, comment)) {
!  *			x_fclose(pcap_file);
!  *			goto done;
!  *		}
!  */
  	}
  
  	x_fclose(pcap_file);


More information about the samba-technical mailing list