Skip to content
Snippets Groups Projects
Commit c5a2005a authored by sveseli's avatar sveseli
Browse files

update sudo rules, change file/directory group owners

parent 419b4de2
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,8 @@ User_Alias USER=DM_SYSTEM_USER ...@@ -5,7 +5,8 @@ User_Alias USER=DM_SYSTEM_USER
Cmnd_Alias SETFACL=/usr/bin/setfacl -m group\:*\:rx DM_DATA_DIR/* Cmnd_Alias SETFACL=/usr/bin/setfacl -m group\:*\:rx DM_DATA_DIR/*
Cmnd_Alias USERMOD=/usr/sbin/usermod -a -G * * Cmnd_Alias USERMOD=/usr/sbin/usermod -a -G * *
Cmnd_Alias GROUPADD=/usr/sbin/groupadd * Cmnd_Alias GROUPADD=/usr/sbin/groupadd *
Cmnd_Alias CHOWN=/bin/chown -R \:* *
USER HOST=(root) NOPASSWD: SETFACL,USERMOD,GROUPADD USER HOST=(root) NOPASSWD: SETFACL,USERMOD,GROUPADD,CHOWN
...@@ -10,6 +10,7 @@ class LinuxUtility: ...@@ -10,6 +10,7 @@ class LinuxUtility:
GROUPADD_CMD = '/usr/sbin/groupadd' GROUPADD_CMD = '/usr/sbin/groupadd'
USERMOD_CMD = '/usr/sbin/usermod' USERMOD_CMD = '/usr/sbin/usermod'
SETFACL_CMD = '/usr/bin/setfacl' SETFACL_CMD = '/usr/bin/setfacl'
CHOWN_CMD = '/bin/chown'
@classmethod @classmethod
def getLogger(cls): def getLogger(cls):
...@@ -52,6 +53,13 @@ class LinuxUtility: ...@@ -52,6 +53,13 @@ class LinuxUtility:
cmd = '%s -m group\:%s\:rx %s' % (cls.SETFACL_CMD, groupName, path) cmd = '%s -m group\:%s\:rx %s' % (cls.SETFACL_CMD, groupName, path)
cls.executeSudoCommand(cmd) cls.executeSudoCommand(cmd)
@classmethod
def changePathGroupOwner(cls, path, groupName):
logger = cls.getLogger()
logger.debug('Changing group owner to %s for path %s' % (groupName, path))
cmd = '%s -R \:%s %s' % (cls.CHOWN_CMD, groupName, path)
cls.executeSudoCommand(cmd)
####################################################################### #######################################################################
# Testing. # Testing.
......
...@@ -91,6 +91,9 @@ class ExperimentManager(Singleton): ...@@ -91,6 +91,9 @@ class ExperimentManager(Singleton):
self.platformUtility.createGroup(experimentName) self.platformUtility.createGroup(experimentName)
self.logger.debug('Setting permissions for %s to %s' % (storageDirectory, self.DIR_PERMISSIONS_MODE)) self.logger.debug('Setting permissions for %s to %s' % (storageDirectory, self.DIR_PERMISSIONS_MODE))
OsUtility.chmodPath(storageDirectory, dirMode=self.DIR_PERMISSIONS_MODE) OsUtility.chmodPath(storageDirectory, dirMode=self.DIR_PERMISSIONS_MODE)
self.logger.debug('Changing group owner for %s to %s' % (storageDirectory, experimentName))
self.platformUtility.changePathGroupOwner(storageDirectory, experimentName)
experimentUsers = experiment.get('experimentUsernameList', []) experimentUsers = experiment.get('experimentUsernameList', [])
self.logger.debug('Found experiment users: %s', experimentUsers) self.logger.debug('Found experiment users: %s', experimentUsers)
for username in experimentUsers: for username in experimentUsers:
...@@ -109,6 +112,8 @@ class ExperimentManager(Singleton): ...@@ -109,6 +112,8 @@ class ExperimentManager(Singleton):
if self.manageStoragePermissions: if self.manageStoragePermissions:
self.logger.debug('Modifying permissions for %s' % filePath) self.logger.debug('Modifying permissions for %s' % filePath)
OsUtility.chmodPath(filePath, fileMode=self.FILE_PERMISSIONS_MODE) OsUtility.chmodPath(filePath, fileMode=self.FILE_PERMISSIONS_MODE)
self.logger.debug('Changing group owner for %s to %s' % (filePath, experimentName))
self.platformUtility.changePathGroupOwner(filePath, experimentName)
self.logger.debug('Processing file %s' % filePath) self.logger.debug('Processing file %s' % filePath)
self.fileProcessingManager.processFile(fileInfo) self.fileProcessingManager.processFile(fileInfo)
else: else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment