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
38985649
Commit
38985649
authored
9 years ago
by
sveseli
Browse files
Options
Downloads
Patches
Plain Diff
fix for auth files refreshing on a remote machine
parent
8bc0efeb
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
doc/RELEASE_NOTES.txt
+1
-1
1 addition, 1 deletion
doc/RELEASE_NOTES.txt
etc/ds-web-service.conf.template
+3
-0
3 additions, 0 deletions
etc/ds-web-service.conf.template
src/python/dm/common/utility/ldapLinuxPlatformUtility.py
+42
-7
42 additions, 7 deletions
src/python/dm/common/utility/ldapLinuxPlatformUtility.py
with
46 additions
and
8 deletions
doc/RELEASE_NOTES.txt
+
1
−
1
View file @
38985649
...
@@ -3,7 +3,7 @@ Release 0.8 (01/26/2016)
...
@@ -3,7 +3,7 @@ Release 0.8 (01/26/2016)
- Enhanced upload/daq performance and functionality (hidden files are not
- Enhanced upload/daq performance and functionality (hidden files are not
processed; for uploads system can detect files that had been processed
processed; for uploads system can detect files that had been processed
already;
add
ed handling and reporting f
or
processing errors)
already;
improv
ed handling and reporting
o
f processing errors)
- Source file checksum is calculated for rsync/gridftp plugins by default
- Source file checksum is calculated for rsync/gridftp plugins by default
Release 0.7 (12/08/2015)
Release 0.7 (12/08/2015)
...
...
This diff is collapsed.
Click to expand it.
etc/ds-web-service.conf.template
+
3
−
0
View file @
38985649
...
@@ -18,6 +18,9 @@ manageStoragePermissions=True
...
@@ -18,6 +18,9 @@ manageStoragePermissions=True
#platformUtility=dm.common.utility.linuxUtility.LinuxUtility()
#platformUtility=dm.common.utility.linuxUtility.LinuxUtility()
platformUtility=dm.common.utility.ldapLinuxPlatformUtility.LdapLinuxPlatformUtility('ldaps://dmid-vm.xray.aps.anl.gov:636', 'uid=DM_SYSTEM_UNIX_ACCOUNT,ou=People,o=aps.anl.gov,dc=aps,dc=anl,dc=gov', 'DM_INSTALL_DIR/etc/DM_SYSTEM_UNIX_ACCOUNT.ldap.passwd', groupDnFormat='cn=%s,ou=DM,ou=Group,o=aps.anl.gov,dc=aps,dc=anl,dc=gov', minGidNumber=66000)
platformUtility=dm.common.utility.ldapLinuxPlatformUtility.LdapLinuxPlatformUtility('ldaps://dmid-vm.xray.aps.anl.gov:636', 'uid=DM_SYSTEM_UNIX_ACCOUNT,ou=People,o=aps.anl.gov,dc=aps,dc=anl,dc=gov', 'DM_INSTALL_DIR/etc/DM_SYSTEM_UNIX_ACCOUNT.ldap.passwd', groupDnFormat='cn=%s,ou=DM,ou=Group,o=aps.anl.gov,dc=aps,dc=anl,dc=gov', minGidNumber=66000)
[LdapLinuxPlatformUtility]
refreshAuthFilesCommand=
[DbManager]
[DbManager]
dbSchema=DM_DB_NAME
dbSchema=DM_DB_NAME
dbUser=DM_DB_NAME
dbUser=DM_DB_NAME
...
...
This diff is collapsed.
Click to expand it.
src/python/dm/common/utility/ldapLinuxPlatformUtility.py
+
42
−
7
View file @
38985649
...
@@ -4,8 +4,10 @@ import grp
...
@@ -4,8 +4,10 @@ import grp
import
ldap
import
ldap
import
ldap.modlist
import
ldap.modlist
import
copy
import
copy
import
threading
from
dm.common.utility.loggingManager
import
LoggingManager
from
dm.common.utility.loggingManager
import
LoggingManager
from
dm.common.utility.configurationManager
import
ConfigurationManager
from
dm.common.exceptions.configurationError
import
ConfigurationError
from
dm.common.exceptions.configurationError
import
ConfigurationError
from
dm.common.exceptions.internalError
import
InternalError
from
dm.common.exceptions.internalError
import
InternalError
from
dm.common.exceptions.authenticationError
import
AuthenticationError
from
dm.common.exceptions.authenticationError
import
AuthenticationError
...
@@ -22,11 +24,17 @@ class LdapLinuxPlatformUtility:
...
@@ -22,11 +24,17 @@ class LdapLinuxPlatformUtility:
GPASSWD_CMD
=
'
/usr/bin/gpasswd
'
GPASSWD_CMD
=
'
/usr/bin/gpasswd
'
NSCD_CMD
=
'
/usr/sbin/nscd
'
NSCD_CMD
=
'
/usr/sbin/nscd
'
CONFIG_SECTION_NAME
=
'
LdapLinuxPlatformUtility
'
REFRESH_AUTH_FILES_COMMAND_KEY
=
'
refreshauthfilescommand
'
TIMER_DELAY_IN_SECONDS
=
10
def
__init__
(
self
,
serverUrl
,
adminDn
,
adminPasswordFile
,
groupDnFormat
,
minGidNumber
=
None
):
def
__init__
(
self
,
serverUrl
,
adminDn
,
adminPasswordFile
,
groupDnFormat
,
minGidNumber
=
None
):
self
.
serverUrl
=
serverUrl
self
.
serverUrl
=
serverUrl
self
.
adminDn
=
adminDn
self
.
adminDn
=
adminDn
self
.
groupDnFormat
=
groupDnFormat
self
.
groupDnFormat
=
groupDnFormat
self
.
minGidNumber
=
minGidNumber
self
.
minGidNumber
=
minGidNumber
self
.
refreshAuthFilesCommand
=
None
self
.
refreshAuthFilesTimer
=
None
self
.
getLogger
().
debug
(
'
Min GID number: %s
'
%
minGidNumber
)
self
.
getLogger
().
debug
(
'
Min GID number: %s
'
%
minGidNumber
)
# Remove first entry from the dn format to get tree base
# Remove first entry from the dn format to get tree base
self
.
groupBaseDn
=
'
,
'
.
join
(
groupDnFormat
.
split
(
'
,
'
)[
1
:])
self
.
groupBaseDn
=
'
,
'
.
join
(
groupDnFormat
.
split
(
'
,
'
)[
1
:])
...
@@ -37,6 +45,13 @@ class LdapLinuxPlatformUtility:
...
@@ -37,6 +45,13 @@ class LdapLinuxPlatformUtility:
raise
ConfigurationError
(
'
LDAP password could not be found in %s file
'
%
adminPasswordFile
)
raise
ConfigurationError
(
'
LDAP password could not be found in %s file
'
%
adminPasswordFile
)
self
.
ldapClient
=
None
self
.
ldapClient
=
None
def
__configure
(
self
):
cm
=
ConfigurationManager
.
getInstance
()
configItems
=
cm
.
getConfigItems
(
LdapLinuxPlatformUtility
.
CONFIG_SECTION_NAME
)
self
.
logger
.
debug
(
'
Got config items: %s
'
%
configItems
)
self
.
refreshAuthFilesCommand
=
cm
.
getConfigOption
(
LdapLinuxPlatformUtility
.
CONFIG_SECTION_NAME
,
LdapLinuxPlatformUtility
.
REFRESH_AUTH_FILES_COMMAND_KEY
)
self
.
logger
.
debug
(
'
Refresh auth files command: %s
'
%
self
.
refreshAuthFilesCommand
)
@classmethod
@classmethod
def
getLogger
(
cls
):
def
getLogger
(
cls
):
logger
=
LoggingManager
.
getInstance
().
getLogger
(
cls
.
__name__
)
logger
=
LoggingManager
.
getInstance
().
getLogger
(
cls
.
__name__
)
...
@@ -47,6 +62,11 @@ class LdapLinuxPlatformUtility:
...
@@ -47,6 +62,11 @@ class LdapLinuxPlatformUtility:
p
=
DmSubprocess
(
'
%s %s
'
%
(
cls
.
SUDO_CMD
,
cmd
))
p
=
DmSubprocess
(
'
%s %s
'
%
(
cls
.
SUDO_CMD
,
cmd
))
p
.
run
()
p
.
run
()
@classmethod
def
executeCommand
(
cls
,
cmd
):
p
=
DmSubprocess
(
'
%s
'
%
(
cmd
))
p
.
run
()
def
getLdapClient
(
self
):
def
getLdapClient
(
self
):
if
self
.
ldapClient
is
not
None
:
if
self
.
ldapClient
is
not
None
:
try
:
try
:
...
@@ -167,8 +187,8 @@ class LdapLinuxPlatformUtility:
...
@@ -167,8 +187,8 @@ class LdapLinuxPlatformUtility:
logger
.
error
(
'
Could not add user %s to group %s: %s
'
%
(
username
,
groupName
,
ex
))
logger
.
error
(
'
Could not add user %s to group %s: %s
'
%
(
username
,
groupName
,
ex
))
raise
InternalError
(
exception
=
ex
)
raise
InternalError
(
exception
=
ex
)
# Refresh
NSCD cache
# Refresh
auth files
self
.
refresh
NscdGroupCache
()
self
.
refresh
AuthFiles
()
def
deleteUserFromGroup
(
self
,
username
,
groupName
):
def
deleteUserFromGroup
(
self
,
username
,
groupName
):
"""
Remove user from group.
"""
"""
Remove user from group.
"""
...
@@ -199,9 +219,8 @@ class LdapLinuxPlatformUtility:
...
@@ -199,9 +219,8 @@ class LdapLinuxPlatformUtility:
logger
.
error
(
'
Could not remove user %s from group %s: %s
'
%
(
username
,
groupName
,
ex
))
logger
.
error
(
'
Could not remove user %s from group %s: %s
'
%
(
username
,
groupName
,
ex
))
raise
InternalError
(
exception
=
ex
)
raise
InternalError
(
exception
=
ex
)
# Refresh NSCD cache
# Refresh auth files
self
.
refreshNscdGroupCache
()
self
.
refreshAuthFiles
()
@classmethod
@classmethod
def
createLocalGroup
(
cls
,
name
):
def
createLocalGroup
(
cls
,
name
):
...
@@ -265,8 +284,8 @@ class LdapLinuxPlatformUtility:
...
@@ -265,8 +284,8 @@ class LdapLinuxPlatformUtility:
logger
.
error
(
'
Could not set users %s for group %s: %s
'
%
(
usernameList
,
groupName
,
ex
))
logger
.
error
(
'
Could not set users %s for group %s: %s
'
%
(
usernameList
,
groupName
,
ex
))
raise
InternalError
(
exception
=
ex
)
raise
InternalError
(
exception
=
ex
)
# Refresh
NSCD cache
# Refresh
auth files
self
.
refresh
NscdGroupCache
()
self
.
refresh
AuthFiles
()
@classmethod
@classmethod
def
setPathReadExecutePermissionsForGroup
(
cls
,
path
,
groupName
):
def
setPathReadExecutePermissionsForGroup
(
cls
,
path
,
groupName
):
...
@@ -293,6 +312,22 @@ class LdapLinuxPlatformUtility:
...
@@ -293,6 +312,22 @@ class LdapLinuxPlatformUtility:
except
Exception
,
ex
:
except
Exception
,
ex
:
logger
.
warn
(
'
Failed to refresh NCSD group cache: %s
'
%
(
str
(
ex
)))
logger
.
warn
(
'
Failed to refresh NCSD group cache: %s
'
%
(
str
(
ex
)))
# Refresh auth files in a timer, to avoid running command too often
def
refreshAuthFiles
(
self
):
if
not
self
.
refreshAuthFilesCommand
:
return
if
self
.
refreshAuthFilesTimer
and
self
.
refreshAuthFilesTimer
.
is_alive
():
return
self
.
refreshAuthFilesTimer
=
threading
.
Timer
(
self
.
TIMER_DELAY_IN_SECONDS
,
self
.
__refreshAuthFiles
)
self
.
refreshAuthFilesTimer
.
start
()
def
__refreshAuthFiles
(
self
):
logger
=
self
.
getLogger
()
try
:
logger
.
debug
(
'
Refreshing auth files
'
)
self
.
executeCommand
(
self
.
refreshAuthFilesCommand
:)
except
Exception
,
ex
:
logger
.
warn
(
'
Failed to refresh auth files: %s
'
%
(
str
(
ex
)))
#######################################################################
#######################################################################
# Testing.
# 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