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.c60
1 files changed, 50 insertions, 10 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c
index ec794ca74e..75fd82709a 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -290,7 +290,7 @@ struct user_auth_info *user_auth_info_init(TALLOC_CTX *mem_ctx)
return result;
}
-const char *get_cmdline_auth_info_username(struct user_auth_info *auth_info)
+const char *get_cmdline_auth_info_username(const struct user_auth_info *auth_info)
{
if (!auth_info->username) {
return "";
@@ -308,7 +308,7 @@ void set_cmdline_auth_info_username(struct user_auth_info *auth_info,
}
}
-const char *get_cmdline_auth_info_password(struct user_auth_info *auth_info)
+const char *get_cmdline_auth_info_password(const struct user_auth_info *auth_info)
{
if (!auth_info->password) {
return "";
@@ -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);
@@ -346,7 +349,7 @@ bool set_cmdline_auth_info_signing_state(struct user_auth_info *auth_info,
return true;
}
-int get_cmdline_auth_info_signing_state(struct user_auth_info *auth_info)
+int get_cmdline_auth_info_signing_state(const struct user_auth_info *auth_info)
{
return auth_info->signing_state;
}
@@ -357,11 +360,22 @@ void set_cmdline_auth_info_use_kerberos(struct user_auth_info *auth_info,
auth_info->use_kerberos = b;
}
-bool get_cmdline_auth_info_use_kerberos(struct user_auth_info *auth_info)
+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)
{
@@ -380,23 +394,23 @@ void set_cmdline_auth_info_use_machine_account(struct user_auth_info *auth_info)
auth_info->use_machine_account = true;
}
-bool get_cmdline_auth_info_got_pass(struct user_auth_info *auth_info)
+bool get_cmdline_auth_info_got_pass(const struct user_auth_info *auth_info)
{
return auth_info->got_pass;
}
-bool get_cmdline_auth_info_smb_encrypt(struct user_auth_info *auth_info)
+bool get_cmdline_auth_info_smb_encrypt(const struct user_auth_info *auth_info)
{
return auth_info->smb_encrypt;
}
-bool get_cmdline_auth_info_use_machine_account(struct user_auth_info *auth_info)
+bool get_cmdline_auth_info_use_machine_account(const struct user_auth_info *auth_info)
{
return auth_info->use_machine_account;
}
struct user_auth_info *get_cmdline_auth_info_copy(TALLOC_CTX *mem_ctx,
- struct user_auth_info *src)
+ const struct user_auth_info *src)
{
struct user_auth_info *result;
@@ -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.
****************************************************************************/
@@ -3102,9 +3142,9 @@ NTSTATUS split_ntfs_stream_name(TALLOC_CTX *mem_ctx, const char *fname,
return NT_STATUS_OK;
}
-bool is_valid_policy_hnd(const POLICY_HND *hnd)
+bool is_valid_policy_hnd(const struct policy_handle *hnd)
{
- POLICY_HND tmp;
+ struct policy_handle tmp;
ZERO_STRUCT(tmp);
return (memcmp(&tmp, hnd, sizeof(tmp)) != 0);
}