Set UTMP_PATH in config.def.h

This commit is contained in:
sin 2014-07-01 15:48:35 +01:00
parent d0145aaf1f
commit 2832db2368
5 changed files with 12 additions and 7 deletions

View File

@ -3,3 +3,5 @@
#define ENV_SUPATH "/bin"
#define ENV_PATH "/bin"
#define PW_CIPHER "$6$" /* SHA-512 */
#undef UTMP_PATH
#define UTMP_PATH "/var/run/utmp"

View File

@ -12,6 +12,7 @@
#include <unistd.h>
#include <utmp.h>
#include "config.h"
#include "util.h"
static void
@ -89,7 +90,7 @@ main(int argc, char *argv[])
eprintf("chmod %s:", tty);
/* Clear all utmp entries for this tty */
fp = fopen("/var/run/utmp", "r+");
fp = fopen(UTMP_PATH, "r+");
if (fp) {
do {
pos = ftell(fp);
@ -105,7 +106,7 @@ main(int argc, char *argv[])
break;
} while (1);
if (ferror(fp))
weprintf("%s: I/O error:", "/var/run/utmp");
weprintf("%s: I/O error:", UTMP_PATH);
fclose(fp);
}

View File

@ -88,9 +88,9 @@ main(int argc, char *argv[])
strlcpy(usr.ut_line, tty, sizeof(usr.ut_line));
usr.ut_tv.tv_sec = time(NULL);
fp = fopen("/var/run/utmp", "a");
fp = fopen(UTMP_PATH, "a");
if (!fp)
weprintf("fopen %s:", "/var/run/utmp");
weprintf("fopen %s:", UTMP_PATH);
fwrite(&usr, sizeof(usr), 1, fp);
fclose(fp);

View File

@ -7,6 +7,7 @@
#include <time.h>
#include <utmpx.h>
#include "config.h"
#include "util.h"
static void
@ -49,7 +50,7 @@ main(int argc, char *argv[])
else
printf("%d min, ", minutes);
if ((ufp = fopen("/var/run/utmp", "r"))) {
if ((ufp = fopen(UTMP_PATH, "r"))) {
while ((n = fread(&utx, sizeof(utx), 1, ufp)) > 0) {
if (!utx.ut_user[0])
continue;

5
who.c
View File

@ -6,6 +6,7 @@
#include <unistd.h>
#include <utmp.h>
#include "config.h"
#include "util.h"
static void
@ -43,8 +44,8 @@ main(int argc, char *argv[])
if (argc > 0)
usage();
if (!(ufp = fopen("/var/run/utmp", "r")))
eprintf("fopen: %s:", "/var/run/utmp");
if (!(ufp = fopen(UTMP_PATH, "r")))
eprintf("fopen: %s:", UTMP_PATH);
while(fread(&usr, sizeof(usr), 1, ufp) == 1) {
if (!*usr.ut_name || !*usr.ut_line ||