2 * SPDX-License-Identifier: ISC
4 * Copyright (c) 1993-1996,1998-2005, 2007-2014
5 * Todd C. Miller <Todd.Miller@sudo.ws>
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 * Sponsored in part by the Defense Advanced Research Projects
20 * Agency (DARPA) and Air Force Research Laboratory, Air Force
21 * Materiel Command, USAF, under agreement number F39502-99-1-0512.
24 #ifndef SUDOERS_CHECK_H
25 #define SUDOERS_CHECK_H
27 /* Status codes for timestamp_status() */
35 * Time stamps are now stored in a single file which contains multiple
36 * records. Each record starts with a 16-bit version number and a 16-bit
37 * record size. Multiple record types can coexist in the same file.
41 /* Time stamp entry types */
42 #define TS_GLOBAL 0x01 /* not restricted by tty or ppid */
43 #define TS_TTY 0x02 /* restricted by tty */
44 #define TS_PPID 0x03 /* restricted by ppid */
45 #define TS_LOCKEXCL 0x04 /* special lock record */
47 /* Time stamp flags */
48 #define TS_DISABLED 0x01 /* entry disabled */
49 #define TS_ANYUID 0x02 /* ignore uid, only valid in the key */
51 struct timestamp_entry_v1 {
52 unsigned short version; /* version number */
53 unsigned short size; /* entry size */
54 unsigned short type; /* TS_GLOBAL, TS_TTY, TS_PPID */
55 unsigned short flags; /* TS_DISABLED, TS_ANYUID */
56 uid_t auth_uid; /* uid to authenticate as */
57 pid_t sid; /* session ID associated with tty/ppid */
58 struct timespec ts; /* time stamp (CLOCK_MONOTONIC) */
60 dev_t ttydev; /* tty device number */
61 pid_t ppid; /* parent pid */
65 struct timestamp_entry {
66 unsigned short version; /* version number */
67 unsigned short size; /* entry size */
68 unsigned short type; /* TS_GLOBAL, TS_TTY, TS_PPID */
69 unsigned short flags; /* TS_DISABLED, TS_ANYUID */
70 uid_t auth_uid; /* uid to authenticate as */
71 pid_t sid; /* session ID associated with tty/ppid */
72 struct timespec start_time; /* session/ppid start time */
73 struct timespec ts; /* time stamp (CLOCK_MONOTONIC) */
75 dev_t ttydev; /* tty device number */
76 pid_t ppid; /* parent pid */
80 void *timestamp_open(const char *user, pid_t sid);
81 void timestamp_close(void *vcookie);
82 bool timestamp_lock(void *vcookie, struct passwd *pw);
83 bool timestamp_update(void *vcookie, struct passwd *pw);
84 int timestamp_status(void *vcookie, struct passwd *pw);
85 int get_starttime(pid_t pid, struct timespec *starttime);
86 bool already_lectured(int status);
87 int set_lectured(void);
89 #endif /* SUDOERS_CHECK_H */