From b6dc13c2d3754704b1bf5af4e6b957b48585102f Mon Sep 17 00:00:00 2001 From: Jonathan Liu Date: Tue, 21 May 2013 17:01:55 +0200 Subject: sulogin: allow system maintenance login if root password is empty The current password checking is unable to distinguish between the user entering an empty password or pressing Control-D. As a result, an empty password always results in normal startup. We modify bb_ask to return NULL if Control-D is pressed without entering a password. The sulogin applet is then modified to only proceed to normal startup if bb_ask returns NULL. This covers EOF with no password, interrupt by timeout and ^C. Signed-off-by: Jonathan Liu Signed-off-by: Denys Vlasenko --- libbb/bb_askpass.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libbb/bb_askpass.c') diff --git a/libbb/bb_askpass.c b/libbb/bb_askpass.c index fe2b50677..77c1bcd95 100644 --- a/libbb/bb_askpass.c +++ b/libbb/bb_askpass.c @@ -65,7 +65,9 @@ char* FAST_FUNC bb_ask(const int fd, int timeout, const char *prompt) i = 0; while (1) { int r = read(fd, &ret[i], 1); - if (r < 0) { + if ((i == 0 && r == 0) /* EOF (^D) with no password */ + || r < 0 + ) { /* read is interrupted by timeout or ^C */ ret = NULL; break; -- cgit v1.2.3