s3-utils/smbget: Fix user-/name password reading from rcfile
authorChristian Ambach <ambi@samba.org>
Wed, 27 Jan 2016 21:00:31 +0000 (22:00 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 28 Jan 2016 08:58:26 +0000 (09:58 +0100)
As the password option is gone, code needs to be able to read password
from user parameter when user%password syntax is used.

Signed-off-by: Christian Ambach <ambi@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/utils/smbget.c

index e332b2d99b42ee74c736710f232759c68664e25e..1dd8d7757476064cfa1a6a383d493c3b6211ecf1 100644 (file)
@@ -738,6 +738,16 @@ static int readrcfile(const char *name, const struct poptOption long_options[])
                        case POPT_ARG_STRING:
                                stringdata = (char **)long_options[i].arg;
                                *stringdata = SMB_STRDUP(val);
+                               if (long_options[i].shortName == 'U') {
+                                       char *p;
+                                       opt.username_specified = true;
+                                       p = strchr(*stringdata, '%');
+                                       if (p != NULL) {
+                                               *p = '\0';
+                                               opt.password = p + 1;
+                                               opt.password_specified = true;
+                                       }
+                               }
                                break;
                        default:
                                fprintf(stderr, "Invalid variable %s at "