[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problem: default realm in openssh



David Komanek <xdavid@lib-eth.natur.cuni.cz> writes:

> unable to find realm of host prfdec

The hostname passed to krb5_get_host_realm should be fully qualified,
so something is obviously wrong.

What does this program output?

/Johan

#include <stdio.h>
#include <stdlib.h>

#include <krb5.h>

int
main(int argc, char **argv)
{
    krb5_context context;
    krb5_error_code ret;
    int i;
    int estatus = 0;

    if(argc < 2) {
	fprintf(stderr, "%s hostname...\n", argv[0]);
	exit(1);
    }
    krb5_init_context(&context);
    for(i = 1; i < argc; i++) {
	char *hostname;
	char **realms, **r;
	ret = krb5_expand_hostname_realms(context, argv[i], 
					  &hostname, &realms);
	if(ret != 0) {
	    krb5_warn(context, ret, 
		      "krb5_expand_hostname_realms(%s)", argv[i]);
	    estatus = 1;
	    continue;
	}
	printf("%s: hostname %s, realms ", argv[i], hostname);
	for(r = realms; *r != NULL; r++)
	    printf("%s ", *r);
	printf("\n");
	free(hostname);
	krb5_free_host_realm (context, realms);
    }
    exit(estatus);
}