Polkit.UnixProcess¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/c |
The UNIX group IDs |
||
r/w/c |
The UNIX process ID |
||
r/w/c |
The UNIX process ID file descriptor |
||
r |
Whether the UNIX process ID file descriptor is safe |
||
r/w/c |
The start time of the process, since the machine booted |
||
r/w/c |
The UNIX user ID |
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class Polkit.UnixProcess(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
An object for representing a UNIX process. In order to be reliable and race-free, this requires support for PID File Descriptors in the kernel, dbus-daemon/broker and systemd. With this functionality, we can reliably track processes without risking PID reuse and race conditions, and compare them.
NOTE: If PID FDs are not available, this object will fall back to using PIDs, and this designed is now known broken; a mechanism to exploit a delay in start time in the Linux kernel was identified. Avoid calling
Polkit.Subject.equal
() to compare two processes.To uniquely identify processes, both the process id and the start time of the process (a monotonic increasing value representing the time since the kernel was started) is used.
NOTE: This object stores, and provides access to, the real UID of the process. That value can change over time (with set*uid*(2) and exec*(2)). Checks whether an operation is allowed need to take care to use the UID value as of the time when the operation was made (or, following the open() privilege check model, when the connection making the operation possible was initiated). That is usually done by initializing this with
Polkit.UnixProcess.new_for_owner
() with trusted data.- classmethod new(pid)¶
- Parameters:
pid (
int
) – The process id.- Returns:
A
Polkit.Subject
. Free withGObject.Object.unref
().- Return type:
Creates a new
Polkit.UnixProcess
for pid.The uid and start time of the process will be looked up in using e.g. the /proc filesystem depending on the platform in use.
- classmethod new_for_owner(pid, start_time, uid)¶
- Parameters:
- Returns:
A
Polkit.Subject
. Free withGObject.Object.unref
().- Return type:
Creates a new
Polkit.UnixProcess
object for pid, start_time and uid.
- classmethod new_full(pid, start_time)¶
- Parameters:
- Returns:
A
Polkit.Subject
. Free withGObject.Object.unref
().- Return type:
Creates a new
Polkit.UnixProcess
object for pid and start_time.The uid of the process will be looked up in using e.g. the /proc filesystem depending on the platform in use.
- classmethod new_pidfd(pidfd, uid, gids)¶
- Parameters:
- Returns:
A
Polkit.Subject
. Free withGObject.Object.unref
().- Return type:
Creates a new
Polkit.UnixProcess
object for pidfd and uid.
- get_gids()¶
- Returns:
a
GLib.Array
of #gid_t containing the group ids for self orNone
if unknown, as a new reference to the array, caller must deref it when done.- Return type:
Gets the group ids for self. Note that this is the real group-ids, not the effective group-ids.
- get_owner()¶
- Raises:
- Return type:
(deprecated)
- get_pidfd()¶
- Returns:
The process id file descriptor for self.
- Return type:
Gets the process id file descriptor for self.
- get_pidfd_is_safe()¶
-
Checks if the process id file descriptor for self is safe or if it was opened locally and thus vulnerable to reuse.
- get_uid()¶
- Returns:
The user id for self or -1 if unknown.
- Return type:
Gets the user id for self. Note that this is the real user-id, not the effective user-id.
NOTE: The UID may change over time, so the returned value may not match the current state of the underlying process; or the UID may have been set by
Polkit.UnixProcess.new_for_owner
() orPolkit.UnixProcess.set_uid
(), in which case it may not correspond to the actual UID of the referenced process at all (at any point in time).
- set_gids(gids)¶
- Parameters:
gids ([[
object
]]) – AGLib.List
of #gid_t containing the group ids to set for self orNone
to unset them. A reference to gids is taken.
Sets the (real, not effective) group ids for self.
Property Details¶
- Polkit.UnixProcess.props.gids¶
- Name:
gids
- Type:
- Default Value:
- Flags:
The UNIX group ids of the process.
- Polkit.UnixProcess.props.pid¶
-
The UNIX process id.
- Polkit.UnixProcess.props.pidfd¶
-
The UNIX process id file descriptor.
- Polkit.UnixProcess.props.pidfd_is_safe¶
-
Whether the UNIX process ID file descriptor is safe
- Polkit.UnixProcess.props.start_time¶
-
The start time of the process.