Merge branch 'vendor/TCSH'
[dragonfly.git] / contrib / amd / hlfsd / hlfsd.h
1 /*
2  * Copyright (c) 1997-1999 Erez Zadok
3  * Copyright (c) 1989 Jan-Simon Pendry
4  * Copyright (c) 1989 Imperial College of Science, Technology & Medicine
5  * Copyright (c) 1989 The Regents of the University of California.
6  * All rights reserved.
7  *
8  * This code is derived from software contributed to Berkeley by
9  * Jan-Simon Pendry at Imperial College, London.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  * 3. All advertising materials mentioning features or use of this software
20  *    must display the following acknowledgment:
21  *      This product includes software developed by the University of
22  *      California, Berkeley and its contributors.
23  * 4. Neither the name of the University nor the names of its contributors
24  *    may be used to endorse or promote products derived from this software
25  *    without specific prior written permission.
26  *
27  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37  * SUCH DAMAGE.
38  *
39  *      %W% (Berkeley) %G%
40  *
41  * $Id: hlfsd.h,v 1.2 1999/01/10 21:54:32 ezk Exp $
42  *
43  * HLFSD was written at Columbia University Computer Science Department, by
44  * Erez Zadok <ezk@cs.columbia.edu> and Alexander Dupuy <dupuy@cs.columbia.edu>
45  * It is being distributed under the same terms and conditions as amd does.
46  */
47
48 #ifndef _HLFSD_HLFS_H
49 #define _HLFSD_HLFS_H
50
51 /*
52  * MACROS AND CONSTANTS:
53  */
54
55 #define HLFSD_VERSION   "hlfsd 1.1 (March 4, 1997-1999)"
56 #define PERS_SPOOLMODE  0755
57 #define OPEN_SPOOLMODE  01777
58 #define DOTSTRING       "."
59
60 /*
61  * ROOTID and SLINKID are the fixed "faked" node IDs (inodes) for
62  * the '.' (also '..') and the one symlink within the hlfs.
63  * They must always be unique, and should never match what a UID
64  * could be.
65  * They used to be -1 and -2, respectively.
66  *
67  * I used to cast these to (uid_t) but it failed to compile
68  * with /opt/SUNWspro/bin/cc because uid_t is long, while struct fattr's
69  * uid field is u_int.  Then it failed to compile on some linux systems
70  * which define uid_t to be unsigned short, so I used the lowest common
71  * size which is unsigned short.
72  */
73 #ifdef EXPERIMENTAL_UID_SIZE
74 #define UID_SHIFT       30
75 # define ROOTID         ((1 << UID_SHIFT) - 1)
76 # define SLINKID        ((1 << UID_SHIFT) - 2)
77 # define INVALIDID      ((1 << UID_SHIFT) - 3)
78 #else /* not EXPERIMENTAL_UID_SIZE */
79 /*
80  * XXX: this will cause problems to systems with UIDs greater than
81  * MAX_UNSIGNED_SHORT-3.
82  */
83 # define ROOTID         (((unsigned short) ~0) - 1)
84 # define SLINKID        (((unsigned short) ~0) - 2)
85 # define INVALIDID      (((unsigned short) ~0) - 3)
86 #endif /* not EXPERIMENTAL_UID_SIZE */
87
88
89 #define DOTCOOKIE       1
90 #define DOTDOTCOOKIE    2
91 #define SLINKCOOKIE     3
92
93 #define ALT_SPOOLDIR "/var/hlfs" /* symlink to use if others fail */
94 #define HOME_SUBDIR ".hlfsdir"  /* dirname in user's home dir */
95 #define DEFAULT_DIRNAME "/hlfs/home"
96 #define DEFAULT_INTERVAL 900    /* secs b/t re-reads of the password maps */
97 #define DEFAULT_CACHE_INTERVAL 300 /* secs during which assume a link is up */
98 #define DEFAULT_HLFS_GROUP      "hlfs"  /* Group name for special hlfs_gid */
99
100 #define PROGNAMESZ      (MAXHOSTNAMELEN - 5)
101
102 #ifdef HAVE_SYSLOG
103 # define DEFAULT_LOGFILE "syslog"
104 #else /* not HAVE)_SYSLOG */
105 # define DEFAULT_LOGFILE 0
106 #endif /* not HAVE)_SYSLOG */
107
108 #define ERRM ": %m"
109 #define fatalerror(str) \
110   (fatal (strcat (strnsave ((str), strlen ((str)) + sizeof (ERRM) - 1), ERRM)))
111
112 /*
113  * TYPEDEFS:
114  */
115 typedef struct uid2home_t uid2home_t;
116 typedef struct username2uid_t username2uid_t;
117
118
119 /*
120  * STRUCTURES:
121  */
122 struct uid2home_t {
123   uid_t uid;                    /* XXX: with or without UID_OFFSET? */
124   pid_t child;
125   char *home;                   /* really allocated */
126   char *uname;                  /* an xref ptr to username2uid_t->username */
127   u_long last_access_time;
128   int last_status;              /* 0=used $HOME/.hlfsspool; !0=used alt dir */
129 };
130
131 struct username2uid_t {
132   char *username;               /* really allocated */
133   uid_t uid;                    /* XXX: with or without UID_OFFSET? */
134   char *home;                   /* an xref ptr to uid2home_t->home */
135 };
136
137 /*
138  * EXTERNALS:
139  */
140 extern RETSIGTYPE cleanup(int);
141 extern RETSIGTYPE interlock(int);
142 extern SVCXPRT *nfs_program_2_transp;   /* For quick_reply() */
143 extern SVCXPRT *nfsxprt;
144 extern char *alt_spooldir;
145 extern char *home_subdir;
146 extern char *homedir(int);
147 extern char *mailbox(int, char *);
148 extern char *passwdfile;
149 extern char *slinkname;
150 extern char mboxfile[];
151 extern gid_t hlfs_gid;
152 extern int cache_interval;
153 extern int noverify;
154 extern int serverpid;
155 extern int untab_index(char *username);
156 extern am_nfs_fh *root_fhp;
157 extern am_nfs_fh root;
158 extern nfstime startup;
159 extern uid2home_t *plt_search(int);
160 extern username2uid_t *untab;   /* user name table */
161 extern void fatal(char *);
162 extern void plt_init(void);
163 extern void hlfsd_init_filehandles(void);
164
165 #if defined(DEBUG) || defined(DEBUG_PRINT)
166 extern void plt_dump(uid2home_t *, pid_t);
167 extern void plt_print(int);
168 #endif /* defined(DEBUG) || defined(DEBUG_PRINT) */
169
170 #endif /* _HLFSD_HLFS_H */