aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2025-05-01 15:31:30 +0000
committerLaurent Bercot <ska@appnovation.com>2025-05-01 15:31:30 +0000
commit303a139e04436058ac9c8ca3cfc9b55df9ae66f2 (patch)
tree13306c00406c6c24b8e63db2f310e5e79e0b63dc
parent20e3fc2dd0c34844cd200fda104354da55942b6c (diff)
downloadutmps-303a139e04436058ac9c8ca3cfc9b55df9ae66f2.tar.gz
Add utmp.h
Signed-off-by: Laurent Bercot <ska@appnovation.com>
-rw-r--r--Makefile1
-rw-r--r--doc/index.html3
-rw-r--r--package/configure-snippets/configure_case_lines2
-rw-r--r--package/configure-snippets/configure_generate_make5
-rw-r--r--package/configure-snippets/configure_help_options3
-rw-r--r--package/configure-snippets/configure_init_vars1
-rw-r--r--package/deps.mak11
-rw-r--r--package/targets.mak3
-rw-r--r--src/include/utmp.h13
-rw-r--r--src/include/utmps/utmp.h40
-rw-r--r--src/include/utmps/utmpx.h6
-rw-r--r--src/utmps/deps-lib/utmps3
-rw-r--r--src/utmps/getutxent_r.c13
-rw-r--r--src/utmps/getutxid_r.c13
-rw-r--r--src/utmps/getutxline_r.c13
15 files changed, 125 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 752b8ba..90098b5 100644
--- a/Makefile
+++ b/Makefile
@@ -112,6 +112,7 @@ tgz: distclean
cp -a . /tmp/$$package-$$version && \
cd /tmp && \
tar -zpcv --owner=0 --group=0 --numeric-owner --exclude=.git* -f /tmp/$$package-$$version.tar.gz $$package-$$version && \
+ sha256sum $$package-$$version.tar.gz > $$package-$$version.tar.gz.sha256 && \
exec rm -rf /tmp/$$package-$$version
strip: $(ALL_LIBS) $(ALL_BINS)
diff --git a/doc/index.html b/doc/index.html
index 2ee875c..6e13ccc 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -76,7 +76,8 @@ suitable replacement for
<h3> Download </h3>
<ul>
- <li> The current released version of utmps is <a href="utmps-0.1.3.0.tar.gz">0.1.3.0</a>. </li>
+ <li> The current released version of utmps is <a href="utmps-0.1.3.0.tar.gz">0.1.3.0</a>.
+You can access its checksum <a href="utmps-0.1.3.0.tar.gz.sha256">here</a>. </li>
<li> Alternatively, you can checkout a copy of the
<a href="//git.skarnet.org/cgi-bin/cgit.cgi/utmps/">utmps
git repository</a>:
diff --git a/package/configure-snippets/configure_case_lines b/package/configure-snippets/configure_case_lines
index f3c9708..3a29521 100644
--- a/package/configure-snippets/configure_case_lines
+++ b/package/configure-snippets/configure_case_lines
@@ -1,3 +1,5 @@
+ --enable-utmp|--enable-utmp=yes) doutmp=true ;;
+ --disable-utmp|--enable-utmp=no) doutmp=false ;;
--enable-libc-includes|--enable-libc-includes=yes) libcincludes=true ;;
--disable-libc-includes|--enable-libc-includes=no) libcincludes=false ;;
--enable-nsss|--enable-nsss=yes) usensss=true ;;
diff --git a/package/configure-snippets/configure_generate_make b/package/configure-snippets/configure_generate_make
index e361a46..ceb9660 100644
--- a/package/configure-snippets/configure_generate_make
+++ b/package/configure-snippets/configure_generate_make
@@ -10,3 +10,8 @@ else
echo "LIBNSSS :="
echo "MAYBEPTHREAD_LIB :="
fi
+if $doutmp ; then
+ echo "DO_UTMP := 1"
+else
+ echo "DO_UTMP :="
+fi
diff --git a/package/configure-snippets/configure_help_options b/package/configure-snippets/configure_help_options
index c0f8c1a..09f883f 100644
--- a/package/configure-snippets/configure_help_options
+++ b/package/configure-snippets/configure_help_options
@@ -1,5 +1,6 @@
--enable-nsss use the nsss library for user information [disabled]
- --enable-libc-includes overwrite utmpx.h in includedir [disabled]
+ --enable-utmp also export utmp.h with Linux-specific declarations
+ --enable-libc-includes overwrite utmp[x].h in includedir [disabled]
--with-utmpd-socket=PATH assume the utmpd socket is at PATH [/run/utmps/.utmpd-socket]
--with-wtmpd-socket=PATH assume the wtmpd socket is at PATH [/run/utmps/.wtmpd-socket]
diff --git a/package/configure-snippets/configure_init_vars b/package/configure-snippets/configure_init_vars
index edb8ad3..c89a438 100644
--- a/package/configure-snippets/configure_init_vars
+++ b/package/configure-snippets/configure_init_vars
@@ -1,4 +1,5 @@
usensss=false
+doutmp=false
libcincludes=false
utmpdpath=/run/utmps/.utmpd-socket
wtmpdpath=/run/utmps/.wtmpd-socket
diff --git a/package/deps.mak b/package/deps.mak
index 0169948..604f525 100644
--- a/package/deps.mak
+++ b/package/deps.mak
@@ -2,13 +2,18 @@
# This file has been generated by tools/gen-deps.sh
#
+src/include/utmps/utmp.h: src/include/utmps/utmpx.h
src/include/utmps/utmps.h: src/include/utmps/utmpx.h
+src/include/utmp.h: src/include/utmps/utmp.h
src/include/utmpx.h: src/include/utmps/utmpx.h
src/utmps/utmps-internal.h: src/include/utmps/utmps.h src/include/utmps/utmpx.h
src/utmps/endutxent.o src/utmps/endutxent.lo: src/utmps/endutxent.c src/utmps/utmps-internal.h src/include/utmps/utmps.h src/include/utmps/utmpx.h
src/utmps/getutxent.o src/utmps/getutxent.lo: src/utmps/getutxent.c src/utmps/utmps-internal.h src/include/utmps/utmps.h src/include/utmps/utmpx.h
+src/utmps/getutxent_r.o src/utmps/getutxent_r.lo: src/utmps/getutxent_r.c src/utmps/utmps-internal.h src/include/utmps/utmps.h src/include/utmps/utmpx.h
src/utmps/getutxid.o src/utmps/getutxid.lo: src/utmps/getutxid.c src/utmps/utmps-internal.h src/include/utmps/utmps.h src/include/utmps/utmpx.h
+src/utmps/getutxid_r.o src/utmps/getutxid_r.lo: src/utmps/getutxid_r.c src/utmps/utmps-internal.h src/include/utmps/utmps.h src/include/utmps/utmpx.h
src/utmps/getutxline.o src/utmps/getutxline.lo: src/utmps/getutxline.c src/utmps/utmps-internal.h src/include/utmps/utmps.h src/include/utmps/utmpx.h
+src/utmps/getutxline_r.o src/utmps/getutxline_r.lo: src/utmps/getutxline_r.c src/utmps/utmps-internal.h src/include/utmps/utmps.h src/include/utmps/utmpx.h
src/utmps/logwtmp.o src/utmps/logwtmp.lo: src/utmps/logwtmp.c src/include/utmps/utmpx.h
src/utmps/pututxline.o src/utmps/pututxline.lo: src/utmps/pututxline.c src/utmps/utmps-internal.h src/include/utmps/utmps.h src/include/utmps/utmpx.h
src/utmps/setutxent.o src/utmps/setutxent.lo: src/utmps/setutxent.c src/utmps/utmps-internal.h src/include/utmps/utmps.h src/include/utmps/utmpx.h
@@ -31,13 +36,13 @@ src/utmps/utmps_utmpx_unpack.o src/utmps/utmps_utmpx_unpack.lo: src/utmps/utmps_
src/utmps/utmpxname.o src/utmps/utmpxname.lo: src/utmps/utmpxname.c src/include/utmps/utmpx.h
ifeq ($(strip $(STATIC_LIBS_ARE_PIC)),)
-libutmps.a.xyzzy: src/utmps/endutxent.o src/utmps/getutxent.o src/utmps/getutxid.o src/utmps/getutxline.o src/utmps/logwtmp.o src/utmps/pututxline.o src/utmps/setutxent.o src/utmps/updwtmpx.o src/utmps/utmpxname.o src/utmps/utmps_end.o src/utmps/utmps_getent.o src/utmps/utmps_getid.o src/utmps/utmps_getline.o src/utmps/utmps_here.o src/utmps/utmps_here_maybe_init.o src/utmps/utmps_putline.o src/utmps/utmps_rewind.o src/utmps/utmps_start.o src/utmps/utmps_updwtmpx.o src/utmps/utmps_utmpx_pack.o src/utmps/utmps_utmpx_unpack.o
+libutmps.a.xyzzy: src/utmps/endutxent.o src/utmps/getutxent.o src/utmps/getutxent_r.o src/utmps/getutxid.o src/utmps/getutxid_r.o src/utmps/getutxline.o src/utmps/getutxline_r.o src/utmps/logwtmp.o src/utmps/pututxline.o src/utmps/setutxent.o src/utmps/updwtmpx.o src/utmps/utmpxname.o src/utmps/utmps_end.o src/utmps/utmps_getent.o src/utmps/utmps_getid.o src/utmps/utmps_getline.o src/utmps/utmps_here.o src/utmps/utmps_here_maybe_init.o src/utmps/utmps_putline.o src/utmps/utmps_rewind.o src/utmps/utmps_start.o src/utmps/utmps_updwtmpx.o src/utmps/utmps_utmpx_pack.o src/utmps/utmps_utmpx_unpack.o
else
-libutmps.a.xyzzy:src/utmps/endutxent.lo src/utmps/getutxent.lo src/utmps/getutxid.lo src/utmps/getutxline.lo src/utmps/logwtmp.lo src/utmps/pututxline.lo src/utmps/setutxent.lo src/utmps/updwtmpx.lo src/utmps/utmpxname.lo src/utmps/utmps_end.lo src/utmps/utmps_getent.lo src/utmps/utmps_getid.lo src/utmps/utmps_getline.lo src/utmps/utmps_here.lo src/utmps/utmps_here_maybe_init.lo src/utmps/utmps_putline.lo src/utmps/utmps_rewind.lo src/utmps/utmps_start.lo src/utmps/utmps_updwtmpx.lo src/utmps/utmps_utmpx_pack.lo src/utmps/utmps_utmpx_unpack.lo
+libutmps.a.xyzzy:src/utmps/endutxent.lo src/utmps/getutxent.lo src/utmps/getutxent_r.lo src/utmps/getutxid.lo src/utmps/getutxid_r.lo src/utmps/getutxline.lo src/utmps/getutxline_r.lo src/utmps/logwtmp.lo src/utmps/pututxline.lo src/utmps/setutxent.lo src/utmps/updwtmpx.lo src/utmps/utmpxname.lo src/utmps/utmps_end.lo src/utmps/utmps_getent.lo src/utmps/utmps_getid.lo src/utmps/utmps_getline.lo src/utmps/utmps_here.lo src/utmps/utmps_here_maybe_init.lo src/utmps/utmps_putline.lo src/utmps/utmps_rewind.lo src/utmps/utmps_start.lo src/utmps/utmps_updwtmpx.lo src/utmps/utmps_utmpx_pack.lo src/utmps/utmps_utmpx_unpack.lo
endif
libutmps.pc: EXTRA_LIBS := -lskarnet
libutmps.so.xyzzy: EXTRA_LIBS := -lskarnet
-libutmps.so.xyzzy:src/utmps/endutxent.lo src/utmps/getutxent.lo src/utmps/getutxid.lo src/utmps/getutxline.lo src/utmps/logwtmp.lo src/utmps/pututxline.lo src/utmps/setutxent.lo src/utmps/updwtmpx.lo src/utmps/utmpxname.lo src/utmps/utmps_end.lo src/utmps/utmps_getent.lo src/utmps/utmps_getid.lo src/utmps/utmps_getline.lo src/utmps/utmps_here.lo src/utmps/utmps_here_maybe_init.lo src/utmps/utmps_putline.lo src/utmps/utmps_rewind.lo src/utmps/utmps_start.lo src/utmps/utmps_updwtmpx.lo src/utmps/utmps_utmpx_pack.lo src/utmps/utmps_utmpx_unpack.lo
+libutmps.so.xyzzy:src/utmps/endutxent.lo src/utmps/getutxent.lo src/utmps/getutxent_r.lo src/utmps/getutxid.lo src/utmps/getutxid_r.lo src/utmps/getutxline.lo src/utmps/getutxline_r.lo src/utmps/logwtmp.lo src/utmps/pututxline.lo src/utmps/setutxent.lo src/utmps/updwtmpx.lo src/utmps/utmpxname.lo src/utmps/utmps_end.lo src/utmps/utmps_getent.lo src/utmps/utmps_getid.lo src/utmps/utmps_getline.lo src/utmps/utmps_here.lo src/utmps/utmps_here_maybe_init.lo src/utmps/utmps_putline.lo src/utmps/utmps_rewind.lo src/utmps/utmps_start.lo src/utmps/utmps_updwtmpx.lo src/utmps/utmps_utmpx_pack.lo src/utmps/utmps_utmpx_unpack.lo
utmps-utmpd: EXTRA_LIBS := ${MAYBEPTHREAD_LIB}
utmps-utmpd: src/utmps/utmps-utmpd.o libutmps.a.xyzzy ${LIBNSSS} -lskarnet
utmps-write: EXTRA_LIBS := ${SOCKET_LIB} ${MAYBEPTHREAD_LIB}
diff --git a/package/targets.mak b/package/targets.mak
index 13b1e4d..e6f13aa 100644
--- a/package/targets.mak
+++ b/package/targets.mak
@@ -10,4 +10,7 @@ UTMPS_DESCRIPTION := The utmps library, a secure utmp implementation
ifneq ($(DO_LIBC_INCLUDES),)
EXTRA_INCLUDES := src/include/utmpx.h
+ifneq ($(DO_UTMP),)
+EXTRA_INCLUDES += src/include/utmp.h
+endif
endif
diff --git a/src/include/utmp.h b/src/include/utmp.h
new file mode 100644
index 0000000..2a7706d
--- /dev/null
+++ b/src/include/utmp.h
@@ -0,0 +1,13 @@
+/* ISC license. */
+
+/*
+ This file is part of the utmps package.
+ See https://skarnet.org/software/utmps/
+*/
+
+#ifndef UTMP_H
+#define UTMP_H
+
+#include <utmps/utmp.h>
+
+#endif
diff --git a/src/include/utmps/utmp.h b/src/include/utmps/utmp.h
new file mode 100644
index 0000000..bd2ea3f
--- /dev/null
+++ b/src/include/utmps/utmp.h
@@ -0,0 +1,40 @@
+/* ISC license. */
+
+#ifndef UTMPS_UTMP_H
+#define UTMPS_UTMP_H
+
+#include <utmps/utmpx.h>
+
+/* Unused, but some packages require these macros to be present */
+#define UTMP_FILE UTMPX_FILE
+#define WTMP_FILE "/var/log/wtmp"
+#define UTMP_FILENAME UTMP_FILE
+#define WTMP_FILENAME WTMP_FILE
+#define _PATH_UTMP UTMP_FILE
+#define _PATH_WTMP WTMP_FILE
+
+struct lastlog
+{
+ time_t ll_time ;
+ char ll_line[UTMPS_UT_LINESIZE] ;
+ char ll_host[UTMPS_UT_HOSTSIZE] ;
+} ;
+
+#define utmp utmpx
+
+#define endutent endutxent
+#define setutent setutxent
+#define getutent getutxent
+#define getutid getutxid
+#define getutline getutxline
+#define pututline pututxline
+#define utmpname utmpxname
+#define updwtmp updwtmpx
+
+#ifdef _DEFAULT_SOURCE
+#define getutent_r utmps_getutxent_r
+#define getutid_r utmps_getutxid_r
+#define getutline_r utmps_getutxline_r
+#endif
+
+#endif
diff --git a/src/include/utmps/utmpx.h b/src/include/utmps/utmpx.h
index 8fa6dd2..fdc1dbc 100644
--- a/src/include/utmps/utmpx.h
+++ b/src/include/utmps/utmpx.h
@@ -79,6 +79,12 @@ extern void logwtmp (char const *, char const *, char const *) ;
# define ut_time ut_tv.tv_sec
#endif
+#ifdef _DEFAULT_SOURCE
+extern int utmps_getutxent_r (struct utmpx *, struct utmpx **) ;
+extern int utmps_getutxid_r (struct utmpx const *, struct utmpx *, struct utmpx **) ;
+extern int utmps_getutxent_r (struct utmpx const *, struct utmpx *, struct utmpx **) ;
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/src/utmps/deps-lib/utmps b/src/utmps/deps-lib/utmps
index c73d439..b3325d8 100644
--- a/src/utmps/deps-lib/utmps
+++ b/src/utmps/deps-lib/utmps
@@ -1,7 +1,10 @@
endutxent.o
getutxent.o
+getutxent_r.o
getutxid.o
+getutxid_r.o
getutxline.o
+getutxline_r.o
logwtmp.o
pututxline.o
setutxent.o
diff --git a/src/utmps/getutxent_r.c b/src/utmps/getutxent_r.c
new file mode 100644
index 0000000..3630bcd
--- /dev/null
+++ b/src/utmps/getutxent_r.c
@@ -0,0 +1,13 @@
+/* ISC license. */
+
+#include <utmps/utmpx.h>
+#include <utmps/utmps.h>
+#include "utmps-internal.h"
+
+int utmps_getutxent_r (struct utmpx *b, struct utmpx **p)
+{
+ if (!utmps_here_maybe_init()) return -1 ;
+ if (!utmps_getent(&utmps_here, b, 0, 0)) return -1 ;
+ *p = b ;
+ return 0 ;
+}
diff --git a/src/utmps/getutxid_r.c b/src/utmps/getutxid_r.c
new file mode 100644
index 0000000..f8438e1
--- /dev/null
+++ b/src/utmps/getutxid_r.c
@@ -0,0 +1,13 @@
+/* ISC license. */
+
+#include <utmps/utmpx.h>
+#include <utmps/utmps.h>
+#include "utmps-internal.h"
+
+int utmps_getutxid_r (struct utmpx const *a, struct utmpx *b, struct utmpx **p)
+{
+ if (!utmps_here_maybe_init()) return -1 ;
+ if (!utmps_getid(&utmps_here, (unsigned short)a->ut_type, a->ut_id, b, 0, 0)) return -1 ;
+ *p = b ;
+ return 0 ;
+}
diff --git a/src/utmps/getutxline_r.c b/src/utmps/getutxline_r.c
new file mode 100644
index 0000000..d43d59b
--- /dev/null
+++ b/src/utmps/getutxline_r.c
@@ -0,0 +1,13 @@
+/* ISC license. */
+
+#include <utmps/utmpx.h>
+#include <utmps/utmps.h>
+#include "utmps-internal.h"
+
+int utmps_getutxline_r (struct utmpx const *a, struct utmpx *b, struct utmpx **p)
+{
+ if (!utmps_here_maybe_init()) return -1 ;
+ if (!utmps_getline(&utmps_here, a->ut_line, b, 0, 0)) return -1 ;
+ *p = b ;
+ return 0 ;
+}