.\"
-.\" "$Id: cupsaddsmb.man,v 1.1 2001/09/18 19:14:47 mike Exp $"
+.\" "$Id: cupsaddsmb.man,v 1.2 2001/11/09 17:19:41 mike Exp $"
.\"
.\" cupsaddsmb man page for the Common UNIX Printing System (CUPS).
.\"
.\" EMail: cups-info@cups.org
.\" WWW: http://www.cups.org
.\"
-.TH cupsaddsmb 8 "Common UNIX Printing System" "18 September 2001" "Easy Software Products"
+.TH cupsaddsmb 8 "Common UNIX Printing System" "9 November 2001" "Easy Software Products"
.SH NAME
cupsaddsmb \- export printers to samba for windows clients
.SH SYNOPSIS
.B cupsaddsmb
-[ -a ]
+[ -a ] [ -U
+.I user
+] [ -v ]
.br
.B cupsaddsmb
-[ printer1 ... printerN ]
+[ -u
+.I user
+] [ -v ] [ printer1 ... printerN ]
.SH DESCRIPTION
\fIcupsaddsmb\fR exports printers to the SAMBA software (version
2.2.0 or higher) for use with Windows clients. Depending on the
.LP
The \fI-a\fR option exports all known printers. Otherwise, only
the named printers are exported.
+.LP
+The \fI-U\fR option specifies the print admin username which defaults
+to your current username.
+.LP
+The \fI-v\fR option specifies that verbose information should be
+shown and is useful for debugging SAMBA configuration problems.
.SH SAMBA CONFIGURATION
\fIcupsaddsmb\fR uses the new RPC-based printing support in
SAMBA 2.2.x to provide printer drivers and PPD files to Windows
.SH COPYRIGHT
Copyright 1993-2001 by Easy Software Products, All Rights Reserved.
.\"
-.\" End of "$Id: cupsaddsmb.man,v 1.1 2001/09/18 19:14:47 mike Exp $".
+.\" End of "$Id: cupsaddsmb.man,v 1.2 2001/11/09 17:19:41 mike Exp $".
.\"
/*
- * "$Id: cupsaddsmb.c,v 1.1 2001/09/18 19:14:47 mike Exp $"
+ * "$Id: cupsaddsmb.c,v 1.2 2001/11/09 17:19:44 mike Exp $"
*
* "cupsaddsmb" command for the Common UNIX Printing System (CUPS).
*
*
* Contents:
*
+ * main() - Export printers on the command-line.
+ * do_samba_command() - Do a SAMBA command, asking for a password as needed.
+ * export_dest() - Export a destination to SAMBA.
*/
/*
#include <errno.h>
+/*
+ * Local globals...
+ */
+
+int Verbosity = 0;
+
+
/*
* Local functions...
*/
-int do_samba_command(const char *, const char *);
+int do_samba_command(const char *, const char *, const char *);
int export_dest(const char *);
if (status)
return (status);
}
+ else if (strcmp(argv[i], "-U") == 0)
+ {
+ i ++;
+ if (i >= argc)
+ {
+ puts("Usage: cupsaddsmb [-a] [-U user] [-v] [printer1 ... printerN]");
+ return (1);
+ }
+
+ cupsSetUser(argv[i]);
+ }
+ else if (strcmp(argv[i], "-v") == 0)
+ Verbosity = 1;
else if (argv[i][0] != '-')
{
if ((status = export_dest(argv[i])) != 0)
}
else
{
- puts("Usage: cupsaddsmb [-a] [printer1 ... printerN]");
+ puts("Usage: cupsaddsmb [-a] [-U user] [-v] [printer1 ... printerN]");
return (1);
}
int /* O - Status of command */
do_samba_command(const char *command, /* I - Command to run */
+ const char *args, /* I - Argument(s) for command */
const char *filename) /* I - File to use as input */
{
int status; /* Status of command */
for (status = 1;;)
{
if (p)
- snprintf(temp, sizeof(temp), "%s -N -U%s%%%s <%s >/dev/null 2>/dev/null",
- command, cupsUser(), p, filename ? filename : "/dev/null");
+ snprintf(temp, sizeof(temp), "%s -N -U \'%s%%%s\' %s <%s",
+ command, cupsUser(), p, args, filename ? filename : "/dev/null");
+ else
+ snprintf(temp, sizeof(temp), "%s -N -U \'%s\' %s <%s",
+ command, cupsUser(), args, filename ? filename : "/dev/null");
+
+ if (Verbosity)
+ {
+ printf("Running the following command:\n\n %s\n", temp);
+
+ if (filename)
+ {
+ char cat[1024];
+
+
+ puts("\nwith the following input:\n");
+
+ snprintf(cat, sizeof(cat), "cat %s", filename);
+ system(cat);
+ }
+ }
else
- snprintf(temp, sizeof(temp), "%s -N -U%s <%s >/dev/null 2>/dev/null",
- command, cupsUser(), filename ? filename : "/dev/null");
+ {
+ strncat(temp, " >/dev/null 2>/dev/null", sizeof(temp) - 1);
+ temp[sizeof(temp) - 1] = '\0';
+ }
if ((status = system(temp)) != 0)
{
+ if (Verbosity)
+ puts("");
+
snprintf(temp, sizeof(temp),
- "Password required to access %s via SAMBA.", cupsServer());
+ "Password for %s required to access %s via SAMBA: ",
+ cupsUser(), cupsServer());
if ((p = cupsGetPassword(temp)) == NULL)
break;
}
else
+ {
+ if (Verbosity)
+ puts("");
+
break;
+ }
}
return (status);
/* Run the smbclient command to copy the Windows drivers... */
snprintf(command, sizeof(command), "smbclient //%s/print\\$", cupsServer());
- if ((status = do_samba_command(command, tempfile)) != 0)
+ if ((status = do_samba_command(command, "", tempfile)) != 0)
{
fprintf(stderr, "ERROR: Unable to copy Windows printer driver files (%d)!\n",
status);
"NULL:RAW:NULL\"\n",
dest, dest);
fprintf(fp, "addprinter %s %s \"%s\" \"\"\n", dest, dest, dest);
+
+ /*
+ * MRS: For some reason, SAMBA doesn't like to install Win9x drivers
+ * with aux files. They are currently commented out but further
+ * investigation is required...
+ */
+
fprintf(fp, "adddriver \"Windows 4.0\" "
"\"%s:ADOBEPS4.DRV:%s.PPD:NULL:ADOBEPS4.HLP:"
- "PSMON.DLL:RAW:ADFONTS.MFM,DEFPRTR2.PPD,ICONLIB.DLL\"\n",
+ "PSMON.DLL:RAW:NULL\"\n",
+ /*"PSMON.DLL:RAW:ADFONTS.MFM,DEFPRTR2.PPD,ICONLIB.DLL\"\n",*/
dest, dest);
fputs("quit\n", fp);
fclose(fp);
/* Run the rpcclient command to install the Windows drivers... */
- snprintf(command, sizeof(command), "rpcclient %s", cupsServer());
-
- if ((status = do_samba_command(command, tempfile)) != 0)
+ if ((status = do_samba_command("rpcclient", cupsServer(), tempfile)) != 0)
{
fprintf(stderr, "ERROR: Unable to install Windows printer driver files (%d)!\n",
status);
/*
- * End of "$Id: cupsaddsmb.c,v 1.1 2001/09/18 19:14:47 mike Exp $".
+ * End of "$Id: cupsaddsmb.c,v 1.2 2001/11/09 17:19:44 mike Exp $".
*/