126206Swpaul%/*
226206Swpaul% * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
326206Swpaul% * unrestricted use provided that this legend is included on all tape
426206Swpaul% * media and as a part of the software program in whole or part.  Users
526206Swpaul% * may copy or modify Sun RPC without charge, but are not authorized
626206Swpaul% * to license or distribute it to anyone else except as part of a product or
726206Swpaul% * program developed by the user or with the express written consent of
826206Swpaul% * Sun Microsystems, Inc.
926206Swpaul% *
1026206Swpaul% * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
1126206Swpaul% * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
1226206Swpaul% * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
1326206Swpaul% *
1426206Swpaul% * Sun RPC is provided with no support and without any obligation on the
1526206Swpaul% * part of Sun Microsystems, Inc. to assist in its use, correction,
1626206Swpaul% * modification or enhancement.
1726206Swpaul% *
1826206Swpaul% * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
1926206Swpaul% * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
2026206Swpaul% * OR ANY PART THEREOF.
2126206Swpaul% *
2226206Swpaul% * In no event will Sun Microsystems, Inc. be liable for any lost revenue
2326206Swpaul% * or profits or other special, indirect and consequential damages, even if
2426206Swpaul% * Sun has been advised of the possibility of such damages.
2526206Swpaul% *
2626206Swpaul% * Sun Microsystems, Inc.
2726206Swpaul% * 2550 Garcia Avenue
2826206Swpaul% * Mountain View, California  94043
2926206Swpaul% */
3026206Swpaul
3126206Swpaul/*
3226206Swpaul *	nis_object.x
3326206Swpaul *
3426206Swpaul *	Copyright (c) 1988-1992 Sun Microsystems Inc
3526206Swpaul *	All Rights Reserved.
3626206Swpaul */
3726206Swpaul
3826206Swpaul/* From: %#pragma ident	"@(#)nis_object.x	1.10	94/05/03 SMI" */
3926206Swpaul
4026206Swpaul#if RPC_HDR
4126206Swpaul%
4226206Swpaul%#ifndef __nis_object_h
4326206Swpaul%#define __nis_object_h
4426206Swpaul%
4526206Swpaul#endif
4626206Swpaul/*
4726206Swpaul * 	This file defines the format for a NIS object in RPC language.
4826206Swpaul * It is included by the main .x file and the database access protocol
4926206Swpaul * file. It is common because both of them need to deal with the same
5026206Swpaul * type of object. Generating the actual code though is a bit messy because
5126206Swpaul * the nis.x file and the nis_dba.x file will generate xdr routines to
5226206Swpaul * encode/decode objects when only one set is needed. Such is life when
5326206Swpaul * one is using rpcgen.
5426206Swpaul *
5526206Swpaul * Note, the protocol doesn't specify any limits on such things as
5626206Swpaul * maximum name length, number of attributes, etc. These are enforced
5726206Swpaul * by the database backend. When you hit them you will no. Also see
5826206Swpaul * the db_getlimits() function for fetching the limit values.
5926206Swpaul *
6026206Swpaul */
6126206Swpaul
6226206Swpaul/* Some manifest constants, chosen to maximize flexibility without
6326206Swpaul * plugging the wire full of data.
6426206Swpaul */
6526206Swpaulconst NIS_MAXSTRINGLEN = 255;
6626206Swpaulconst NIS_MAXNAMELEN   = 1024;
6726206Swpaulconst NIS_MAXATTRNAME  = 32;
6826206Swpaulconst NIS_MAXATTRVAL   = 2048;
6926206Swpaulconst NIS_MAXCOLUMNS   = 64;
7026206Swpaulconst NIS_MAXATTR      = 16;
7126206Swpaulconst NIS_MAXPATH      = 1024;
7226206Swpaulconst NIS_MAXREPLICAS  = 128;
7326206Swpaulconst NIS_MAXLINKS     = 16;
7426206Swpaul
7526206Swpaulconst NIS_PK_NONE      = 0;	/* no public key (unix/sys auth) */
7626206Swpaulconst NIS_PK_DH	       = 1;	/* Public key is Diffie-Hellman type */
7726206Swpaulconst NIS_PK_RSA       = 2;	/* Public key if RSA type */
7826206Swpaulconst NIS_PK_KERB      = 3;	/* Use kerberos style authentication */
7926206Swpaul
8026206Swpaul/*
8126206Swpaul * The fundamental name type of NIS. The name may consist of two parts,
8226206Swpaul * the first being the fully qualified name, and the second being an
8326206Swpaul * optional set of attribute/value pairs.
8426206Swpaul */
8526206Swpaulstruct nis_attr {
8626206Swpaul	string	zattr_ndx<>;	/* name of the index 		*/
8726206Swpaul	opaque	zattr_val<>;	/* Value for the attribute. 	*/
8826206Swpaul};
8926206Swpaul
9026206Swpaultypedef string nis_name<>;	/* The NIS name itself. */
9126206Swpaul
9226206Swpaul/* NIS object types are defined by the following enumeration. The numbers
9326206Swpaul * they use are based on the following scheme :
9426206Swpaul *		     0 - 1023 are reserved for Sun,
9526206Swpaul * 		1024 - 2047 are defined to be private to a particular tree.
9626206Swpaul *		2048 - 4095 are defined to be user defined.
9726206Swpaul *		4096 - ...  are reserved for future use.
9826206Swpaul */
9926206Swpaul
10026206Swpaulenum zotypes {
10126206Swpaul	BOGUS_OBJ  	= 0,	/* Uninitialized object structure 	*/
10226206Swpaul	NO_OBJ   	= 1,	/* NULL object (no data)	 	*/
10326206Swpaul	DIRECTORY_OBJ 	= 2,	/* Directory object describing domain 	*/
10426206Swpaul	GROUP_OBJ  	= 3,	/* Group object (a list of names) 	*/
10526206Swpaul	TABLE_OBJ  	= 4,	/* Table object (a database schema) 	*/
10626206Swpaul	ENTRY_OBJ  	= 5,	/* Entry object (a database record) 	*/
10726206Swpaul	LINK_OBJ   	= 6, 	/* A name link.				*/
10826206Swpaul	PRIVATE_OBJ   	= 7 	/* Private object (all opaque data) 	*/
10926206Swpaul};
11026206Swpaul
11126206Swpaul/*
11226206Swpaul * The types of Name services NIS knows about. They are enumerated
11326206Swpaul * here. The Binder code will use this type to determine if it has
11426206Swpaul * a set of library routines that will access the indicated name service.
11526206Swpaul */
11626206Swpaulenum nstype {
11726206Swpaul	UNKNOWN = 0,
11826206Swpaul	NIS = 1,	/* Nis Plus Service		*/
11926206Swpaul	SUNYP = 2,	/* Old NIS Service		*/
12026206Swpaul	IVY = 3,	/* Nis Plus Plus Service	*/
12126206Swpaul	DNS = 4,	/* Domain Name Service		*/
12226206Swpaul	X500 = 5,	/* ISO/CCCIT X.500 Service	*/
12326206Swpaul	DNANS = 6,	/* Digital DECNet Name Service	*/
12426206Swpaul	XCHS = 7,	/* Xerox ClearingHouse Service	*/
12526206Swpaul	CDS= 8
12626206Swpaul};
12726206Swpaul
12826206Swpaul/*
12926206Swpaul * DIRECTORY - The name service object. These objects identify other name
13026206Swpaul * servers that are serving some portion of the name space. Each has a
13126206Swpaul * type associated with it. The resolver library will note whether or not
13226206Swpaul * is has the needed routines to access that type of service.
13326206Swpaul * The oarmask structure defines an access rights mask on a per object
13426206Swpaul * type basis for the name spaces. The only bits currently used are
13526206Swpaul * create and destroy. By enabling or disabling these access rights for
13626206Swpaul * a specific object type for a one of the accessor entities (owner,
13726206Swpaul * group, world) the administrator can control what types of objects
13826206Swpaul * may be freely added to the name space and which require the
13926206Swpaul * administrator's approval.
14026206Swpaul */
14126206Swpaulstruct oar_mask {
14226206Swpaul	u_long	oa_rights;	/* Access rights mask 	*/
14326206Swpaul	zotypes	oa_otype;	/* Object type 		*/
14426206Swpaul};
14526206Swpaul
14626206Swpaulstruct endpoint {
14726206Swpaul	string		uaddr<>;
14826206Swpaul	string		family<>;   /* Transport family (INET, OSI, etc) */
14926206Swpaul	string		proto<>;    /* Protocol (TCP, UDP, CLNP,  etc)   */
15026206Swpaul};
15126206Swpaul
15226206Swpaul/*
15326206Swpaul * Note: pkey is a netobj which is limited to 1024 bytes which limits the
15426206Swpaul * keysize to 8192 bits. This is consider to be a reasonable limit for
15526206Swpaul * the expected lifetime of this service.
15626206Swpaul */
15726206Swpaulstruct nis_server {
15826206Swpaul	nis_name	name; 	 	/* Principal name of the server  */
15926206Swpaul	endpoint	ep<>;  		/* Universal addr(s) for server  */
16026206Swpaul	u_long		key_type;	/* Public key type		 */
16126206Swpaul	netobj		pkey;		/* server's public key  	 */
16226206Swpaul};
16326206Swpaul
16426206Swpaulstruct directory_obj {
16526206Swpaul	nis_name   do_name;	 /* Name of the directory being served   */
16626206Swpaul	nstype	   do_type;	 /* one of NIS, DNS, IVY, YP, or X.500 	 */
16726206Swpaul	nis_server do_servers<>; /* <0> == Primary name server     	 */
16826206Swpaul	u_long	   do_ttl;	 /* Time To Live (for caches) 		 */
16926206Swpaul	oar_mask   do_armask<>;  /* Create/Destroy rights by object type */
17026206Swpaul};
17126206Swpaul
17226206Swpaul/*
17326206Swpaul * ENTRY - This is one row of data from an information base.
17426206Swpaul * The type value is used by the client library to convert the entry to
17526206Swpaul * it's internal structure representation. The Table name is a back pointer
17626206Swpaul * to the table where the entry is stored. This allows the client library
17726206Swpaul * to determine where to send a request if the client wishes to change this
17826206Swpaul * entry but got to it through a LINK rather than directly.
17926206Swpaul * If the entry is a "standalone" entry then this field is void.
18026206Swpaul */
18126206Swpaulconst EN_BINARY   = 1;	/* Indicates value is binary data 	*/
18226206Swpaulconst EN_CRYPT    = 2;	/* Indicates the value is encrypted	*/
18326206Swpaulconst EN_XDR      = 4;	/* Indicates the value is XDR encoded	*/
18426206Swpaulconst EN_MODIFIED = 8;	/* Indicates entry is modified. 	*/
18526206Swpaulconst EN_ASN1     = 64;	/* Means contents use ASN.1 encoding    */
18626206Swpaul
18726206Swpaulstruct entry_col {
18826206Swpaul	u_long	ec_flags;	/* Flags for this value */
18926206Swpaul	opaque	ec_value<>;	/* It's textual value	*/
19026206Swpaul};
19126206Swpaul
19226206Swpaulstruct entry_obj {
19326206Swpaul	string 	en_type<>;	/* Type of entry such as "passwd" */
19426206Swpaul	entry_col en_cols<>;	/* Value for the entry		  */
19526206Swpaul};
19626206Swpaul
19726206Swpaul/*
19826206Swpaul * GROUP - The group object contains a list of NIS principal names. Groups
19926206Swpaul * are used to authorize principals. Each object has a set of access rights
20026206Swpaul * for members of its group. Principal names in groups are in the form
20126206Swpaul * name.directory and recursive groups are expressed as @groupname.directory
20226206Swpaul */
20326206Swpaulstruct group_obj {
20426206Swpaul	u_long		gr_flags;	/* Flags controlling group	*/
20526206Swpaul	nis_name	gr_members<>;  	/* List of names in group 	*/
20626206Swpaul};
20726206Swpaul
20826206Swpaul/*
20926206Swpaul * LINK - This is the LINK object. It is quite similar to a symbolic link
21026206Swpaul * in the UNIX filesystem. The attributes in the main object structure are
21126206Swpaul * relative to the LINK data and not what it points to (like the file system)
21226206Swpaul * "modify" privleges here indicate the right to modify what the link points
21326206Swpaul * at and not to modify that actual object pointed to by the link.
21426206Swpaul */
21526206Swpaulstruct link_obj {
21626206Swpaul	zotypes	 li_rtype;	/* Real type of the object	*/
21726206Swpaul	nis_attr li_attrs<>;	/* Attribute/Values for tables	*/
21826206Swpaul	nis_name li_name; 	/* The object's real NIS name	*/
21926206Swpaul};
22026206Swpaul
22126206Swpaul/*
22226206Swpaul * TABLE - This is the table object. It implements a simple
22326206Swpaul * data base that applications and use for configuration or
22426206Swpaul * administration purposes. The role of the table is to group together
22526206Swpaul * a set of related entries. Tables are the simple database component
22626206Swpaul * of NIS. Like many databases, tables are logically divided into columns
22726206Swpaul * and rows. The columns are labeled with indexes and each ENTRY makes
22826206Swpaul * up a row. Rows may be addressed within the table by selecting one
22926206Swpaul * or more indexes, and values for those indexes. Each row which has
23026206Swpaul * a value for the given index that matches the desired value is returned.
23126206Swpaul * Within the definition of each column there is a flags variable, this
23226206Swpaul * variable contains flags which determine whether or not the column is
23326206Swpaul * searchable, contains binary data, and access rights for the entry objects
23426206Swpaul * column value.
23526206Swpaul */
23626206Swpaul
23726206Swpaulconst TA_BINARY     = 1;	/* Means table data is binary 		*/
23826206Swpaulconst TA_CRYPT      = 2;	/* Means value should be encrypted 	*/
23926206Swpaulconst TA_XDR        = 4;	/* Means value is XDR encoded		*/
24026206Swpaulconst TA_SEARCHABLE = 8;	/* Means this column is searchable	*/
24126206Swpaulconst TA_CASE       = 16;	/* Means this column is Case Sensitive	*/
24226206Swpaulconst TA_MODIFIED   = 32;	/* Means this columns attrs are modified*/
24326206Swpaulconst TA_ASN1       = 64;	/* Means contents use ASN.1 encoding     */
24426206Swpaul
24526206Swpaulstruct table_col {
24626206Swpaul	string	tc_name<64>;	/* Column Name 	 	   */
24726206Swpaul	u_long	tc_flags;	/* control flags	   */
24826206Swpaul	u_long	tc_rights;	/* Access rights mask	   */
24926206Swpaul};
25026206Swpaul
25126206Swpaulstruct table_obj {
25226206Swpaul	string 	  ta_type<64>;	 /* Table type such as "passwd"	*/
25326206Swpaul	int	  ta_maxcol;	 /* Total number of columns	*/
25426206Swpaul	u_char	  ta_sep;	 /* Separator character 	*/
25526206Swpaul	table_col ta_cols<>; 	 /* The number of table indexes */
25626206Swpaul	string	  ta_path<>;	 /* A search path for this table */
25726206Swpaul};
25826206Swpaul
25926206Swpaul/*
26026206Swpaul * This union joins together all of the currently known objects.
26126206Swpaul */
26226206Swpaulunion objdata switch (zotypes zo_type) {
26326206Swpaul        case DIRECTORY_OBJ :
26426206Swpaul                struct directory_obj di_data;
26526206Swpaul        case GROUP_OBJ :
26626206Swpaul                struct group_obj gr_data;
26726206Swpaul        case TABLE_OBJ :
26826206Swpaul                struct table_obj ta_data;
26926206Swpaul        case ENTRY_OBJ:
27026206Swpaul                struct entry_obj en_data;
27126206Swpaul        case LINK_OBJ :
27226206Swpaul                struct link_obj li_data;
27326206Swpaul        case PRIVATE_OBJ :
27426206Swpaul                opaque	po_data<>;
27526206Swpaul	case NO_OBJ :
27626206Swpaul		void;
27726206Swpaul        case BOGUS_OBJ :
27826206Swpaul		void;
27926206Swpaul        default :
28026206Swpaul                void;
28126206Swpaul};
28226206Swpaul
28326206Swpaul/*
28426206Swpaul * This is the basic NIS object data type. It consists of a generic part
28526206Swpaul * which all objects contain, and a specialized part which varies depending
28626206Swpaul * on the type of the object. All of the specialized sections have been
28726206Swpaul * described above. You might have wondered why they all start with an
28826206Swpaul * integer size, followed by the useful data. The answer is, when the
28926206Swpaul * server doesn't recognize the type returned it treats it as opaque data.
29026206Swpaul * And the definition for opaque data is {int size; char *data;}. In this
29126206Swpaul * way, servers and utility routines that do not understand a given type
29226206Swpaul * may still pass it around. One has to be careful in setting
29326206Swpaul * this variable accurately, it must take into account such things as
29426206Swpaul * XDR padding of structures etc. The best way to set it is to note one's
29526206Swpaul * position in the XDR encoding stream, encode the structure, look at the
29626206Swpaul * new position and calculate the size.
29726206Swpaul */
29826206Swpaulstruct nis_oid {
29926206Swpaul	u_long	ctime;		/* Time of objects creation 	*/
30026206Swpaul	u_long	mtime;		/* Time of objects modification */
30126206Swpaul};
30226206Swpaul
30326206Swpaulstruct nis_object {
30426206Swpaul	nis_oid	 zo_oid;	/* object identity verifier.		*/
30526206Swpaul	nis_name zo_name;	/* The NIS name for this object		*/
30626206Swpaul	nis_name zo_owner;	/* NIS name of object owner.		*/
30726206Swpaul	nis_name zo_group;	/* NIS name of access group.		*/
30826206Swpaul	nis_name zo_domain;	/* The administrator for the object	*/
30926206Swpaul	u_long	 zo_access;	/* Access rights (owner, group, world)	*/
31026206Swpaul	u_long	 zo_ttl;	/* Object's time to live in seconds.	*/
31126206Swpaul	objdata	 zo_data;	/* Data structure for this type 	*/
31226206Swpaul};
31326206Swpaul#if RPC_HDR
31426206Swpaul%
31526206Swpaul%#endif /* if __nis_object_h */
31626206Swpaul%
31726206Swpaul#endif
318