xref: /freebsd/include/rpcsvc/nis.x (revision 3494f7c0)
1 %/*-
2 % * Copyright (c) 2010, Oracle America, Inc.
3 % *
4 % * Redistribution and use in source and binary forms, with or without
5 % * modification, are permitted provided that the following conditions are
6 % * met:
7 % *
8 % *     * Redistributions of source code must retain the above copyright
9 % *       notice, this list of conditions and the following disclaimer.
10 % *     * Redistributions in binary form must reproduce the above
11 % *       copyright notice, this list of conditions and the following
12 % *       disclaimer in the documentation and/or other materials
13 % *       provided with the distribution.
14 % *     * Neither the name of the "Oracle America, Inc." nor the names of its
15 % *       contributors may be used to endorse or promote products derived
16 % *       from this software without specific prior written permission.
17 % *
18 % *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 % *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 % *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 % *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 % *   COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23 % *   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 % *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
25 % *   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 % *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 % *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 % *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 % *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 % */
31 
32 /*
33  *
34  * RPC Language Protocol description file for NIS Plus
35  * This version : 1.61
36  * Last Modified : 3/19/91
37  */
38 #ifdef RPC_HDR
39 %/*
40 % *	nis.h
41 % *
42 % *	This file is the main include file for NIS clients. It contains
43 % *	both the client library function defines and the various data
44 % * 	structures used by the NIS service. It includes the file nis_tags.h
45 % *	which defines the tag values. This allows the tags to change without
46 % *	having to change the nis.x file.
47 % *
48 % *	NOTE : DO NOT EDIT THIS FILE! It is automatically generated when
49 % *	       rpcgen is run on the nis.x file. Note that there is a
50 % *	       simple sed script to remove some unneeded lines. (See the
51 % *	       Makefile target nis.h)
52 % *
53 % */
54 %#include <rpcsvc/nis_tags.h>
55 #endif
56 
57 /* This gets stuffed into the source files. */
58 #if RPC_HDR
59 %#include <rpc/xdr.h>
60 #endif
61 /*
62  * This is just pointless.
63  */
64 #ifdef SUN_STUPIDITY
65 #if RPC_SVC
66 %#include "nis_svc.h"
67 #endif
68 #endif
69 
70 /* Include the RPC Language description of NIS objects */
71 #include "nis_object.x"
72 
73 /* Errors  that can be returned by the service */
74 enum nis_error {
75 	NIS_SUCCESS = 0,	/* A-ok, let's rock n roll 	*/
76 	NIS_S_SUCCESS = 1,	/* Name found (maybe)	   	*/
77 	NIS_NOTFOUND = 2,	/* Name definitely not found 	*/
78 	NIS_S_NOTFOUND = 3,	/* Name maybe not found 	*/
79 	NIS_CACHEEXPIRED = 4,	/* Name exists but cache out of date */
80 	NIS_NAMEUNREACHABLE = 5, /* Can't get there from here */
81 	NIS_UNKNOWNOBJ = 6,	/* Object type is bogus */
82 	NIS_TRYAGAIN = 7,	/* I'm busy, call back */
83 	NIS_SYSTEMERROR = 8,	/* Out of band failure */
84 	NIS_CHAINBROKEN = 9,	/* First/Next warning */
85 	NIS_PERMISSION = 10,	/* Not enough permission to access */
86 	NIS_NOTOWNER = 11,	/* You don't own it, sorry */
87 	NIS_NOT_ME = 12,	/* I don't serve this name */
88 	NIS_NOMEMORY = 13,	/* Outta VM! Help! */
89 	NIS_NAMEEXISTS = 14,	/* Can't create over another name */
90 	NIS_NOTMASTER = 15,	/* I'm justa secondaray, don't ask me */
91 	NIS_INVALIDOBJ = 16,	/* Object is broken somehow */
92 	NIS_BADNAME = 17,	/* Unparsable name */
93 	NIS_NOCALLBACK = 18,	/* Couldn't talk to call back proc */
94 	NIS_CBRESULTS = 19,	/* Results being called back to you */
95 	NIS_NOSUCHNAME = 20,	/* Name unknown */
96 	NIS_NOTUNIQUE = 21,	/* Value is not uniques (entry) */
97 	NIS_IBMODERROR = 22,	/* Inf. Base. Modify error. */
98 	NIS_NOSUCHTABLE = 23,	/* Name for table was wrong */
99 	NIS_TYPEMISMATCH = 24, 	/* Entry and table type mismatch */
100 	NIS_LINKNAMEERROR = 25,	/* Link points to bogus name */
101 	NIS_PARTIAL = 26,	/* Partial success, found table */
102 	NIS_TOOMANYATTRS = 27,	/* Too many attributes */
103 	NIS_RPCERROR = 28,	/* RPC error encountered */
104 	NIS_BADATTRIBUTE = 29,	/* Bad or invalid attribute */
105 	NIS_NOTSEARCHABLE = 30,	/* Non-searchable object searched */
106 	NIS_CBERROR = 31,	/* Error during callback (svc crash) */
107 	NIS_FOREIGNNS = 32,	/* Foreign Namespace */
108 	NIS_BADOBJECT = 33,	/* Malformed object structure */
109 	NIS_NOTSAMEOBJ = 34,	/* Object swapped during deletion */
110 	NIS_MODFAIL = 35,	/* Failure during a Modify. */
111 	NIS_BADREQUEST = 36,	/* Illegal query for table */
112 	NIS_NOTEMPTY = 37,	/* Attempt to remove a non-empty tbl */
113 	NIS_COLDSTART_ERR = 38, /* Error accesing the cold start file */
114 	NIS_RESYNC = 39,	/* Transaction log too far out of date */
115 	NIS_FAIL = 40,		/* NIS operation failed. */
116 	NIS_UNAVAIL = 41,	/* NIS+ service is unavailable (client) */
117 	NIS_RES2BIG = 42,	/* NIS+ result too big for datagram */
118 	NIS_SRVAUTH = 43,	/* NIS+ server wasn't authenticated. */
119 	NIS_CLNTAUTH = 44,	/* NIS+ Client wasn't authenticated. */
120 	NIS_NOFILESPACE = 45,	/* NIS+ server ran out of disk space */
121 	NIS_NOPROC = 46,	/* NIS+ server couldn't create new proc */
122 	NIS_DUMPLATER = 47	/* NIS+ server already has dump child */
123 };
124 
125 
126 /*
127  * Structure definitions for the parameters and results of the actual
128  * NIS RPC calls.
129  *
130  * This is the standard result (in the protocol) of most of the nis
131  * requests.
132  */
133 
134 struct nis_result {
135 	nis_error	status;		/* Status of the response */
136 	nis_object	objects<>;	/* objects found 	  */
137 	netobj		cookie;		/* Cookie Data 		  */
138 	u_long		zticks;		/* server ticks	 	  */
139 	u_long		dticks;		/* DBM ticks.		  */
140 	u_long		aticks;		/* Cache (accel) ticks	  */
141 	u_long		cticks;		/* Client ticks		  */
142 };
143 
144 /*
145  * A Name Service request
146  * This request is used to access the name space, ns_name is the name
147  * of the object within the namespace and the object is it's value, for
148  * add/modify, a copy of the original for remove.
149  */
150 
151 struct ns_request {
152 	nis_name	ns_name;	/* Name in the NIS name space	*/
153 	nis_object	ns_object<1>;	/* Optional Object (add/remove)	*/
154 };
155 
156 /*
157  * An information base request
158  * This request includes the NIS name of the table we wish to search, the
159  * search criteria in the form of attribute/value pairs and an optional
160  * callback program number. If the callback program number is provided
161  * the server will send back objects one at a time, otherwise it will
162  * return them all in the response.
163  */
164 
165 struct ib_request {
166 	nis_name  	ibr_name;	/* The name of the Table 	*/
167 	nis_attr  	ibr_srch<>; 	/* The search critereia 	*/
168 	u_long		ibr_flags;	/* Optional flags 		*/
169 	nis_object	ibr_obj<1>;	/* optional object (add/modify) */
170 	nis_server	ibr_cbhost<1>;	/* Optional callback info	*/
171 	u_long		ibr_bufsize;	/* Optional first/next bufsize	*/
172 	netobj		ibr_cookie;	/* The first/next cookie	*/
173 };
174 
175 /*
176  * This argument to the PING call notifies the replicas that something in
177  * a directory has changed and this is it's timestamp. The replica will use
178  * the timestamp to determine if its resync operation was successful.
179  */
180 struct ping_args {
181 	nis_name	dir;	/* Directory that had the change */
182 	u_long		stamp;	/* timestamp of the transaction  */
183 };
184 
185 /*
186  * These are the type of entries that are stored in the transaction log,
187  * note that modifications will appear as two entries, for names, they have
188  * an "OLD" entry followed by a "NEW" entry. For entries in tables, there
189  * is a remove followed by an add. It is done this way so that we can read
190  * the log backwards to back out transactions and forwards to propagate
191  * updates.
192  */
193 enum log_entry_t {
194 	LOG_NOP = 0,
195 	ADD_NAME = 1,		/* Name Added to name space 		  */
196 	REM_NAME = 2,		/* Name removed from name space 	  */
197 	MOD_NAME_OLD = 3,	/* Name was modified in the name space 	  */
198 	MOD_NAME_NEW = 4,	/* Name was modified in the name space 	  */
199 	ADD_IBASE = 5,		/* Entry added to information base 	  */
200 	REM_IBASE = 6,		/* Entry removed from information base    */
201 	MOD_IBASE = 7,		/* Entry was modified in information base */
202 	UPD_STAMP = 8		/* Update timestamp (used as fenceposts)  */
203 };
204 
205 /*
206  * This result is returned from the name service when it is requested to
207  * dump logged entries from its transaction log. Information base updates
208  * will have the name of the information base in the le_name field and
209  * a canonical set of attribute/value pairs to fully specify the entry's
210  * 'name'.
211  */
212 struct log_entry {
213 	u_long		le_time;	/* Time in seconds 		*/
214 	log_entry_t	le_type;	/* Type of log entry 		*/
215 	nis_name	le_princp;	/* Principal making the change	*/
216 	nis_name	le_name;	/* Name of table/dir involved 	*/
217 	nis_attr	le_attrs<>;	/* List of AV pairs.		*/
218 	nis_object	le_object;	/* Actual object value 		*/
219 };
220 
221 struct log_result {
222 	nis_error 	lr_status;	/* The status itself 	 	*/
223 	netobj		lr_cookie;	/* Used by the dump callback	*/
224 	log_entry	lr_entries<>;	/* zero or more entries 	*/
225 };
226 
227 struct cp_result {
228 	nis_error	cp_status;	/* Status of the checkpoint 	*/
229 	u_long		cp_zticks;	/* Service 'ticks' 	    	*/
230 	u_long		cp_dticks;	/* Database 'ticks'	    	*/
231 };
232 
233 /*
234  * This structure defines a generic NIS tag list. The taglist contains
235  * zero or tags, each of which is a type and a value. (u_long).
236  * These are used to report statistics (see tag definitions below)
237  * and to set or reset state variables.
238  */
239 struct nis_tag {
240 	u_long	tag_type;	/* Statistic tag (may vary) 	 */
241 	string	tag_val<1024>;	/* Statistic value may also vary */
242 };
243 
244 struct nis_taglist {
245 	nis_tag tags<>;		/* List of tags */
246 };
247 
248 struct dump_args {
249 	nis_name	da_dir;		/* Directory to dump 	*/
250 	u_long		da_time;	/* From this timestamp	*/
251 	nis_server	da_cbhost<1>;	/* Callback to use.	*/
252 };
253 
254 struct fd_args {
255 	nis_name	dir_name;  /* The directory we're looking for */
256 	nis_name	requester; /* Host principal name for signature */
257 };
258 
259 struct fd_result {
260 	nis_error	status;		/* Status returned by function	*/
261 	nis_name	source;		/* Source of this answer   	*/
262 	opaque		dir_data<>;	/* Directory Data (XDR'ed) 	*/
263 	opaque		signature<>;	/* Signature of the source 	*/
264 };
265 
266 
267 /*
268  * What's going on here? Well, it's like this. When the service
269  * is being compiled it wants to have the service definition specific
270  * info included, and when the client is being compiled it wants that
271  * info. This includes the appropriate file which was generated by
272  * make in the protocols directory (probably /usr/include/rpcsvc).
273  *
274  * Uhm... guys? With RPC, you aren't supposed to have separate
275  * server-specific and client-specific header files. You have one header
276  * file that's suitable for both. If your code doesn't work using just
277  * the one header file, I submit to you that it's broken.
278  *							-Bill
279  */
280 #ifdef SUN_STUPIDITY
281 #ifdef RPC_SVC
282 %#include "nis_svc.h"
283 #endif
284 #ifdef RPC_CLNT
285 %#include "nis_clnt.h"
286 #endif
287 #endif
288 
289 program  NIS_PROG {
290 
291 	/* RPC Language description of the NIS+ protocol */
292 	version NIS_VERSION {
293 		/* The name service functions */
294 		nis_result  NIS_LOOKUP(ns_request) = 1;
295 		nis_result  NIS_ADD(ns_request) = 2;
296 		nis_result  NIS_MODIFY(ns_request) = 3;
297 		nis_result  NIS_REMOVE(ns_request) = 4;
298 
299 		/* The information base functions */
300 		nis_result  NIS_IBLIST(ib_request) = 5;
301 		nis_result  NIS_IBADD(ib_request) = 6;
302 		nis_result  NIS_IBMODIFY(ib_request) = 7;
303 		nis_result  NIS_IBREMOVE(ib_request) = 8;
304 		nis_result  NIS_IBFIRST(ib_request) = 9;
305 		nis_result  NIS_IBNEXT(ib_request) = 10;
306 
307 		/* NIS Administrative functions */
308 		fd_result   NIS_FINDDIRECTORY(fd_args) = 12;
309 
310 		/* If fetch and optionally reset statistics */
311 		nis_taglist  NIS_STATUS(nis_taglist) = 14;
312 
313 		/* Dump changes to directory since time in da_time */
314 		log_result  NIS_DUMPLOG(dump_args) = 15;
315 
316 		/* Dump contents of directory named */
317 		log_result  NIS_DUMP(dump_args) = 16;
318 
319 		/* Check status of callback thread */
320 		bool	    NIS_CALLBACK(netobj) = 17;
321 
322 		/* Return last update time for named dir */
323 		u_long      NIS_CPTIME(nis_name) = 18;
324 
325 		/* Checkpoint directory or table named */
326 		cp_result   NIS_CHECKPOINT(nis_name) = 19;
327 
328 		/* Send 'status changed' ping to replicates */
329 		void	    NIS_PING(ping_args) = 20;
330 
331 		/* Modify server behaviour (such as debugging) */
332 		nis_taglist NIS_SERVSTATE(nis_taglist) = 21;
333 
334 		/* Create a Directory */
335 		nis_error   NIS_MKDIR(nis_name) = 22;
336 
337 		/* Remove a Directory */
338 		nis_error   NIS_RMDIR(nis_name) = 23;
339 
340 		/* Update public keys of a directory object */
341 		nis_error   NIS_UPDKEYS(nis_name) = 24;
342 	} = 3;
343 } = 100300;
344 
345 /*
346  * Included below are the defines that become part of nis.h,
347  * they are technically not part of the protocol, but do define
348  * key aspects of the implementation and are therefore useful
349  * in building a conforming server or client.
350  */
351 #if RPC_HDR
352 %/*
353 % * Generic "hash" datastructures, used by all types of hashed data.
354 % */
355 %struct nis_hash_data {
356 %	nis_name		name;	   /* NIS name of hashed item      */
357 %	int			keychain;  /* It's hash key (for pop)      */
358 %	struct nis_hash_data	*next;	   /* Hash collision pointer       */
359 %	struct nis_hash_data	*prv_item; /* A serial, doubly linked list */
360 %	struct nis_hash_data	*nxt_item; /* of items in the hash table   */
361 %};
362 %typedef struct nis_hash_data NIS_HASH_ITEM;
363 %
364 %struct nis_hash_table {
365 %	NIS_HASH_ITEM	*keys[64];	/* A hash table of items           */
366 %	NIS_HASH_ITEM	*first;		/* The first "item" in serial list */
367 %};
368 %typedef struct nis_hash_table NIS_HASH_TABLE;
369 %
370 %/* Structure for storing dynamically allocated static data */
371 %struct nis_sdata {
372 %	void	*buf;	/* Memory allocation pointer 	*/
373 %	u_long	size;	/* Buffer size			*/
374 %};
375 %
376 %/* Generic client creating flags */
377 %#define ZMH_VC		1
378 %#define ZMH_DG		2
379 %#define ZMH_AUTH	4
380 %
381 %/* Testing Access rights for objects */
382 %
383 %#define NIS_READ_ACC		1
384 %#define NIS_MODIFY_ACC		2
385 %#define NIS_CREATE_ACC		4
386 %#define NIS_DESTROY_ACC	8
387 %/* Test macros. a == access rights, m == desired rights. */
388 %#define WORLD(a, m)	(((a) & (m)) != 0)
389 %#define GROUP(a, m)	(((a) & ((m) << 8)) != 0)
390 %#define OWNER(a, m)	(((a) & ((m) << 16)) != 0)
391 %#define NOBODY(a, m)	(((a) & ((m) << 24)) != 0)
392 %
393 %#define OATYPE(d, n) (((d)->do_armask.do_armask_val+n)->oa_otype)
394 %#define OARIGHTS(d, n) (((d)->do_armask.do_armask_val+n)->oa_rights)
395 %#define WORLD_DEFAULT (NIS_READ_ACC)
396 %#define GROUP_DEFAULT (NIS_READ_ACC << 8)
397 %#define OWNER_DEFAULT ((NIS_READ_ACC + NIS_MODIFY_ACC + NIS_CREATE_ACC + NIS_DESTROY_ACC) << 16)
398 %#define DEFAULT_RIGHTS (WORLD_DEFAULT | GROUP_DEFAULT | OWNER_DEFAULT)
399 %
400 %/* Result manipulation defines ... */
401 %#define NIS_RES_NUMOBJ(x)	((x)->objects.objects_len)
402 %#define NIS_RES_OBJECT(x)	((x)->objects.objects_val)
403 %#define NIS_RES_COOKIE(x)	((x)->cookie)
404 %#define NIS_RES_STATUS(x)	((x)->status)
405 %
406 %/* These defines make getting at the variant part of the object easier. */
407 %#define TA_data zo_data.objdata_u.ta_data
408 %#define EN_data zo_data.objdata_u.en_data
409 %#define DI_data zo_data.objdata_u.di_data
410 %#define LI_data zo_data.objdata_u.li_data
411 %#define GR_data zo_data.objdata_u.gr_data
412 %
413 %#define __type_of(o) ((o)->zo_data.zo_type)
414 %
415 %/* Declarations for the internal subroutines in nislib.c */
416 %enum name_pos {SAME_NAME, HIGHER_NAME, LOWER_NAME, NOT_SEQUENTIAL, BAD_NAME};
417 %typedef enum name_pos name_pos;
418 %
419 %/*
420 % * Defines for getting at column data in entry objects. Because RPCGEN
421 % * generates some rather wordy structures, we create some defines that
422 % * collapse the needed keystrokes to access a particular value using
423 % * these definitions they take an nis_object *, and an int and return
424 % * a u_char * for Value, and an int for length.
425 % */
426 %#define ENTRY_VAL(obj, col) (obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_val
427 %#define ENTRY_LEN(obj, col) (obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len
428 %
429 %#ifdef __cplusplus
430 %}
431 %#endif
432 %
433 %/* Prototypes, and extern declarations for the NIS library functions. */
434 %#include <rpcsvc/nislib.h>
435 %#endif /* __NIS_RPCGEN_H */
436 %/* EDIT_START */
437 %
438 %/*
439 % * nis_3.h
440 % *
441 % * This file contains definitions that are only of interest to the actual
442 % * service daemon and client stubs. Normal users of NIS will not include
443 % * this file.
444 % *
445 % * NOTE : This include file is automatically created by a combination
446 % * of rpcgen and sed. DO NOT EDIT IT, change the nis.x file instead
447 % * and then remake this file.
448 % */
449 %#ifndef __nis_3_h
450 %#define __nis_3_h
451 %#ifdef __cplusplus
452 %extern "C" {
453 %#endif
454 #endif
455