Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rabbitmq_agents
Manage
Activity
Members
Labels
Plan
Issues
16
Issue boards
Milestones
Wiki
Code
Merge requests
9
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
rc
rabbitmq_agents
Commits
af42f429
Commit
af42f429
authored
5 years ago
by
Eesaan Atluri
Browse files
Options
Downloads
Patches
Plain Diff
replace LDAP check with getent & move it to callback function.
parent
da7225e7
No related branches found
No related tags found
6 merge requests
!147
Merge previous default branch feat-cod-rmq into main
,
!85
kill nginx process running under user from login node
,
!51
Fix acct create wait
,
!39
WIP:Feat cod rmq
,
!38
WIP: Feat cod rmq
,
!28
Feat resolve uid gid
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
get-next-uid-gid.py
+6
-16
6 additions, 16 deletions
get-next-uid-gid.py
with
6 additions
and
16 deletions
get-next-uid-gid.py
+
6
−
16
View file @
af42f429
...
...
@@ -18,19 +18,6 @@ args = rc_util.get_args()
# Logger
logger
=
rc_util
.
get_logger
()
#Check if the username already exists via LDAP
def
user_exists
(
username
):
try
:
logger
.
info
(
f
"
Searching LDAP for the user:
{
username
}
"
)
con
=
ldap
.
initialize
(
'
ldap://ldapserver
'
)
ldap_base
=
"
dc=cm,dc=cluster
"
query
=
"
(uid={})
"
.
format
(
username
)
result
=
con
.
search_s
(
ldap_base
,
ldap
.
SCOPE_SUBTREE
,
query
)
logging
.
debug
(
f
"
The search result is:
{
result
}
"
)
return
result
except
ldap
.
LDAPError
:
logger
.
exception
(
"
Fatal LDAP error:
"
)
# Define your callback function
def
get_next_uid_gid
(
ch
,
method
,
properties
,
body
):
...
...
@@ -42,10 +29,13 @@ def get_next_uid_gid(ch, method, properties, body):
# Determine next available UID
try
:
if
user_exists
(
username
):
user_exists_cmd
=
"
/usr/bin/getent passwd {username}
"
user_exists
=
popen
(
user_exists_cmd
).
read
().
rstrip
()
if
user_exists
:
logger
.
info
(
"
The user, {} already exists
"
.
format
(
username
))
msg
[
'
uid
'
]
=
result
[
0
][
1
][
'
uidNumber
'
][
0
].
decode
(
'
utf-8
'
)
msg
[
'
gid
'
]
=
result
[
0
][
1
][
'
gidNumber
'
][
0
].
decode
(
'
utf-8
'
)
msg
[
'
uid
'
]
=
user_exists
.
split
(
'
:
'
)[
2
]
msg
[
'
gid
'
]
=
user_exists
.
split
(
'
:
'
)[
3
]
else
:
cmd_uid
=
"
/usr/bin/getent passwd |
\
...
...
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