mirror of
https://github.com/troglobit/finit.git
synced 2026-11-19 19:40:50 +00:00
sulogin: check for Ctrl-D also if no pwd to abort and continue boot
Signed-off-by: Joachim Wiberg <joachim.nilsson@westermo.se>
This commit is contained in:
1 parent
e011dac98b
commit
430d402b14
1 file changed
+11
-7
+11
-7
@@ -128,6 +128,7 @@ int main(void)
|
|||||||
{
|
{
|
||||||
struct termios old, raw;
|
struct termios old, raw;
|
||||||
struct passwd pw = { 0 };
|
struct passwd pw = { 0 };
|
||||||
|
int rc = 1, ch;
|
||||||
|
|
||||||
if (get_passwd(&pw))
|
if (get_passwd(&pw))
|
||||||
err(1, "reading credentials for UID 0");
|
err(1, "reading credentials for UID 0");
|
||||||
@@ -137,8 +138,13 @@ int main(void)
|
|||||||
printf("The %s account is locked, allowing entry.\n", pw.pw_name);
|
printf("The %s account is locked, allowing entry.\n", pw.pw_name);
|
||||||
/* fallthrough */
|
/* fallthrough */
|
||||||
case 0: /* no password at all? */
|
case 0: /* no password at all? */
|
||||||
printf("Press enter for maintenance.");
|
printf("Press enter for maintenance (Ctrl-D to continue) ");
|
||||||
getchar();
|
fflush(stdout);
|
||||||
|
ch = getchar();
|
||||||
|
if (ch == 4 || ch == EOF) { /* Ctrl-D */
|
||||||
|
rc = 0;
|
||||||
|
goto SWdone;
|
||||||
|
}
|
||||||
goto nopass;
|
goto nopass;
|
||||||
|
|
||||||
case '$': /* md5/shaN or similar, original DES not supported */
|
case '$': /* md5/shaN or similar, original DES not supported */
|
||||||
@@ -168,12 +174,10 @@ int main(void)
|
|||||||
printf("Give %s password for maintenance (Ctrl-D to continue): ", pw.pw_name);
|
printf("Give %s password for maintenance (Ctrl-D to continue): ", pw.pw_name);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
do {
|
do {
|
||||||
int ch;
|
|
||||||
|
|
||||||
ch = getchar();
|
ch = getchar();
|
||||||
if (ch == EOF || ch == '\n' || ch == '\r')
|
if (ch == '\n' || ch == '\r')
|
||||||
break;
|
break;
|
||||||
if (ch == 4) /* Ctrl-D */
|
if (ch == 4 || ch == EOF) /* Ctrl-D */
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
pwd[i++] = ch;
|
pwd[i++] = ch;
|
||||||
@@ -196,7 +200,7 @@ exit:
|
|||||||
puts("");
|
puts("");
|
||||||
done:
|
done:
|
||||||
freepw(&pw);
|
freepw(&pw);
|
||||||
return 1;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user