home *** CD-ROM | disk | FTP | other *** search
- /* History:
- 5/3/91 DJB modified to have safe behavior under !HAVE_UCRED
- 5/1/91 DJB baseline public domain
- */
-
- /*
-
- struct ucred *getfcred(f) struct file *f; returns the user credentials
- for open file f (in user memory). Note that on machines without struct
- ucred, all open file descriptions are considered to be owned by root.
-
- getfcredstrerr is a strerrfun for getfcred().
-
- */
-
- #include "structfile.h"
- #include "structucred.h"
- #include "getfcred.h"
- #include "kmem.h"
- #include "strerr.h"
- #include "conffcredptr.h"
- #include "confhaveucred.h"
-
- static int getfcrederrno = 0;
-
- static struct strerrtab e[] = {
- { 0, "getfcred error 0", 0 }
- #define GF_KMEM 1
- , { GF_KMEM, "cannot get file credentials: ", kmemstrerr }
- } ;
-
- char *getfcredstrerr(ke)
- strerrfun *ke;
- {
- return strerrtaberr(ke,getfcrederrno,e,sizeof(e)/sizeof(*e),"unknown getfcred error");
- }
-
- static struct ucred uc;
-
- struct ucred *getfcred(f)
- struct file *f;
- {
- #ifndef HAVE_UCRED
- uc.uid = -1; uc.gid = -1; /*XXX*/
- return &uc;
- #else
- #ifdef FCRED_ISNOT_POINTER
- return &(f->f_cred);
- #else
- if (kmemcpy((char *) &uc,(char *) f->f_cred,sizeof(uc)) == -1)
- RETERN(0,getfcrederrno,GF_KMEM)
- return &uc;
- #endif
- #endif
- }
-