linux/net/sunrpc/svcauth.c
<<
>>
Prefs
   1/*
   2 * linux/net/sunrpc/svcauth.c
   3 *
   4 * The generic interface for RPC authentication on the server side.
   5 *
   6 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
   7 *
   8 * CHANGES
   9 * 19-Apr-2000 Chris Evans      - Security fix
  10 */
  11
  12#include <linux/types.h>
  13#include <linux/module.h>
  14#include <linux/sunrpc/types.h>
  15#include <linux/sunrpc/xdr.h>
  16#include <linux/sunrpc/svcsock.h>
  17#include <linux/sunrpc/svcauth.h>
  18#include <linux/err.h>
  19#include <linux/hash.h>
  20
  21#define RPCDBG_FACILITY RPCDBG_AUTH
  22
  23
  24/*
  25 * Table of authenticators
  26 */
  27extern struct auth_ops svcauth_null;
  28extern struct auth_ops svcauth_unix;
  29
  30static DEFINE_SPINLOCK(authtab_lock);
  31static struct auth_ops  *authtab[RPC_AUTH_MAXFLAVOR] = {
  32        [0] = &svcauth_null,
  33        [1] = &svcauth_unix,
  34};
  35
  36int
  37svc_authenticate(struct svc_rqst *rqstp, __be32 *authp)
  38{
  39        rpc_authflavor_t        flavor;
  40        struct auth_ops         *aops;
  41
  42        *authp = rpc_auth_ok;
  43
  44        flavor = svc_getnl(&rqstp->rq_arg.head[0]);
  45
  46        dprintk("svc: svc_authenticate (%d)\n", flavor);
  47
  48        spin_lock(&authtab_lock);
  49        if (flavor >= RPC_AUTH_MAXFLAVOR || !(aops = authtab[flavor]) ||
  50            !try_module_get(aops->owner)) {
  51                spin_unlock(&authtab_lock);
  52                *authp = rpc_autherr_badcred;
  53                return SVC_DENIED;
  54        }
  55        spin_unlock(&authtab_lock);
  56
  57        rqstp->rq_authop = aops;
  58        return aops->accept(rqstp, authp);
  59}
  60EXPORT_SYMBOL_GPL(svc_authenticate);
  61
  62int svc_set_client(struct svc_rqst *rqstp)
  63{
  64        return rqstp->rq_authop->set_client(rqstp);
  65}
  66EXPORT_SYMBOL_GPL(svc_set_client);
  67
  68/* A request,d)oicsvc_getnl" class="sref">svc_getnl(&rqstp->b26">  26ed, htb2now execu>ed class="comment"> *
  60<6a>       26 *
EXPO7T_SYMBOL_GPL(  11
<26nd release56nd resourcepan class="comment"> */
  62int 7ine" name="L2">   2svc7set_client(struct <7 href7"+code=svc_rqst" class="srefstp" rise="line" name="L61">  61 riselass="sref">rqstp)
  63{
  64<7a>   7    return r7stp->aops;
  41
set_client(  66<7a>EXPO7T_SYMBOL_GPL(rq_authop = aops;
);
NULelass"net/sunrpc/svcauth.c#L68" id="L67_getnl" 7lass="sref">svc_getnl(&am78    60<7a>Rame="L41">  41
EXPO8T_SYMBOL_GPL(rq_authop =v(rqstp,   65}
  62int 8ref="+code=authtab_lock" class="srefss="sreput/sunrpc/svcauthss="sreputowner)) {
  51       ="net/sunrpc/svcauth.c#L66" id="L8ref">svc8set_client(struct <8 href8_autherr_badc+code=EXPORT_SYMBOL_GPL" class="s84" class8"line" name="L64">  64<8a>   8href="net/sun="sref">rq_authop-&v(r8stp->  66<8a>EXPO8T_SYMBOL_GPL(  51flavor;
  50     ,s class="sref">aops;
  41
(&am8      60<8a>);
EXPO9T_SYMBOL_GPL(rq_authop thtab_lock);
  49        if (  62int 91_AUTH_MAXFLAVOR" class="sref">RPC_AUTH_MAXFLAVOR || !(aops = vcautvcautlavor]) ||
  50       =8" class="line" nNULet_client);
NULelass         svc9set_client(struct <9 href9_autherr_badcred" claavor]) ||
  50       =" class="line" name="L58">  58        return   64<9a>   9href="net/sunrpc/svcac_rqst" class="rv(r9stp->  66<9a>authtab_lock);
  56
EXPO9T_SYMBOL_GPL(rq_authop-&v((&am98=svc_authenticate" class="sref">svc_authenticate);
  51  12  51flavor;
  50     ="net/sunrpc/svcauth.c#L64" id="L10" class="0fref">linux/types.h&02"+c" 2   linux/module.hrq_authop thtab_lock);
  49        if (linux/sunrp04"+c" 4_AUTH_MAXFLAVOR" class="sref">RPC_AUTH_MAXFLAVOR || !(aops = linux/sunrpc/05"+c" 5autherr_badcred" claavor]) ||
  50       =" class="line" nNULet_client);
NULelass"net/sunrpc/svcauth.c#L68" id="L610svcsock.h0" class="fref">linux/sun06"+c" t;svc: svc_authenticate (">authtab_lock);
  56
linux/sun07"+c" 7ef="+code=EXPORT_SYMBOL_GPL" class="s10class="fr0ef">linux/err.h>
08"+c" 8=svc_authenticate" class="sref">svc_authenticate);
  51linux/hash.h>09"+c" c   11/************************************************** href="net/sunrpc/svcauth.c#L12" id="L12"" class="lline" name="L12">  121"+c"1ine" name="L2">   2  1 class="comment"> *
linux/types.h&>
11auth.c#L3" id="L3" class="lineWheL5">  d="tu="ference to 3" 'sref_domain' is dropped,class="comment"> *
linux/module.h>11ine" name="L4">   4  object is unhtbhedo6nd freed class="comment"> *
linux/sunrppc/ty11r side.
 _domain  
     fails to findo6n ="nry, it willu="srefclass="comment"> *
linux/sunrpc//xdr.11h.c#L26" id="L26" class="line"it's secondo6rguss=" 'new'. uIL2ame= is non-    , it willclass="comment"> *
linux/sunnrpc/11>
  tname class="comment"> *
linux/sunnrpc/11ine" name="L8">   8linux/err.h>

linux/hash.h>t;
  51  21#de1ine   51  51RPCDBG_FACILITY linux/types.h&ggt;
1href="ab" class="sref">authtab[hlist_e" name="L45">  45 _domain tnamef="net/sunrpc/svcautdomain tnameL50" id="L50" class=DN_HASH clame="L51">  51  24;
 _domain ="line" name="L56">  56_domain ="liref=etnet/sunrpc/svcauth.c#L57" id="L514types.h" /svcauth.c#L25" id="L25"1 clas12 class="sref">svc_getnl(_/sunr_pc/s_Urpc/se" name="L54">  5_/sunr_pc/s_Urpc/se"owner)) {
 _domain ="line" name="L56">  56_domain ="liref=="net/sunrpc/svcauth.c#L57" id="L51cators
 _domain put/sunrpc/svcauth6"> _domain putlass="sref">rqstp)
 _domain/sunrpc/svcauth6"> _domain#L41"" class="line" ndom/sunrpc/svcauthdom;svc="net/sunrpc/svcauth.c#L64" id="L1asvcauth.h>auth_ops auth_ops Ratomic_de="snd ="line" name="L56"> tomic_de="snd ="lirpc/svcauth.c#L56" id="L5dom/sunrpc/svcauthdom;svcrqstp,   56_domain ="liref==           30sta129e=authtab_los="sref">svc_getnl(/list_dehref="+code=rq_a/list_dehrpc/svcauth.c#L56" id="L5dom/sunrpc/svcauthdom;svcrqstp, DEFINE_SPINLOCK(rq_authop dom/sunrpc/svcauthdom;svcrqstp,   50ur;svcrqstp, )) {
auth_ops  *authtab_lock);
  56_domain ="liref=="net/sunrpc/svcauth.c#L57" id="L51null" cla1ss="sref">svcauth_null,
<13_autherr_badc+code=EXPORT_SYMBOL_GPL" class="s1unix" cla1ss="sref">svcauth_unix,
<1 href=+code=EXPORT_SYMBOL_GPL" class="s1utypes.h" s="line" name="L35">  351
1a href_authenticate" class="sref">svc_authenticate);
 _domain put/sunrpc/svcauth6"> _domain putlass="net/sunrpc/svcauth.c#L57" id="L51nators  36int1  3171a href"sref">rqstp)
 _domain/sunrpc/svcauth6"> _domain#L41""f="net/sunrpc/svcauth.c#L37" id=1"svcauth.huthenticate(struct <1a hre1="+code=svc_rqst" cla6"> _domain  
    ne" name="L56">  56_domain ="    sunrpchar"" class="line" ntrucne" name="L56">truc    ,s class="sref">aops;
 _domain#L41"" class="line" nnewne" name="L56">tew;svc="net/sunrpc/svcauth.c#L64" id="L139" class1="line" name="L39">  39<1/a>  1     rpc_authflavor_t 1     1 aops;
 _domain#L41"" class="line" name="L59">  59auth_ops         *1aopshlist_e" name="L45">  45  45
  42   141"+code=aops" class="sref">aopshlist_n  45  59 =   44   143class="sref">rq_authop a" name="L45">  45
 _domain tnamef="net/sunrpc/svcautdomain tnameL50" id="L50" class=/tbh_ clref="+code=rq_a/tbh_ clsunrpc/svcauth.c#L61trucne" name="L56">truc    ,scauth.c#Lss="srDN_HASHBITSame="L51">  51flavor<1/a> =   46   14de=authtab_lock" class="sref">aut_lock);
  56_domain ="liref=="net/sunrpc/svcauth.c#L57" id="L51f">dprint1k(&q14     48   14 class="sref">rq_authop /list_for_each_="nryame="L45">  45  59  59  45
spin1_lock(&R clcmme="L59">  59  59, truc    ,scauth.c#Lss="srtrucne" name="L56">truc    )==0=         >= rq_authop kaut href="+code=owner"kaut hrerpc/svcauth.c#L49" id="L4ame="L59">  59, try_module_get1(authtab_lock);
  56_domain ="liref=="net/sunrpc/svcauth.c#L57" id="L51" class="1sref">spin_unlock(&a1mp;rq_authop-ame="L59">  59authp = SVC_DENIED;
<1 href="net/sun+code=EXPORT_SYMBOL_GPL" class="s1D>flavor<15" class="line" name="L515">  154_AUTH_MAXFLAVOR" class="sref">Rnewne" name="L56">tew;svc="net/sunrpc/svcauth.c#L64" id="L1"sref">sp1in_unlock(&]) ||
  45tew;svcrqstp,   45
dprint1"line" name="L57">  57   15t;svc: svc_authenticate (">authtab_lock);
  56_domain ="liref=="net/sunrpc/svcauth.c#L57" id="L51"" class=1>->rq_authop-newne" name="L56">tew;svc"net/sunrpc/svcauth.c#L57" id="L51"ef">spin1ps->  60<1/a>svc_authenticate);
 _domain  
    ne" name="L56">  56_domain ="    sunr="net/sunrpc/svcauth.c#L57" id="L51ref">EXPO1RT_SYMBOL_GPL(  62int161href"sref">rqstp)
 _domain/sunrpc/svcauth6"> _domain#L41""c/svcauth.c#L616"> _domain findne" name="L56">  56_domain findsunrpchar"" class="line" ntrucne" name="L56">truc    ="net/sunrpc/svcauth.c#L64" id="L1sref">svc1_set_client(struct <1a hre162     64<1/a>  16href="net/sun="sref">rq_authop-6"> _domain  
    ne" name="L56">  56_domain ="    sunrp, truc    ,scauth.c#Lss="srNULet_client);
NULelass "net/sunrpc/svcauth.c#L57" id="L51r>flavor<1qstp->  66<1/a>svc_authenticate);
 _domain findne" name="L56">  56_domain findsunr "net/sunrpc/svcauth.c#L57" id="L51rsvcsock.h"" class="fref">linux/sunr>   1de=svc_/pre/div>

<

03efd287a9f27lass="ffoot na>
nrpcoriginal LXR softwaresby ">  et/sunrpchttp://sourceforge./svcprojects/lxna>LXR 8  2.no">lxn@l>  2.no;svc"
03efd28a9f27lass="fsubfoot na>
lxn.l>  2.no kindly hostedoby"et/sunrpchttp://www.redpill-l> pro.no">Redpill L> pro AS    ,sprovider="L2L>  2 8