listener module

listener module#

listener.setuid(uid: int | str) None[source]#

Set the current process’s effective user id. Use unsetuid() to return to the listeners UID.

When used with any other user than root. Be aware that listener.unsetuid() will not be possible afterwards, as that requires root privileges.

Parameters:

uid (int or str) – UID the process should have

Returns:

None

listener.unsetuid() None[source]#

Return the current process’s effective user id to the listeners UID. Only possible if the current effective user id is root.

Returns:

None

listener.run(exe: str, argv: list[str], uid: int = -1, wait: bool = True) int[source]#

Execute a the program exe with arguments argv and effective user id uid.

Parameters:
  • exe (str) – path to executable

  • argv (list(str)) – arguments to pass to executable

  • uid (int) – effective user id the process should be started with

  • wait (bool) – if true will block until the process has finished and return either its exit code or the signal that lead to its stop (a negative number), see os.P_WAIT. If false will return as soon as the new process has been created, with the process id as the return value (see os.P_NOWAIT).

Returns:

exit code or signal number or process id

Return type:

int

Warning

Not waiting for the sub-process leads to zombie processes.

class listener.SetUID(uid: int = 0)[source]#

Bases: object

Temporarily change effective UID to given user.

Parameters:

uid (int) – Numeric user ID. Defaults to root.