source: trunk/athena/bin/attach/attach.h @ 6704

Revision 6704, 9.6 KB checked in by vrt, 31 years ago (diff)
problems with AIX and redeclarations.
Line 
1/*
2 * $Id: attach.h,v 1.17 1993-06-30 16:52:17 vrt Exp $
3 *
4 * Copyright (c) 1988,1991 by the Massachusetts Institute of Technology.
5 *
6 * For redistribution rights, see "mit-copyright.h"
7 */
8
9#include "config.h"
10
11#include <stdio.h>
12#include <ctype.h>
13#include <errno.h>
14#ifdef _AIX
15#undef geterrno
16#endif
17#include <netdb.h>
18#include <strings.h>
19
20#include <sys/types.h>
21#include <sys/file.h>
22#include <sys/param.h>
23#include <sys/socket.h>
24#include <sys/time.h>
25
26#include <netinet/in.h>
27
28#ifdef NFS
29#include <rpc/rpc.h>
30#ifndef i386
31#include <nfs/nfs.h>
32#else
33#include <rpc/nfs.h>
34#endif
35#ifdef NeXT
36#include <nfs/nfs_mount.h>              /* Newer versions of NFS (?) */
37#endif /* NeXT */
38#include <rpcsvc/mount.h>
39#ifdef _AUX_SOURCE
40#include <nfs/mount.h>
41#endif
42#ifdef SOLARIS
43#include <nfs/mount.h>
44#include <sys/fs/ufs_mount.h>
45#endif
46#endif /* NFS */
47
48#ifdef ultrix
49#include <ufs/ufs_mount.h>
50#ifdef NFS
51#include <nfs/nfs_gfs.h>
52#endif /* NFS */
53#define KERNEL
54/* AACK!  this @#OU@#)($(#) file defines and initializes an array which
55   loses on multiple includes, but it's surrounded by #ifdef KERNEL. */
56#include <sys/fs_types.h>
57#undef KERNEL
58#endif /* ultrix */
59
60#include <sys/mount.h>
61#ifdef _AIX
62#include <sys/vmount.h>
63#define M_RDONLY        MNT_READONLY
64#endif
65
66#if defined(_AUX_SOURCE) || defined(NeXT) || defined(_AIX)
67#define vfork   fork
68#endif
69
70/*
71 * If MOUNT_CMD or UMOUNT_CMD are defined, it will run the program
72 * specified rather than trying to use in-line code.
73 */
74#if defined(_IBMR2)
75#define MOUNT_CMD       "/etc/mount"
76#endif
77#if defined(SOLARIS)
78#define MOUNT_CMD "/etc/fs/nfs/mount"
79#define UMOUNT_CMD "/usr/sbin/umount"
80#endif
81
82#define MAXOWNERS 64
83#define MAXHOSTS 64
84
85/*
86 * We don't really want to deal with malloc'ing and free'ing stuff
87 * in this structure...
88 */
89
90struct _attachtab {
91        struct _attachtab       *next, *prev;
92        char            version[3];
93        char            explicit;
94        char            status;
95        char            mode;
96        struct _fstypes *fs;
97        struct          in_addr hostaddr[MAXHOSTS];
98        int             rmdir;
99        int             drivenum;
100        int             flags;
101        int             nowners;
102        uid_t           owners[MAXOWNERS];
103        char            hesiodname[BUFSIZ];
104        char            host[BUFSIZ];
105        char            hostdir[MAXPATHLEN];
106        char            mntpt[MAXPATHLEN];
107};
108
109/*
110 * Attach flags defines
111 *
112 * FLAG_NOSETUID --- this filesystem was mounted nosetuid (no meaning
113 *      for afs filesystems)
114 * FLAG_LOCKED --- this filesystem is passed over by detach -a, and
115 *      you must be the owner of the filesystem to detach it.
116 * FLAG_ANYONE --- anyone can detach this filesystem  (not yet implemented)
117 * FLAG_PERMANENT --- when this filesytem is detached, don't do
118 *      actually unmount it; just deauthenticate, if necessary.  attach
119 *      sets this flag if it finds the filesystem already mounted but
120 *      not in attachtab.
121 */
122#define FLAG_NOSETUID   1
123#define FLAG_LOCKED     2
124#define FLAG_ANYONE     4
125#define FLAG_PERMANENT  8
126
127#define ATTACH_VERSION  "A1"
128
129#define ATTACHTABMODE   644
130
131#define STATUS_ATTACHED         '+'
132#define STATUS_ATTACHING        '*'
133#define STATUS_DETACHING        '-'
134
135#define TYPE_NFS        001
136#define TYPE_RVD        002
137#define TYPE_UFS        004
138#define TYPE_ERR        010
139#define TYPE_AFS        020
140#define TYPE_MUL        040
141#define ALL_TYPES       067
142
143/*
144 * Attach configuration defines
145 */
146#define MAXFILTAB       100
147#define MAXTRUIDTAB     100
148
149/*
150 * Type table
151 */
152
153struct _fstypes {
154    char        *name;
155    int         type;
156    int         mount_type;
157    int         flags;
158    char        *good_flags;
159    int         (*attach)();
160    int         (*detach)();
161    char **     (*explicit)();
162    int         (*flush)();
163};
164
165/*
166 * Flags for _fstypes.flags
167 */
168#define AT_FS_MNTPT             1
169#define AT_FS_REMOTE            2
170#define AT_FS_PARENTMNTPT       4
171#define AT_FS_MNTPT_CANON       8
172
173extern struct _fstypes fstypes[];
174
175/*
176 * Mount options
177 */
178#ifndef M_RDONLY
179#define M_RDONLY        0x01            /* mount fs read-only */
180#endif
181#ifndef M_NOSUID
182#define M_NOSUID        0x02            /* mount fs without setuid perms */
183#endif
184
185/*
186 * Mount option table
187 */
188struct mntopts {
189        int     type;           /* File system type */
190        int     flags;          /* Mount flags */
191#ifdef NFS
192        int     nfs_port;       /* Valid only for NFS, port for rpc.mountd */
193#endif
194        union tsa {
195#ifdef UFS
196                struct ufs_args ufs;
197#endif
198#ifdef NFS
199                struct nfs_args nfs;
200#endif
201        } tsa;
202};
203
204/*
205 * Command option lists
206 */
207
208struct command_list {
209    char        *large;
210    char        *small;
211};
212
213/*
214 * RVD defines
215 */
216
217#define RVD_ATTACH_TIMEOUT      30
218
219/*
220 * RPC caching
221 */
222
223#define RPC_MAXCACHE 10
224
225struct cache_ent {
226    struct      in_addr addr;
227    CLIENT      *handle;
228    struct      sockaddr_in sin;
229    int         fd;
230    int         error;
231};
232
233/*
234 * Calls to RPC.MOUNTD
235 */
236
237#ifndef MOUNTPROC_KUIDMAP
238#define MOUNTPROC_KUIDMAP       7
239#define MOUNTPROC_KUIDUMAP      8
240#define MOUNTPROC_KUIDPURGE     9
241#define MOUNTPROC_KUIDUPURGE    10
242#endif
243
244/*
245 * Command names
246 */
247
248#define ATTACH_CMD      "attach"
249#define DETACH_CMD      "detach"
250#define NFSID_CMD       "nfsid"
251#define FSID_CMD        "fsid"
252#ifdef ZEPHYR
253#define ZINIT_CMD       "zinit"
254#endif /* ZEPHYR */
255   
256/*
257 * Generic defines
258 */
259
260#define SUCCESS 0
261#define FAILURE 1
262
263/*
264 * Error status defininitions
265 */
266
267#define ERR_NONE        0       /* No error */
268#define ERR_BADARGS     1       /* Bad arguments */
269#define ERR_SOMETHING   2       /* Something wrong - > 1 args */
270#define ERR_FATAL       3       /* Internal failure */
271#define ERR_INTERRUPT   4       /* Program externally aborted */
272#define ERR_BADCONF     5       /* Bad configuration file */
273#define ERR_BADFSDSC    6       /* Bad filesystem description */
274#define ERR_BADFSFLAG   7       /* Bad filsys flag */
275
276#define ERR_KERBEROS    10      /* Kerberos failure */
277#define ERR_HOST        11      /* General host communication failure */
278#define ERR_AUTHFAIL    12      /* Authentication failure */
279#define ERR_NOPORTS     13      /* Out of reserved ports */
280
281#define ERR_NFSIDNOTATTACHED 20 /* Filesystem with -f not attached */
282#define ERR_NFSIDBADHOST 21     /* Can't resolve hostname */
283#define ERR_NFSIDPERM   22      /* unauthorized nfsid -p */
284
285#define ERR_ATTACHBADFILSYS 20  /* Bad filesystem name */
286#define ERR_ATTACHINUSE 21      /* Filesystem in use by another proc */
287#define ERR_ATTACHNEEDPW 22     /* RVD spinup needs a password */
288#define ERR_ATTACHFSCK  23      /* FSCK returned error on RVD */
289#define ERR_ATTACHNOTALLOWED 24 /* User not allowed to do operation */
290#define ERR_ATTACHBADMNTPT 25   /* User not allowed to mount a */
291                                /* filesystem here */
292#define ERR_ATTACHNOFILSYS 26   /* The remote filesystem doesn't exist */
293#define ERR_ATTACHDIRINUSE 27 /* Some other filesystem is using the */
294                              /* mountpoint directory */
295
296#define ERR_DETACHNOTATTACHED 20 /* Filesystem not attached */
297#define ERR_DETACHINUSE 21      /* Filesystem in use by another proc */
298#define ERR_DETACHNOTALLOWED 22 /* User not allowed to do operations */
299
300#define ERR_ZINITZLOSING        20      /* Random zephyr lossage */
301
302/*
303 * Zephyr definitions
304 */
305
306#ifdef ZEPHYR
307#define ZEPHYR_CLASS "filsrv"
308#define ZEPHYR_MAXSUBS 100      /* 50 filesystems... */
309#define ZEPHYR_TIMEOUT  60      /* 1 minute timeout */
310#endif /* ZEPHYR */
311
312/* AFS */
313#ifdef AFS
314#ifdef __STDC__
315extern int afs_auth(const char *, const char *), afs_auth_to_cell(const char *);
316extern int afs_zinit(const char *, const char *);
317#else
318extern int afs_auth(), afs_auth_to_cell();
319#endif
320#endif
321
322/*
323 * Externals
324 */
325
326extern  char    *errstr();      /* convert errno to string */
327
328AUTH    *spoofunix_create_default();
329CLIENT  *rpc_create();
330extern char *strdup(), *strtok();
331extern int errno;
332extern unsigned long rvderrno;
333extern char *sys_errlist[];
334extern char **build_hesiod_line(), **conf_filsys_resolve();
335extern struct _fstypes *get_fs();
336extern char *filsys_options();
337extern char *stropt(), *struid(), *path_canon();
338extern struct _attachtab *attachtab_lookup(), *attachtab_lookup_mntpt();
339
340extern int verbose, debug_flag, map_anyway, do_nfsid, print_path, explicit;
341extern int owner_check, owner_list, override, keep_mount;
342extern int error_status, force, lock_filesystem, lookup, euid, clean_detach;
343extern int exp_mntpt, exp_allow;
344#ifdef ZEPHYR
345extern int use_zephyr;
346#endif /* ZEPHYR */
347extern char override_mode, *mount_options, *filsys_type;
348extern char *mntpt;
349extern int override_suid, default_suid, skip_fsck, nfs_root_hack;
350extern char *spoofhost, *attachtab_fn, *mtab_fn, *nfs_mount_dir;
351#ifdef AFS
352extern char *aklog_fn, *afs_mount_dir;
353#endif
354extern char *fsck_fn;
355
356extern char *ownerlist();
357extern void add_an_owner();
358extern int is_an_owner(), real_uid, effective_uid, owner_uid;
359
360extern char internal_getopt();
361extern void mark_in_use(), add_options(), check_root_privs();
362
363extern char exp_hesline[BUFSIZ];        /* Place to store explicit */
364extern char *exp_hesptr[2];             /* ``hesiod'' entry */
365extern char *abort_msg;
366
367/* High C 2.1 can optimize small bcopys such as are used to copy 4
368   byte IP addrs */
369#ifdef __HIGHC__
370#define bcopy(src, dest, cnt)   memcpy(dest, src, cnt)
371extern char *memcpy();
372#endif
373#ifdef __STDC__
374#ifdef NFS
375extern int      nfsid(const char *, struct in_addr, int, int, const char *, int, int);
376extern AUTH     *spoofunix_create_default(char *, int);
377#endif
378extern int      attach(const char *), detach(const char *);
379extern  void    detach_all(void), detach_host(const char *);
380extern int      read_config_file(const char *);
381extern int      parse_username(const char *);
382extern int      trusted_user(int);
383extern void     lock_attachtab(void), unlock_attachtab(void);
384extern void     lint_attachtab(void), get_attachtab(void), free_attachtab(void);
385#ifdef ZEPHYR
386extern  int     zephyr_sub(int), zephyr_unsub(int);
387extern  void    zephyr_addsub(const char *);
388#endif
389#else
390#ifdef NFS
391extern int      nfsid();
392extern AUTH     *spoofunix_create_default();
393#endif
394extern  int     attach(), detach();
395extern  void    detach_all(), detach_host();
396extern  int     read_config_file(), parse_username(), trusted_user();
397extern  void    lock_attachtab(), unlock_attachtab();
398extern  void    get_attachtab(), free_attachtab();
399#ifdef ZEPHYR
400extern  int     zephyr_sub(), zephyr_unsub();
401extern  void    zephyr_addsub();
402#endif
403#endif
404
405extern  char    *progname;
406
407/*
408 * Instead of ifdef-ing all const declarations, make one global definition.
409 * The AIX PS/2 compiler understands "const", but does not define __STDC__.
410 */
411#if !defined(__STDC__) && !(defined(AIX) && defined(i386))
412#define const
413#endif
Note: See TracBrowser for help on using the repository browser.