1 /*	$NetBSD: kafs.h,v 1.1.1.3 2014/04/24 12:45:49 pettai Exp $	*/
2 
3 /*
4  * Copyright (c) 1995 - 2001, 2003 Kungliga Tekniska Högskolan
5  * (Royal Institute of Technology, Stockholm, Sweden).
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * 3. Neither the name of the Institute nor the names of its contributors
20  *    may be used to endorse or promote products derived from this software
21  *    without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  */
35 
36 /* Id */
37 
38 #ifndef __KAFS_H
39 #define __KAFS_H
40 
41 /* XXX must include krb5.h or krb.h */
42 
43 /* sys/ioctl.h must be included manually before kafs.h */
44 
45 /*
46  */
47 #define AFSCALL_PIOCTL 20
48 #define AFSCALL_SETPAG 21
49 
50 #ifndef _VICEIOCTL
51 #define _VICEIOCTL(id)  ((unsigned int ) _IOW('V', id, struct ViceIoctl))
52 #define _AFSCIOCTL(id)  ((unsigned int ) _IOW('C', id, struct ViceIoctl))
53 #endif /* _VICEIOCTL */
54 
55 #define VIOCSETAL		_VICEIOCTL(1)
56 #define VIOCGETAL		_VICEIOCTL(2)
57 #define VIOCSETTOK		_VICEIOCTL(3)
58 #define VIOCGETVOLSTAT		_VICEIOCTL(4)
59 #define VIOCSETVOLSTAT		_VICEIOCTL(5)
60 #define VIOCFLUSH		_VICEIOCTL(6)
61 #define VIOCGETTOK		_VICEIOCTL(8)
62 #define VIOCUNLOG		_VICEIOCTL(9)
63 #define VIOCCKSERV		_VICEIOCTL(10)
64 #define VIOCCKBACK		_VICEIOCTL(11)
65 #define VIOCCKCONN		_VICEIOCTL(12)
66 #define VIOCWHEREIS		_VICEIOCTL(14)
67 #define VIOCACCESS		_VICEIOCTL(20)
68 #define VIOCUNPAG		_VICEIOCTL(21)
69 #define VIOCGETFID		_VICEIOCTL(22)
70 #define VIOCSETCACHESIZE	_VICEIOCTL(24)
71 #define VIOCFLUSHCB		_VICEIOCTL(25)
72 #define VIOCNEWCELL		_VICEIOCTL(26)
73 #define VIOCGETCELL		_VICEIOCTL(27)
74 #define VIOC_AFS_DELETE_MT_PT	_VICEIOCTL(28)
75 #define VIOC_AFS_STAT_MT_PT	_VICEIOCTL(29)
76 #define VIOC_FILE_CELL_NAME	_VICEIOCTL(30)
77 #define VIOC_GET_WS_CELL	_VICEIOCTL(31)
78 #define VIOC_AFS_MARINER_HOST	_VICEIOCTL(32)
79 #define VIOC_GET_PRIMARY_CELL	_VICEIOCTL(33)
80 #define VIOC_VENUSLOG		_VICEIOCTL(34)
81 #define VIOC_GETCELLSTATUS	_VICEIOCTL(35)
82 #define VIOC_SETCELLSTATUS	_VICEIOCTL(36)
83 #define VIOC_FLUSHVOLUME	_VICEIOCTL(37)
84 #define VIOC_AFS_SYSNAME	_VICEIOCTL(38)
85 #define VIOC_EXPORTAFS		_VICEIOCTL(39)
86 #define VIOCGETCACHEPARAMS	_VICEIOCTL(40)
87 #define VIOC_GCPAGS		_VICEIOCTL(48)
88 
89 #define VIOCGETTOK2		_AFSCIOCTL(7)
90 #define VIOCSETTOK2		_AFSCIOCTL(8)
91 
92 struct ViceIoctl {
93   caddr_t in, out;
94   unsigned short in_size;
95   unsigned short out_size;
96 };
97 
98 struct ClearToken {
99   int32_t AuthHandle;
100   char HandShakeKey[8];
101   int32_t ViceId;
102   int32_t BeginTimestamp;
103   int32_t EndTimestamp;
104 };
105 
106 /* Use k_hasafs() to probe if the machine supports AFS syscalls.
107    The other functions will generate a SIGSYS if AFS is not supported */
108 
109 int k_hasafs (void);
110 int k_hasafs_recheck (void);
111 
112 int krb_afslog (const char *cell, const char *realm);
113 int krb_afslog_uid (const char *cell, const char *realm, uid_t uid);
114 int krb_afslog_home (const char *cell, const char *realm,
115 			 const char *homedir);
116 int krb_afslog_uid_home (const char *cell, const char *realm, uid_t uid,
117 			     const char *homedir);
118 
119 int krb_realm_of_cell (const char *cell, char **realm);
120 
121 /* compat */
122 #define k_afsklog krb_afslog
123 #define k_afsklog_uid krb_afslog_uid
124 
125 int k_pioctl (char *a_path,
126 		  int o_opcode,
127 		  struct ViceIoctl *a_paramsP,
128 		  int a_followSymlinks);
129 int k_unlog (void);
130 int k_setpag (void);
131 int k_afs_cell_of_file (const char *path, char *cell, int len);
132 
133 
134 
135 /* XXX */
136 #ifdef KFAILURE
137 #define KRB_H_INCLUDED
138 #endif
139 
140 #ifdef KRB5_RECVAUTH_IGNORE_VERSION
141 #define KRB5_H_INCLUDED
142 #endif
143 
144 void kafs_set_verbose (void (*kafs_verbose)(void *, const char *), void *);
145 int kafs_settoken_rxkad (const char *, struct ClearToken *,
146 			     void *ticket, size_t ticket_len);
147 #ifdef KRB_H_INCLUDED
148 int kafs_settoken (const char*, uid_t, CREDENTIALS*);
149 #endif
150 #ifdef KRB5_H_INCLUDED
151 int kafs_settoken5 (krb5_context, const char*, uid_t, krb5_creds*);
152 #endif
153 
154 
155 #ifdef KRB5_H_INCLUDED
156 krb5_error_code krb5_afslog_uid (krb5_context context,
157 				     krb5_ccache id,
158 				     const char *cell,
159 				     krb5_const_realm realm,
160 				     uid_t uid);
161 krb5_error_code krb5_afslog (krb5_context context,
162 				 krb5_ccache id,
163 				 const char *cell,
164 				 krb5_const_realm realm);
165 krb5_error_code krb5_afslog_uid_home (krb5_context context,
166 					  krb5_ccache id,
167 					  const char *cell,
168 					  krb5_const_realm realm,
169 					  uid_t uid,
170 					  const char *homedir);
171 
172 krb5_error_code krb5_afslog_home (krb5_context context,
173 				      krb5_ccache id,
174 				      const char *cell,
175 				      krb5_const_realm realm,
176 				      const char *homedir);
177 
178 krb5_error_code krb5_realm_of_cell (const char *cell, char **realm);
179 
180 #endif
181 
182 
183 #define _PATH_VICE		"/usr/vice/etc/"
184 #define _PATH_THISCELL 		_PATH_VICE "ThisCell"
185 #define _PATH_CELLSERVDB 	_PATH_VICE "CellServDB"
186 #define _PATH_THESECELLS	_PATH_VICE "TheseCells"
187 
188 #define _PATH_ARLA_VICE		"/usr/arla/etc/"
189 #define _PATH_ARLA_THISCELL	_PATH_ARLA_VICE "ThisCell"
190 #define _PATH_ARLA_CELLSERVDB 	_PATH_ARLA_VICE "CellServDB"
191 #define _PATH_ARLA_THESECELLS	_PATH_ARLA_VICE "TheseCells"
192 
193 #define _PATH_OPENAFS_DEBIAN_VICE		"/etc/openafs/"
194 #define _PATH_OPENAFS_DEBIAN_THISCELL		_PATH_OPENAFS_DEBIAN_VICE "ThisCell"
195 #define _PATH_OPENAFS_DEBIAN_CELLSERVDB 	_PATH_OPENAFS_DEBIAN_VICE "CellServDB"
196 #define _PATH_OPENAFS_DEBIAN_THESECELLS		_PATH_OPENAFS_DEBIAN_VICE "TheseCells"
197 
198 #define _PATH_OPENAFS_MACOSX_VICE		"/var/db/openafs/etc/"
199 #define _PATH_OPENAFS_MACOSX_THISCELL		_PATH_OPENAFS_MACOSX_VICE "ThisCell"
200 #define _PATH_OPENAFS_MACOSX_CELLSERVDB		_PATH_OPENAFS_MACOSX_VICE "CellServDB"
201 #define _PATH_OPENAFS_MACOSX_THESECELLS		_PATH_OPENAFS_MACOSX_VICE "TheseCells"
202 
203 #define _PATH_ARLA_DEBIAN_VICE			"/etc/arla/"
204 #define _PATH_ARLA_DEBIAN_THISCELL		_PATH_ARLA_DEBIAN_VICE "ThisCell"
205 #define _PATH_ARLA_DEBIAN_CELLSERVDB		_PATH_ARLA_DEBIAN_VICE "CellServDB"
206 #define _PATH_ARLA_DEBIAN_THESECELLS		_PATH_ARLA_DEBIAN_VICE "TheseCells"
207 
208 #define _PATH_ARLA_OPENBSD_VICE			"/etc/afs/"
209 #define _PATH_ARLA_OPENBSD_THISCELL		_PATH_ARLA_OPENBSD_VICE "ThisCell"
210 #define _PATH_ARLA_OPENBSD_CELLSERVDB		_PATH_ARLA_OPENBSD_VICE "CellServDB"
211 #define _PATH_ARLA_OPENBSD_THESECELLS		_PATH_ARLA_OPENBSD_VICE "TheseCells"
212 
213 extern int _kafs_debug;
214 
215 #endif /* __KAFS_H */
216