--- Begin Message ---
Package: cupsys-client
Severity: wishlist
Tags: patch
Hi,
It is possible with most of the Samba utils to specify both the user and
the password to use when connecting to the server via the -U option, but
cupsaddsmb doesn't offer this possibility.
The attached patch makes it possible to specify a login+password pair
with the usual -U user%password syntax. It is especially useful when
using cupsaddsmb in a script.
Please apply,
JB.
--
Julien BLACHE <jblache@siriustech.org>
Sirius Technologies <http://www.siriustech.org>
--- cupsys-1.1.20final+cvs20040330.orig/systemv/cupsaddsmb.c
+++ cupsys-1.1.20final+cvs20040330/systemv/cupsaddsmb.c
@@ -46,8 +46,8 @@
*/
int Verbosity = 0;
-const char *SAMBAUser,
- *SAMBAServer;
+char *SAMBAUser;
+const char *SAMBAServer;
/*
@@ -80,7 +80,7 @@
export_all = 0;
- SAMBAUser = cupsUser();
+ SAMBAUser = strdup(cupsUser());
SAMBAServer = NULL;
for (i = 1; i < argc; i ++)
@@ -92,7 +92,8 @@
if (i >= argc)
usage();
- SAMBAUser = argv[i];
+ free(SAMBAUser);
+ SAMBAUser = strdup(argv[i]);
}
else if (strcmp(argv[i], "-H") == 0)
{
@@ -152,6 +153,8 @@
return (status);
}
+ free(SAMBAUser);
+
return (0);
}
@@ -167,19 +170,27 @@
{
int status; /* Status of command */
char temp[4096]; /* Command/prompt string */
- static const char *p = NULL; /* Password data */
+ static char *p = NULL; /* Password data */
for (status = 1;;)
{
if (p == NULL)
{
- snprintf(temp, sizeof(temp),
- "Password for %s required to access %s via SAMBA: ",
- SAMBAUser, SAMBAServer);
-
- if ((p = cupsGetPassword(temp)) == NULL)
- break;
+ if ((p = strchr(SAMBAUser, '%')) != NULL)
+ {
+ *p = '\0';
+ p++;
+ }
+ else
+ {
+ snprintf(temp, sizeof(temp),
+ "Password for %s required to access %s via SAMBA: ",
+ SAMBAUser, SAMBAServer);
+
+ if ((p = cupsGetPassword(temp)) == NULL)
+ break;
+ }
}
snprintf(temp, sizeof(temp), "%s -N -U\'%s%%%s\' -c \'%s\'",
--- End Message ---