Home | History | Annotate | Line # | Download | only in rpc.pcnfsd
pcnfsd_v2.c revision 1.5.2.1
      1  1.5.2.1  veego /*	$NetBSD: pcnfsd_v2.c,v 1.5.2.1 1997/11/09 21:52:26 veego Exp $	*/
      2      1.2    gwr 
      3      1.1    jtc /* RE_SID: @(%)/usr/dosnfs/shades_SCCS/unix/pcnfsd/v2/src/SCCS/s.pcnfsd_v2.c 1.2 91/12/18 13:26:13 SMI */
      4      1.1    jtc /*
      5      1.1    jtc **=====================================================================
      6      1.1    jtc ** Copyright (c) 1986,1987,1988,1989,1990,1991 by Sun Microsystems, Inc.
      7      1.1    jtc **	@(#)pcnfsd_v2.c	1.2	12/18/91
      8      1.1    jtc **=====================================================================
      9      1.1    jtc */
     10      1.1    jtc /*
     11      1.1    jtc **=====================================================================
     12      1.1    jtc **             I N C L U D E   F I L E   S E C T I O N                *
     13      1.1    jtc **                                                                    *
     14      1.1    jtc ** If your port requires different include files, add a suitable      *
     15      1.1    jtc ** #define in the customization section, and make the inclusion or    *
     16      1.1    jtc ** exclusion of the files conditional on this.                        *
     17      1.1    jtc **=====================================================================
     18      1.1    jtc */
     19      1.1    jtc 
     20      1.1    jtc #include <sys/file.h>
     21      1.1    jtc #include <sys/ioctl.h>
     22  1.5.2.1  veego #include <sys/stat.h>
     23  1.5.2.1  veego 
     24  1.5.2.1  veego #include <grp.h>
     25      1.1    jtc #include <netdb.h>
     26  1.5.2.1  veego #include <pwd.h>
     27  1.5.2.1  veego #include <signal.h>
     28  1.5.2.1  veego #include <stdio.h>
     29  1.5.2.1  veego #include <stdlib.h>
     30      1.1    jtc #include <string.h>
     31  1.5.2.1  veego #include <unistd.h>
     32      1.1    jtc 
     33      1.1    jtc #ifdef USE_YP
     34      1.1    jtc #include <rpcsvc/ypclnt.h>
     35      1.1    jtc #endif
     36      1.1    jtc 
     37      1.1    jtc #ifndef SYSV
     38      1.1    jtc #include <sys/wait.h>
     39      1.1    jtc #endif
     40      1.1    jtc 
     41      1.1    jtc #ifdef ISC_2_0
     42      1.1    jtc #include <sys/fcntl.h>
     43      1.1    jtc #endif
     44      1.1    jtc 
     45      1.1    jtc #ifdef SHADOW_SUPPORT
     46      1.1    jtc #include <shadow.h>
     47      1.1    jtc #endif
     48      1.1    jtc 
     49  1.5.2.1  veego #include "common.h"
     50  1.5.2.1  veego #include "pcnfsd.h"
     51  1.5.2.1  veego #include "extern.h"
     52      1.1    jtc 
     53      1.1    jtc /*
     54      1.1    jtc **=====================================================================
     55      1.4    gwr **                      C O D E   S E C T I O N                       *
     56      1.4    gwr **=====================================================================
     57      1.1    jtc */
     58      1.1    jtc 
     59      1.1    jtc 
     60      1.1    jtc static char no_comment[] = "No comment";
     61      1.1    jtc static char not_supported[] = "Not supported";
     62      1.1    jtc static char pcnfsd_version[] = "@(#)pcnfsd_v2.c	1.2 - rpc.pcnfsd V2.0 (c) 1991 Sun Technology Enterprises, Inc.";
     63      1.1    jtc 
     64      1.1    jtc /*ARGSUSED*/
     65  1.5.2.1  veego void   *
     66  1.5.2.1  veego pcnfsd2_null_2_svc(arg, req)
     67  1.5.2.1  veego 	void   *arg;
     68  1.5.2.1  veego 	struct svc_req *req;
     69  1.5.2.1  veego {
     70  1.5.2.1  veego 	static char dummy;
     71  1.5.2.1  veego 	return ((void *) &dummy);
     72  1.5.2.1  veego }
     73  1.5.2.1  veego 
     74  1.5.2.1  veego v2_auth_results *
     75  1.5.2.1  veego pcnfsd2_auth_2_svc(arg, req)
     76  1.5.2.1  veego 	v2_auth_args *arg;
     77  1.5.2.1  veego 	struct svc_req *req;
     78  1.5.2.1  veego {
     79  1.5.2.1  veego 	static v2_auth_results r;
     80  1.5.2.1  veego 
     81  1.5.2.1  veego 	char    uname[32];
     82  1.5.2.1  veego 	char    pw[64];
     83  1.5.2.1  veego 	int     c1, c2;
     84  1.5.2.1  veego 	struct passwd *p;
     85  1.5.2.1  veego 	static u_int extra_gids[EXTRAGIDLEN];
     86  1.5.2.1  veego 	static char home[256];
     87      1.1    jtc #ifdef USE_YP
     88  1.5.2.1  veego 	char   *yphome;
     89  1.5.2.1  veego 	char   *cp;
     90  1.5.2.1  veego #endif				/* USE_YP */
     91      1.1    jtc 
     92      1.1    jtc 
     93      1.1    jtc 	r.stat = AUTH_RES_FAIL;	/* assume failure */
     94  1.5.2.1  veego 	r.uid = (int) -2;
     95  1.5.2.1  veego 	r.gid = (int) -2;
     96      1.1    jtc 	r.cm = &no_comment[0];
     97      1.1    jtc 	r.gids.gids_len = 0;
     98      1.1    jtc 	r.gids.gids_val = &extra_gids[0];
     99      1.1    jtc 	home[0] = '\0';
    100      1.1    jtc 	r.home = &home[0];
    101      1.1    jtc 	r.def_umask = umask(0);
    102  1.5.2.1  veego 	(void) umask(r.def_umask);	/* or use 022 */
    103      1.1    jtc 
    104      1.1    jtc 	scramble(arg->id, uname);
    105      1.1    jtc 	scramble(arg->pw, pw);
    106      1.1    jtc 
    107      1.1    jtc #ifdef USER_CACHE
    108  1.5.2.1  veego 	if (check_cache(uname, pw, &r.uid, &r.gid)) {
    109  1.5.2.1  veego 		r.stat = AUTH_RES_OK;
    110      1.1    jtc #ifdef WTMP
    111      1.1    jtc 		wlogin(uname, req);
    112      1.1    jtc #endif
    113  1.5.2.1  veego 		fillin_extra_groups
    114  1.5.2.1  veego 		    (uname, r.gid, &r.gids.gids_len, extra_gids);
    115      1.1    jtc #ifdef USE_YP
    116      1.1    jtc 		yphome = find_entry(uname, "auto.home");
    117  1.5.2.1  veego 		if (yphome) {
    118      1.1    jtc 			strcpy(home, yphome);
    119      1.1    jtc 			free(yphome);
    120      1.1    jtc 			cp = strchr(home, ':');
    121      1.1    jtc 			cp++;
    122      1.1    jtc 			cp = strchr(cp, ':');
    123  1.5.2.1  veego 			if (cp)
    124      1.1    jtc 				*cp = '/';
    125      1.1    jtc 		}
    126      1.1    jtc #endif
    127  1.5.2.1  veego 		return (&r);
    128  1.5.2.1  veego 	}
    129      1.1    jtc #endif
    130      1.1    jtc 
    131      1.1    jtc 	p = get_password(uname);
    132  1.5.2.1  veego 	if (p == (struct passwd *) NULL)
    133  1.5.2.1  veego 		return (&r);
    134      1.1    jtc 
    135      1.1    jtc 	c1 = strlen(pw);
    136      1.1    jtc 	c2 = strlen(p->pw_passwd);
    137      1.1    jtc 	if ((c1 && !c2) || (c2 && !c1) ||
    138  1.5.2.1  veego 	    (strcmp(p->pw_passwd, crypt(pw, p->pw_passwd)))) {
    139  1.5.2.1  veego 		return (&r);
    140  1.5.2.1  veego 	}
    141      1.1    jtc 	r.stat = AUTH_RES_OK;
    142      1.1    jtc 	r.uid = p->pw_uid;
    143      1.1    jtc 	r.gid = p->pw_gid;
    144      1.1    jtc #ifdef WTMP
    145      1.1    jtc 	wlogin(uname, req);
    146      1.1    jtc #endif
    147  1.5.2.1  veego 	fillin_extra_groups(uname, r.gid, &r.gids.gids_len, extra_gids);
    148      1.1    jtc 
    149      1.1    jtc #ifdef USE_YP
    150      1.1    jtc 	yphome = find_entry(uname, "auto.home");
    151  1.5.2.1  veego 	if (yphome) {
    152      1.1    jtc 		strcpy(home, yphome);
    153      1.1    jtc 		free(yphome);
    154      1.1    jtc 		cp = strchr(home, ':');
    155      1.1    jtc 		cp++;
    156      1.1    jtc 		cp = strchr(cp, ':');
    157  1.5.2.1  veego 		if (cp)
    158      1.1    jtc 			*cp = '/';
    159      1.1    jtc 	}
    160      1.1    jtc #endif
    161      1.1    jtc 
    162      1.1    jtc #ifdef USER_CACHE
    163      1.1    jtc 	add_cache_entry(p);
    164      1.1    jtc #endif
    165      1.1    jtc 
    166  1.5.2.1  veego 	return (&r);
    167      1.1    jtc 
    168      1.1    jtc }
    169      1.1    jtc 
    170  1.5.2.1  veego v2_pr_init_results *
    171  1.5.2.1  veego pcnfsd2_pr_init_2_svc(arg, req)
    172  1.5.2.1  veego 	v2_pr_init_args *arg;
    173  1.5.2.1  veego 	struct svc_req *req;
    174      1.1    jtc {
    175  1.5.2.1  veego 	static v2_pr_init_results res;
    176      1.1    jtc 
    177  1.5.2.1  veego 	res.stat =
    178  1.5.2.1  veego 	    (pirstat) pr_init(arg->system, arg->pn, &res.dir);
    179      1.1    jtc 	res.cm = &no_comment[0];
    180      1.1    jtc 
    181      1.1    jtc 
    182  1.5.2.1  veego 	return (&res);
    183      1.1    jtc }
    184      1.1    jtc 
    185  1.5.2.1  veego v2_pr_start_results *
    186  1.5.2.1  veego pcnfsd2_pr_start_2_svc(arg, req)
    187  1.5.2.1  veego 	v2_pr_start_args *arg;
    188  1.5.2.1  veego 	struct svc_req *req;
    189      1.1    jtc {
    190  1.5.2.1  veego 	static v2_pr_start_results res;
    191      1.1    jtc 
    192      1.1    jtc 	res.stat =
    193  1.5.2.1  veego 	    (psrstat) pr_start2(arg->system, arg->pn, arg->user,
    194  1.5.2.1  veego 	    arg->file, arg->opts, &res.id);
    195      1.1    jtc 	res.cm = &no_comment[0];
    196      1.1    jtc 
    197  1.5.2.1  veego 	return (&res);
    198      1.1    jtc }
    199      1.1    jtc /*ARGSUSED*/
    200  1.5.2.1  veego v2_pr_list_results *
    201  1.5.2.1  veego pcnfsd2_pr_list_2_svc(arg, req)
    202  1.5.2.1  veego 	void   *arg;
    203  1.5.2.1  veego 	struct svc_req *req;
    204      1.1    jtc {
    205  1.5.2.1  veego 	static v2_pr_list_results res;
    206      1.1    jtc 
    207  1.5.2.1  veego 	if (printers == NULL)
    208  1.5.2.1  veego 		(void) build_pr_list();
    209      1.1    jtc 	res.cm = &no_comment[0];
    210      1.1    jtc 	res.printers = printers;
    211      1.1    jtc 
    212  1.5.2.1  veego 	return (&res);
    213      1.1    jtc }
    214      1.1    jtc 
    215  1.5.2.1  veego v2_pr_queue_results *
    216  1.5.2.1  veego pcnfsd2_pr_queue_2_svc(arg, req)
    217  1.5.2.1  veego 	v2_pr_queue_args *arg;
    218  1.5.2.1  veego 	struct svc_req *req;
    219      1.1    jtc {
    220  1.5.2.1  veego 	static v2_pr_queue_results res;
    221      1.1    jtc 
    222      1.1    jtc 	res.stat = build_pr_queue(arg->pn, arg->user,
    223  1.5.2.1  veego 	    arg->just_mine, &res.qlen, &res.qshown);
    224      1.1    jtc 	res.cm = &no_comment[0];
    225      1.1    jtc 	res.just_yours = arg->just_mine;
    226      1.1    jtc 	res.jobs = queue;
    227      1.1    jtc 
    228  1.5.2.1  veego 
    229  1.5.2.1  veego 	return (&res);
    230      1.1    jtc }
    231      1.1    jtc 
    232  1.5.2.1  veego v2_pr_status_results *
    233  1.5.2.1  veego pcnfsd2_pr_status_2_svc(arg, req)
    234  1.5.2.1  veego 	v2_pr_status_args *arg;
    235  1.5.2.1  veego 	struct svc_req *req;
    236      1.1    jtc {
    237  1.5.2.1  veego 	static v2_pr_status_results res;
    238  1.5.2.1  veego 	static char status[128];
    239      1.1    jtc 
    240      1.1    jtc 	res.stat = get_pr_status(arg->pn, &res.avail, &res.printing,
    241  1.5.2.1  veego 	    &res.qlen, &res.needs_operator, &status[0]);
    242  1.5.2.1  veego 	res.status = &status[0];
    243      1.1    jtc 	res.cm = &no_comment[0];
    244      1.1    jtc 
    245  1.5.2.1  veego 	return (&res);
    246      1.1    jtc }
    247      1.1    jtc 
    248  1.5.2.1  veego v2_pr_cancel_results *
    249  1.5.2.1  veego pcnfsd2_pr_cancel_2_svc(arg, req)
    250  1.5.2.1  veego 	v2_pr_cancel_args *arg;
    251  1.5.2.1  veego 	struct svc_req *req;
    252      1.1    jtc {
    253  1.5.2.1  veego 	static v2_pr_cancel_results res;
    254      1.1    jtc 
    255      1.1    jtc 	res.stat = pr_cancel(arg->pn, arg->user, arg->id);
    256      1.1    jtc 	res.cm = &no_comment[0];
    257      1.1    jtc 
    258  1.5.2.1  veego 	return (&res);
    259      1.1    jtc }
    260      1.1    jtc /*ARGSUSED*/
    261  1.5.2.1  veego v2_pr_requeue_results *
    262  1.5.2.1  veego pcnfsd2_pr_requeue_2_svc(arg, req)
    263  1.5.2.1  veego 	v2_pr_requeue_args *arg;
    264  1.5.2.1  veego 	struct svc_req *req;
    265      1.1    jtc {
    266  1.5.2.1  veego 	static v2_pr_requeue_results res;
    267      1.1    jtc 	res.stat = PC_RES_FAIL;
    268      1.1    jtc 	res.cm = &not_supported[0];
    269      1.1    jtc 
    270  1.5.2.1  veego 	return (&res);
    271      1.1    jtc }
    272      1.1    jtc /*ARGSUSED*/
    273  1.5.2.1  veego v2_pr_hold_results *
    274  1.5.2.1  veego pcnfsd2_pr_hold_2_svc(arg, req)
    275  1.5.2.1  veego 	v2_pr_hold_args *arg;
    276  1.5.2.1  veego 	struct svc_req *req;
    277      1.1    jtc {
    278  1.5.2.1  veego 	static v2_pr_hold_results res;
    279      1.1    jtc 
    280      1.1    jtc 	res.stat = PC_RES_FAIL;
    281      1.1    jtc 	res.cm = &not_supported[0];
    282      1.1    jtc 
    283  1.5.2.1  veego 	return (&res);
    284      1.1    jtc }
    285      1.1    jtc /*ARGSUSED*/
    286  1.5.2.1  veego v2_pr_release_results *
    287  1.5.2.1  veego pcnfsd2_pr_release_2_svc(arg, req)
    288  1.5.2.1  veego 	v2_pr_release_args *arg;
    289  1.5.2.1  veego 	struct svc_req *req;
    290      1.1    jtc {
    291  1.5.2.1  veego 	static v2_pr_release_results res;
    292      1.1    jtc 
    293      1.1    jtc 	res.stat = PC_RES_FAIL;
    294      1.1    jtc 	res.cm = &not_supported[0];
    295      1.1    jtc 
    296  1.5.2.1  veego 	return (&res);
    297      1.1    jtc }
    298      1.1    jtc /*ARGSUSED*/
    299  1.5.2.1  veego v2_pr_admin_results *
    300  1.5.2.1  veego pcnfsd2_pr_admin_2_svc(arg, req)
    301  1.5.2.1  veego 	v2_pr_admin_args *arg;
    302  1.5.2.1  veego 	struct svc_req *req;
    303      1.1    jtc {
    304  1.5.2.1  veego 	static v2_pr_admin_results res;
    305      1.1    jtc /*
    306      1.1    jtc ** The default action for admin is to fail.
    307      1.1    jtc ** If someone wishes to implement an administration
    308      1.1    jtc ** mechanism, and isn't worried about the security
    309      1.1    jtc ** holes, go right ahead.
    310      1.1    jtc */
    311      1.1    jtc 
    312      1.1    jtc 	res.cm = &not_supported[0];
    313      1.1    jtc 	res.stat = PI_RES_FAIL;
    314      1.1    jtc 
    315  1.5.2.1  veego 	return (&res);
    316      1.1    jtc }
    317      1.1    jtc 
    318      1.1    jtc void
    319      1.1    jtc free_mapreq_results(p)
    320  1.5.2.1  veego 	mapreq_res p;
    321      1.1    jtc {
    322  1.5.2.1  veego 	if (p->mapreq_next)
    323  1.5.2.1  veego 		free_mapreq_results(p->mapreq_next);	/* recurse */
    324  1.5.2.1  veego 	if (p->name)
    325  1.5.2.1  veego 		(void) free(p->name);
    326  1.5.2.1  veego 	(void) free(p);
    327      1.1    jtc 	return;
    328      1.1    jtc }
    329      1.1    jtc 
    330  1.5.2.1  veego static char *my_strdup __P((char *));
    331  1.5.2.1  veego 
    332      1.1    jtc static char *
    333      1.1    jtc my_strdup(s)
    334  1.5.2.1  veego 	char   *s;
    335      1.1    jtc {
    336  1.5.2.1  veego 	char   *r;
    337  1.5.2.1  veego 	r = (char *) grab(strlen(s) + 1);
    338      1.1    jtc 	strcpy(r, s);
    339  1.5.2.1  veego 	return (r);
    340      1.1    jtc }
    341      1.1    jtc 
    342  1.5.2.1  veego v2_mapid_results *
    343  1.5.2.1  veego pcnfsd2_mapid_2_svc(arg, req)
    344  1.5.2.1  veego 	v2_mapid_args *arg;
    345  1.5.2.1  veego 	struct svc_req *req;
    346      1.1    jtc {
    347  1.5.2.1  veego 	static v2_mapid_results res;
    348  1.5.2.1  veego 	struct passwd *p_passwd;
    349  1.5.2.1  veego 	struct group *p_group;
    350      1.1    jtc 
    351  1.5.2.1  veego 	mapreq_arg a;
    352  1.5.2.1  veego 	mapreq_res next_r;
    353  1.5.2.1  veego 	mapreq_res last_r = NULL;
    354      1.1    jtc 
    355      1.1    jtc 
    356  1.5.2.1  veego 	if (res.res_list) {
    357      1.1    jtc 		free_mapreq_results(res.res_list);
    358      1.1    jtc 		res.res_list = NULL;
    359      1.1    jtc 	}
    360      1.1    jtc 	a = arg->req_list;
    361  1.5.2.1  veego 	while (a) {
    362      1.1    jtc 		next_r = (struct mapreq_res_item *)
    363  1.5.2.1  veego 		    grab(sizeof(struct mapreq_res_item));
    364      1.1    jtc 		next_r->stat = MAP_RES_UNKNOWN;
    365      1.1    jtc 		next_r->req = a->req;
    366      1.1    jtc 		next_r->id = a->id;
    367      1.1    jtc 		next_r->name = NULL;
    368      1.1    jtc 		next_r->mapreq_next = NULL;
    369      1.1    jtc 
    370  1.5.2.1  veego 		if (last_r == NULL)
    371      1.1    jtc 			res.res_list = next_r;
    372      1.1    jtc 		else
    373      1.1    jtc 			last_r->mapreq_next = next_r;
    374      1.1    jtc 		last_r = next_r;
    375  1.5.2.1  veego 		switch (a->req) {
    376      1.1    jtc 		case MAP_REQ_UID:
    377  1.5.2.1  veego 			p_passwd = getpwuid((uid_t) a->id);
    378  1.5.2.1  veego 			if (p_passwd) {
    379      1.1    jtc 				next_r->name = my_strdup(p_passwd->pw_name);
    380      1.1    jtc 				next_r->stat = MAP_RES_OK;
    381      1.1    jtc 			}
    382      1.1    jtc 			break;
    383      1.1    jtc 		case MAP_REQ_GID:
    384  1.5.2.1  veego 			p_group = getgrgid((gid_t) a->id);
    385  1.5.2.1  veego 			if (p_group) {
    386      1.1    jtc 				next_r->name = my_strdup(p_group->gr_name);
    387      1.1    jtc 				next_r->stat = MAP_RES_OK;
    388      1.1    jtc 			}
    389      1.1    jtc 			break;
    390      1.1    jtc 		case MAP_REQ_UNAME:
    391      1.1    jtc 			next_r->name = my_strdup(a->name);
    392      1.1    jtc 			p_passwd = getpwnam(a->name);
    393  1.5.2.1  veego 			if (p_passwd) {
    394      1.1    jtc 				next_r->id = p_passwd->pw_uid;
    395      1.1    jtc 				next_r->stat = MAP_RES_OK;
    396      1.1    jtc 			}
    397      1.1    jtc 			break;
    398      1.1    jtc 		case MAP_REQ_GNAME:
    399      1.1    jtc 			next_r->name = my_strdup(a->name);
    400      1.1    jtc 			p_group = getgrnam(a->name);
    401  1.5.2.1  veego 			if (p_group) {
    402      1.1    jtc 				next_r->id = p_group->gr_gid;
    403      1.1    jtc 				next_r->stat = MAP_RES_OK;
    404      1.1    jtc 			}
    405      1.1    jtc 			break;
    406      1.1    jtc 		}
    407  1.5.2.1  veego 		if (next_r->name == NULL)
    408      1.1    jtc 			next_r->name = my_strdup("");
    409      1.1    jtc 		a = a->mapreq_next;
    410      1.1    jtc 	}
    411      1.1    jtc 
    412      1.1    jtc 	res.cm = &no_comment[0];
    413      1.1    jtc 
    414  1.5.2.1  veego 	return (&res);
    415      1.1    jtc }
    416      1.1    jtc 
    417  1.5.2.1  veego 
    418      1.1    jtc /*ARGSUSED*/
    419  1.5.2.1  veego v2_alert_results *
    420  1.5.2.1  veego pcnfsd2_alert_2_svc(arg, req)
    421  1.5.2.1  veego 	v2_alert_args *arg;
    422  1.5.2.1  veego 	struct svc_req *req;
    423      1.1    jtc {
    424  1.5.2.1  veego 	static v2_alert_results res;
    425      1.1    jtc 
    426      1.1    jtc 	res.stat = ALERT_RES_FAIL;
    427      1.1    jtc 	res.cm = &not_supported[0];
    428      1.1    jtc 
    429  1.5.2.1  veego 	return (&res);
    430      1.1    jtc }
    431      1.1    jtc /*ARGSUSED*/
    432  1.5.2.1  veego v2_info_results *
    433  1.5.2.1  veego pcnfsd2_info_2_svc(arg, req)
    434  1.5.2.1  veego 	v2_info_args *arg;
    435  1.5.2.1  veego 	struct svc_req *req;
    436  1.5.2.1  veego {
    437  1.5.2.1  veego 	static v2_info_results res;
    438  1.5.2.1  veego 	static int facilities[FACILITIESMAX];
    439  1.5.2.1  veego 	static int onetime = 1;
    440      1.1    jtc 
    441      1.1    jtc #define UNSUPPORTED -1
    442      1.1    jtc #define QUICK 100
    443      1.1    jtc #define SLOW 2000
    444      1.1    jtc 
    445  1.5.2.1  veego 	if (onetime) {
    446      1.1    jtc 		onetime = 0;
    447      1.1    jtc 		facilities[PCNFSD2_NULL] = QUICK;
    448      1.1    jtc 		facilities[PCNFSD2_INFO] = QUICK;
    449      1.1    jtc 		facilities[PCNFSD2_PR_INIT] = QUICK;
    450      1.1    jtc 		facilities[PCNFSD2_PR_START] = SLOW;
    451  1.5.2.1  veego 		facilities[PCNFSD2_PR_LIST] = QUICK;	/* except first time */
    452      1.1    jtc 		facilities[PCNFSD2_PR_QUEUE] = SLOW;
    453      1.1    jtc 		facilities[PCNFSD2_PR_STATUS] = SLOW;
    454      1.1    jtc 		facilities[PCNFSD2_PR_CANCEL] = SLOW;
    455      1.1    jtc 		facilities[PCNFSD2_PR_ADMIN] = UNSUPPORTED;
    456      1.1    jtc 		facilities[PCNFSD2_PR_REQUEUE] = UNSUPPORTED;
    457      1.1    jtc 		facilities[PCNFSD2_PR_HOLD] = UNSUPPORTED;
    458      1.1    jtc 		facilities[PCNFSD2_PR_RELEASE] = UNSUPPORTED;
    459      1.1    jtc 		facilities[PCNFSD2_MAPID] = QUICK;
    460      1.1    jtc 		facilities[PCNFSD2_AUTH] = QUICK;
    461      1.1    jtc 		facilities[PCNFSD2_ALERT] = QUICK;
    462      1.1    jtc 	}
    463  1.5.2.1  veego 	res.facilities.facilities_len = PCNFSD2_ALERT + 1;
    464      1.1    jtc 	res.facilities.facilities_val = facilities;
    465  1.5.2.1  veego 
    466      1.1    jtc 	res.vers = &pcnfsd_version[0];
    467      1.1    jtc 	res.cm = &no_comment[0];
    468      1.1    jtc 
    469  1.5.2.1  veego 	return (&res);
    470      1.1    jtc }
    471      1.1    jtc 
    472      1.1    jtc 
    473      1.1    jtc 
    474      1.1    jtc void
    475      1.1    jtc fillin_extra_groups(uname, main_gid, len, extra_gids)
    476  1.5.2.1  veego 	char   *uname;
    477  1.5.2.1  veego 	gid_t   main_gid;
    478  1.5.2.1  veego 	int    *len;
    479  1.5.2.1  veego 	gid_t   extra_gids[EXTRAGIDLEN];
    480  1.5.2.1  veego {
    481  1.5.2.1  veego 	struct group *grp;
    482  1.5.2.1  veego 	char  **members;
    483  1.5.2.1  veego 	int     n = 0;
    484      1.1    jtc 
    485      1.1    jtc 	setgrent();
    486      1.1    jtc 
    487  1.5.2.1  veego 	while (n < EXTRAGIDLEN) {
    488      1.1    jtc 		grp = getgrent();
    489  1.5.2.1  veego 		if (grp == NULL)
    490      1.1    jtc 			break;
    491  1.5.2.1  veego 		if (grp->gr_gid == main_gid)
    492      1.1    jtc 			continue;
    493  1.5.2.1  veego 		for (members = grp->gr_mem; members && *members; members++) {
    494  1.5.2.1  veego 			if (!strcmp(*members, uname)) {
    495      1.1    jtc 				extra_gids[n++] = grp->gr_gid;
    496      1.1    jtc 				break;
    497      1.1    jtc 			}
    498      1.1    jtc 		}
    499      1.1    jtc 	}
    500      1.1    jtc 	endgrent();
    501      1.1    jtc 	*len = n;
    502      1.1    jtc }
    503      1.1    jtc 
    504      1.1    jtc #ifdef USE_YP
    505      1.1    jtc /* the following is from rpcsvc/yp_prot.h */
    506      1.1    jtc #define YPMAXDOMAIN 64
    507  1.5.2.1  veego 
    508      1.1    jtc /*
    509      1.1    jtc  * find_entry returns NULL on any error (printing a message) and
    510      1.1    jtc  * otherwise returns a pointer to the malloc'd result. The caller
    511      1.1    jtc  * is responsible for free()ing the result string.
    512      1.1    jtc  */
    513  1.5.2.1  veego char   *
    514      1.1    jtc find_entry(key, map)
    515  1.5.2.1  veego 	char   *key;
    516  1.5.2.1  veego 	char   *map;
    517      1.1    jtc {
    518  1.5.2.1  veego 	int     err;
    519  1.5.2.1  veego 	char   *val = NULL;
    520  1.5.2.1  veego 	char   *cp;
    521  1.5.2.1  veego 	int     len = 0;
    522  1.5.2.1  veego 	static char domain[YPMAXDOMAIN + 1];
    523      1.1    jtc 
    524  1.5.2.1  veego 	if (getdomainname(domain, YPMAXDOMAIN)) {
    525      1.1    jtc 		msg_out("rpc.pcnfsd: getdomainname failed");
    526  1.5.2.1  veego 		return (NULL);
    527      1.1    jtc 	}
    528  1.5.2.1  veego 	if ((err = yp_bind(domain)) != 0) {
    529      1.3    gwr #ifdef	DEBUG
    530      1.1    jtc 		msg_out("rpc.pcnfsd: yp_bind failed");
    531      1.3    gwr #endif
    532  1.5.2.1  veego 		return (NULL);
    533      1.1    jtc 	}
    534      1.1    jtc 	err = yp_match(domain, map, key, strlen(key), &val, &len);
    535      1.1    jtc 
    536      1.1    jtc 	if (err) {
    537      1.1    jtc 		msg_out("rpc.pcnfsd: yp_match failed");
    538      1.5  lukem 		if (val)
    539      1.5  lukem 			free(val);
    540  1.5.2.1  veego 		return (NULL);
    541      1.1    jtc 	}
    542  1.5.2.1  veego 	if ((cp = strchr(val, '\n')) != NULL)
    543  1.5.2.1  veego 		*cp = '\0';	/* in case we get an extra NL at the end */
    544  1.5.2.1  veego 	return (val);
    545      1.1    jtc }
    546      1.1    jtc #endif
    547