138494Sobrien/*
2174313Sobrien * Copyright (c) 1997-2006 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
2042629Sobrien *    must display the following acknowledgment:
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 *
40174313Sobrien * File: am-utils/hlfsd/hlfsd.h
4138494Sobrien *
4238494Sobrien * HLFSD was written at Columbia University Computer Science Department, by
4338494Sobrien * Erez Zadok <ezk@cs.columbia.edu> and Alexander Dupuy <dupuy@cs.columbia.edu>
4438494Sobrien * It is being distributed under the same terms and conditions as amd does.
4538494Sobrien */
4638494Sobrien
4738494Sobrien#ifndef _HLFSD_HLFS_H
4838494Sobrien#define _HLFSD_HLFS_H
4938494Sobrien
5038494Sobrien/*
5138494Sobrien * MACROS AND CONSTANTS:
5238494Sobrien */
5338494Sobrien
54119682Smbr#define HLFSD_VERSION	"hlfsd 1.2 (1993-2002)"
5538494Sobrien#define PERS_SPOOLMODE	0755
5638494Sobrien#define OPEN_SPOOLMODE	01777
5738494Sobrien#define DOTSTRING	"."
5838494Sobrien
5938494Sobrien/*
6038494Sobrien * ROOTID and SLINKID are the fixed "faked" node IDs (inodes) for
6138494Sobrien * the '.' (also '..') and the one symlink within the hlfs.
6238494Sobrien * They must always be unique, and should never match what a UID
6338494Sobrien * could be.
6438494Sobrien * They used to be -1 and -2, respectively.
6538494Sobrien *
6638494Sobrien * I used to cast these to (uid_t) but it failed to compile
6738494Sobrien * with /opt/SUNWspro/bin/cc because uid_t is long, while struct fattr's
6838494Sobrien * uid field is u_int.  Then it failed to compile on some linux systems
6938494Sobrien * which define uid_t to be unsigned short, so I used the lowest common
7038494Sobrien * size which is unsigned short.
7138494Sobrien */
7238494Sobrien/*
7338494Sobrien * XXX: this will cause problems to systems with UIDs greater than
7438494Sobrien * MAX_UNSIGNED_SHORT-3.
7538494Sobrien */
7682794Sobrien#define ROOTID		(((unsigned short) ~0) - 1)
7782794Sobrien#define SLINKID		(((unsigned short) ~0) - 2)
7882794Sobrien#ifndef INVALIDID
7982794Sobrien/* this is also defined in include/am_utils.h */
8038494Sobrien# define INVALIDID	(((unsigned short) ~0) - 3)
8182794Sobrien#endif /* not INVALIDID */
8238494Sobrien
8338494Sobrien#define DOTCOOKIE	1
8438494Sobrien#define DOTDOTCOOKIE	2
8538494Sobrien#define SLINKCOOKIE	3
8638494Sobrien
8738494Sobrien#define ALT_SPOOLDIR "/var/hlfs" /* symlink to use if others fail */
8838494Sobrien#define HOME_SUBDIR ".hlfsdir"	/* dirname in user's home dir */
8938494Sobrien#define DEFAULT_DIRNAME "/hlfs/home"
9038494Sobrien#define DEFAULT_INTERVAL 900	/* secs b/t re-reads of the password maps */
9138494Sobrien#define DEFAULT_CACHE_INTERVAL 300 /* secs during which assume a link is up */
9238494Sobrien#define DEFAULT_HLFS_GROUP	"hlfs"	/* Group name for special hlfs_gid */
9338494Sobrien
9438494Sobrien#define PROGNAMESZ	(MAXHOSTNAMELEN - 5)
9538494Sobrien
9638494Sobrien#ifdef HAVE_SYSLOG
9738494Sobrien# define DEFAULT_LOGFILE "syslog"
9838494Sobrien#else /* not HAVE)_SYSLOG */
9938494Sobrien# define DEFAULT_LOGFILE 0
10038494Sobrien#endif /* not HAVE)_SYSLOG */
10138494Sobrien
10238494Sobrien
10338494Sobrien/*
10442629Sobrien * TYPEDEFS:
10538494Sobrien */
10638494Sobrientypedef struct uid2home_t uid2home_t;
10738494Sobrientypedef struct username2uid_t username2uid_t;
10838494Sobrien
10938494Sobrien
11038494Sobrien/*
11138494Sobrien * STRUCTURES:
11238494Sobrien */
11338494Sobrienstruct uid2home_t {
11438494Sobrien  uid_t uid;			/* XXX: with or without UID_OFFSET? */
11538494Sobrien  pid_t child;
11638494Sobrien  char *home;			/* really allocated */
11738494Sobrien  char *uname;			/* an xref ptr to username2uid_t->username */
11838494Sobrien  u_long last_access_time;
11938494Sobrien  int last_status;		/* 0=used $HOME/.hlfsspool; !0=used alt dir */
12038494Sobrien};
12138494Sobrien
12238494Sobrienstruct username2uid_t {
12338494Sobrien  char *username;		/* really allocated */
12438494Sobrien  uid_t uid;			/* XXX: with or without UID_OFFSET? */
12538494Sobrien  char *home;			/* an xref ptr to uid2home_t->home */
12638494Sobrien};
12738494Sobrien
12838494Sobrien/*
12938494Sobrien * EXTERNALS:
13038494Sobrien */
13138494Sobrienextern RETSIGTYPE cleanup(int);
13238494Sobrienextern RETSIGTYPE interlock(int);
13338494Sobrienextern SVCXPRT *nfs_program_2_transp;	/* For quick_reply() */
13438494Sobrienextern SVCXPRT *nfsxprt;
13538494Sobrienextern char *alt_spooldir;
13638494Sobrienextern char *home_subdir;
137119682Smbrextern char *homedir(int, int);
13838494Sobrienextern char *mailbox(int, char *);
13938494Sobrienextern char *passwdfile;
14038494Sobrienextern char *slinkname;
14138494Sobrienextern gid_t hlfs_gid;
142174313Sobrienextern u_int cache_interval;
14338494Sobrienextern int noverify;
14438494Sobrienextern int serverpid;
14538494Sobrienextern int untab_index(char *username);
14638494Sobrienextern am_nfs_fh *root_fhp;
14738494Sobrienextern am_nfs_fh root;
14838494Sobrienextern nfstime startup;
149174313Sobrienextern uid2home_t *plt_search(u_int);
15038494Sobrienextern username2uid_t *untab;	/* user name table */
15138494Sobrienextern void fatal(char *);
15238494Sobrienextern void plt_init(void);
15338494Sobrienextern void hlfsd_init_filehandles(void);
15438494Sobrien
15538494Sobrien#if defined(DEBUG) || defined(DEBUG_PRINT)
15638494Sobrienextern void plt_dump(uid2home_t *, pid_t);
15738494Sobrienextern void plt_print(int);
15838494Sobrien#endif /* defined(DEBUG) || defined(DEBUG_PRINT) */
15938494Sobrien
16038494Sobrien#endif /* _HLFSD_HLFS_H */
161