const char *get_cmdline_auth_info_username(const struct user_auth_info *auth_info);
void set_cmdline_auth_info_username(struct user_auth_info *auth_info,
const char *username);
+void reset_cmdline_auth_info_username(struct user_auth_info *auth_info);
const char *get_cmdline_auth_info_domain(const struct user_auth_info *auth_info);
void set_cmdline_auth_info_domain(struct user_auth_info *auth_info,
const char *domain);
void popt_common_credentials_post(void)
{
- const char *username = NULL;
-
if (get_cmdline_auth_info_use_machine_account(cmdline_auth_info) &&
!set_cmdline_auth_info_machine_account_creds(cmdline_auth_info))
{
* correctly parsed yet. If we have a username we need to set it again
* to run the string parser for the username correctly.
*/
- username = get_cmdline_auth_info_username(cmdline_auth_info);
- if (username != NULL && username[0] != '\0') {
- set_cmdline_auth_info_username(cmdline_auth_info, username);
- }
+ reset_cmdline_auth_info_username(cmdline_auth_info);
}
static void popt_common_credentials_callback(poptContext con,
struct user_auth_info {
struct cli_credentials *creds;
struct loadparm_context *lp_ctx;
+ bool got_username;
bool got_pass;
int signing_state;
bool smb_encrypt;
if (!ok) {
exit(EIO);
}
+ auth_info->got_username = true;
}
const char *get_cmdline_auth_info_username(const struct user_auth_info *auth_info)
exit(ENOMEM);
}
+ auth_info->got_username = true;
if (strchr_m(username, '%') != NULL) {
auth_info->got_pass = true;
}
}
+void reset_cmdline_auth_info_username(struct user_auth_info *auth_info)
+{
+ const char *username = NULL;
+ const char *new_val = NULL;
+
+ if (!auth_info->got_username) {
+ return;
+ }
+
+ username = cli_credentials_get_username(auth_info->creds);
+ if (username == NULL) {
+ return;
+ }
+ if (username[0] == '\0') {
+ return;
+ }
+
+ cli_credentials_parse_string(auth_info->creds,
+ username,
+ CRED_SPECIFIED);
+ new_val = cli_credentials_get_username(auth_info->creds);
+ if (new_val == NULL) {
+ exit(ENOMEM);
+ }
+}
+
const char *get_cmdline_auth_info_domain(const struct user_auth_info *auth_info)
{
const char *domain = NULL;