summaryrefslogtreecommitdiff
path: root/source3/lib/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib/util.c')
-rw-r--r--source3/lib/util.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 613cc1eae7..80a807d7e4 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -320,6 +320,9 @@ void set_cmdline_auth_info_password(struct user_auth_info *auth_info,
const char *password)
{
TALLOC_FREE(auth_info->password);
+ if (password == NULL) {
+ password = "";
+ }
auth_info->password = talloc_strdup(auth_info, password);
if (!auth_info->password) {
exit(ENOMEM);
@@ -362,6 +365,17 @@ bool get_cmdline_auth_info_use_kerberos(const struct user_auth_info *auth_info)
return auth_info->use_kerberos;
}
+void set_cmdline_auth_info_fallback_after_kerberos(struct user_auth_info *auth_info,
+ bool b)
+{
+ auth_info->fallback_after_kerberos = b;
+}
+
+bool get_cmdline_auth_info_fallback_after_kerberos(const struct user_auth_info *auth_info)
+{
+ return auth_info->fallback_after_kerberos;
+}
+
/* This should only be used by lib/popt_common.c JRA */
void set_cmdline_auth_info_use_krb5_ticket(struct user_auth_info *auth_info)
{
@@ -456,6 +470,32 @@ bool set_cmdline_auth_info_machine_account_creds(struct user_auth_info *auth_inf
}
/****************************************************************************
+ Ensure we have a password if one not given.
+****************************************************************************/
+
+void set_cmdline_auth_info_getpass(struct user_auth_info *auth_info)
+{
+ char *label = NULL;
+ char *pass;
+ TALLOC_CTX *frame;
+
+ if (get_cmdline_auth_info_got_pass(auth_info) ||
+ get_cmdline_auth_info_use_kerberos(auth_info)) {
+ /* Already got one... */
+ return;
+ }
+
+ frame = talloc_stackframe();
+ label = talloc_asprintf(frame, "Enter %s's password: ",
+ get_cmdline_auth_info_username(auth_info));
+ pass = getpass(label);
+ if (pass) {
+ set_cmdline_auth_info_password(auth_info, pass);
+ }
+ TALLOC_FREE(frame);
+}
+
+/****************************************************************************
Add a gid to an array of gids if it's not already there.
****************************************************************************/