Skip to main content
Files added late

2 files were added to this release more than 14 days after its initial publication. Inspect the release files before installing.

Introduction

The pyutmp module provides a Python-oriented interface to the utmp file on Unix-like operating systems. To paraphrase the Linux Programmer’s Manual page utmp(5), the utmp file allows one to discover information about who is currently using (i.e., is logged into) the system. The utmp file is a series of entries whose structure is typically defined by the utmp.h C header file.

This module provides an read-only interface to the underlying operating system’s C utmp API.

Interface and Usage

The pyutmp module supplies two classes: UtmpFile and Utmp. A UtmpFile object represents the open utmp file; when you iterate over a UtmpFile object, it yields successive Utmp objects. For example:

from pyutmp import UtmpFile
import time

for utmp in UtmpFile():
    # utmp is a Utmp object
    if utmp.ut_user_process:
        print '%s logged in at %s on tty %s' % (utmp.ut_user, time.ctime(utmp.ut_time), utmp.ut_line)

UtmpFile

In addition to the __iter__() generator method, allowing iteration over the contents of the utmp file, the UtmpFile class also provides a rewind() method that permits you to reset the file pointer to the top of the file. See the class documentation for details.

Utmp

The fields of the Utmp class are operating system-dependent. However, they will always include at least the following fields:

Field

Type

Description

ut_user

str

The user associated with the utmp entry, if any.

ut_line

str

The tty or pseudo-tty associated with the entry, if any. In this API, the line will always be the full path to the device.

ut_host

str

The host name associated with the entry, if any.

ut_time

timestamp

The timestamp associated with the entry. This timestamp is in the form returned by time.time() and may be passed directly to methods like time.ctime().

ut_user_process

bool

Whether or not the utmp entry is a user process (as opposed to a reboot or some other system event).

On some operating systems, other fields may be present. For instance, on Linux and Solaris systems (and other System V-derived systems), Utmp also contains the following fields:

Optional Field

Type

Description

ut_type

str

The type of the entry, typically one of the following string values: “RUN_LVL”, “BOOT_TIME”, “NEW_TIME”, “OLD_TIME”, “INIT_PROCESS”, “LOGIN_PROCESS”, “USER_PROCESS”, “DEAD_PROCESS”, “ACCOUNTING”. See the utmp(5) manual page for a description of these values

ut_pid

int

Associated process ID, if any.

ut_id

str

The init(8) ID, or the abbreviated tty name.

ut_exit_code

int

Process exit code, if applicable.

ut_session

int

Session ID, for windowing.

ut_addr

int array

IPv4 address of remote host (if applicable), one octet per array element.

If you’re writing portable code, you should not count on the presence of those attributes–or, at the very least, you should wrap access to them in a try/catch block that catches AttributeError.

Notes

This module has been tested on the following operating systems:

  • Ubuntu Linux, version 8.04

  • FreeBSD

  • Mac OS X 10.4 (Tiger)

  • OpenSolaris (2008.05, x86, using the SunStudio 12 compiler suite)

Adding support for other Unix variants should be straightforward.

Restrictions

  • Access to the utmp file is read-only. There is no provision for writing to the file.

Metadata

Release files for pyutmp 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Files added late

2 files were uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.

We recommend inspecting the release files before installing.

Source distributions (sdists)

Source distribution for pyutmp 0.2.1
File Size Uploaded Provenance
pyutmp-0.2.1.zip 41.0 kB Without provenance Details
pyutmp-0.2.1.tar.gz 33.7 kB Without provenance Details

Release files / pyutmp-0.2.1.zip

File added late

This file was uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.

We recommend inspecting the release file before installing.

Download URL pyutmp-0.2.1.zip
Size 41.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d2d6d4b47f7094f1299114a81217c7c34e1af5ceb4af7837134dc6037af53fdf
BLAKE2b-256 checksum
How to use checksums
42f60faec911c0d47ad7424a2afa9489d4ba6ec23969fd81b016a16bb9246e30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pyutmp-0.2.1.tar.gz

File added late

This file was uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.

We recommend inspecting the release file before installing.

Download URL pyutmp-0.2.1.tar.gz
Size 33.7 kB
Tags Source
SHA-256 checksum
How to use checksums
957ae25bc6997c3b18d8255399eb8409c9f47c9fd47c1ac852e49659bfd54869
BLAKE2b-256 checksum
How to use checksums
dd65da24e5a673cc828f58ec698c73b7fa145c3645d7d03bc8ea993c26532f9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for pyutmp 0.2.1

Upload timing

Files added late

2 files were uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.


Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files No provenance

0.2

0.1

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page