At 2007-02-16 10:30, [EMAIL PROTECTED] said:

> Otherwise I think setting KRB5_KTNAME in some kind of startup script
> as mentioned by Daniel and Simon in the two other responses is an
> adequate solution.

you also can set the variable directly within your code with putenv(),
if you want to read the value from a config file or the command line.

For example, here's testkrb5kt.c:

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

/* 
  testkrb5kt.c: a demonstration of choosing the default keytab name.
  build with:
    gcc -g -Wall --pedantic -o testkrb5kt testkrb5kt.c -lkrb5
*/

int main(int argc, char* argv[]) {
  char inp[1024];
  char buf[1024];
  int ret;
  krb5_context context;

  if (argc > 1) {
    snprintf(inp, sizeof(inp), "KRB5_KTNAME=FILE:%s", argv[1]);
    putenv(inp);
  }

  krb5_init_context(&context);
  ret = krb5_kt_default_name(context, buf, sizeof(buf));
  printf("%s\n", buf);
  krb5_free_context(context);
  return ret;
}



hth,

        --dkg
________________________________________________
Kerberos mailing list           [email protected]
https://mailman.mit.edu/mailman/listinfo/kerberos

Reply via email to