[22531] | 1 | /* $Id: locker_private.h,v 1.8 2006-08-08 21:50:10 ghudson Exp $ */ |
---|
[12745] | 2 | |
---|
[12582] | 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 | |
---|
[22841] | 22 | #define LOCKER_PATH_ATTACHTAB "/var/run/attachtab" |
---|
[12582] | 23 | #define LOCKER_PATH_ATTACH_CONF "/etc/athena/attach.conf" |
---|
[17985] | 24 | #define LOCKER_PATH_LOCAL "/var/athena/local-validated" |
---|
[12582] | 25 | |
---|
| 26 | #define LOCKER_AFS_MOUNT_DIR "/mit" |
---|
| 27 | #define LOCKER_UFS_MOUNT_DIR "/mnt" |
---|
[14654] | 28 | #define LOCKER_LOC_MOUNT_DIR "/mit" |
---|
[12582] | 29 | |
---|
| 30 | #define LOCKER_NFS_KSERVICE "rvdsrv" |
---|
| 31 | |
---|
| 32 | #define LOCKER_DEFAULT_GID 101 |
---|
| 33 | |
---|
| 34 | #define LOCKER_MOUNT_TIMEOUT 20 |
---|
| 35 | |
---|
| 36 | #define LOCKER_ZEPHYR_CLASS "filsrv" |
---|
| 37 | |
---|
| 38 | enum explstate { LOCKER_DONT_CARE, LOCKER_EXPLICIT, LOCKER_NOEXPLICIT }; |
---|
| 39 | |
---|
| 40 | union locker__datum { |
---|
| 41 | char *string; |
---|
| 42 | int flag; |
---|
| 43 | }; |
---|
| 44 | |
---|
| 45 | struct locker__regexp { |
---|
| 46 | int fstypes; |
---|
| 47 | enum explstate explicit; |
---|
| 48 | regex_t pattern; |
---|
| 49 | union locker__datum data; |
---|
| 50 | }; |
---|
| 51 | |
---|
| 52 | struct locker__regexp_list { |
---|
| 53 | struct locker__regexp *tab; |
---|
| 54 | int size, num; |
---|
| 55 | int defflag; |
---|
| 56 | }; |
---|
| 57 | |
---|
| 58 | struct locker_context { |
---|
| 59 | /* attach.conf variables */ |
---|
| 60 | int exp_desc, exp_mountpoint, keep_mount, nfs_root_hack, ownercheck; |
---|
[22531] | 61 | int use_krb4; |
---|
[17985] | 62 | char *afs_mount_dir, *attachtab, *nfs_mount_dir, *local_dir; |
---|
[12582] | 63 | struct locker__regexp_list allow, setuid, mountpoint; |
---|
| 64 | struct locker__regexp_list allowopts, defopts, filesystem, reqopts; |
---|
| 65 | |
---|
| 66 | /* Defined fs types */ |
---|
| 67 | struct locker_ops **fstype; |
---|
| 68 | int nfstypes; |
---|
| 69 | |
---|
| 70 | /* error reporting function and its cookie */ |
---|
| 71 | locker_error_fun errfun; |
---|
| 72 | void *errdata; |
---|
| 73 | |
---|
| 74 | /* user we're acting on behalf of, and whether or not s/he is trusted */ |
---|
| 75 | uid_t user; |
---|
| 76 | int trusted; |
---|
| 77 | |
---|
| 78 | /* Hesiod context */ |
---|
| 79 | void *hes_context; |
---|
| 80 | |
---|
[12783] | 81 | /* Queued zephyr subs */ |
---|
| 82 | char **zsubs; |
---|
| 83 | int nzsubs; |
---|
[12582] | 84 | |
---|
| 85 | /* Number of locks held on attachtab */ |
---|
| 86 | int locks; |
---|
| 87 | }; |
---|
| 88 | |
---|
| 89 | /* "kind"s for locker__attachtab_pathname */ |
---|
| 90 | #define LOCKER_LOCK 0 |
---|
| 91 | #define LOCKER_NAME 1 |
---|
| 92 | #define LOCKER_MOUNTPOINT 2 |
---|
| 93 | #define LOCKER_DIRECTORY 3 |
---|
| 94 | /* Already a full path: don't touch it. */ |
---|
| 95 | #define LOCKER_FULL_PATH 4 |
---|
| 96 | |
---|
[13171] | 97 | /* options for locker__canonicalize_path */ |
---|
| 98 | #define LOCKER_CANON_CHECK_NONE 0 |
---|
| 99 | #define LOCKER_CANON_CHECK_MOST 1 |
---|
| 100 | #define LOCKER_CANON_CHECK_ALL 2 |
---|
| 101 | |
---|
[12582] | 102 | /* Prototypes from attachtab.c */ |
---|
| 103 | locker_attachent *locker__new_attachent(locker_context context, |
---|
| 104 | struct locker_ops *type); |
---|
| 105 | int locker__lookup_attachent(locker_context context, char *name, |
---|
| 106 | char *mountpoint, int create, |
---|
| 107 | locker_attachent **atp); |
---|
| 108 | int locker__lookup_attachent_explicit(locker_context context, char *type, |
---|
| 109 | char *desc, char *mountpoint, |
---|
| 110 | int create, locker_attachent **atp); |
---|
| 111 | void locker__update_attachent(locker_context context, locker_attachent *at); |
---|
| 112 | char *locker__attachtab_pathname(locker_context context, |
---|
| 113 | int kind, char *name); |
---|
| 114 | |
---|
| 115 | /* Prototypes from conf.c */ |
---|
| 116 | int locker__fs_ok(locker_context context, struct locker__regexp_list list, |
---|
| 117 | struct locker_ops *fs, char *filesystem); |
---|
| 118 | char *locker__fs_data(locker_context context, struct locker__regexp_list list, |
---|
| 119 | struct locker_ops *fs, char *filesystem); |
---|
| 120 | struct locker_ops *locker__get_fstype(locker_context context, char *fstype); |
---|
| 121 | void locker__error(locker_context context, char *fmt, ...); |
---|
| 122 | |
---|
| 123 | /* Prototypes from mount.c */ |
---|
| 124 | int locker__mount(locker_context context, locker_attachent *at, |
---|
| 125 | char *mountoptions); |
---|
| 126 | int locker__unmount(locker_context context, locker_attachent *at); |
---|
| 127 | |
---|
| 128 | /* Prototypes from mountpoint.c */ |
---|
| 129 | int locker__canonicalize_path(locker_context context, int check, |
---|
| 130 | char **pathp, char **extp); |
---|
| 131 | int locker__build_mountpoint(locker_context context, locker_attachent *at); |
---|
| 132 | int locker__remove_mountpoint(locker_context context, locker_attachent *at); |
---|
[16551] | 133 | void locker__put_mountpoint(locker_context context, locker_attachent *at); |
---|
[12582] | 134 | |
---|
| 135 | /* Prototypes from util.c */ |
---|
| 136 | int locker__read_line(FILE *fp, char **buf, int *bufsize); |
---|
| 137 | |
---|
| 138 | /* Prototypes from zephyr.c */ |
---|
[12783] | 139 | int locker__add_zsubs(locker_context context, char **subs, int nsubs); |
---|
| 140 | void locker__free_zsubs(locker_context context); |
---|