This commit is contained in:
Your Name 2024-09-30 16:11:43 +03:00
parent 04ff3cf8e7
commit 0306c4319b
3 changed files with 32 additions and 15 deletions

View file

@ -60,23 +60,24 @@ static int password(const struct passwd *pw) {
fflush(stdout);
if (hide_input(STDIN_FILENO, 1)) {
fprintf(stderr, "su: %s\n", strerror(errno));
fprintf(stderr, "\nsu: %s\n", strerror(errno));
return 1;
}
off_t ret = 0;
if ((ret = read(STDIN_FILENO, psswd, sizeof(psswd))) <= 0) {
fprintf(stderr, "su: %s\n", strerror(errno));
fprintf(stderr, "\nsu: %s\n", strerror(errno));
return 1;
}
putchar('\n');
psswd[ret - 1] = '\0';
if (pw_check("su", pw, psswd)) {
memset(psswd, '\0', sizeof(psswd));
return 1;
}
printf("\n");
memset(psswd, '\0', sizeof(psswd));
return 0;
}