1/*
2 * Copyright (c) 1997-2006 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 *
40 * File: am-utils/hlfsd/hlfsd.h
41 *
42 * HLFSD was written at Columbia University Computer Science Department, by
43 * Erez Zadok <ezk@cs.columbia.edu> and Alexander Dupuy <dupuy@cs.columbia.edu>
44 * It is being distributed under the same terms and conditions as amd does.
45 */
46
47#ifndef _HLFSD_HLFS_H
48#define _HLFSD_HLFS_H
49
50/*
51 * MACROS AND CONSTANTS:
52 */
53
54#define HLFSD_VERSION	"hlfsd 1.2 (1993-2002)"
55#define PERS_SPOOLMODE	0755
56#define OPEN_SPOOLMODE	01777
57#define DOTSTRING	"."
58
59/*
60 * ROOTID and SLINKID are the fixed "faked" node IDs (inodes) for
61 * the '.' (also '..') and the one symlink within the hlfs.
62 * They must always be unique, and should never match what a UID
63 * could be.
64 * They used to be -1 and -2, respectively.
65 *
66 * I used to cast these to (uid_t) but it failed to compile
67 * with /opt/SUNWspro/bin/cc because uid_t is long, while struct fattr's
68 * uid field is u_int.  Then it failed to compile on some linux systems
69 * which define uid_t to be unsigned short, so I used the lowest common
70 * size which is unsigned short.
71 */
72/*
73 * XXX: this will cause problems to systems with UIDs greater than
74 * MAX_UNSIGNED_SHORT-3.
75 */
76#define ROOTID		(((unsigned short) ~0) - 1)
77#define SLINKID		(((unsigned short) ~0) - 2)
78#ifndef INVALIDID
79/* this is also defined in include/am_utils.h */
80# define INVALIDID	(((unsigned short) ~0) - 3)
81#endif /* not INVALIDID */
82
83#define DOTCOOKIE	1
84#define DOTDOTCOOKIE	2
85#define SLINKCOOKIE	3
86
87#define ALT_SPOOLDIR "/var/hlfs" /* symlink to use if others fail */
88#define HOME_SUBDIR ".hlfsdir"	/* dirname in user's home dir */
89#define DEFAULT_DIRNAME "/hlfs/home"
90#define DEFAULT_INTERVAL 900	/* secs b/t re-reads of the password maps */
91#define DEFAULT_CACHE_INTERVAL 300 /* secs during which assume a link is up */
92#define DEFAULT_HLFS_GROUP	"hlfs"	/* Group name for special hlfs_gid */
93
94#define PROGNAMESZ	(MAXHOSTNAMELEN - 5)
95
96#ifdef HAVE_SYSLOG
97# define DEFAULT_LOGFILE "syslog"
98#else /* not HAVE)_SYSLOG */
99# define DEFAULT_LOGFILE 0
100#endif /* not HAVE)_SYSLOG */
101
102
103/*
104 * TYPEDEFS:
105 */
106typedef struct uid2home_t uid2home_t;
107typedef struct username2uid_t username2uid_t;
108
109
110/*
111 * STRUCTURES:
112 */
113struct uid2home_t {
114  uid_t uid;			/* XXX: with or without UID_OFFSET? */
115  pid_t child;
116  char *home;			/* really allocated */
117  char *uname;			/* an xref ptr to username2uid_t->username */
118  u_long last_access_time;
119  int last_status;		/* 0=used $HOME/.hlfsspool; !0=used alt dir */
120};
121
122struct username2uid_t {
123  char *username;		/* really allocated */
124  uid_t uid;			/* XXX: with or without UID_OFFSET? */
125  char *home;			/* an xref ptr to uid2home_t->home */
126};
127
128/*
129 * EXTERNALS:
130 */
131extern RETSIGTYPE cleanup(int);
132extern RETSIGTYPE interlock(int);
133extern SVCXPRT *nfs_program_2_transp;	/* For quick_reply() */
134extern SVCXPRT *nfsxprt;
135extern char *alt_spooldir;
136extern char *home_subdir;
137extern char *homedir(int, int);
138extern char *mailbox(int, char *);
139extern char *passwdfile;
140extern char *slinkname;
141extern gid_t hlfs_gid;
142extern u_int cache_interval;
143extern int noverify;
144extern int serverpid;
145extern int untab_index(char *username);
146extern am_nfs_fh *root_fhp;
147extern am_nfs_fh root;
148extern nfstime startup;
149extern uid2home_t *plt_search(u_int);
150extern username2uid_t *untab;	/* user name table */
151extern void fatal(char *);
152extern void plt_init(void);
153extern void hlfsd_init_filehandles(void);
154
155#if defined(DEBUG) || defined(DEBUG_PRINT)
156extern void plt_dump(uid2home_t *, pid_t);
157extern void plt_print(int);
158#endif /* defined(DEBUG) || defined(DEBUG_PRINT) */
159
160#endif /* _HLFSD_HLFS_H */
161