[hackers] [ubase] Set UTMP_PATH in config.def.h || sin

From: <git_AT_suckless.org>
Date: Wed, 02 Jul 2014 13:06:11 +0200

commit 2832db2368b7b2e3efa4f1475414e21711cb9d27
Author: sin <sin_AT_2f30.org>
Date: Tue Jul 1 15:48:35 2014 +0100

    Set UTMP_PATH in config.def.h

diff --git a/config.def.h b/config.def.h
index 98e4c3d..1ea5ca5 100644
--- a/config.def.h
+++ b/config.def.h
_AT_@ -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
index e522516..542f70b 100644
--- a/getty.c
+++ b/getty.c
_AT_@ -12,6 +12,7 @@
 #include <unistd.h>
 #include <utmp.h>
 
+#include "config.h"
 #include "util.h"
 
 static void
_AT_@ -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);
_AT_@ -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
index 76d8022..3b39902 100644
--- a/login.c
+++ b/login.c
_AT_@ -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
index e5ac878..98dec65 100644
--- a/uptime.c
+++ b/uptime.c
_AT_@ -7,6 +7,7 @@
 #include <time.h>
 #include <utmpx.h>
 
+#include "config.h"
 #include "util.h"
 
 static void
_AT_@ -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
index def8682..d5205a0 100644
--- a/who.c
+++ b/who.c
_AT_@ -6,6 +6,7 @@
 #include <unistd.h>
 #include <utmp.h>
 
+#include "config.h"
 #include "util.h"
 
 static void
_AT_@ -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 ||
Received on Wed Jul 02 2014 - 13:06:11 CEST

This archive was generated by hypermail 2.3.0 : Wed Jul 02 2014 - 13:12:14 CEST