1 | /* $Id: locker_private.h,v 1.5 2000-04-24 02:13:44 mwhitson Exp $ */ |
---|
2 | |
---|
3 | /* Copyright 1998 by the Massachusetts Institute of Technology. |
---|
4 | * |
---|
5 | * Permission to use, copy, modify, and distribute this |
---|
6 | * software and its documentation for any purpose and without |
---|
7 | * fee is hereby granted, provided that the above copyright |
---|
8 | * notice appear in all copies and that both that copyright |
---|
9 | * notice and this permission notice appear in supporting |
---|
10 | * documentation, and that the name of M.I.T. not be used in |
---|
11 | * advertising or publicity pertaining to distribution of the |
---|
12 | * software without specific, written prior permission. |
---|
13 | * M.I.T. makes no representations about the suitability of |
---|
14 | * this software for any purpose. It is provided "as is" |
---|
15 | * without express or implied warranty. |
---|
16 | */ |
---|
17 | |
---|
18 | #include <sys/types.h> |
---|
19 | #include <regex.h> |
---|
20 | #include <stdarg.h> |
---|
21 | |
---|
22 | #define LOCKER_PATH_ATTACHTAB "/var/athena/attachtab" |
---|
23 | #define LOCKER_PATH_ATTACH_CONF "/etc/athena/attach.conf" |
---|
24 | |
---|
25 | #define LOCKER_AFS_MOUNT_DIR "/mit" |
---|
26 | #define LOCKER_UFS_MOUNT_DIR "/mnt" |
---|
27 | #define LOCKER_LOC_MOUNT_DIR "/mit" |
---|
28 | |
---|
29 | #define LOCKER_NFS_KSERVICE "rvdsrv" |
---|
30 | |
---|
31 | #define LOCKER_DEFAULT_GID 101 |
---|
32 | |
---|
33 | #define LOCKER_MOUNT_TIMEOUT 20 |
---|
34 | |
---|
35 | #define LOCKER_ZEPHYR_CLASS "filsrv" |
---|
36 | |
---|
37 | enum explstate { LOCKER_DONT_CARE, LOCKER_EXPLICIT, LOCKER_NOEXPLICIT }; |
---|
38 | |
---|
39 | union locker__datum { |
---|
40 | char *string; |
---|
41 | int flag; |
---|
42 | }; |
---|
43 | |
---|
44 | struct locker__regexp { |
---|
45 | int fstypes; |
---|
46 | enum explstate explicit; |
---|
47 | regex_t pattern; |
---|
48 | union locker__datum data; |
---|
49 | }; |
---|
50 | |
---|
51 | struct locker__regexp_list { |
---|
52 | struct locker__regexp *tab; |
---|
53 | int size, num; |
---|
54 | int defflag; |
---|
55 | }; |
---|
56 | |
---|
57 | struct locker_context { |
---|
58 | /* attach.conf variables */ |
---|
59 | int exp_desc, exp_mountpoint, keep_mount, nfs_root_hack, ownercheck; |
---|
60 | char *afs_mount_dir, *attachtab, *nfs_mount_dir; |
---|
61 | struct locker__regexp_list allow, setuid, mountpoint; |
---|
62 | struct locker__regexp_list allowopts, defopts, filesystem, reqopts; |
---|
63 | |
---|
64 | /* Defined fs types */ |
---|
65 | struct locker_ops **fstype; |
---|
66 | int nfstypes; |
---|
67 | |
---|
68 | /* error reporting function and its cookie */ |
---|
69 | locker_error_fun errfun; |
---|
70 | void *errdata; |
---|
71 | |
---|
72 | /* user we're acting on behalf of, and whether or not s/he is trusted */ |
---|
73 | uid_t user; |
---|
74 | int trusted; |
---|
75 | |
---|
76 | /* Hesiod context */ |
---|
77 | void *hes_context; |
---|
78 | |
---|
79 | /* Queued zephyr subs */ |
---|
80 | char **zsubs; |
---|
81 | int nzsubs; |
---|
82 | |
---|
83 | /* Number of locks held on attachtab */ |
---|
84 | int locks; |
---|
85 | }; |
---|
86 | |
---|
87 | /* "kind"s for locker__attachtab_pathname */ |
---|
88 | #define LOCKER_LOCK 0 |
---|
89 | #define LOCKER_NAME 1 |
---|
90 | #define LOCKER_MOUNTPOINT 2 |
---|
91 | #define LOCKER_DIRECTORY 3 |
---|
92 | /* Already a full path: don't touch it. */ |
---|
93 | #define LOCKER_FULL_PATH 4 |
---|
94 | |
---|
95 | /* options for locker__canonicalize_path */ |
---|
96 | #define LOCKER_CANON_CHECK_NONE 0 |
---|
97 | #define LOCKER_CANON_CHECK_MOST 1 |
---|
98 | #define LOCKER_CANON_CHECK_ALL 2 |
---|
99 | |
---|
100 | /* Prototypes from attachtab.c */ |
---|
101 | locker_attachent *locker__new_attachent(locker_context context, |
---|
102 | struct locker_ops *type); |
---|
103 | int locker__lookup_attachent(locker_context context, char *name, |
---|
104 | char *mountpoint, int create, |
---|
105 | locker_attachent **atp); |
---|
106 | int locker__lookup_attachent_explicit(locker_context context, char *type, |
---|
107 | char *desc, char *mountpoint, |
---|
108 | int create, locker_attachent **atp); |
---|
109 | void locker__update_attachent(locker_context context, locker_attachent *at); |
---|
110 | char *locker__attachtab_pathname(locker_context context, |
---|
111 | int kind, char *name); |
---|
112 | |
---|
113 | /* Prototypes from conf.c */ |
---|
114 | int locker__fs_ok(locker_context context, struct locker__regexp_list list, |
---|
115 | struct locker_ops *fs, char *filesystem); |
---|
116 | char *locker__fs_data(locker_context context, struct locker__regexp_list list, |
---|
117 | struct locker_ops *fs, char *filesystem); |
---|
118 | struct locker_ops *locker__get_fstype(locker_context context, char *fstype); |
---|
119 | void locker__error(locker_context context, char *fmt, ...); |
---|
120 | |
---|
121 | /* Prototypes from mount.c */ |
---|
122 | int locker__mount(locker_context context, locker_attachent *at, |
---|
123 | char *mountoptions); |
---|
124 | int locker__unmount(locker_context context, locker_attachent *at); |
---|
125 | |
---|
126 | /* Prototypes from mountpoint.c */ |
---|
127 | int locker__canonicalize_path(locker_context context, int check, |
---|
128 | char **pathp, char **extp); |
---|
129 | int locker__build_mountpoint(locker_context context, locker_attachent *at); |
---|
130 | int locker__remove_mountpoint(locker_context context, locker_attachent *at); |
---|
131 | |
---|
132 | /* Prototypes from util.c */ |
---|
133 | int locker__read_line(FILE *fp, char **buf, int *bufsize); |
---|
134 | |
---|
135 | /* Prototypes from zephyr.c */ |
---|
136 | int locker__add_zsubs(locker_context context, char **subs, int nsubs); |
---|
137 | void locker__free_zsubs(locker_context context); |
---|