ReactOS  0.4.14-dev-114-gc8cbd56
svc_auth.c File Reference
#include <wintirpc.h>
#include <reentrant.h>
#include <sys/types.h>
#include <rpc/rpc.h>
#include <stdlib.h>
Include dependency graph for svc_auth.c:

Go to the source code of this file.

Classes

struct  authsvc
 

Functions

enum auth_stat _authenticate (struct svc_req *rqst, struct rpc_msg *msg)
 
enum auth_stat _svcauth_null (struct svc_req *rqst, struct rpc_msg *msg)
 
int svc_auth_reg (int cred_flavor, enum auth_stat *handler)
 

Variables

static struct authsvcAuths = NULL
 

Function Documentation

◆ _authenticate()

enum auth_stat _authenticate ( struct svc_req rqst,
struct rpc_msg msg 
)

Definition at line 86 of file svc_auth.c.

89 {
90  int cred_flavor;
91  struct authsvc *asp;
92  enum auth_stat dummy;
93  extern mutex_t authsvc_lock;
94 
95 /* VARIABLES PROTECTED BY authsvc_lock: asp, Auths */
96 
97  rqst->rq_cred = msg->rm_call.cb_cred;
98  rqst->rq_xprt->xp_verf.oa_flavor = _null_auth.oa_flavor;
99  rqst->rq_xprt->xp_verf.oa_length = 0;
100  cred_flavor = rqst->rq_cred.oa_flavor;
101  switch (cred_flavor) {
102  case AUTH_NULL:
103  dummy = _svcauth_null(rqst, msg);
104  return (dummy);
105  case AUTH_SYS:
106  dummy = _svcauth_unix(rqst, msg);
107  return (dummy);
108  case AUTH_SHORT:
109  dummy = _svcauth_short(rqst, msg);
110  return (dummy);
111 #ifdef DES_BUILTIN
112  case AUTH_DES:
113  dummy = _svcauth_des(rqst, msg);
114  return (dummy);
115 #endif
116  default:
117  break;
118  }
119 
120  /* flavor doesn't match any of the builtin types, so try new ones */
122  for (asp = Auths; asp; asp = asp->next) {
123  if (asp->flavor == cred_flavor) {
124  enum auth_stat as;
125 
126  as = (*asp->handler)(rqst, msg);
128  return (as);
129  }
130  }
132 
133  return (AUTH_REJECTEDCRED);
134 }
struct authsvc * next
Definition: svc_auth.c:63
static struct authsvc * Auths
Definition: svc_auth.c:65
enum auth_stat(* handler)(struct svc_req *, struct rpc_msg *)
Definition: svc_auth.c:62
enum auth_stat _svcauth_unix(struct svc_req *rqst, struct rpc_msg *msg)
Definition: svc_auth_unix.c:51
#define mutex_lock(m)
Definition: reentrant.h:128
SVCXPRT * rq_xprt
Definition: svc.h:139
#define mutex_unlock(m)
Definition: reentrant.h:129
struct opaque_auth _null_auth
auth_stat
Definition: auth.h:144
struct opaque_auth rq_cred
Definition: svc.h:137
mutex_t authsvc_lock
Definition: mt_misc.c:47
enum auth_stat _svcauth_null(struct svc_req *rqst, struct rpc_msg *msg)
Definition: svc_auth.c:138
#define AUTH_NULL
Definition: auth.h:402
#define AUTH_SYS
Definition: auth.h:403
unsigned char dummy
Definition: maze.c:118
enum auth_stat _svcauth_short(struct svc_req *rqst, struct rpc_msg *msg)
#define AUTH_DES
Definition: auth.h:407
#define msg(x)
Definition: auth_time.c:54
struct opaque_auth xp_verf
Definition: svc.h:121
enum auth_stat _svcauth_des(struct svc_req *rqst, struct rpc_msg *msg)
Definition: svc_auth_des.c:106
#define AUTH_SHORT
Definition: auth.h:405
Definition: module.h:446
int flavor
Definition: svc_auth.c:61

Referenced by svc_getreq_common().

◆ _svcauth_null()

enum auth_stat _svcauth_null ( struct svc_req rqst,
struct rpc_msg msg 
)

Definition at line 138 of file svc_auth.c.

141 {
142  return (AUTH_OK);
143 }
Definition: auth.h:145

Referenced by _authenticate().

◆ svc_auth_reg()

int svc_auth_reg ( int  cred_flavor,
enum auth_stat handler 
)

Definition at line 160 of file svc_auth.c.

163 {
164  struct authsvc *asp;
165  extern mutex_t authsvc_lock;
166 
167  switch (cred_flavor) {
168  case AUTH_NULL:
169  case AUTH_SYS:
170  case AUTH_SHORT:
171 #ifdef DES_BUILTIN
172  case AUTH_DES:
173 #endif
174  /* already registered */
175  return (1);
176 
177  default:
179  for (asp = Auths; asp; asp = asp->next) {
180  if (asp->flavor == cred_flavor) {
181  /* already registered */
183  return (1);
184  }
185  }
186 
187  /* this is a new one, so go ahead and register it */
188  asp = mem_alloc(sizeof (*asp));
189  if (asp == NULL) {
191  return (-1);
192  }
193  asp->flavor = cred_flavor;
194  asp->handler = handler;
195  asp->next = Auths;
196  Auths = asp;
198  break;
199  }
200  return (0);
201 }
struct authsvc * next
Definition: svc_auth.c:63
static struct authsvc * Auths
Definition: svc_auth.c:65
enum auth_stat(* handler)(struct svc_req *, struct rpc_msg *)
Definition: svc_auth.c:62
#define mutex_lock(m)
Definition: reentrant.h:128
#define mutex_unlock(m)
Definition: reentrant.h:129
#define mem_alloc(bsize)
Definition: types.h:123
smooth NULL
Definition: ftsmooth.c:416
mutex_t authsvc_lock
Definition: mt_misc.c:47
#define AUTH_NULL
Definition: auth.h:402
#define AUTH_SYS
Definition: auth.h:403
#define AUTH_DES
Definition: auth.h:407
#define AUTH_SHORT
Definition: auth.h:405
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7786
Definition: module.h:446
int flavor
Definition: svc_auth.c:61

Variable Documentation

◆ Auths

struct authsvc* Auths = NULL
static

Definition at line 65 of file svc_auth.c.

Referenced by _authenticate(), and svc_auth_reg().