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
cb8e7a87
Commit
cb8e7a87
authored
10 years ago
by
Danny Auble
Browse files
Options
Downloads
Patches
Plain Diff
Move DBD auth check for accounts into the plugin instead of only in the DBD
parent
60266e8f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/plugins/accounting_storage/mysql/as_mysql_acct.c
+28
-0
28 additions, 0 deletions
src/plugins/accounting_storage/mysql/as_mysql_acct.c
src/slurmdbd/proc_req.c
+2
-51
2 additions, 51 deletions
src/slurmdbd/proc_req.c
with
30 additions
and
51 deletions
src/plugins/accounting_storage/mysql/as_mysql_acct.c
+
28
−
0
View file @
cb8e7a87
...
...
@@ -136,6 +136,24 @@ extern int as_mysql_add_accts(mysql_conn_t *mysql_conn, uint32_t uid,
if
(
check_connection
(
mysql_conn
)
!=
SLURM_SUCCESS
)
return
ESLURM_DB_CONNECTION
;
if
(
!
is_user_min_admin_level
(
mysql_conn
,
uid
,
SLURMDB_ADMIN_OPERATOR
))
{
slurmdb_user_rec_t
user
;
memset
(
&
user
,
0
,
sizeof
(
slurmdb_user_rec_t
));
user
.
uid
=
uid
;
if
(
!
is_user_any_coord
(
mysql_conn
,
&
user
))
{
error
(
"Only admins/operators/coordinators "
"can add accounts"
);
return
ESLURM_ACCESS_DENIED
;
}
/* If the user is a coord of any acct they can add
* accounts they are only able to make associations to
* these accounts if they are coordinators of the
* parent they are trying to add to
*/
}
user_name
=
uid_to_string
((
uid_t
)
uid
);
itr
=
list_iterator_create
(
acct_list
);
while
((
object
=
list_next
(
itr
)))
{
...
...
@@ -261,6 +279,11 @@ extern List as_mysql_modify_accts(mysql_conn_t *mysql_conn, uint32_t uid,
if
(
check_connection
(
mysql_conn
)
!=
SLURM_SUCCESS
)
return
NULL
;
if
(
!
is_user_min_admin_level
(
mysql_conn
,
uid
,
SLURMDB_ADMIN_OPERATOR
))
{
errno
=
ESLURM_ACCESS_DENIED
;
return
NULL
;
}
xstrcat
(
extra
,
"where deleted=0"
);
if
(
acct_cond
->
assoc_cond
&&
acct_cond
->
assoc_cond
->
acct_list
...
...
@@ -399,6 +422,11 @@ extern List as_mysql_remove_accts(mysql_conn_t *mysql_conn, uint32_t uid,
if
(
check_connection
(
mysql_conn
)
!=
SLURM_SUCCESS
)
return
NULL
;
if
(
!
is_user_min_admin_level
(
mysql_conn
,
uid
,
SLURMDB_ADMIN_OPERATOR
))
{
errno
=
ESLURM_ACCESS_DENIED
;
return
NULL
;
}
xstrcat
(
extra
,
"where deleted=0"
);
if
(
acct_cond
->
assoc_cond
&&
acct_cond
->
assoc_cond
->
acct_list
...
...
This diff is collapsed.
Click to expand it.
src/slurmdbd/proc_req.c
+
2
−
51
View file @
cb8e7a87
...
...
@@ -530,33 +530,6 @@ static int _add_accounts(slurmdbd_conn_t *slurmdbd_conn,
char
*
comment
=
NULL
;
debug2
(
"DBD_ADD_ACCOUNTS: called"
);
if
((
*
uid
!=
slurmdbd_conf
->
slurm_user_id
&&
*
uid
!=
0
)
&&
assoc_mgr_get_admin_level
(
slurmdbd_conn
->
db_conn
,
*
uid
)
<
SLURMDB_ADMIN_OPERATOR
)
{
slurmdb_user_rec_t
user
;
memset
(
&
user
,
0
,
sizeof
(
slurmdb_user_rec_t
));
user
.
uid
=
*
uid
;
if
(
assoc_mgr_fill_in_user
(
slurmdbd_conn
->
db_conn
,
&
user
,
1
,
NULL
)
!=
SLURM_SUCCESS
)
{
comment
=
"Your user has not been added to the accounting system yet."
;
error
(
"CONN:%u %s"
,
slurmdbd_conn
->
newsockfd
,
comment
);
rc
=
SLURM_ERROR
;
goto
end_it
;
}
if
(
!
user
.
coord_accts
||
!
list_count
(
user
.
coord_accts
))
{
comment
=
"Your user doesn't have privilege to perform this action"
;
error
(
"CONN:%u %s"
,
slurmdbd_conn
->
newsockfd
,
comment
);
rc
=
ESLURM_ACCESS_DENIED
;
goto
end_it
;
}
/* If the user is a coord of any acct they can add
* accounts they are only able to make associations to
* these accounts if they are coordinators of the
* parent they are trying to add to
*/
}
if
(
slurmdbd_unpack_list_msg
(
&
get_msg
,
slurmdbd_conn
->
rpc_version
,
DBD_ADD_ACCOUNTS
,
in_buffer
)
!=
...
...
@@ -569,6 +542,8 @@ static int _add_accounts(slurmdbd_conn_t *slurmdbd_conn,
rc
=
acct_storage_g_add_accounts
(
slurmdbd_conn
->
db_conn
,
*
uid
,
get_msg
->
my_list
);
if
(
rc
==
ESLURM_ACCESS_DENIED
)
comment
=
"Your user doesn't have privilege to perform this action"
;
end_it:
slurmdbd_free_list_msg
(
get_msg
);
*
out_buffer
=
make_dbd_rc_msg
(
slurmdbd_conn
->
rpc_version
,
...
...
@@ -2092,18 +2067,6 @@ static int _modify_accounts(slurmdbd_conn_t *slurmdbd_conn,
debug2
(
"DBD_MODIFY_ACCOUNTS: called"
);
if
((
*
uid
!=
slurmdbd_conf
->
slurm_user_id
&&
*
uid
!=
0
)
&&
assoc_mgr_get_admin_level
(
slurmdbd_conn
->
db_conn
,
*
uid
)
<
SLURMDB_ADMIN_OPERATOR
)
{
comment
=
"Your user doesn't have privilege to perform this action"
;
error
(
"CONN:%u %s"
,
slurmdbd_conn
->
newsockfd
,
comment
);
*
out_buffer
=
make_dbd_rc_msg
(
slurmdbd_conn
->
rpc_version
,
ESLURM_ACCESS_DENIED
,
comment
,
DBD_MODIFY_ACCOUNTS
);
return
ESLURM_ACCESS_DENIED
;
}
if
(
slurmdbd_unpack_modify_msg
(
&
get_msg
,
slurmdbd_conn
->
rpc_version
,
DBD_MODIFY_ACCOUNTS
,
in_buffer
)
!=
SLURM_SUCCESS
)
{
...
...
@@ -3040,18 +3003,6 @@ static int _remove_accounts(slurmdbd_conn_t *slurmdbd_conn,
debug2
(
"DBD_REMOVE_ACCOUNTS: called"
);
if
((
*
uid
!=
slurmdbd_conf
->
slurm_user_id
&&
*
uid
!=
0
)
&&
assoc_mgr_get_admin_level
(
slurmdbd_conn
->
db_conn
,
*
uid
)
<
SLURMDB_ADMIN_OPERATOR
)
{
comment
=
"Your user doesn't have privilege to perform this action"
;
error
(
"CONN:%u %s"
,
slurmdbd_conn
->
newsockfd
,
comment
);
*
out_buffer
=
make_dbd_rc_msg
(
slurmdbd_conn
->
rpc_version
,
ESLURM_ACCESS_DENIED
,
comment
,
DBD_REMOVE_ACCOUNTS
);
return
ESLURM_ACCESS_DENIED
;
}
if
(
slurmdbd_unpack_cond_msg
(
&
get_msg
,
slurmdbd_conn
->
rpc_version
,
DBD_REMOVE_ACCOUNTS
,
in_buffer
)
!=
SLURM_SUCCESS
)
{
...
...
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