pwd --- パスワードデータベースへのアクセスを提供する


このモジュールは Unix のユーザアカウントとパスワードのデータベースへのアクセスを提供します。全ての Unix 系 OS で利用できます。

Availability: Unix, not WASI, not iOS.

パスワードデータベースの各エントリはタプルのようなオブジェクトで提供され、それぞれの属性は passwd 構造体のメンバに対応しています(下の属性欄については、<pwd.h> を見てください):

インデックス

属性

意味

0

pw_name

ログイン名

1

pw_passwd

暗号化されたパスワード(optional))

2

pw_uid

ユーザID(UID)

3

pw_gid

グループID(GID)

4

pw_gecos

実名またはコメント

5

pw_dir

ホームディレクトリ

6

pw_shell

シェル

UIDとGIDは整数で、それ以外は全て文字列です。検索したエントリが見つからないと KeyError が発生します。

注釈

In traditional Unix the field pw_passwd usually contains a password encrypted with a DES derived algorithm. However most modern unices use a so-called shadow password system. On those unices the pw_passwd field only contains an asterisk ('*') or the letter 'x' where the encrypted password is stored in a file /etc/shadow which is not world readable. Whether the pw_passwd field contains anything useful is system-dependent.

このモジュールでは以下の内容を定義しています:

pwd.getpwuid(uid)

与えられたUIDに対応するパスワードデータベースのエントリを返します。

pwd.getpwnam(name)

与えられたユーザ名に対応するパスワードデータベースのエントリを返します。

pwd.getpwall()

パスワードデータベースの全てのエントリを、任意の順番で並べたリストを返します。

参考

grp モジュール

このモジュールに似た、グループデータベースへのアクセスを提供するモジュール。