Author: mjg
Date: Tue Oct 28 04:59:33 2014
New Revision: 273764
URL: https://svnweb.freebsd.org/changeset/base/273764

Log:
  Simplify sys_getloginclass.
  
  Just use current thread credentials as they have the same accuracy as the
  ones obtained from proc..

Modified:
  head/sys/kern/kern_loginclass.c

Modified: head/sys/kern/kern_loginclass.c
==============================================================================
--- head/sys/kern/kern_loginclass.c     Tue Oct 28 04:33:57 2014        
(r273763)
+++ head/sys/kern/kern_loginclass.c     Tue Oct 28 04:59:33 2014        
(r273764)
@@ -178,24 +178,14 @@ struct getloginclass_args {
 int
 sys_getloginclass(struct thread *td, struct getloginclass_args *uap)
 {
-       int error = 0;
-       size_t lcnamelen;
-       struct proc *p;
        struct loginclass *lc;
+       size_t lcnamelen;
 
-       p = td->td_proc;
-       PROC_LOCK(p);
-       lc = p->p_ucred->cr_loginclass;
-       loginclass_hold(lc);
-       PROC_UNLOCK(p);
-
+       lc = td->td_ucred->cr_loginclass;
        lcnamelen = strlen(lc->lc_name) + 1;
        if (lcnamelen > uap->namelen)
-               error = ERANGE;
-       if (error == 0)
-               error = copyout(lc->lc_name, uap->namebuf, lcnamelen);
-       loginclass_free(lc);
-       return (error);
+               return (ERANGE);
+       return (copyout(lc->lc_name, uap->namebuf, lcnamelen));
 }
 
 /*
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to