diff options
author | Andrew Bartlett <abartlet@samba.org> | 2011-06-24 16:26:23 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2011-06-24 16:26:23 +1000 |
commit | 6da26870e0ae5acd6ff49a30ec2f6886b44d095e (patch) | |
tree | 850c71039563c16a5d563c47e7ba2ab645baf198 /source3/libads/kerberos.c | |
parent | 6925a799d04c6fa59dd2ddef1f5510f9bb7d17d1 (diff) | |
parent | 2610c05b5b95cc7036b3d6dfb894c6cfbdb68483 (diff) | |
download | samba-4.0.0alpha16.tar.gz samba-4.0.0alpha16.tar.xz samba-4.0.0alpha16.zip |
Merge 2610c05b5b95cc7036b3d6dfb894c6cfbdb68483 as Samba-4.0alpha16samba-4.0.0alpha16
Diffstat (limited to 'source3/libads/kerberos.c')
-rw-r--r-- | source3/libads/kerberos.c | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/source3/libads/kerberos.c b/source3/libads/kerberos.c index d496ade71b0..913d6900493 100644 --- a/source3/libads/kerberos.c +++ b/source3/libads/kerberos.c @@ -223,8 +223,8 @@ int kerberos_kinit_password_ext(const char *principal, krb5_get_init_creds_opt_set_address_list(opt, addr->addrs); } - if ((code = krb5_get_init_creds_password(ctx, &my_creds, me, CONST_DISCARD(char *,password), - kerb_prompter, CONST_DISCARD(char *,password), + if ((code = krb5_get_init_creds_password(ctx, &my_creds, me, discard_const_p(char,password), + kerb_prompter, discard_const_p(char, password), 0, NULL, opt))) { goto out; } @@ -352,7 +352,7 @@ char* kerberos_standard_des_salt( void ) { fstring salt; - fstr_sprintf( salt, "host/%s.%s@", global_myname(), lp_realm() ); + fstr_sprintf( salt, "host/%s.%s@", lp_netbios_name(), lp_realm() ); strlower_m( salt ); fstrcat( salt, lp_realm() ); @@ -958,22 +958,37 @@ bool create_local_private_krb5_conf_for_domain(const char *realm, /* Insanity, sheer insanity..... */ if (strequal(realm, lp_realm())) { - char linkpath[PATH_MAX+1]; - int lret; - - lret = readlink(SYSTEM_KRB5_CONF_PATH, linkpath, sizeof(linkpath)-1); - if (lret != -1) { - linkpath[lret] = '\0'; - } - - if (lret != -1 || strcmp(linkpath, fname) == 0) { - /* Symlink already exists. */ - goto done; + SMB_STRUCT_STAT sbuf; + + if (sys_lstat(SYSTEM_KRB5_CONF_PATH, &sbuf, false) == 0) { + if (S_ISLNK(sbuf.st_ex_mode) && sbuf.st_ex_size) { + int lret; + size_t alloc_size = sbuf.st_ex_size + 1; + char *linkpath = talloc_array(talloc_tos(), char, + alloc_size); + if (!linkpath) { + goto done; + } + lret = readlink(SYSTEM_KRB5_CONF_PATH, linkpath, + alloc_size - 1); + if (lret == -1) { + TALLOC_FREE(linkpath); + goto done; + } + linkpath[lret] = '\0'; + + if (strcmp(linkpath, fname) == 0) { + /* Symlink already exists. */ + TALLOC_FREE(linkpath); + goto done; + } + TALLOC_FREE(linkpath); + } } /* Try and replace with a symlink. */ if (symlink(fname, SYSTEM_KRB5_CONF_PATH) == -1) { - const char *newpath = SYSTEM_KRB5_CONF_PATH ## ".saved"; + const char *newpath = SYSTEM_KRB5_CONF_PATH ".saved"; if (errno != EEXIST) { DEBUG(0,("create_local_private_krb5_conf_for_domain: symlink " "of %s to %s failed. Errno %s\n", |