summaryrefslogtreecommitdiff
path: root/source3/client
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2017-07-11 10:40:39 +0200
committerAndreas Schneider <asn@cryptomilk.org>2017-07-25 09:14:19 +0200
commita553f12418a16c58b278745e3da6329ce24fe3c7 (patch)
tree17b7b5aa5940be0e495b63e1031718e24b1b18b3 /source3/client
parent924e7f7c80b203e147823f802926c323d9402248 (diff)
downloadsamba-a553f12418a16c58b278745e3da6329ce24fe3c7.tar.gz
s3:client: Fix the usage of argv in smbspool
We use argv[0] to print the name of the binary, but have shifted it away. Do not do that. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source3/client')
-rw-r--r--source3/client/smbspool.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/source3/client/smbspool.c b/source3/client/smbspool.c
index 49241c73bf1..f8489d0d9cf 100644
--- a/source3/client/smbspool.c
+++ b/source3/client/smbspool.c
@@ -100,16 +100,6 @@ main(int argc, /* I - Number of command-line arguments */
null_str[0] = '\0';
- /*
- * we expect the URI in argv[0]. Detect the case where it is in
- * argv[1] and cope
- */
- if (argc > 2 && strncmp(argv[0], "smb://", 6) &&
- strncmp(argv[1], "smb://", 6) == 0) {
- argv++;
- argc--;
- }
-
if (argc == 1) {
/*
* NEW! In CUPS 1.1 the backends are run with no arguments
@@ -124,7 +114,7 @@ main(int argc, /* I - Number of command-line arguments */
goto done;
}
- if (argc < 6 || argc > 7) {
+ if (argc < 7 || argc > 8) {
fprintf(stderr,
"Usage: %s [DEVICE_URI] job-id user title copies options [file]\n"
" The DEVICE_URI environment variable can also contain the\n"
@@ -140,18 +130,18 @@ main(int argc, /* I - Number of command-line arguments */
* Otherwise, print data from stdin...
*/
- if (argc == 6) {
+ if (argc == 7) {
/*
* Print from Copy stdin to a temporary file...
*/
fp = stdin;
copies = 1;
- } else if ((fp = fopen(argv[6], "rb")) == NULL) {
+ } else if ((fp = fopen(argv[7], "rb")) == NULL) {
perror("ERROR: Unable to open print file");
goto done;
} else {
- char *p = argv[4];
+ char *p = argv[5];
char *endp;
copies = strtol(p, &endp, 10);
@@ -168,10 +158,10 @@ main(int argc, /* I - Number of command-line arguments */
dev_uri = getenv("DEVICE_URI");
if (dev_uri) {
strncpy(uri, dev_uri, sizeof(uri) - 1);
- } else if (strncmp(argv[0], "smb://", 6) == 0) {
- strncpy(uri, argv[0], sizeof(uri) - 1);
+ } else if (strncmp(argv[1], "smb://", 6) == 0) {
+ strncpy(uri, argv[1], sizeof(uri) - 1);
} else {
- fputs("ERROR: No device URI found in DEVICE_URI environment variable or argv[0] !\n", stderr);
+ fputs("ERROR: No device URI found in DEVICE_URI environment variable or arg1 !\n", stderr);
goto done;
}
@@ -267,7 +257,7 @@ main(int argc, /* I - Number of command-line arguments */
do {
cli = smb_connect(workgroup, server, port, printer,
- username, password, argv[2], &need_auth);
+ username, password, argv[3], &need_auth);
if (cli == NULL) {
if (need_auth) {
exit(2);
@@ -303,7 +293,7 @@ main(int argc, /* I - Number of command-line arguments */
*/
for (i = 0; i < copies; i++) {
- status = smb_print(cli, argv[3] /* title */ , fp);
+ status = smb_print(cli, argv[4] /* title */ , fp);
if (status != 0) {
break;
}