| Revision: | 1.24 |
| Committed: | Mon May 24 14:22:51 2021 UTC (5 years, 4 months ago) by sf-exg |
| Content type: | text/plain |
| Branch: | MAIN |
| Changes since 1.23: | +5 -8 lines |
| Log Message: | Stop using utmp if utmpx is available This commit changes ptytty to use only utmpx on systems where both utmpx and utmp are available, as utmp is generally deprecated and pointless to use on these, glibc being the exception. The commit also refactors code to reduce the amount of ifdeffery. |
| # | User | Rev | Content |
|---|---|---|---|
| 1 | root | 1.1 | #ifndef PTYTTY_H |
| 2 | #define PTYTTY_H | ||
| 3 | |||
| 4 | root | 1.5 | #include "libptytty.h" |
| 5 | root | 1.3 | #include "ptytty_conf.h" |
| 6 | root | 1.1 | |
| 7 | sf-exg | 1.23 | #include <sys/types.h> |
| 8 | |||
| 9 | root | 1.2 | #if defined(HAVE__GETPTY) || defined(HAVE_OPENPTY) || defined(UNIX98_PTY) |
| 10 | root | 1.1 | # define NO_SETOWNER_TTYDEV 1 |
| 11 | #endif | ||
| 12 | |||
| 13 | root | 1.2 | #if UTMP_SUPPORT |
| 14 | sf-exg | 1.24 | # if defined(HAVE_STRUCT_UTMPX) && !defined(__GLIBC__) |
| 15 | # define USE_UTMPX | ||
| 16 | # elif defined(HAVE_STRUCT_UTMP) | ||
| 17 | # define USE_UTMP | ||
| 18 | # else | ||
| 19 | root | 1.2 | # error cannot build with utmp support - no utmp or utmpx struct found |
| 20 | # endif | ||
| 21 | root | 1.1 | #endif |
| 22 | root | 1.2 | |
| 23 | root | 1.4 | struct ptytty_unix : ptytty |
| 24 | root | 1.2 | { |
| 25 | char *name; | ||
| 26 | |||
| 27 | sf-exg | 1.15 | void log_session (bool login, const char *hostname); |
| 28 | |||
| 29 | root | 1.1 | public: |
| 30 | |||
| 31 | root | 1.4 | ptytty_unix (); |
| 32 | ~ptytty_unix (); | ||
| 33 | root | 1.1 | |
| 34 | bool get (); | ||
| 35 | void put (); | ||
| 36 | |||
| 37 | root | 1.6 | void login (int cmd_pid, bool login_shell, const char *hostname); |
| 38 | |||
| 39 | root | 1.2 | #if UTMP_SUPPORT |
| 40 | sf-exg | 1.20 | int utmp_pos; |
| 41 | root | 1.2 | int cmd_pid; |
| 42 | bool login_shell; | ||
| 43 | #endif | ||
| 44 | root | 1.1 | }; |
| 45 | |||
| 46 | #endif | ||
| 47 |