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

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