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