freebsd-dev/usr.sbin/rpc.statd/statd.h
Alfred Perlstein 8360efbd6c Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and
associated changes that had to happen to make this possible as well as
bugs fixed along the way.

  Bring in required TLI library routines to support this.

  Since we don't support TLI we've essentially copied what NetBSD
  has done, adding a thin layer to emulate direct the TLI calls
  into BSD socket calls.

  This is mostly from Sun's tirpc release that was made in 1994,
  however some fixes were backported from the 1999 release (supposedly
  only made available after this porting effort was underway).

  The submitter has agreed to continue on and bring us up to the
  1999 release.

  Several key features are introduced with this update:
    Client calls are thread safe. (1999 code has server side thread
    safe)
    Updated, a more modern interface.

  Many userland updates were done to bring the code up to par with
  the recent RPC API.

  There is an update to the pthreads library, a function
  pthread_main_np() was added to emulate a function of Sun's threads
  library.

  While we're at it, bring in NetBSD's lockd, it's been far too
  long of a wait.

  New rpcbind(8) replaces portmap(8) (supporting communication over
  an authenticated Unix-domain socket, and by default only allowing
  set and unset requests over that channel). It's much more secure
  than the old portmapper.

  Umount(8), mountd(8), mount_nfs(8), nfsd(8) have also been upgraded
  to support TI-RPC and to support IPV6.

  Umount(8) is also fixed to unmount pathnames longer than 80 chars,
  which are currently truncated by the Kernel statfs structure.

Submitted by: Martin Blapp <mb@imp.ch>
Manpage review: ru
Secure RPC implemented by: wpaul
2001-03-19 12:50:13 +00:00

111 lines
4.5 KiB
C

/*
* Copyright (c) 1995
* A.R. Gordon (andrew.gordon@net-tel.co.uk). All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed for the FreeBSD project
* 4. Neither the name of the author nor the names of any co-contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY ANDREW GORDON AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#include "sm_inter.h"
/* ------------------------------------------------------------------------- */
/*
Data structures for recording monitored hosts
The information held by the status monitor comprises a list of hosts
that we have been asked to monitor, and, associated with each monitored
host, one or more clients to be called back if the monitored host crashes.
The list of monitored hosts must be retained over a crash, so that upon
re-boot we can call the SM_NOTIFY procedure in all those hosts so as to
cause them to start recovery processing. On the other hand, the client
call-backs are not required to be preserved: they are assumed (in the
protocol design) to be local processes which will have crashed when
we did, and so are discarded on restart.
We handle this by keeping the list of monitored hosts in a file
(/var/statd.state) which is mmap()ed and whose format is described
by the typedef FileLayout. The lists of client callbacks are chained
off this structure, but are held in normal memory and so will be
lost after a re-boot. Hence the actual values of MonList * pointers
in the copy on disc have no significance, but their NULL/non-NULL
status indicates whether this host is actually being monitored or if it
is an empty slot in the file.
*/
typedef struct MonList_s
{
struct MonList_s *next; /* Next in list or NULL */
char notifyHost[SM_MAXSTRLEN + 1]; /* Host to notify */
int notifyProg; /* RPC program number to call */
int notifyVers; /* version number */
int notifyProc; /* procedure number */
unsigned char notifyData[16]; /* Opaque data from caller */
} MonList;
typedef struct
{
char hostname[SM_MAXSTRLEN + 1]; /* Name of monitored host */
int notifyReqd; /* TRUE if we've crashed and not yet */
/* informed the monitored host */
MonList *monList; /* List of clients to inform if we */
/* hear that the monitored host has */
/* crashed, NULL if no longer monitored */
} HostInfo;
/* Overall file layout. */
typedef struct
{
int ourState; /* State number as defined in statd protocol */
int noOfHosts; /* Number of elements in hosts[] */
char reserved[248]; /* Reserved for future use */
HostInfo hosts[1]; /* vector of monitored hosts */
} FileLayout;
#define HEADER_LEN (sizeof(FileLayout) - sizeof(HostInfo))
/* ------------------------------------------------------------------------- */
/* Global variables */
extern FileLayout *status_info; /* The mmap()ed status file */
extern int debug; /* =1 to enable diagnostics to syslog */
/* Function prototypes */
extern HostInfo *find_host(char * /*hostname*/, int /*create*/);
extern void init_file(char * /*filename*/);
extern void notify_hosts(void);
extern void sync_file(void);