Skip to content

Add support for multiline badpass_message #419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 54 additions & 2 deletions plugins/sudoers/auth/sudo_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,56 @@ sudo_auth_cleanup(const struct sudoers_context *ctx, struct passwd *pw,
debug_return_int(AUTH_SUCCESS);
}


static void
convert_str(char *str) {
char *src = str;
char *dst = str;

while (*src) {
if (src[0] == '\\')
{
switch (src[1])
{
case 'a':
*dst = '\a';
src += 2;
break;
case 'b':
*dst = '\b';
src += 2;
break;
case 'v':
*dst = '\v';
src += 2;
break;
case 'f':
*dst = '\f';
src += 2;
break;
case 'n':
*dst = '\n';
src += 2;
break;
case 'e':
*dst = '\033';
src += 2;
break;
default:
src++;
break;
}
}
else
{
*dst = *src;
src++;
}
dst++;
}
*dst = '\0';
}

static void
pass_warn(void)
{
Expand All @@ -233,8 +283,10 @@ pass_warn(void)
if (def_insults)
warning = _(INSULT);
#endif
sudo_printf(SUDO_CONV_ERROR_MSG|SUDO_CONV_PREFER_TTY, "%s\n", warning);

char *second_warning = strdup(warning);
convert_str(second_warning);
sudo_printf(SUDO_CONV_ERROR_MSG|SUDO_CONV_PREFER_TTY, "%s\n", second_warning);
free(second_warning);
debug_return;
}

Expand Down