2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 06:15:37 +00:00

Pass back a failure or error string to the front end.

The audit_failure() function now stores the failure string.
This will allow an audit plugin to log the reason if the user's
request is a rejected.
This commit is contained in:
Todd C. Miller
2020-01-30 13:25:36 -07:00
parent 22105009d8
commit 45e589d443
8 changed files with 176 additions and 98 deletions

View File

@@ -1,7 +1,7 @@
/*
* SPDX-License-Identifier: ISC
*
* Copyright (c) 2009-2015 Todd C. Miller <Todd.Miller@sudo.ws>
* Copyright (c) 2009-2015, 2019-2020 Todd C. Miller <Todd.Miller@sudo.ws>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -26,6 +26,7 @@
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sudoers.h"
@@ -39,6 +40,8 @@
# include "solaris_audit.h"
#endif
char *audit_msg = NULL;
int
audit_success(int argc, char *argv[])
{
@@ -70,14 +73,22 @@ int
audit_failure(int argc, char *argv[], char const *const fmt, ...)
{
int rc = 0;
va_list ap;
debug_decl(audit_success, SUDOERS_DEBUG_AUDIT);
/* Set audit_msg for audit plugin. */
free(audit_msg);
audit_msg = NULL;
va_start(ap, fmt);
if (vasprintf(&audit_msg, fmt, ap) == -1)
rc = -1;
va_end(ap);
if (!def_log_denied)
debug_return_int(0);
#if defined(HAVE_BSM_AUDIT) || defined(HAVE_LINUX_AUDIT)
if (argv != NULL) {
va_list ap;
int oldlocale;
/* Audit error messages should be in the sudoers locale. */