Skip to contentSkip to conversation

sulogin: make getpasswd(...) return NULL on ^D

PATCH In review Andreas Henriksson 2 participants 3 messages Nov 28, 2016 – Dec 7, 2016 Util-Linux package

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sulogin: make getpasswd(...) return NULL on ^D

This makes the caller bail out early instead of evaluating the input as a password.

Addresses: http://bugs.debian.org/846112

---
 login-utils/sulogin.c | 1 +
 1 file changed, 1 insertion(+)
login-utils/sulogin.c +1 -0
index 1c4313a..43117b2 100644
@@ -695,6 +695,7 @@ static char *getpasswd(struct console *con)
 				ptr--;
 			break;
 		case CEOF:
+			ret = NULL;
 			goto quit;
 		default:
 			if ((size_t)(ptr - &pass[0]) >= (sizeof(pass) -1 )) {
Signature · 1 line
2.10.2
#1 lore raw

PATCH 1/1 sulogin: bail out from getpasswd(...) on timeout

If timeout happens while waiting in prompt, bail out instead of retrying.

Addresses: http://bugs.debian.org/846107

---
 login-utils/sulogin.c | 4 ++++
 1 file changed, 4 insertions(+)
login-utils/sulogin.c +4 -0
index 43117b2..79a9274 100644
@@ -645,6 +645,10 @@ static char *getpasswd(struct console *con)
 	while (cp->eol == '\0') {
 		if (read(fd, &c, 1) < 1) {
 			if (errno == EINTR || errno == EAGAIN) {
+				if (alarm_rised) {
+					ret = NULL;
+					goto quit;
+				}
 				xusleep(250000);
 				continue;
 			}
Signature · 1 line
2.10.2