OPSI.Util.Task.Rights module

Setting access rights for opsi.

Opsi needs different access rights and ownerships for files and folders during its use. To ease the setting of these permissions this modules provides helpers for this task.

New in version 4.0.6.1.

Changed in version 4.0.6.3: Added function chown().

Changed in version 4.0.6.4: Improved removeDuplicatesFromDirectories().

Changed in version 4.0.6.24: Disabled removeDuplicatesFromDirectories() to avoid problems with wrong rights set on /var/lib/opsi/depot

Changed in version 4.0.7.9: Many internal refactorings to make adding new directories easier.

copyright:uib GmbH <info@uib.de>
author:Niko Wenselowski <n.wenselowski@uib.de>
license:GNU Affero General Public License version 3
class OPSI.Util.Task.Rights.Rights(uid, gid, files, directories, correctLinks)

Bases: tuple

Alias for field number 4

directories

Alias for field number 3

files

Alias for field number 2

gid

Alias for field number 1

uid

Alias for field number 0

OPSI.Util.Task.Rights.chown(path, uid, gid)

Set the ownership of a file or folder.

The uid will only be set if the efficte uid is 0 - i.e. running with sudo.

If changing the owner fails an Exception will only be risen if the current uid is 0 - we are root. In all other cases only a warning is shown.

OPSI.Util.Task.Rights.filterDirsAndRights(path, iterable)

Iterates over iterable and the yields the appropriate directories.

This function also avoids that directorires get returned more than once.

OPSI.Util.Task.Rights.getAbsoluteDir(path)

Returns to absolute path to the directory.

If path is no directory the absolute path to the dir containing path will be used.

OPSI.Util.Task.Rights.getDepotDirectory(path)
OPSI.Util.Task.Rights.getDepotUrl()
OPSI.Util.Task.Rights.getDirectoriesAndExpectedRights(path)
OPSI.Util.Task.Rights.getLocalFQDN()
OPSI.Util.Task.Rights.getPxeDirectory()
OPSI.Util.Task.Rights.getWebserverRepositoryPath()

Returns the path to the directory where packages for Linux netboot installations may be.

On an unsuported distribution or without the relevant folder existing None will be returned.

OPSI.Util.Task.Rights.getWebserverUsernameAndGroupname()

Returns the name of the user and group belonging to the webserver in the default configuration.

Raises:RuntimeError – If running on an Unsupported distribution.
OPSI.Util.Task.Rights.getWorkbenchDirectory()
OPSI.Util.Task.Rights.setRights(path=u'/')
OPSI.Util.Task.Rights.setRightsOnFile(filepath, filemod)
OPSI.Util.Task.Rights.setRightsOnSSHDirectory(userId, groupId, path=u'/var/lib/opsi/.ssh')