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 #ifndef _RPCSVC_NIS_H 33 #define _RPCSVC_NIS_H 1 34 35 #include <features.h> 36 #include <rpc/rpc.h> 37 #include <rpcsvc/nis_tags.h> 38 39 __BEGIN_DECLS 40 41 /* 42 * nis.h 43 * 44 * This file is the main include file for NIS clients. It contains 45 * both the client library function defines and the various data 46 * structures used by the NIS service. It includes the file nis_tags.h 47 * which defines the tag values. This allows the tags to change without 48 * having to change the nis.x file. 49 * 50 * NOTE : THIS FILE IS NOT GENERATED WITH RPCGEN ! SO YOU HAVE TO 51 * ADD ALL THE CHANGES ON nis_*.x FILES HERE AGAIN ! 52 * 53 * I have removed all the Solaris internal structs and variables, 54 * because they are not supported, Sun changed them between various 55 * releases and they shouldn't be used in user programs. 56 * <kukuk@suse.de> 57 */ 58 59 60 #ifndef __nis_object_h 61 #define __nis_object_h 62 63 #define NIS_MAXSTRINGLEN 255 64 #define NIS_MAXNAMELEN 1024 65 #define NIS_MAXATTRNAME 32 66 #define NIS_MAXATTRVAL 2048 67 #define NIS_MAXCOLUMNS 64 68 #define NIS_MAXATTR 16 69 #define NIS_MAXPATH 1024 70 #define NIS_MAXREPLICAS 128 71 #define NIS_MAXLINKS 16 72 #define NIS_PK_NONE 0 73 #define NIS_PK_DH 1 74 #define NIS_PK_RSA 2 75 #define NIS_PK_KERB 3 76 #define NIS_PK_DHEXT 4 77 78 struct nis_attr { 79 char *zattr_ndx; 80 struct { 81 u_int zattr_val_len; 82 char *zattr_val_val; 83 } zattr_val; 84 }; 85 typedef struct nis_attr nis_attr; 86 87 typedef char *nis_name; 88 89 enum zotypes { 90 BOGUS_OBJ = 0, 91 NO_OBJ = 1, 92 DIRECTORY_OBJ = 2, 93 GROUP_OBJ = 3, 94 TABLE_OBJ = 4, 95 ENTRY_OBJ = 5, 96 LINK_OBJ = 6, 97 PRIVATE_OBJ = 7, 98 NIS_BOGUS_OBJ = 0, 99 NIS_NO_OBJ = 1, 100 NIS_DIRECTORY_OBJ = 2, 101 NIS_GROUP_OBJ = 3, 102 NIS_TABLE_OBJ = 4, 103 NIS_ENTRY_OBJ = 5, 104 NIS_LINK_OBJ = 6, 105 NIS_PRIVATE_OBJ = 7 106 }; 107 typedef enum zotypes zotypes; 108 109 enum nstype { 110 UNKNOWN = 0, 111 NIS = 1, 112 SUNYP = 2, 113 IVY = 3, 114 DNS = 4, 115 X500 = 5, 116 DNANS = 6, 117 XCHS = 7, 118 CDS = 8, 119 }; 120 typedef enum nstype nstype; 121 122 struct oar_mask { 123 uint32_t oa_rights; 124 zotypes oa_otype; 125 }; 126 typedef struct oar_mask oar_mask; 127 128 struct endpoint { 129 char *uaddr; 130 char *family; 131 char *proto; 132 }; 133 typedef struct endpoint endpoint; 134 135 struct nis_server { 136 nis_name name; 137 struct { 138 u_int ep_len; 139 endpoint *ep_val; 140 } ep; 141 uint32_t key_type; 142 netobj pkey; 143 }; 144 typedef struct nis_server nis_server; 145 146 struct directory_obj { 147 nis_name do_name; 148 nstype do_type; 149 struct { 150 u_int do_servers_len; 151 nis_server *do_servers_val; 152 } do_servers; 153 uint32_t do_ttl; 154 struct { 155 u_int do_armask_len; 156 oar_mask *do_armask_val; 157 } do_armask; 158 }; 159 typedef struct directory_obj directory_obj; 160 161 #define EN_BINARY 1 162 #define EN_CRYPT 2 163 #define EN_XDR 4 164 #define EN_MODIFIED 8 165 #define EN_ASN1 64 166 167 struct entry_col { 168 uint32_t ec_flags; 169 struct { 170 u_int ec_value_len; 171 char *ec_value_val; 172 } ec_value; 173 }; 174 typedef struct entry_col entry_col; 175 176 struct entry_obj { 177 char *en_type; 178 struct { 179 u_int en_cols_len; 180 entry_col *en_cols_val; 181 } en_cols; 182 }; 183 typedef struct entry_obj entry_obj; 184 185 struct group_obj { 186 uint32_t gr_flags; 187 struct { 188 u_int gr_members_len; 189 nis_name *gr_members_val; 190 } gr_members; 191 }; 192 typedef struct group_obj group_obj; 193 194 struct link_obj { 195 zotypes li_rtype; 196 struct { 197 u_int li_attrs_len; 198 nis_attr *li_attrs_val; 199 } li_attrs; 200 nis_name li_name; 201 }; 202 typedef struct link_obj link_obj; 203 204 #define TA_BINARY 1 205 #define TA_CRYPT 2 206 #define TA_XDR 4 207 #define TA_SEARCHABLE 8 208 #define TA_CASE 16 209 #define TA_MODIFIED 32 210 #define TA_ASN1 64 211 212 struct table_col { 213 char *tc_name; 214 uint32_t tc_flags; 215 uint32_t tc_rights; 216 }; 217 typedef struct table_col table_col; 218 219 struct table_obj { 220 char *ta_type; 221 int ta_maxcol; 222 u_char ta_sep; 223 struct { 224 u_int ta_cols_len; 225 table_col *ta_cols_val; 226 } ta_cols; 227 char *ta_path; 228 }; 229 typedef struct table_obj table_obj; 230 231 struct objdata { 232 zotypes zo_type; 233 union { 234 struct directory_obj di_data; 235 struct group_obj gr_data; 236 struct table_obj ta_data; 237 struct entry_obj en_data; 238 struct link_obj li_data; 239 struct { 240 u_int po_data_len; 241 char *po_data_val; 242 } po_data; 243 } objdata_u; 244 }; 245 typedef struct objdata objdata; 246 247 struct nis_oid { 248 uint32_t ctime; 249 uint32_t mtime; 250 }; 251 typedef struct nis_oid nis_oid; 252 253 struct nis_object { 254 nis_oid zo_oid; 255 nis_name zo_name; 256 nis_name zo_owner; 257 nis_name zo_group; 258 nis_name zo_domain; 259 uint32_t zo_access; 260 uint32_t zo_ttl; 261 objdata zo_data; 262 }; 263 typedef struct nis_object nis_object; 264 265 #endif /* if __nis_object_h */ 266 267 enum nis_error { 268 NIS_SUCCESS = 0, 269 NIS_S_SUCCESS = 1, 270 NIS_NOTFOUND = 2, 271 NIS_S_NOTFOUND = 3, 272 NIS_CACHEEXPIRED = 4, 273 NIS_NAMEUNREACHABLE = 5, 274 NIS_UNKNOWNOBJ = 6, 275 NIS_TRYAGAIN = 7, 276 NIS_SYSTEMERROR = 8, 277 NIS_CHAINBROKEN = 9, 278 NIS_PERMISSION = 10, 279 NIS_NOTOWNER = 11, 280 NIS_NOT_ME = 12, 281 NIS_NOMEMORY = 13, 282 NIS_NAMEEXISTS = 14, 283 NIS_NOTMASTER = 15, 284 NIS_INVALIDOBJ = 16, 285 NIS_BADNAME = 17, 286 NIS_NOCALLBACK = 18, 287 NIS_CBRESULTS = 19, 288 NIS_NOSUCHNAME = 20, 289 NIS_NOTUNIQUE = 21, 290 NIS_IBMODERROR = 22, 291 NIS_NOSUCHTABLE = 23, 292 NIS_TYPEMISMATCH = 24, 293 NIS_LINKNAMEERROR = 25, 294 NIS_PARTIAL = 26, 295 NIS_TOOMANYATTRS = 27, 296 NIS_RPCERROR = 28, 297 NIS_BADATTRIBUTE = 29, 298 NIS_NOTSEARCHABLE = 30, 299 NIS_CBERROR = 31, 300 NIS_FOREIGNNS = 32, 301 NIS_BADOBJECT = 33, 302 NIS_NOTSAMEOBJ = 34, 303 NIS_MODFAIL = 35, 304 NIS_BADREQUEST = 36, 305 NIS_NOTEMPTY = 37, 306 NIS_COLDSTART_ERR = 38, 307 NIS_RESYNC = 39, 308 NIS_FAIL = 40, 309 NIS_UNAVAIL = 41, 310 NIS_RES2BIG = 42, 311 NIS_SRVAUTH = 43, 312 NIS_CLNTAUTH = 44, 313 NIS_NOFILESPACE = 45, 314 NIS_NOPROC = 46, 315 NIS_DUMPLATER = 47, 316 }; 317 typedef enum nis_error nis_error; 318 319 struct nis_result { 320 nis_error status; 321 struct { 322 u_int objects_len; 323 nis_object *objects_val; 324 } objects; 325 netobj cookie; 326 uint32_t zticks; 327 uint32_t dticks; 328 uint32_t aticks; 329 uint32_t cticks; 330 }; 331 typedef struct nis_result nis_result; 332 333 struct ns_request { 334 nis_name ns_name; 335 struct { 336 u_int ns_object_len; 337 nis_object *ns_object_val; 338 } ns_object; 339 }; 340 typedef struct ns_request ns_request; 341 342 struct ib_request { 343 nis_name ibr_name; 344 struct { 345 u_int ibr_srch_len; 346 nis_attr *ibr_srch_val; 347 } ibr_srch; 348 uint32_t ibr_flags; 349 struct { 350 u_int ibr_obj_len; 351 nis_object *ibr_obj_val; 352 } ibr_obj; 353 struct { 354 u_int ibr_cbhost_len; 355 nis_server *ibr_cbhost_val; 356 } ibr_cbhost; 357 u_int ibr_bufsize; 358 netobj ibr_cookie; 359 }; 360 typedef struct ib_request ib_request; 361 362 struct ping_args { 363 nis_name dir; 364 uint32_t stamp; 365 }; 366 typedef struct ping_args ping_args; 367 368 enum log_entry_t { 369 LOG_NOP = 0, 370 ADD_NAME = 1, 371 REM_NAME = 2, 372 MOD_NAME_OLD = 3, 373 MOD_NAME_NEW = 4, 374 ADD_IBASE = 5, 375 REM_IBASE = 6, 376 MOD_IBASE = 7, 377 UPD_STAMP = 8, 378 }; 379 typedef enum log_entry_t log_entry_t; 380 381 struct log_entry { 382 uint32_t le_time; 383 log_entry_t le_type; 384 nis_name le_princp; 385 nis_name le_name; 386 struct { 387 u_int le_attrs_len; 388 nis_attr *le_attrs_val; 389 } le_attrs; 390 nis_object le_object; 391 }; 392 typedef struct log_entry log_entry; 393 394 struct log_result { 395 nis_error lr_status; 396 netobj lr_cookie; 397 struct { 398 u_int lr_entries_len; 399 log_entry *lr_entries_val; 400 } lr_entries; 401 }; 402 typedef struct log_result log_result; 403 404 struct cp_result { 405 nis_error cp_status; 406 uint32_t cp_zticks; 407 uint32_t cp_dticks; 408 }; 409 typedef struct cp_result cp_result; 410 411 struct nis_tag { 412 uint32_t tag_type; 413 char *tag_val; 414 }; 415 typedef struct nis_tag nis_tag; 416 417 struct nis_taglist { 418 struct { 419 u_int tags_len; 420 nis_tag *tags_val; 421 } tags; 422 }; 423 typedef struct nis_taglist nis_taglist; 424 425 struct dump_args { 426 nis_name da_dir; 427 uint32_t da_time; 428 struct { 429 u_int da_cbhost_len; 430 nis_server *da_cbhost_val; 431 } da_cbhost; 432 }; 433 typedef struct dump_args dump_args; 434 435 struct fd_args { 436 nis_name dir_name; 437 nis_name requester; 438 }; 439 typedef struct fd_args fd_args; 440 441 struct fd_result { 442 nis_error status; 443 nis_name source; 444 struct { 445 u_int dir_data_len; 446 char *dir_data_val; 447 } dir_data; 448 struct { 449 u_int signature_len; 450 char *signature_val; 451 } signature; 452 }; 453 typedef struct fd_result fd_result; 454 455 /* Generic client creating flags */ 456 #define ZMH_VC 1 457 #define ZMH_DG 2 458 #define ZMH_AUTH 4 459 460 /* Testing Access rights for objects */ 461 462 #define NIS_READ_ACC 1 463 #define NIS_MODIFY_ACC 2 464 #define NIS_CREATE_ACC 4 465 #define NIS_DESTROY_ACC 8 466 /* Test macros. a == access rights, m == desired rights. */ 467 #define NIS_WORLD(a, m) (((a) & (m)) != 0) 468 #define NIS_GROUP(a, m) (((a) & ((m) << 8)) != 0) 469 #define NIS_OWNER(a, m) (((a) & ((m) << 16)) != 0) 470 #define NIS_NOBODY(a, m) (((a) & ((m) << 24)) != 0) 471 /* 472 * EOL Alert - The following non-prefixed test macros are 473 * here for backward compatibility, and will be not be present 474 * in future releases - use the NIS_*() macros above. 475 */ 476 #define WORLD(a, m) (((a) & (m)) != 0) 477 #define GROUP(a, m) (((a) & ((m) << 8)) != 0) 478 #define OWNER(a, m) (((a) & ((m) << 16)) != 0) 479 #define NOBODY(a, m) (((a) & ((m) << 24)) != 0) 480 481 #define OATYPE(d, n) (((d)->do_armask.do_armask_val+n)->oa_otype) 482 #define OARIGHTS(d, n) (((d)->do_armask.do_armask_val+n)->oa_rights) 483 #define WORLD_DEFAULT (NIS_READ_ACC) 484 #define GROUP_DEFAULT (NIS_READ_ACC << 8) 485 #define OWNER_DEFAULT ((NIS_READ_ACC + NIS_MODIFY_ACC + NIS_CREATE_ACC +\ 486 NIS_DESTROY_ACC) << 16) 487 #define DEFAULT_RIGHTS (WORLD_DEFAULT | GROUP_DEFAULT | OWNER_DEFAULT) 488 489 /* Result manipulation defines ... */ 490 #define NIS_RES_NUMOBJ(x) ((x)->objects.objects_len) 491 #define NIS_RES_OBJECT(x) ((x)->objects.objects_val) 492 #define NIS_RES_COOKIE(x) ((x)->cookie) 493 #define NIS_RES_STATUS(x) ((x)->status) 494 495 /* These defines make getting at the variant part of the object easier. */ 496 #define TA_data zo_data.objdata_u.ta_data 497 #define EN_data zo_data.objdata_u.en_data 498 #define DI_data zo_data.objdata_u.di_data 499 #define LI_data zo_data.objdata_u.li_data 500 #define GR_data zo_data.objdata_u.gr_data 501 502 #define __type_of(o) ((o)->zo_data.zo_type) 503 504 /* Declarations for the internal subroutines in nislib.c */ 505 enum name_pos {SAME_NAME, HIGHER_NAME, LOWER_NAME, NOT_SEQUENTIAL, BAD_NAME}; 506 typedef enum name_pos name_pos; 507 508 /* 509 * Defines for getting at column data in entry objects. Because RPCGEN 510 * generates some rather wordy structures, we create some defines that 511 * collapse the needed keystrokes to access a particular value using 512 * these definitions they take an nis_object *, and an int and return 513 * a u_char * for Value, and an int for length. 514 */ 515 #define ENTRY_VAL(obj, col) (obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_val 516 #define ENTRY_LEN(obj, col) (obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len 517 518 519 /* Prototypes, and extern declarations for the NIS library functions. */ 520 #include <rpcsvc/nislib.h> 521 #endif 522 523 /* 524 * nis_3.h 525 * 526 * This file contains definitions that are only of interest to the actual 527 * service daemon and client stubs. Normal users of NIS will not include 528 * this file. 529 * 530 * NOTE : This include file is automatically created by a combination 531 * of rpcgen and sed. DO NOT EDIT IT, change the nis.x file instead 532 * and then remake this file. 533 */ 534 #ifndef __nis_3_h 535 #define __nis_3_h 536 537 #define NIS_PROG 100300 538 #define NIS_VERSION 3 539 540 #define NIS_LOOKUP 1 541 extern nis_result * nis_lookup_3 (ns_request *, CLIENT *) __THROW; 542 extern nis_result * nis_lookup_3_svc (ns_request *, struct svc_req *) __THROW; 543 #define NIS_ADD 2 544 extern nis_result * nis_add_3 (ns_request *, CLIENT *) __THROW; 545 extern nis_result * nis_add_3_svc (ns_request *, struct svc_req *) __THROW; 546 #define NIS_MODIFY 3 547 extern nis_result * nis_modify_3 (ns_request *, CLIENT *) __THROW; 548 extern nis_result * nis_modify_3_svc (ns_request *, struct svc_req *) __THROW; 549 #define NIS_REMOVE 4 550 extern nis_result * nis_remove_3 (ns_request *, CLIENT *) __THROW; 551 extern nis_result * nis_remove_3_svc (ns_request *, struct svc_req *) __THROW; 552 #define NIS_IBLIST 5 553 extern nis_result * nis_iblist_3 (ib_request *, CLIENT *) __THROW; 554 extern nis_result * nis_iblist_3_svc (ib_request *, struct svc_req *) __THROW; 555 #define NIS_IBADD 6 556 extern nis_result * nis_ibadd_3 (ib_request *, CLIENT *) __THROW; 557 extern nis_result * nis_ibadd_3_svc (ib_request *, struct svc_req *) __THROW; 558 #define NIS_IBMODIFY 7 559 extern nis_result * nis_ibmodify_3 (ib_request *, CLIENT *) __THROW; 560 extern nis_result * nis_ibmodify_3_svc (ib_request *, struct svc_req *) 561 __THROW; 562 #define NIS_IBREMOVE 8 563 extern nis_result * nis_ibremove_3 (ib_request *, CLIENT *) __THROW; 564 extern nis_result * nis_ibremove_3_svc (ib_request *, struct svc_req *) 565 __THROW; 566 #define NIS_IBFIRST 9 567 extern nis_result * nis_ibfirst_3 (ib_request *, CLIENT *) __THROW; 568 extern nis_result * nis_ibfirst_3_svc (ib_request *, struct svc_req *) 569 __THROW; 570 #define NIS_IBNEXT 10 571 extern nis_result * nis_ibnext_3 (ib_request *, CLIENT *) __THROW; 572 extern nis_result * nis_ibnext_3_svc (ib_request *, struct svc_req *) __THROW; 573 #define NIS_FINDDIRECTORY 12 574 extern fd_result * nis_finddirectory_3 (fd_args *, CLIENT *) __THROW; 575 extern fd_result * nis_finddirectory_3_svc (fd_args *, 576 struct svc_req *) __THROW; 577 #define NIS_STATUS 14 578 extern nis_taglist * nis_status_3 (nis_taglist *, CLIENT *) __THROW; 579 extern nis_taglist * nis_status_3_svc (nis_taglist *, struct svc_req *) 580 __THROW; 581 #define NIS_DUMPLOG 15 582 extern log_result * nis_dumplog_3 (dump_args *, CLIENT *) __THROW; 583 extern log_result * nis_dumplog_3_svc (dump_args *, struct svc_req *) __THROW; 584 #define NIS_DUMP 16 585 extern log_result * nis_dump_3 (dump_args *, CLIENT *) __THROW; 586 extern log_result * nis_dump_3_svc (dump_args *, struct svc_req *) __THROW; 587 #define NIS_CALLBACK 17 588 extern bool_t * nis_callback_3 (netobj *, CLIENT *) __THROW; 589 extern bool_t * nis_callback_3_svc (netobj *, struct svc_req *) __THROW; 590 #define NIS_CPTIME 18 591 extern uint32_t * nis_cptime_3 (nis_name *, CLIENT *) __THROW; 592 extern uint32_t * nis_cptime_3_svc (nis_name *, struct svc_req *) __THROW; 593 #define NIS_CHECKPOINT 19 594 extern cp_result * nis_checkpoint_3 (nis_name *, CLIENT *) __THROW; 595 extern cp_result * nis_checkpoint_3_svc (nis_name *, struct svc_req *) 596 __THROW; 597 #define NIS_PING 20 598 extern void * nis_ping_3 (ping_args *, CLIENT *) __THROW; 599 extern void * nis_ping_3_svc (ping_args *, struct svc_req *) __THROW; 600 #define NIS_SERVSTATE 21 601 extern nis_taglist * nis_servstate_3 (nis_taglist *, CLIENT *) __THROW; 602 extern nis_taglist * nis_servstate_3_svc (nis_taglist *, 603 struct svc_req *) __THROW; 604 #define NIS_MKDIR 22 605 extern nis_error * nis_mkdir_3 (nis_name *, CLIENT *) __THROW; 606 extern nis_error * nis_mkdir_3_svc (nis_name *, struct svc_req *) __THROW; 607 #define NIS_RMDIR 23 608 extern nis_error * nis_rmdir_3 (nis_name *, CLIENT *) __THROW; 609 extern nis_error * nis_rmdir_3_svc (nis_name *, struct svc_req *) __THROW; 610 #define NIS_UPDKEYS 24 611 extern nis_error * nis_updkeys_3 (nis_name *, CLIENT *) __THROW; 612 extern nis_error * nis_updkeys_3_svc (nis_name *, struct svc_req *) __THROW; 613 614 __END_DECLS 615 616 #endif /* ! _RPCSVC_NIS_H */ 617