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

View File

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

View File

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

5
who.c
View File

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