9#define UTMP_FILE _PATH_UTMP
11#define UTMP_FILE "/etc/utmp"
29char bufutmp[
sizeof(
struct utmp) * 16];
37char line[
sizeof(
ut.ut_line) + 1];
75 if (chdir(
"/dev") == -1)
_exit(0);
92 for (i = 0; i <
tofrom.len; ++i)
99 for (i = 0; i <
text.len; ++i)
100 if ((
text.s[i] < 32) || (
text.s[i] > 126))
105 if (!stralloc_cats(&
woof,
"\015\n"))
_exit(0);
107 if (!stralloc_cats(&
woof,
"\015\n"))
_exit(0);
110 fdutmp = open_read(UTMP_FILE);
111 if (fdutmp == -1)
_exit(0);
112 buffer_init(&
b,read,fdutmp,bufutmp,
sizeof(bufutmp));
114 while (buffer_get(&
b,&
ut,
sizeof(
ut)) ==
sizeof(
ut))
115 if (!str_diffn(
ut.ut_name,
user,
sizeof(
ut.ut_name))) {
117 while ((
ut = getutxent()) != 0)
118 if (
ut->ut_type == USER_PROCESS && !str_diffn(
ut->ut_user,
user,
sizeof(
ut->ut_user))) {
121 byte_copy(
line,
sizeof(
ut.ut_line),
ut.ut_line);
122 line[
sizeof(
ut.ut_line)] = 0;
124 byte_copy(
line,
sizeof(
ut->ut_line),
ut->ut_line);
125 line[
sizeof(
ut->ut_line)] = 0;
127 if (
line[0] ==
'/')
continue;
128 if (!
line[0])
continue;
129 if (
line[str_chr(
line,
'.')])
continue;
132 if (
fdtty == -1)
continue;
133 if (fstat(
fdtty,&st) == -1) { close(
fdtty);
continue; }
134 if (!(st.st_mode & 0100)) { close(
fdtty);
continue; }
135 if (st.st_uid != getuid()) { close(
fdtty);
continue; }
int stralloc_copys(stralloc *, char const *)
unsigned int hfield_skipname()
void h(char *, int, int, int)
void doheader(stralloc *h)
char line[sizeof(ut->ut_line)+1]