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