Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Slurm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tud-zih-energy
Slurm
Commits
13051398
Commit
13051398
authored
22 years ago
by
Mark Grondona
Browse files
Options
Downloads
Patches
Plain Diff
o update slurm_auth_init() to be MT-safe
parent
dc31586e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/common/slurm_auth.c
+39
-66
39 additions, 66 deletions
src/common/slurm_auth.c
with
39 additions
and
66 deletions
src/common/slurm_auth.c
+
39
−
66
View file @
13051398
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
*****************************************************************************
*****************************************************************************
* Copyright (C) 2002 The Regents of the University of California.
* Copyright (C) 2002 The Regents of the University of California.
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
* Written by
Kevin Tew <tew1@llnl.gov> et. al.
* Written by
Jay Windley <jwindley@lnxi.com>
* UCRL-CODE-2002-040.
* UCRL-CODE-2002-040.
*
*
* This file is part of SLURM, a resource management program.
* This file is part of SLURM, a resource management program.
...
@@ -47,12 +47,12 @@
...
@@ -47,12 +47,12 @@
typedef
struct
slurm_auth_ops
{
typedef
struct
slurm_auth_ops
{
void
*
(
*
alloc
)
(
void
);
void
*
(
*
alloc
)
(
void
);
void
(
*
free
)
(
void
*
cred
);
void
(
*
free
)
(
void
*
cred
);
int
(
*
activate
)
(
void
*
cred
,
int
secs
);
int
(
*
activate
)
(
void
*
cred
,
int
secs
);
int
(
*
verify
)
(
void
*
cred
);
int
(
*
verify
)
(
void
*
cred
);
uid_t
(
*
get_uid
)
(
void
*
cred
);
uid_t
(
*
get_uid
)
(
void
*
cred
);
gid_t
(
*
get_gid
)
(
void
*
cred
);
gid_t
(
*
get_gid
)
(
void
*
cred
);
void
(
*
pack
)
(
void
*
cred
,
Buf
buf
);
void
(
*
pack
)
(
void
*
cred
,
Buf
buf
);
int
(
*
unpack
)
(
void
*
cred
,
Buf
buf
);
int
(
*
unpack
)
(
void
*
cred
,
Buf
buf
);
void
(
*
print
)
(
void
*
cred
,
FILE
*
fp
);
void
(
*
print
)
(
void
*
cred
,
FILE
*
fp
);
}
slurm_auth_ops_t
;
}
slurm_auth_ops_t
;
...
@@ -63,7 +63,7 @@ typedef struct slurm_auth_ops {
...
@@ -63,7 +63,7 @@ typedef struct slurm_auth_ops {
* operations implemented pertinent to that context.
* operations implemented pertinent to that context.
*
*
* auth_type - the string (presumably from configuration files)
* auth_type - the string (presumably from configuration files)
* describing the desired form of authentication, such as "auth/munge
d
"
* describing the desired form of authentication, such as "auth/munge"
* or "auth/kerberos" or "auth/none".
* or "auth/kerberos" or "auth/none".
*
*
* plugin_list - the plugin rack managing the loading and unloading of
* plugin_list - the plugin rack managing the loading and unloading of
...
@@ -86,11 +86,13 @@ struct slurm_auth_context {
...
@@ -86,11 +86,13 @@ struct slurm_auth_context {
* A global authentication context. "Global" in the sense that there's
* A global authentication context. "Global" in the sense that there's
* only one, with static bindings. We don't export it.
* only one, with static bindings. We don't export it.
*/
*/
static
slurm_auth_context_t
g_context
=
NULL
;
static
slurm_auth_context_t
g_context
=
NULL
;
static
pthread_mutex_t
context_lock
=
PTHREAD_MUTEX_INITIALIZER
;
static
slurm_ctl_conf_t
conf
;
static
slurm_ctl_conf_t
conf
;
static
pthread_mutex_t
config_lock
=
PTHREAD_MUTEX_INITIALIZER
;
static
pthread_mutex_t
config_lock
=
PTHREAD_MUTEX_INITIALIZER
;
static
char
*
static
char
*
get_plugin_dir
(
void
)
get_plugin_dir
(
void
)
{
{
...
@@ -228,23 +230,30 @@ slurm_auth_context_destroy( slurm_auth_context_t c )
...
@@ -228,23 +230,30 @@ slurm_auth_context_destroy( slurm_auth_context_t c )
int
int
slurm_auth_init
(
void
)
slurm_auth_init
(
void
)
{
{
i
f
(
g_context
)
{
i
nt
retval
=
SLURM_SUCCESS
;
return
SLURM_SUCCESS
;
}
slurm_mutex_lock
(
&
context_lock
);
if
(
g_context
)
goto
done
;
g_context
=
slurm_auth_context_create
(
get_auth_type
()
);
g_context
=
slurm_auth_context_create
(
get_auth_type
()
);
if
(
g_context
==
NULL
)
{
if
(
g_context
==
NULL
)
{
verbose
(
"cannot create a context for %s"
,
get_auth_type
()
);
verbose
(
"cannot create a context for %s"
,
get_auth_type
()
);
return
SLURM_ERROR
;
retval
=
SLURM_ERROR
;
goto
done
;
}
}
if
(
slurm_auth_get_ops
(
g_context
)
==
NULL
)
{
if
(
slurm_auth_get_ops
(
g_context
)
==
NULL
)
{
verbose
(
"cannot resolve plugin operations"
);
verbose
(
"cannot resolve plugin operations"
);
ret
urn
SLURM_ERROR
;
ret
val
=
SLURM_ERROR
;
}
else
{
}
else
{
ret
urn
SLURM_SUCCESS
;
ret
val
=
SLURM_SUCCESS
;
}
}
done:
slurm_mutex_unlock
(
&
context_lock
);
return
retval
;
}
}
/*
/*
...
@@ -361,12 +370,8 @@ c_slurm_auth_print( slurm_auth_context_t c, void *cred, FILE *fp )
...
@@ -361,12 +370,8 @@ c_slurm_auth_print( slurm_auth_context_t c, void *cred, FILE *fp )
void
*
void
*
g_slurm_auth_alloc
(
void
)
g_slurm_auth_alloc
(
void
)
{
{
if
(
!
g_context
)
{
if
(
slurm_auth_init
()
<
0
)
if
(
slurm_auth_init
()
!=
SLURM_SUCCESS
)
{
return
NULL
;
error
(
"can't allocate credential - authentication init failed"
);
return
NULL
;
}
}
return
(
*
(
g_context
->
ops
.
alloc
))();
return
(
*
(
g_context
->
ops
.
alloc
))();
}
}
...
@@ -374,12 +379,8 @@ g_slurm_auth_alloc( void )
...
@@ -374,12 +379,8 @@ g_slurm_auth_alloc( void )
void
void
g_slurm_auth_free
(
void
*
cred
)
g_slurm_auth_free
(
void
*
cred
)
{
{
if
(
!
g_context
)
{
if
(
slurm_auth_init
()
<
0
)
if
(
slurm_auth_init
()
!=
SLURM_SUCCESS
)
{
return
;
error
(
"can't free credential - authentication init failed"
);
return
;
}
}
(
*
(
g_context
->
ops
.
free
))(
cred
);
(
*
(
g_context
->
ops
.
free
))(
cred
);
}
}
...
@@ -387,12 +388,8 @@ g_slurm_auth_free( void *cred )
...
@@ -387,12 +388,8 @@ g_slurm_auth_free( void *cred )
int
int
g_slurm_auth_activate
(
void
*
cred
,
int
secs
)
g_slurm_auth_activate
(
void
*
cred
,
int
secs
)
{
{
if
(
!
g_context
)
{
if
(
slurm_auth_init
()
<
0
)
if
(
slurm_auth_init
()
!=
SLURM_SUCCESS
)
{
return
SLURM_ERROR
;
error
(
"can't activate credential - authentication init failed"
);
return
SLURM_ERROR
;
}
}
return
(
*
(
g_context
->
ops
.
activate
))(
cred
,
secs
);
return
(
*
(
g_context
->
ops
.
activate
))(
cred
,
secs
);
}
}
...
@@ -400,12 +397,8 @@ g_slurm_auth_activate( void *cred, int secs )
...
@@ -400,12 +397,8 @@ g_slurm_auth_activate( void *cred, int secs )
int
int
g_slurm_auth_verify
(
void
*
cred
)
g_slurm_auth_verify
(
void
*
cred
)
{
{
if
(
!
g_context
)
{
if
(
slurm_auth_init
()
<
0
)
if
(
slurm_auth_init
()
!=
SLURM_SUCCESS
)
{
return
SLURM_ERROR
;
error
(
"can't verify credential - authentication init failed"
);
return
SLURM_ERROR
;
}
}
return
(
*
(
g_context
->
ops
.
verify
))(
cred
);
return
(
*
(
g_context
->
ops
.
verify
))(
cred
);
}
}
...
@@ -413,12 +406,8 @@ g_slurm_auth_verify( void *cred )
...
@@ -413,12 +406,8 @@ g_slurm_auth_verify( void *cred )
uid_t
uid_t
g_slurm_auth_get_uid
(
void
*
cred
)
g_slurm_auth_get_uid
(
void
*
cred
)
{
{
if
(
!
g_context
)
{
if
(
slurm_auth_init
()
<
0
)
if
(
slurm_auth_init
()
!=
SLURM_SUCCESS
)
{
return
SLURM_AUTH_NOBODY
;
error
(
"can't get UID - authentication init failed"
);
return
SLURM_AUTH_NOBODY
;
}
}
return
(
*
(
g_context
->
ops
.
get_uid
))(
cred
);
return
(
*
(
g_context
->
ops
.
get_uid
))(
cred
);
}
}
...
@@ -426,12 +415,8 @@ g_slurm_auth_get_uid( void *cred )
...
@@ -426,12 +415,8 @@ g_slurm_auth_get_uid( void *cred )
gid_t
gid_t
g_slurm_auth_get_gid
(
void
*
cred
)
g_slurm_auth_get_gid
(
void
*
cred
)
{
{
if
(
!
g_context
)
{
if
(
slurm_auth_init
()
<
0
)
if
(
slurm_auth_init
()
!=
SLURM_SUCCESS
)
{
return
SLURM_AUTH_NOBODY
;
error
(
"can't get GID - authentication init failed"
);
return
SLURM_AUTH_NOBODY
;
}
}
return
(
*
(
g_context
->
ops
.
get_gid
))(
cred
);
return
(
*
(
g_context
->
ops
.
get_gid
))(
cred
);
}
}
...
@@ -439,12 +424,8 @@ g_slurm_auth_get_gid( void *cred )
...
@@ -439,12 +424,8 @@ g_slurm_auth_get_gid( void *cred )
void
void
g_slurm_auth_pack
(
void
*
cred
,
Buf
buf
)
g_slurm_auth_pack
(
void
*
cred
,
Buf
buf
)
{
{
if
(
!
g_context
)
{
if
(
slurm_auth_init
()
<
0
)
if
(
slurm_auth_init
()
!=
SLURM_SUCCESS
)
{
return
;
error
(
"can't pack credential - authentication init failed"
);
return
;
}
}
(
*
(
g_context
->
ops
.
pack
))(
cred
,
buf
);
(
*
(
g_context
->
ops
.
pack
))(
cred
,
buf
);
}
}
...
@@ -452,12 +433,8 @@ g_slurm_auth_pack( void *cred, Buf buf )
...
@@ -452,12 +433,8 @@ g_slurm_auth_pack( void *cred, Buf buf )
int
int
g_slurm_auth_unpack
(
void
*
cred
,
Buf
buf
)
g_slurm_auth_unpack
(
void
*
cred
,
Buf
buf
)
{
{
if
(
!
g_context
)
{
if
(
slurm_auth_init
()
<
0
)
if
(
slurm_auth_init
()
!=
SLURM_SUCCESS
)
{
return
SLURM_ERROR
;
error
(
"can't unpack credential - authentication init failed"
);
return
SLURM_ERROR
;
}
}
return
(
*
(
g_context
->
ops
.
unpack
))(
cred
,
buf
);
return
(
*
(
g_context
->
ops
.
unpack
))(
cred
,
buf
);
}
}
...
@@ -465,12 +442,8 @@ g_slurm_auth_unpack( void *cred, Buf buf )
...
@@ -465,12 +442,8 @@ g_slurm_auth_unpack( void *cred, Buf buf )
void
void
g_slurm_auth_print
(
void
*
cred
,
FILE
*
fp
)
g_slurm_auth_print
(
void
*
cred
,
FILE
*
fp
)
{
{
if
(
!
g_context
)
{
if
(
slurm_auth_init
()
<
0
)
if
(
slurm_auth_init
()
!=
SLURM_SUCCESS
)
{
return
;
error
(
"can't print credential - authentication init failed"
);
return
;
}
}
(
*
(
g_context
->
ops
.
print
))(
cred
,
fp
);
(
*
(
g_context
->
ops
.
print
))(
cred
,
fp
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment