opsicommon.server package

Submodules

opsicommon.server.rights module

server rights

class opsicommon.server.rights.DirPermission(path, username, groupname, file_permissions, dir_permissions, recursive=True, correct_links=False, modify_file_exe=True)

Bases: FilePermission

Parameters:
  • path (str | Path)

  • username (str | None)

  • groupname (str | None)

  • file_permissions (int)

  • dir_permissions (int)

  • recursive (bool)

  • correct_links (bool)

  • modify_file_exe (bool)

chmod(path, stat_res=None)
Parameters:
  • path (str | Path)

  • stat_res (Optional[stat_result])

Return type:

None

chown(path, stat_res=None)
Parameters:
  • path (str | Path)

  • stat_res (Optional[stat_result])

Return type:

None

dir_permissions: int
modify_file_exe: bool = True
recursive: bool = True
class opsicommon.server.rights.FilePermission(path, username, groupname, file_permissions)

Bases: object

Parameters:
  • path (str | Path)

  • username (str | None)

  • groupname (str | None)

  • file_permissions (int)

apply(path)
Parameters:

path (str | Path)

Return type:

None

chmod(path, stat_res=None)
Parameters:
  • path (str | Path)

  • stat_res (Optional[stat_result])

Return type:

None

chown(path, stat_res=None)
Parameters:
  • path (str | Path)

  • stat_res (Optional[stat_result])

Return type:

None

file_permissions: int
property gid: int
groupname: str | None
static groupname_to_gid(groupname)
Parameters:

groupname (str)

Return type:

int

path: str | Path
property uid: int
username: str | None
static username_to_uid(username)
Parameters:

username (str)

Return type:

int

class opsicommon.server.rights.PermissionRegistry

Bases: object

property permissions: dict[str, FilePermission]
register_default_permissions()
Return type:

None

register_permission(*permission)
Parameters:

permission (FilePermission)

Return type:

None

reinit()
Return type:

None

remove_permissions()
Return type:

None

opsicommon.server.rights.set_rights(start_path='/')
Parameters:

start_path (str | Path)

Return type:

None

opsicommon.server.setup module

server setup tasks

opsicommon.server.setup.add_user_to_group(username, groupname)
Parameters:
  • username (str)

  • groupname (str)

Return type:

None

opsicommon.server.setup.create_group(groupname, system=False)
Parameters:
  • groupname (str)

  • system (bool)

Return type:

None

opsicommon.server.setup.create_user(username, primary_groupname, home, shell, system=False)
Parameters:
  • username (str)

  • primary_groupname (str)

  • home (str)

  • shell (str)

  • system (bool)

Return type:

None

opsicommon.server.setup.get_groups()
Return type:

dict[str, struct_group]

opsicommon.server.setup.get_users()
Return type:

dict[str, struct_passwd]

opsicommon.server.setup.modify_user(username, home=None, shell=None)
Parameters:
  • username (str)

  • home (str | None)

  • shell (str | None)

Return type:

None

opsicommon.server.setup.set_primary_group(username, groupname)
Parameters:
  • username (str)

  • groupname (str)

Return type:

None

opsicommon.server.setup.setup(ignore_errors=False)
Parameters:

ignore_errors (bool)

Return type:

None

opsicommon.server.setup.setup_file_permissions(path='/')
Parameters:

path (str)

Return type:

None

opsicommon.server.setup.setup_users_and_groups(ignore_errors=False)
Parameters:

ignore_errors (bool)

Return type:

None

Module contents

server specific