hlfsd.h revision 38494
138494Sobrien/*
238494Sobrien * Copyright (c) 1997-1998 Erez Zadok
338494Sobrien * Copyright (c) 1989 Jan-Simon Pendry
438494Sobrien * Copyright (c) 1989 Imperial College of Science, Technology & Medicine
538494Sobrien * Copyright (c) 1989 The Regents of the University of California.
638494Sobrien * All rights reserved.
738494Sobrien *
838494Sobrien * This code is derived from software contributed to Berkeley by
938494Sobrien * Jan-Simon Pendry at Imperial College, London.
1038494Sobrien *
1138494Sobrien * Redistribution and use in source and binary forms, with or without
1238494Sobrien * modification, are permitted provided that the following conditions
1338494Sobrien * are met:
1438494Sobrien * 1. Redistributions of source code must retain the above copyright
1538494Sobrien *    notice, this list of conditions and the following disclaimer.
1638494Sobrien * 2. Redistributions in binary form must reproduce the above copyright
1738494Sobrien *    notice, this list of conditions and the following disclaimer in the
1838494Sobrien *    documentation and/or other materials provided with the distribution.
1938494Sobrien * 3. All advertising materials mentioning features or use of this software
2038494Sobrien *    must display the following acknowledgement:
2138494Sobrien *      This product includes software developed by the University of
2238494Sobrien *      California, Berkeley and its contributors.
2338494Sobrien * 4. Neither the name of the University nor the names of its contributors
2438494Sobrien *    may be used to endorse or promote products derived from this software
2538494Sobrien *    without specific prior written permission.
2638494Sobrien *
2738494Sobrien * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2838494Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2938494Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3038494Sobrien * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3138494Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3238494Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3338494Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3438494Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3538494Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3638494Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3738494Sobrien * SUCH DAMAGE.
3838494Sobrien *
3938494Sobrien *      %W% (Berkeley) %G%
4038494Sobrien *
4138494Sobrien * $Id: hlfs.h,v 1.9 1993/09/13 15:11:00 ezk Exp $
4238494Sobrien *
4338494Sobrien * HLFSD was written at Columbia University Computer Science Department, by
4438494Sobrien * Erez Zadok <ezk@cs.columbia.edu> and Alexander Dupuy <dupuy@cs.columbia.edu>
4538494Sobrien * It is being distributed under the same terms and conditions as amd does.
4638494Sobrien */
4738494Sobrien
4838494Sobrien#ifndef _HLFSD_HLFS_H
4938494Sobrien#define _HLFSD_HLFS_H
5038494Sobrien
5138494Sobrien/*
5238494Sobrien * MACROS AND CONSTANTS:
5338494Sobrien */
5438494Sobrien
5538494Sobrien#define HLFSD_VERSION	"hlfsd 1.1 (March 4, 1997-1998)"
5638494Sobrien#define PERS_SPOOLMODE	0755
5738494Sobrien#define OPEN_SPOOLMODE	01777
5838494Sobrien#define DOTSTRING	"."
5938494Sobrien
6038494Sobrien/*
6138494Sobrien * ROOTID and SLINKID are the fixed "faked" node IDs (inodes) for
6238494Sobrien * the '.' (also '..') and the one symlink within the hlfs.
6338494Sobrien * They must always be unique, and should never match what a UID
6438494Sobrien * could be.
6538494Sobrien * They used to be -1 and -2, respectively.
6638494Sobrien *
6738494Sobrien * I used to cast these to (uid_t) but it failed to compile
6838494Sobrien * with /opt/SUNWspro/bin/cc because uid_t is long, while struct fattr's
6938494Sobrien * uid field is u_int.  Then it failed to compile on some linux systems
7038494Sobrien * which define uid_t to be unsigned short, so I used the lowest common
7138494Sobrien * size which is unsigned short.
7238494Sobrien */
7338494Sobrien#ifdef EXPERIMENTAL_UID_SIZE
7438494Sobrien#define UID_SHIFT	30
7538494Sobrien# define ROOTID		((1 << UID_SHIFT) - 1)
7638494Sobrien# define SLINKID	((1 << UID_SHIFT) - 2)
7738494Sobrien# define INVALIDID	((1 << UID_SHIFT) - 3)
7838494Sobrien#else /* not EXPERIMENTAL_UID_SIZE */
7938494Sobrien/*
8038494Sobrien * XXX: this will cause problems to systems with UIDs greater than
8138494Sobrien * MAX_UNSIGNED_SHORT-3.
8238494Sobrien */
8338494Sobrien# define ROOTID		(((unsigned short) ~0) - 1)
8438494Sobrien# define SLINKID	(((unsigned short) ~0) - 2)
8538494Sobrien# define INVALIDID	(((unsigned short) ~0) - 3)
8638494Sobrien#endif /* not EXPERIMENTAL_UID_SIZE */
8738494Sobrien
8838494Sobrien
8938494Sobrien#define DOTCOOKIE	1
9038494Sobrien#define DOTDOTCOOKIE	2
9138494Sobrien#define SLINKCOOKIE	3
9238494Sobrien
9338494Sobrien#define ALT_SPOOLDIR "/var/hlfs" /* symlink to use if others fail */
9438494Sobrien#define HOME_SUBDIR ".hlfsdir"	/* dirname in user's home dir */
9538494Sobrien#define DEFAULT_DIRNAME "/hlfs/home"
9638494Sobrien#define DEFAULT_INTERVAL 900	/* secs b/t re-reads of the password maps */
9738494Sobrien#define DEFAULT_CACHE_INTERVAL 300 /* secs during which assume a link is up */
9838494Sobrien#define DEFAULT_HLFS_GROUP	"hlfs"	/* Group name for special hlfs_gid */
9938494Sobrien
10038494Sobrien#define PROGNAMESZ	(MAXHOSTNAMELEN - 5)
10138494Sobrien
10238494Sobrien#ifdef HAVE_SYSLOG
10338494Sobrien# define DEFAULT_LOGFILE "syslog"
10438494Sobrien#else /* not HAVE)_SYSLOG */
10538494Sobrien# define DEFAULT_LOGFILE 0
10638494Sobrien#endif /* not HAVE)_SYSLOG */
10738494Sobrien
10838494Sobrien#define ERRM ": %m"
10938494Sobrien#define fatalerror(str) \
11038494Sobrien  (fatal (strcat (strnsave ((str), strlen ((str)) + sizeof (ERRM) - 1), ERRM)))
11138494Sobrien
11238494Sobrien/*
11338494Sobrien * TYPDEFS:
11438494Sobrien */
11538494Sobrientypedef struct uid2home_t uid2home_t;
11638494Sobrientypedef struct username2uid_t username2uid_t;
11738494Sobrien
11838494Sobrien
11938494Sobrien/*
12038494Sobrien * STRUCTURES:
12138494Sobrien */
12238494Sobrienstruct uid2home_t {
12338494Sobrien  uid_t uid;			/* XXX: with or without UID_OFFSET? */
12438494Sobrien  pid_t child;
12538494Sobrien  char *home;			/* really allocated */
12638494Sobrien  char *uname;			/* an xref ptr to username2uid_t->username */
12738494Sobrien  u_long last_access_time;
12838494Sobrien  int last_status;		/* 0=used $HOME/.hlfsspool; !0=used alt dir */
12938494Sobrien};
13038494Sobrien
13138494Sobrienstruct username2uid_t {
13238494Sobrien  char *username;		/* really allocated */
13338494Sobrien  uid_t uid;			/* XXX: with or without UID_OFFSET? */
13438494Sobrien  char *home;			/* an xref ptr to uid2home_t->home */
13538494Sobrien};
13638494Sobrien
13738494Sobrien/*
13838494Sobrien * EXTERNALS:
13938494Sobrien */
14038494Sobrienextern RETSIGTYPE cleanup(int);
14138494Sobrienextern RETSIGTYPE interlock(int);
14238494Sobrienextern SVCXPRT *nfs_program_2_transp;	/* For quick_reply() */
14338494Sobrienextern SVCXPRT *nfsxprt;
14438494Sobrienextern char *alt_spooldir;
14538494Sobrienextern char *home_subdir;
14638494Sobrienextern char *homedir(int);
14738494Sobrienextern char *mailbox(int, char *);
14838494Sobrienextern char *passwdfile;
14938494Sobrienextern char *slinkname;
15038494Sobrienextern char mboxfile[];
15138494Sobrienextern gid_t hlfs_gid;
15238494Sobrienextern int cache_interval;
15338494Sobrienextern int noverify;
15438494Sobrienextern int serverpid;
15538494Sobrienextern int sys_nerr;
15638494Sobrienextern int untab_index(char *username);
15738494Sobrienextern am_nfs_fh *root_fhp;
15838494Sobrienextern am_nfs_fh root;
15938494Sobrienextern nfstime startup;
16038494Sobrienextern uid2home_t *plt_search(int);
16138494Sobrienextern username2uid_t *untab;	/* user name table */
16238494Sobrienextern void fatal(char *);
16338494Sobrienextern void plt_init(void);
16438494Sobrienextern void hlfsd_init_filehandles(void);
16538494Sobrien
16638494Sobrien#if defined(DEBUG) || defined(DEBUG_PRINT)
16738494Sobrienextern void plt_dump(uid2home_t *, pid_t);
16838494Sobrienextern void plt_print(int);
16938494Sobrien#endif /* defined(DEBUG) || defined(DEBUG_PRINT) */
17038494Sobrien
17138494Sobrien#endif /* _HLFSD_HLFS_H */
172