summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-10-20 07:44:09 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:15:34 -0500
commitf58f1468345b585ea00680a3a08c19644d147d53 (patch)
treeb13050575469f6e4a53e30898baf5b5fd8f43b2a /source3
parent6e2b290672be77383ca9045bf129ae30dd27c6c6 (diff)
downloadsamba-f58f1468345b585ea00680a3a08c19644d147d53.tar.gz
samba-f58f1468345b585ea00680a3a08c19644d147d53.tar.bz2
samba-f58f1468345b585ea00680a3a08c19644d147d53.zip
r19422: Doh ! Put the krb5 user@realm code in the right place.
Jeremy. (This used to be commit a31bbbaee1042143d750a29b8fcec4720bfdb374)
Diffstat (limited to 'source3')
-rw-r--r--source3/utils/net.c40
1 files changed, 37 insertions, 3 deletions
diff --git a/source3/utils/net.c b/source3/utils/net.c
index a43fae5c80..a6fae57bc3 100644
--- a/source3/utils/net.c
+++ b/source3/utils/net.c
@@ -160,6 +160,7 @@ int net_run_function2(int argc, const char **argv, const char *whoami,
/****************************************************************************
connect to \\server\service
****************************************************************************/
+
NTSTATUS connect_to_service(struct cli_state **c, struct in_addr *server_ip,
const char *server_name,
const char *service_name,
@@ -173,13 +174,13 @@ NTSTATUS connect_to_service(struct cli_state **c, struct in_addr *server_ip,
opt_password = SMB_STRDUP(pass);
}
}
-
+
nt_status = cli_full_connection(c, NULL, server_name,
server_ip, opt_port,
service_name, service_type,
opt_user_name, opt_workgroup,
opt_password, 0, Undefined, NULL);
-
+
if (NT_STATUS_IS_OK(nt_status)) {
return nt_status;
} else {
@@ -236,20 +237,53 @@ NTSTATUS connect_to_ipc_anonymous(struct cli_state **c,
}
/****************************************************************************
+ Return malloced user@realm for krb5 login.
+****************************************************************************/
+
+static char *get_user_and_realm(const char *username)
+{
+ char *user_and_realm = NULL;
+
+ if (strchr_m(username, '@')) {
+ user_and_realm = SMB_STRDUP(username);
+ } else {
+ if (asprintf(&user_and_realm, "%s@%s", username, lp_realm()) == -1) {
+ user_and_realm = NULL;
+ }
+ }
+ return user_and_realm;
+}
+
+/****************************************************************************
connect to \\server\ipc$ using KRB5
****************************************************************************/
NTSTATUS connect_to_ipc_krb5(struct cli_state **c,
struct in_addr *server_ip, const char *server_name)
{
NTSTATUS nt_status;
+ char *user_and_realm = NULL;
+
+ if (!opt_password && !opt_machine_pass) {
+ char *pass = getpass("Password:");
+ if (pass) {
+ opt_password = SMB_STRDUP(pass);
+ }
+ }
+
+ user_and_realm = get_user_and_realm(opt_user_name);
+ if (!user_and_realm) {
+ return NT_STATUS_NO_MEMORY;
+ }
nt_status = cli_full_connection(c, NULL, server_name,
server_ip, opt_port,
"IPC$", "IPC",
- opt_user_name, opt_workgroup,
+ user_and_realm, opt_workgroup,
opt_password, CLI_FULL_CONNECTION_USE_KERBEROS,
Undefined, NULL);
+ SAFE_FREE(user_and_realm);
+
if (NT_STATUS_IS_OK(nt_status)) {
return nt_status;
} else {