Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dm-docs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
hammonds
dm-docs
Commits
27d453f6
Commit
27d453f6
authored
9 years ago
by
sveseli
Browse files
Options
Downloads
Patches
Plain Diff
added refreshing for NSCD cache after modifying group membership
parent
12718088
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
etc/dm.sudo-rules.template
+2
-1
2 additions, 1 deletion
etc/dm.sudo-rules.template
src/python/dm/common/utility/ldapLinuxPlatformUtility.py
+22
-0
22 additions, 0 deletions
src/python/dm/common/utility/ldapLinuxPlatformUtility.py
with
24 additions
and
1 deletion
etc/dm.sudo-rules.template
+
2
−
1
View file @
27d453f6
...
...
@@ -7,7 +7,8 @@ Cmnd_Alias USERMOD=/usr/sbin/usermod -a -G * *
Cmnd_Alias GROUPADD=/usr/sbin/groupadd *
Cmnd_Alias CHOWN=/bin/chown -R \:* *
Cmnd_Alias GPASSWD=/usr/bin/gpasswd * * *
Cmnd_Alias NSCD=/usr/sbin/nscd -i *
USER HOST = (root) NOPASSWD: SETFACL,USERMOD,GROUPADD,CHOWN,GPASSWD
USER HOST = (root) NOPASSWD: SETFACL,USERMOD,GROUPADD,CHOWN,GPASSWD
,NSCD
This diff is collapsed.
Click to expand it.
src/python/dm/common/utility/ldapLinuxPlatformUtility.py
+
22
−
0
View file @
27d453f6
...
...
@@ -20,6 +20,7 @@ class LdapLinuxPlatformUtility:
SETFACL_CMD
=
'
/usr/bin/setfacl
'
CHOWN_CMD
=
'
/bin/chown
'
GPASSWD_CMD
=
'
/usr/bin/gpasswd
'
NSCD_CMD
=
'
/usr/sbin/nscd
'
def
__init__
(
self
,
serverUrl
,
adminDn
,
adminPasswordFile
,
groupDnFormat
,
minGidNumber
=
None
):
self
.
serverUrl
=
serverUrl
...
...
@@ -166,6 +167,9 @@ class LdapLinuxPlatformUtility:
logger
.
error
(
'
Could not add user %s to group %s: %s
'
%
(
username
,
groupName
,
ex
))
raise
InternalError
(
exception
=
ex
)
# Refresh NSCD cache
self
.
refreshNscdGroupCache
()
def
deleteUserFromGroup
(
self
,
username
,
groupName
):
"""
Remove user from group.
"""
logger
=
self
.
getLogger
()
...
...
@@ -195,6 +199,10 @@ class LdapLinuxPlatformUtility:
logger
.
error
(
'
Could not remove user %s from group %s: %s
'
%
(
username
,
groupName
,
ex
))
raise
InternalError
(
exception
=
ex
)
# Refresh NSCD cache
self
.
refreshNscdGroupCache
()
@classmethod
def
createLocalGroup
(
cls
,
name
):
"""
Create local group if it does not exist.
"""
...
...
@@ -257,6 +265,9 @@ class LdapLinuxPlatformUtility:
logger
.
error
(
'
Could not set users %s for group %s: %s
'
%
(
usernameList
,
groupName
,
ex
))
raise
InternalError
(
exception
=
ex
)
# Refresh NSCD cache
self
.
refreshNscdGroupCache
()
@classmethod
def
setPathReadExecutePermissionsForGroup
(
cls
,
path
,
groupName
):
"""
Set path permissions for the given group.
"""
...
...
@@ -272,6 +283,17 @@ class LdapLinuxPlatformUtility:
cmd
=
'
%s \:%s %s
'
%
(
cls
.
CHOWN_CMD
,
groupName
,
path
)
cls
.
executeSudoCommand
(
cmd
)
@classmethod
def
refreshNscdGroupCache
(
cls
):
logger
=
cls
.
getLogger
()
try
:
logger
.
debug
(
'
Refreshing NCSD secondary group membership cache
'
)
cmd
=
'
%s -i group
'
%
(
cls
.
NSCD_CMD
)
cls
.
executeSudoCommand
(
cmd
)
except
Exception
,
ex
:
logger
.
warn
(
'
Failed to refresh NCSD group cache: %s
'
%
(
str
(
ex
)))
#######################################################################
# Testing.
...
...
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