summaryrefslogtreecommitdiff
path: root/user/netqmail/0002-qbiffutmpx-20170820.patch
diff options
context:
space:
mode:
authorLaurent Bercot <ska-adelie@skarnet.org>2018-08-28 16:14:58 +0000
committerLaurent Bercot <ska-adelie@skarnet.org>2018-08-28 16:14:58 +0000
commit6990bd384a5a11f1dfa75bc32d094dd02d1851a2 (patch)
tree8a0febc1bd96aafde6f622faf5ca43abbcce51f1 /user/netqmail/0002-qbiffutmpx-20170820.patch
parent3f2f1bfb288e936b66a25b31319690fb479fa10c (diff)
downloadpackages-6990bd384a5a11f1dfa75bc32d094dd02d1851a2.tar.gz
packages-6990bd384a5a11f1dfa75bc32d094dd02d1851a2.tar.bz2
packages-6990bd384a5a11f1dfa75bc32d094dd02d1851a2.tar.xz
packages-6990bd384a5a11f1dfa75bc32d094dd02d1851a2.zip
user/netqmail: new package. First of *many* iterations.
Diffstat (limited to 'user/netqmail/0002-qbiffutmpx-20170820.patch')
-rw-r--r--user/netqmail/0002-qbiffutmpx-20170820.patch130
1 files changed, 130 insertions, 0 deletions
diff --git a/user/netqmail/0002-qbiffutmpx-20170820.patch b/user/netqmail/0002-qbiffutmpx-20170820.patch
new file mode 100644
index 000000000..a55044f6e
--- /dev/null
+++ b/user/netqmail/0002-qbiffutmpx-20170820.patch
@@ -0,0 +1,130 @@
+<https://schmonz.com/qmail/qbiffutmpx>
+
+diff --git a/Makefile b/Makefile
+index 0f0e31a..ae8d229 100644
+--- a/Makefile
++++ b/Makefile
+@@ -685,6 +685,13 @@ chkshsgr warn-shsgr tryshsgr.c compile load
+ hasshsgr.h
+ rm -f tryshsgr.o tryshsgr
+
++hasutmpx.h: \
++tryutmpx.c compile load
++ ( ( ./compile tryutmpx.c && ./load tryutmpx ) >/dev/null \
++ 2>&1 \
++ && echo \#define HASUTMPX 1 || exit 0 ) > hasutmpx.h
++ rm -f tryutmpx.o tryutmpx
++
+ haswaitp.h: \
+ trywaitp.c compile load
+ ( ( ./compile trywaitp.c && ./load trywaitp ) >/dev/null \
+@@ -1071,7 +1078,8 @@ qbiff.1
+
+ qbiff.o: \
+ compile qbiff.c readwrite.h stralloc.h gen_alloc.h substdio.h subfd.h \
+-substdio.h open.h byte.h str.h headerbody.h hfield.h env.h exit.h
++substdio.h open.h byte.h str.h headerbody.h hfield.h env.h exit.h \
++hasutmpx.h
+ ./compile qbiff.c
+
+ qmail-clean: \
+diff --git a/TARGETS b/TARGETS
+index facdad7..c37a453 100644
+--- a/TARGETS
++++ b/TARGETS
+@@ -388,3 +388,4 @@
+ man
+ setup
+ check
++hasutmpx.h
+diff --git a/qbiff.c b/qbiff.c
+index 4e9f1d8..f21b6bf 100644
+--- a/qbiff.c
++++ b/qbiff.c
+@@ -1,5 +1,9 @@
+ #include <sys/types.h>
+ #include <sys/stat.h>
++#include "hasutmpx.h"
++#ifdef HASUTMPX
++#include <utmpx.h>
++#else
+ #include <utmp.h>
+ #ifndef UTMP_FILE
+ #ifdef _PATH_UTMP
+@@ -8,6 +12,7 @@
+ #define UTMP_FILE "/etc/utmp"
+ #endif
+ #endif
++#endif
+ #include "readwrite.h"
+ #include "stralloc.h"
+ #include "substdio.h"
+@@ -20,15 +25,22 @@
+ #include "env.h"
+ #include "exit.h"
+
++#ifndef HASUTMPX
+ substdio ssutmp;
+ char bufutmp[sizeof(struct utmp) * 16];
+ int fdutmp;
++#endif
+ substdio sstty;
+ char buftty[1024];
+ int fdtty;
+
++#ifdef HASUTMPX
++struct utmpx *ut;
++char line[sizeof(ut->ut_line) + 1];
++#else
+ struct utmp ut;
+ char line[sizeof(ut.ut_line) + 1];
++#endif
+ stralloc woof = {0};
+ stralloc tofrom = {0};
+ stralloc text = {0};
+@@ -63,7 +75,11 @@ void main()
+ if (!(user = env_get("USER"))) _exit(0);
+ if (!(sender = env_get("SENDER"))) _exit(0);
+ if (!(userext = env_get("LOCAL"))) _exit(0);
++#ifdef HASUTMPX
++ if (str_len(user) > sizeof(ut->ut_user)) _exit(0);
++#else
+ if (str_len(user) > sizeof(ut.ut_name)) _exit(0);
++#endif
+
+ if (!stralloc_copys(&tofrom,"*** TO <")) _exit(0);
+ if (!stralloc_cats(&tofrom,userext)) _exit(0);
+@@ -88,6 +104,7 @@ void main()
+ if (!stralloc_cat(&woof,&text)) _exit(0);
+ if (!stralloc_cats(&woof,"\015\n")) _exit(0);
+
++#ifndef HASUTMPX
+ fdutmp = open_read(UTMP_FILE);
+ if (fdutmp == -1) _exit(0);
+ substdio_fdbuf(&ssutmp,read,fdutmp,bufutmp,sizeof(bufutmp));
+@@ -97,6 +114,13 @@ void main()
+ {
+ byte_copy(line,sizeof(ut.ut_line),ut.ut_line);
+ line[sizeof(ut.ut_line)] = 0;
++#else
++ while ((ut = getutxent()))
++ if (ut->ut_type == USER_PROCESS && !str_diffn(ut->ut_user,user,sizeof(ut->ut_user)))
++ {
++ byte_copy(line,sizeof(ut->ut_line),ut->ut_line);
++ line[sizeof(ut->ut_line)] = 0;
++#endif
+ if (line[0] == '/') continue;
+ if (!line[0]) continue;
+ if (line[str_chr(line,'.')]) continue;
+diff --git a/tryutmpx.c b/tryutmpx.c
+new file mode 100644
+index 0000000..551b597
+--- /dev/null
++++ b/tryutmpx.c
+@@ -0,0 +1,6 @@
++#include <utmpx.h>
++
++void main()
++{
++ ;
++}