utmp.h 文件

用途

定义特定用户和记帐信息文件的结构。

描述

utmpwtmpfailedlogin 文件中记录的结构在 /usr/include/utmp.h 文件中定义。 此头文件中的 utmp 结构包含以下字段:

描述
ut_user 用户登录名。
ut_line 设备名 (控制台或 lnxx)。 此字段中字符串的最大长度为 11 个字符加上空字符。 当对进程以外的内容进行记帐时,允许使用以下特殊字符串或格式:
运行 LVL_MSG
运行级别: 具体来说,是进程的运行级别。
启动信息
系统引导: 具体来说,是初始程序装入 (IPL) 的时间。
(OTIME_MSG)
旧时间: 具体来说,是登录的时间。
NTIME_MSG
新时间: 具体来说,时间闲置。
ut_pid 进程标识。
ut_type 条目类型,可以是下列其中一个值:
空的
文件中未使用的空间。
运行 LVL
进程的运行级别,如 inittab 文件中所定义。
启动时间
系统启动的时间。
旧时光
用户登录系统的时间。
新纪元
用户空闲的时间量。
初始化进程
init 命令衍生的进程。
登录流程
等待登录的 getty 进程。
用户进程
用户进程。
DEAD_PROCESS
僵尸进程。
记帐
系统记帐过程。
UTMAXTYPE 记帐
允许的最大法律价值ut_type

嵌入在 utmp 结构中的是 exit_status 结构,其中包含以下字段:

描述
e_termination 进程的终止状态。
e_exit 进程的退出状态,标记为 DEAD_PROCESS 值。
ut_time 输入的时间。

示例

#ifndef -H-UTMP
#define _H_UTMP
#define UTMP_FILE        "/etc/utmp"
#define WTMP_FILE        "/var/adm/wtmp"
#define ILOG_FILE        "/etc/.ilog"
#define ut_name  ut_user
  
struct utmp
{
        char ut_user[256];             /* User login name */
        char ut_id[14];                /* /etc/inittab id */
        char ut_line[64];              /* device name (console, lnxx) */
        pid_t ut_pid;                  /* process id */
        short ut_type;                 /* type of entry */
#if !defined(__64BIT__) 
        int __time_t_space;            /* for 32vs64-bit time_t PPC */
#endif
        time_t ut_time;                /* time entry was made */
        struct exit_status
        {
            short e_termination;       /* Process termination status */
            short e_exit;              /* Process exit status */
        }
        ut_exit;                       /* The exit status of a process
                                        * marked as DEAD_PROCESS.
                                        */
        char ut_host[256];             /* host name */
        int __dbl_word_pad;            /* for double word alignment */
        int __reservedA[2];
        int __reservedV[6];
};
                    /*  Definitions for ut_type */
#define EMPTY              0
#define RUN_LVL            1
#define BOOT_TIME          2
#define OLD_TIME           3
#define NEW_TIME           4
#define INIT_PROCESS       5         /* Process spawned by "init"                 */
#define LOGIN_PROCESS      6         /* A "getty" process                         */

                                     /* waitingforlogin                           */
#define USER_PROCESS       7         /* A user process                            */
#define DEAD_PROCESS       8
#define ACCOUNTING         9
#define UTMAXTYPE ACCOUNTING         /* Largest legal value                        */
                                     /* of ut_type                                 */

   /* Special strings or formats used in the          */
   /* "ut_line" field when accounting for             */
   /* something other than a process.                 */
   /* No string for the ut_line field can be more     */
   /* than 11 chars + a NULL in length.               */

#define RUNLVL_MSG          "run-level %c"
#define BOOT_MSG            "system boot"
#define OTIME_MSG           "old time"
#define TIME_MSG            "new time"

#endif                /* _H_UTMP    */
注: 人员 命令从 /etc/utmp/var/adm/wtmp中抽取信息。 和 /etc/security/failedlogin 文件。

文件

描述
/etc/utmp utmp 文件的路径,其中包含登录到系统的用户的记录。
/var/adm/wtmp wtmp 文件的路径,其中包含有关已登录用户的记帐信息。
/etc/security/failedlogin failedlogin 文件的路径,其中包含无效登录尝试的列表。