summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2009-03-17 14:53:06 -0700
committerJeremy Allison <jra@samba.org>2009-03-17 14:53:06 -0700
commit8dd1faaa2992851f6852ba7ea4498445af5faadd (patch)
tree9720fbd58d974d3245d9c933e448ddff220277d1 /source3/lib
parent153a837bd61338c0b912c43458900224de0654f7 (diff)
downloadsamba-8dd1faaa2992851f6852ba7ea4498445af5faadd.tar.gz
samba-8dd1faaa2992851f6852ba7ea4498445af5faadd.tar.bz2
samba-8dd1faaa2992851f6852ba7ea4498445af5faadd.zip
Remove the global "struct cm_cred_struct" and associated calls, make
callers pass in a struct user_auth_info * instead. This commit causes smbc_set_credentials() to print out a message telling callers to use smbc_set_credentials_with_fallback() instead, as smbc_set_credentials() has a broken API (no SMBCCTX * pointer). No more global variables used in the connection manager API for client dfs calls. Jeremy.
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/netapi/cm.c32
-rw-r--r--source3/lib/util.c40
2 files changed, 56 insertions, 16 deletions
diff --git a/source3/lib/netapi/cm.c b/source3/lib/netapi/cm.c
index 43ebed6c22..b676ae63dd 100644
--- a/source3/lib/netapi/cm.c
+++ b/source3/lib/netapi/cm.c
@@ -29,36 +29,36 @@ static WERROR libnetapi_open_ipc_connection(struct libnetapi_ctx *ctx,
const char *server_name,
struct cli_state **cli)
{
+ struct user_auth_info *auth_info = NULL;
struct cli_state *cli_ipc = NULL;
if (!ctx || !cli || !server_name) {
return WERR_INVALID_PARAM;
}
- cli_cm_set_signing_state(Undefined);
-
- if (ctx->use_kerberos) {
- cli_cm_set_use_kerberos();
- }
-
- if (ctx->password) {
- cli_cm_set_password(ctx->password);
- }
- if (ctx->username) {
- cli_cm_set_username(ctx->username);
+ auth_info = user_auth_info_init(NULL);
+ if (!auth_info) {
+ return WERR_NOMEM;
}
+ auth_info->signing_state = Undefined;
+ set_cmdline_auth_info_use_kerberos(auth_info, ctx->use_kerberos);
+ set_cmdline_auth_info_password(auth_info, ctx->password);
+ set_cmdline_auth_info_username(auth_info, ctx->username);
if (ctx->username && ctx->username[0] &&
ctx->password && ctx->password[0] &&
ctx->use_kerberos) {
- cli_cm_set_fallback_after_kerberos();
+ set_cmdline_auth_info_fallback_after_kerberos(auth_info, true);
}
cli_ipc = cli_cm_open(ctx, NULL,
- server_name, "IPC$",
- false, false,
- PROTOCOL_NT1,
- 0, 0x20);
+ server_name, "IPC$",
+ auth_info,
+ false, false,
+ PROTOCOL_NT1,
+ 0, 0x20);
+ TALLOC_FREE(auth_info);
+
if (!cli_ipc) {
libnetapi_set_error_string(ctx,
"Failed to connect to IPC$ share on %s", server_name);
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.
****************************************************************************/