1 /* $NetBSD: pcnfsd_cache.c,v 1.3 1997/10/25 13:45:57 lukem Exp $ */
3 /* RE_SID: @(%)/usr/dosnfs/shades_SCCS/unix/pcnfsd/v2/src/SCCS/s.pcnfsd_cache.c 1.1 91/09/03 12:45:14 SMI */
5 **=====================================================================
6 ** Copyright (c) 1986,1987,1988,1989,1990,1991 by Sun Microsystems, Inc.
7 ** @(#)pcnfsd_cache.c 1.1 9/3/91
8 **=====================================================================
11 **=====================================================================
12 ** I N C L U D E F I L E S E C T I O N *
14 ** If your port requires different include files, add a suitable *
15 ** #define in the customization section, and make the inclusion or *
16 ** exclusion of the files conditional on this. *
17 **=====================================================================
31 **---------------------------------------------------------------------
32 ** Misc. variable definitions
33 **---------------------------------------------------------------------
37 #define CACHE_SIZE 16 /* keep it small, as linear searches are done */
42 char cuname
[10]; /* keep this even for machines with alignment
44 } User_cache
[CACHE_SIZE
];
48 **---------------------------------------------------------------------
49 ** User cache support procedures
50 **---------------------------------------------------------------------
55 check_cache(name
, pw
, p_uid
, p_gid
)
64 for (i
= 0; i
< CACHE_SIZE
; i
++) {
65 if (!strcmp(User_cache
[i
].cuname
, name
)) {
67 c2
= strlen(User_cache
[i
].cpw
);
69 !(strcmp(User_cache
[i
].cpw
,
70 crypt(pw
, User_cache
[i
].cpw
)))) {
71 *p_uid
= User_cache
[i
].cuid
;
72 *p_gid
= User_cache
[i
].cgid
;
75 User_cache
[i
].cuname
[0] = '\0'; /* nuke entry */
88 for (i
= CACHE_SIZE
- 1; i
> 0; i
--)
89 User_cache
[i
] = User_cache
[i
- 1];
90 User_cache
[0].cuid
= p
->pw_uid
;
91 User_cache
[0].cgid
= p
->pw_gid
;
92 (void) strlcpy(User_cache
[0].cpw
, p
->pw_passwd
,
93 sizeof(User_cache
[0].cpw
));
94 (void) strlcpy(User_cache
[0].cuname
, p
->pw_name
,
95 sizeof(User_cache
[0].cuname
));
98 #endif /* USER_CACHE */