ubase

suckless linux base utils
git clone git://git.2f30.org/ubase
Log | Files | Refs | README | LICENSE

commit 2832db2368b7b2e3efa4f1475414e21711cb9d27
parent d0145aaf1f156606ce1eb1ba32a5e432cd55888a
Author: sin <sin@2f30.org>
Date:   Tue,  1 Jul 2014 15:48:35 +0100

Set UTMP_PATH in config.def.h

Diffstat:
Mconfig.def.h | 2++
Mgetty.c | 5+++--
Mlogin.c | 4++--
Muptime.c | 3++-
Mwho.c | 5+++--
5 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -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" diff --git a/getty.c b/getty.c @@ -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); } diff --git a/login.c b/login.c @@ -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); diff --git a/uptime.c b/uptime.c @@ -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; diff --git a/who.c b/who.c @@ -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 ||