1 | /* |
---|
2 | * $Id: aklog_param.c,v 1.10 1997-11-17 16:23:49 ghudson Exp $ |
---|
3 | * |
---|
4 | * Copyright 1990,1991 by the Massachusetts Institute of Technology |
---|
5 | * For distribution and copying rights, see the file "mit-copyright.h" |
---|
6 | */ |
---|
7 | |
---|
8 | static const char rcsid[] = "$Id: aklog_param.c,v 1.10 1997-11-17 16:23:49 ghudson Exp $"; |
---|
9 | |
---|
10 | #include "aklog.h" |
---|
11 | #include <sys/stat.h> |
---|
12 | |
---|
13 | #ifndef TRUE |
---|
14 | #define TRUE 1 |
---|
15 | #endif |
---|
16 | |
---|
17 | #ifndef FALSE |
---|
18 | #define FALSE 0 |
---|
19 | #endif |
---|
20 | |
---|
21 | |
---|
22 | static int isdir(char *path, unsigned char *val) |
---|
23 | { |
---|
24 | struct stat statbuf; |
---|
25 | |
---|
26 | if (lstat(path, &statbuf) < 0) |
---|
27 | return (-1); |
---|
28 | else { |
---|
29 | if ((statbuf.st_mode & S_IFMT) == S_IFDIR) |
---|
30 | *val = TRUE; |
---|
31 | else |
---|
32 | *val = FALSE; |
---|
33 | return (0); |
---|
34 | } |
---|
35 | } |
---|
36 | |
---|
37 | |
---|
38 | static int get_cred(char *name, char *inst, char *realm, CREDENTIALS *c) |
---|
39 | { |
---|
40 | int status; |
---|
41 | |
---|
42 | status = krb_get_cred(name, inst, realm, c); |
---|
43 | if (status != KSUCCESS) { |
---|
44 | status = get_ad_tkt(name, inst, realm, 255); |
---|
45 | if (status == KSUCCESS) |
---|
46 | status = krb_get_cred(name, inst, realm, c); |
---|
47 | } |
---|
48 | |
---|
49 | return (status); |
---|
50 | } |
---|
51 | |
---|
52 | |
---|
53 | static int get_user_realm(char *realm) |
---|
54 | { |
---|
55 | return (krb_get_tf_realm(TKT_FILE, realm)); |
---|
56 | } |
---|
57 | |
---|
58 | |
---|
59 | static void pstderr(char *string) |
---|
60 | { |
---|
61 | write(2, string, strlen(string)); |
---|
62 | } |
---|
63 | |
---|
64 | |
---|
65 | static void pstdout(char *string) |
---|
66 | { |
---|
67 | write(1, string, strlen(string)); |
---|
68 | } |
---|
69 | |
---|
70 | |
---|
71 | static void exitprog(char status) |
---|
72 | { |
---|
73 | exit(status); |
---|
74 | } |
---|
75 | |
---|
76 | |
---|
77 | void aklog_init_params(aklog_params *params) |
---|
78 | { |
---|
79 | params->readlink = readlink; |
---|
80 | params->isdir = isdir; |
---|
81 | params->getcwd = getcwd; |
---|
82 | params->get_cred = get_cred; |
---|
83 | params->get_user_realm = get_user_realm; |
---|
84 | params->pstderr = pstderr; |
---|
85 | params->pstdout = pstdout; |
---|
86 | params->exitprog = exitprog; |
---|
87 | } |
---|