summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Bogatov <KAction@gnu.org>2017-09-01 04:11:07 +0300
committerDmitry Bogatov <KAction@debian.org>2019-01-07 20:35:25 +0000
commitbb778bcea47776c32e51ae9d8eb1d532838af1ee (patch)
treee113191010ff4350663d2156210300f91da4ae9d
parent31ec842874e021aec51d9e41995b4388eefbf736 (diff)
[PATCH] Link checkpassword with gnu libc, not diet libc
Unfortunately, crypt(3) from diet libc does not recognize $6$ prefix of hash in /etc/shadow and as such, no login was possible at all. Author of diet libc proposed to either contribute apporiate code to diet libc, or link with other libc. There was choice to statically link with musl libc or dynamically gnu libc. Static linking with musl libc results in 76Kb binary (aganist 15Kb with diet libc) and as I found it unreasonable. Also, with dynamic linking, if new hashing method would ever reach gnu libc, checkpassword would catch it without my interaction. Unfortunately, this patch can't be forwarded, since upstream is not interested. Gbp-Pq: Name patch-link-checkpassword-with-gnu-libc-n.patch
-rw-r--r--Makefile6
-rw-r--r--checkpassword.c2
2 files changed, 5 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index df32647..a1ae4ad 100644
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,6 @@ all: fgetty login login2 checkpassword
DIET=diet -Os
#CROSS=arm-linux-
CROSS=
-LDFLAGS=
%.o: %.c
# gcc -march=i386 -mcpu=i386 -pipe -Os -fomit-frame-pointer -I../dietlibc/include -c $^ -DTEST
@@ -15,13 +14,14 @@ LDFLAGS=
# gcc -march=i386 -mcpu=i386 -pipe -g -I../dietlibc/include -DTEST -c $^
%: %.o
- $(DIET) $(CROSS)$(CC) -o $@ $^ $(LDFLAGS)
+ $(DIET) $(CROSS)$(CC) -o $@ $^
fgetty: fgetty.o fmt_ulong.o
login: login.o
login2: login2.o
-checkpassword: checkpassword.o
+checkpassword: checkpassword.c
+ gcc -Os $(CFLAGS) $(CPPFLAGS) $^ -lcrypt $(LDFLAGS) -o $@
checkpassword-pam: checkpassword-pam.o checkpassword-pam2.o
$(CROSS)$(CC) -o $@ $^ -lmisc $(LDFLAGS)
diff --git a/checkpassword.c b/checkpassword.c
index b7bbe85..655668a 100644
--- a/checkpassword.c
+++ b/checkpassword.c
@@ -1,8 +1,10 @@
+#define _XOPEN_SOURCE
#include <string.h>
#include <unistd.h>
#include <pwd.h>
#include <shadow.h>
#include <stdio.h>
+#include <alloca.h>
#ifdef __dietlibc__
#include <write12.h>
#else