summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <anschneider@suse.de>2008-01-17 11:35:40 +0100
committerJeremy Allison <jra@samba.org>2008-01-23 14:57:45 -0800
commitcfe7b54e96d39d19ad6b28c0d7db380907171e21 (patch)
treea2bdc8d076e7b9b770a394b215441a3b1ab94e26
parent691c4b1a4175e3d4a073c396a2a7d8d315cd42bd (diff)
downloadsamba-cfe7b54e96d39d19ad6b28c0d7db380907171e21.tar.gz
samba-cfe7b54e96d39d19ad6b28c0d7db380907171e21.tar.bz2
samba-cfe7b54e96d39d19ad6b28c0d7db380907171e21.zip
Fix Windows 2008 (Longhorn) join.
During 'net ads join' the cli->desthost is a hostname (e.g. rupert.galaxy.site). Check if we have a hostname and use only the first part, the machine name, of the string. (This used to be commit 5f60ed4af680ba2811db8d9f8267348ce05f26d2)
-rw-r--r--source3/libsmb/cliconnect.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index 4560521d4a..de5813df6b 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -872,13 +872,26 @@ ADS_STATUS cli_session_setup_spnego(struct cli_state *cli, const char *user,
!strequal(star_smbserver_name,
cli->desthost)) {
char *realm = NULL;
+ char *machine = NULL;
+ char *host = NULL;
DEBUG(3,("cli_session_setup_spnego: got a "
"bad server principal, trying to guess ...\n"));
+ host = strchr(cli->desthost, '.');
+ if (host) {
+ machine = SMB_STRNDUP(cli->desthost,
+ host - cli->desthost);
+ } else {
+ machine = SMB_STRDUP(cli->desthost);
+ }
+ if (machine == NULL) {
+ return ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
+ }
+
realm = kerberos_get_default_realm_from_ccache();
if (realm && *realm) {
if (asprintf(&principal, "%s$@%s",
- cli->desthost, realm) < 0) {
+ machine, realm) < 0) {
SAFE_FREE(realm);
return ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
}
@@ -886,6 +899,7 @@ ADS_STATUS cli_session_setup_spnego(struct cli_state *cli, const char *user,
"server principal=%s\n",
principal ? principal : "<null>"));
}
+ SAFE_FREE(machine);
SAFE_FREE(realm);
}