|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2017-05-23 09:09 UTC] chanlists at googlemail dot com
Description:
------------
Suppose we are using a virtual host in apache where the name of the virtual host name <vhost> is a cname for the actual hostname <hostname>. In this case, the web browser will present a service ticket for HTTP/<vhost>, but the krb5 package will set the service principal to HTTP/<hostname> because of the use of gethostbyname() in the KRB5NegotiateAuth constructor. This will not work. If I modify the constructor as follows, it works:
server_name = zend_compat_hash_find(HASH_OF(server), "SERVER_NAME", sizeof("SERVER_NAME"));
if ( server_name != NULL ) {
char *hostname = Z_STRVAL_P(server_name);
// struct hostent* host = gethostbyname(hostname);
// if(!host) {
// zend_throw_exception(NULL, "Failed to get server FQDN - Lookup failure", 0 TSRMLS_CC);
// return;
//}
nametmp.length = strlen(hostname) + 6;
nametmp.value = emalloc(sizeof(char)*nametmp.length);
snprintf(nametmp.value, nametmp.length, "HTTP@%s",hostname);
Note that for this to work, one also has to set
dns_canonicalize_hostname = false
in /etc/krb5.conf because otherwise the krb5 library will try to do hostname canonicalization as well. So I think there should either be a way to set the name of the service principal using a method, or hostname canonicalization should be disabled in the krb5 library as above, or it should be possible to turn it off with a flag. I would be happy to contribute a patch depending on what you prefer. Thanks for this great piece of software,
Christian
Test script:
---------------
see above
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 15:00:01 2025 UTC |
Thinking a bit more about it - now that dns_canonicalize_hostname is no longer required on the server, we cannot really control what the client has set. Right now, gss_acquire_cred is called like status = gss_acquire_cred(&minor_status, object->servname, 0, GSS_C_NO_OID_SET, GSS_C_ACCEPT, &server_creds, NULL, NULL); It would be great if there were an option to replace obj->servname in the call by GSS_C_NO_NAME. My understanding is that in this case, any principal in the keytab should work. So I could stick HTTP/<vhost_name> and HTTP/<real_hostanme> and HTTP/<short_name> in the keytab, and all should work... What do you think? Happy to test... ChristianOK, what I have tried now is the following patch relative to your latest version: 248,249d247 < } else if(spn[0] == '@') { < object->servname = GSS_C_NO_NAME; The effect of this is that if I set the service name to '@', it will use GSS_C_NO_NAME... and therefore accept all principals in the keytab.