changeset 13751:fcb6d06601cc

2991 Allow building without SMB printing support Reviewed by: Bill Pijewski <wdp@joyent.com> Reviewed by: Jason King <jason.brian.king@gmail.com> Approved by: Garrett D'Amore <garrett@damore.org>
author Gordon Ross <gwr@nexenta.com>
date Sat, 14 Jul 2012 22:45:25 -0400
parents 6c5d0718e821
children 9f5f6c52ba19
files usr/src/cmd/smbsrv/smbd/Makefile usr/src/cmd/smbsrv/smbd/smbd_spool.c usr/src/lib/libshare/smb/Makefile.com usr/src/lib/libshare/smb/libshare_smb.c usr/src/lib/smbsrv/libmlsvc/Makefile.com usr/src/lib/smbsrv/libmlsvc/common/spoolss_svc.c usr/src/tools/env/illumos.sh usr/src/uts/common/fs/smbsrv/smb_print.c usr/src/uts/common/fs/smbsrv/smb_server.c usr/src/uts/common/smbsrv/smb_kproto.h
diffstat 10 files changed, 126 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/smbsrv/smbd/Makefile	Thu Jun 28 04:06:54 2012 +0100
+++ b/usr/src/cmd/smbsrv/smbd/Makefile	Sat Jul 14 22:45:25 2012 -0400
@@ -20,6 +20,7 @@
 #
 #
 # Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright 2012 Nexenta Systems, Inc.  All rights reserved.
 #
 
 
@@ -55,6 +56,8 @@
 	-lzfs -lbsm -lsocket -lnsl -lscf -lumem -lcmdutils
 LDFLAGS += -R/usr/lib/smbsrv
 
+$(ENABLE_SMB_PRINTING) CPPFLAGS += -DHAVE_CUPS
+
 ROOTSMBDDIR = $(ROOTLIB)/smbsrv
 ROOTSMBDFILE = $(PROG:%=$(ROOTSMBDDIR)/%)
 
--- a/usr/src/cmd/smbsrv/smbd/smbd_spool.c	Thu Jun 28 04:06:54 2012 +0100
+++ b/usr/src/cmd/smbsrv/smbd/smbd_spool.c	Sat Jul 14 22:45:25 2012 -0400
@@ -20,7 +20,7 @@
  */
 /*
  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright 2012 Nexenta Systems, Inc.  All rights reserved.
  */
 
 /*
@@ -29,7 +29,6 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <cups/cups.h>
 #include <strings.h>
 #include <syslog.h>
 #include <signal.h>
@@ -41,6 +40,9 @@
 #include <smbsrv/smb_share.h>
 #include "smbd.h"
 
+#ifdef	HAVE_CUPS
+#include <cups/cups.h>
+
 #define	SMB_SPOOL_WAIT			2
 #define	SMBD_PJOBLEN			256
 #define	SMBD_PRINTER			"Postscript"
@@ -512,3 +514,47 @@
 
 	(void) strlcpy(si->shr_cmnt, comment, SMB_SHARE_CMNT_MAX);
 }
+
+#else	/* HAVE_CUPS */
+
+/*
+ * If not HAVE_CUPS, just provide a few "stubs".
+ */
+
+int
+smbd_cups_init(void)
+{
+	return (ENOENT);
+}
+
+void
+smbd_cups_fini(void)
+{
+}
+
+void
+smbd_load_printers(void)
+{
+}
+
+void
+smbd_spool_init(void)
+{
+}
+
+void
+smbd_spool_fini(void)
+{
+}
+
+void
+smbd_spool_start(void)
+{
+}
+
+void
+smbd_spool_stop(void)
+{
+}
+
+#endif 	/* HAVE_CUPS */
--- a/usr/src/lib/libshare/smb/Makefile.com	Thu Jun 28 04:06:54 2012 +0100
+++ b/usr/src/lib/libshare/smb/Makefile.com	Sat Jul 14 22:45:25 2012 -0400
@@ -22,6 +22,8 @@
 # Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
+# Copyright 2012 Nexenta Systems, Inc.  All rights reserved.
+#
 
 LIBRARY =	libshare_smb.a
 VERS =		.1
@@ -49,6 +51,7 @@
 CFLAGS +=	$(CCVERBOSE)
 CPPFLAGS +=	-D_REENTRANT -I/usr/include/libxml2 \
 		-I$(SRCDIR)/../common
+$(ENABLE_SMB_PRINTING) CPPFLAGS += -DHAVE_CUPS
 
 .KEEP_STATE:
 
--- a/usr/src/lib/libshare/smb/libshare_smb.c	Thu Jun 28 04:06:54 2012 +0100
+++ b/usr/src/lib/libshare/smb/libshare_smb.c	Sat Jul 14 22:45:25 2012 -0400
@@ -21,6 +21,7 @@
 
 /*
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2012 Nexenta Systems, Inc.  All rights reserved.
  */
 
 /*
@@ -76,6 +77,7 @@
 static int range_check_validator(int, char *);
 static int range_check_validator_zero_ok(int, char *);
 static int string_length_check_validator(int, char *);
+static int print_enable_validator(int, char *);
 static int true_false_validator(int, char *);
 static int ipv4_validator(int, char *);
 static int hostname_validator(int, char *);
@@ -912,7 +914,7 @@
 	{ SMB_CI_AUTOHOME_MAP, 0, MAX_VALUE_BUFLEN, path_validator, 0 },
 	{ SMB_CI_IPV6_ENABLE, 0, 0, true_false_validator,
 	    SMB_REFRESH_REFRESH },
-	{ SMB_CI_PRINT_ENABLE, 0, 0, true_false_validator,
+	{ SMB_CI_PRINT_ENABLE, 0, 0, print_enable_validator,
 	    SMB_REFRESH_REFRESH },
 	{ SMB_CI_MAP, 0, MAX_VALUE_BUFLEN, cmd_validator, SMB_REFRESH_REFRESH },
 	{ SMB_CI_UNMAP, 0, MAX_VALUE_BUFLEN, cmd_validator,
@@ -999,6 +1001,27 @@
 }
 
 /*
+ * If printing support is compiled in, this is the same as:
+ * true_false_validator.  Otherwise, only allow false.
+ */
+/*ARGSUSED*/
+static int
+print_enable_validator(int index, char *value)
+{
+	if (value == NULL)
+		return (SA_BAD_VALUE);
+
+#ifdef	HAVE_CUPS
+	if (strcasecmp(value, "true") == 0)
+		return (SA_OK);
+#endif
+	if (strcasecmp(value, "false") == 0)
+		return (SA_OK);
+
+	return (SA_BAD_VALUE);
+}
+
+/*
  * Check IP v4 address.
  */
 /*ARGSUSED*/
--- a/usr/src/lib/smbsrv/libmlsvc/Makefile.com	Thu Jun 28 04:06:54 2012 +0100
+++ b/usr/src/lib/smbsrv/libmlsvc/Makefile.com	Sat Jul 14 22:45:25 2012 -0400
@@ -19,7 +19,7 @@
 # CDDL HEADER END
 #
 #
-# Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
+# Copyright 2012 Nexenta Systems, Inc.  All rights reserved.
 # Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
 #
 
@@ -87,6 +87,7 @@
 	-lscf -lcmdutils -lsec -lavl -lnvpair -luutil -luuid -lgen -lzfs -lc
 
 CPPFLAGS += $(INCS) -D_REENTRANT
+$(ENABLE_SMB_PRINTING) CPPFLAGS += -DHAVE_CUPS
 
 SRCS=   $(OBJS_COMMON:%.o=$(SRCDIR)/%.c)
 
--- a/usr/src/lib/smbsrv/libmlsvc/common/spoolss_svc.c	Thu Jun 28 04:06:54 2012 +0100
+++ b/usr/src/lib/smbsrv/libmlsvc/common/spoolss_svc.c	Sat Jul 14 22:45:25 2012 -0400
@@ -20,6 +20,7 @@
  */
 /*
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2012 Nexenta Systems, Inc.  All rights reserved.
  */
 
 /*
@@ -44,6 +45,8 @@
 #include <smbsrv/nmpipes.h>
 #include <mlsvc.h>
 
+#ifdef	HAVE_CUPS
+
 #define	SPOOLSS_PRINTER		"Postscript"
 
 typedef struct smb_spool {
@@ -1194,3 +1197,27 @@
 	FIXUP_PDU_SIZE(spoolss_GetPrinter_result, size2);
 	FIXUP_PDU_SIZE(spoolss_GetPrinter, size3);
 }
+
+#else	/* HAVE_CUPS */
+
+/*
+ * If not HAVE_CUPS, just provide a few "stubs".
+ */
+
+void
+spoolss_initialize(void)
+{
+}
+
+void
+spoolss_finalize(void)
+{
+}
+
+/*ARGSUSED*/
+void
+spoolss_register_copyfile(spoolss_copyfile_t copyfile)
+{
+}
+
+#endif 	/* HAVE_CUPS */
--- a/usr/src/tools/env/illumos.sh	Thu Jun 28 04:06:54 2012 +0100
+++ b/usr/src/tools/env/illumos.sh	Sat Jul 14 22:45:25 2012 -0400
@@ -226,3 +226,6 @@
 # POST_NIGHTLY can be any command to be run at the end of nightly.  See
 # nightly(1) for interactions between environment variables and this command.
 #POST_NIGHTLY=
+
+# Uncomment this to disable support for SMB printing.
+# export ENABLE_SMB_PRINTING='#'
--- a/usr/src/uts/common/fs/smbsrv/smb_print.c	Thu Jun 28 04:06:54 2012 +0100
+++ b/usr/src/uts/common/fs/smbsrv/smb_print.c	Sat Jul 14 22:45:25 2012 -0400
@@ -20,7 +20,7 @@
  */
 /*
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright 2012 Nexenta Systems, Inc.  All rights reserved.
  */
 
 /*
@@ -183,8 +183,12 @@
 {
 	smb_sdrc_t rc;
 
-	if (sr->sr_server->sv_cfg.skc_print_enable == 0 ||
-	    !STYPE_ISPRN(sr->tid_tree->t_res_type)) {
+	/*
+	 * If sv_cfg.skc_print_enable somehow went false while
+	 * we have a print FID open, close the FID.  In this
+	 * situation, smb_spool_add_fid() will do nothing.
+	 */
+	if (!STYPE_ISPRN(sr->tid_tree->t_res_type)) {
 		smbsr_error(sr, NT_STATUS_BAD_DEVICE_TYPE,
 		    ERRDOS, ERROR_BAD_DEV_TYPE);
 		cmn_err(CE_WARN, "smb_com_close_print_file: SDRC_ERROR");
@@ -192,8 +196,7 @@
 	}
 	rc = smb_com_close(sr);
 
-	(void) smb_spool_add_fid(sr->smb_fid);
-	cv_broadcast(&sr->sr_server->sp_info.sp_cv);
+	smb_spool_add_fid(sr->sr_server, sr->smb_fid);
 
 	return (rc);
 }
--- a/usr/src/uts/common/fs/smbsrv/smb_server.c	Thu Jun 28 04:06:54 2012 +0100
+++ b/usr/src/uts/common/fs/smbsrv/smb_server.c	Sat Jul 14 22:45:25 2012 -0400
@@ -20,7 +20,7 @@
  */
 /*
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright 2012 Nexenta Systems, Inc.  All rights reserved.
  */
 
 /*
@@ -2156,17 +2156,14 @@
  *
  */
 
-int
-smb_spool_add_fid(uint16_t fid)
+void
+smb_spool_add_fid(smb_server_t *sv, uint16_t fid)
 {
 	smb_llist_t	*fidlist;
-	smb_server_t	*sv;
 	smb_spoolfid_t  *sf;
-	int rc = 0;
 
-	rc = smb_server_lookup(&sv);
-	if (rc)
-		return (rc);
+	if (sv->sv_cfg.skc_print_enable == 0)
+		return;
 
 	sf = kmem_zalloc(sizeof (smb_spoolfid_t), KM_SLEEP);
 	fidlist = &sv->sp_info.sp_fidlist;
@@ -2174,8 +2171,7 @@
 	sf->sf_fid = fid;
 	smb_llist_insert_tail(fidlist, sf);
 	smb_llist_exit(fidlist);
-	smb_server_release(sv);
-	return (rc);
+	cv_broadcast(&sv->sp_info.sp_cv);
 }
 
 /*
--- a/usr/src/uts/common/smbsrv/smb_kproto.h	Thu Jun 28 04:06:54 2012 +0100
+++ b/usr/src/uts/common/smbsrv/smb_kproto.h	Sat Jul 14 22:45:25 2012 -0400
@@ -21,7 +21,7 @@
 
 /*
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright 2012 Nexenta Systems, Inc.  All rights reserved.
  */
 
 /*
@@ -381,7 +381,7 @@
 
 int smb_server_spooldoc(smb_ioc_spooldoc_t *);
 int smb_spool_add_doc(smb_kspooldoc_t *);
-int smb_spool_add_fid(uint16_t);
+void smb_spool_add_fid(smb_server_t *, uint16_t);
 
 void smb_server_inc_nbt_sess(smb_server_t *);
 void smb_server_dec_nbt_sess(smb_server_t *);