added tty logging
This commit is contained in:
38
logging.c
38
logging.c
@@ -94,6 +94,7 @@ void log_error(code)
|
|||||||
register char *p;
|
register char *p;
|
||||||
register int count;
|
register int count;
|
||||||
time_t now;
|
time_t now;
|
||||||
|
char *tty;
|
||||||
#if (LOGGING & SLOG_FILE)
|
#if (LOGGING & SLOG_FILE)
|
||||||
register FILE *fp;
|
register FILE *fp;
|
||||||
#endif /* LOGGING & SLOG_FILE */
|
#endif /* LOGGING & SLOG_FILE */
|
||||||
@@ -102,6 +103,14 @@ void log_error(code)
|
|||||||
char *tmp, save;
|
char *tmp, save;
|
||||||
#endif /* LOGGING & SLOG_SYSLOG */
|
#endif /* LOGGING & SLOG_SYSLOG */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get our ttyname or set to "none"
|
||||||
|
*/
|
||||||
|
if (isatty(0))
|
||||||
|
tty = ttyname(0);
|
||||||
|
else
|
||||||
|
tty = "none";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* we will skip this stuff when using syslog(3) but it is
|
* we will skip this stuff when using syslog(3) but it is
|
||||||
* necesary for mail and file logs.
|
* necesary for mail and file logs.
|
||||||
@@ -117,52 +126,56 @@ void log_error(code)
|
|||||||
switch (code) {
|
switch (code) {
|
||||||
|
|
||||||
case ALL_SYSTEMS_GO:
|
case ALL_SYSTEMS_GO:
|
||||||
(void) sprintf(p, "PWD=%s ; COMMAND=", cwd);
|
(void) sprintf(p, "TTY=%s ; PWD=%s ; COMMAND=", tty, cwd);
|
||||||
#if (LOGGING & SLOG_SYSLOG)
|
#if (LOGGING & SLOG_SYSLOG)
|
||||||
pri = Syslog_priority_OK;
|
pri = Syslog_priority_OK;
|
||||||
#endif /* LOGGING & SLOG_SYSLOG */
|
#endif /* LOGGING & SLOG_SYSLOG */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VALIDATE_NO_USER:
|
case VALIDATE_NO_USER:
|
||||||
(void) sprintf(p, "user NOT in sudoers ; PWD=%s ; COMMAND=", cwd);
|
(void) sprintf(p,
|
||||||
|
"user NOT in sudoers ; TTY=%s ; PWD=%s ; COMMAND=", tty, cwd);
|
||||||
#if (LOGGING & SLOG_SYSLOG)
|
#if (LOGGING & SLOG_SYSLOG)
|
||||||
pri = Syslog_priority_NO;
|
pri = Syslog_priority_NO;
|
||||||
#endif /* LOGGING & SLOG_SYSLOG */
|
#endif /* LOGGING & SLOG_SYSLOG */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VALIDATE_NOT_OK:
|
case VALIDATE_NOT_OK:
|
||||||
(void) sprintf(p, "command not allowed ; PWD=%s ; COMMAND=", cwd);
|
(void) sprintf(p,
|
||||||
|
"command not allowed ; TTY=%s ; PWD=%s ; COMMAND=", tty, cwd);
|
||||||
#if (LOGGING & SLOG_SYSLOG)
|
#if (LOGGING & SLOG_SYSLOG)
|
||||||
pri = Syslog_priority_NO;
|
pri = Syslog_priority_NO;
|
||||||
#endif /* LOGGING & SLOG_SYSLOG */
|
#endif /* LOGGING & SLOG_SYSLOG */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VALIDATE_ERROR:
|
case VALIDATE_ERROR:
|
||||||
(void) sprintf(p, "error in %s, line %d ; PWD=%s. ",
|
(void) sprintf(p, "error in %s, line %d ; TTY=%s ; PWD=%s. ",
|
||||||
_PATH_SUDO_SUDOERS, errorlineno, cwd);
|
_PATH_SUDO_SUDOERS, errorlineno, tty, cwd);
|
||||||
#if (LOGGING & SLOG_SYSLOG)
|
#if (LOGGING & SLOG_SYSLOG)
|
||||||
pri = Syslog_priority_NO;
|
pri = Syslog_priority_NO;
|
||||||
#endif /* LOGGING & SLOG_SYSLOG */
|
#endif /* LOGGING & SLOG_SYSLOG */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GLOBAL_NO_PW_ENT:
|
case GLOBAL_NO_PW_ENT:
|
||||||
(void) sprintf(p, "There is no /etc/passwd entry for uid %d. ",
|
(void) sprintf(p,
|
||||||
uid);
|
"There is no passwd entry for uid %d (TTY=%s). ", uid, tty);
|
||||||
#if (LOGGING & SLOG_SYSLOG)
|
#if (LOGGING & SLOG_SYSLOG)
|
||||||
pri = Syslog_priority_NO;
|
pri = Syslog_priority_NO;
|
||||||
#endif /* LOGGING & SLOG_SYSLOG */
|
#endif /* LOGGING & SLOG_SYSLOG */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PASSWORD_NOT_CORRECT:
|
case PASSWORD_NOT_CORRECT:
|
||||||
(void) sprintf(p, "password incorrect ; PWD=%s ; COMMAND=", cwd);
|
(void) sprintf(p,
|
||||||
|
"password incorrect ; TTY=%s ; PWD=%s ; COMMAND=", tty, cwd);
|
||||||
#if (LOGGING & SLOG_SYSLOG)
|
#if (LOGGING & SLOG_SYSLOG)
|
||||||
pri = Syslog_priority_NO;
|
pri = Syslog_priority_NO;
|
||||||
#endif /* LOGGING & SLOG_SYSLOG */
|
#endif /* LOGGING & SLOG_SYSLOG */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PASSWORDS_NOT_CORRECT:
|
case PASSWORDS_NOT_CORRECT:
|
||||||
(void) sprintf(p, "%d incorrect passwords ; PWD=%s ; COMMAND=",
|
(void) sprintf(p,
|
||||||
TRIES_FOR_PASSWORD, cwd);
|
"%d incorrect passwords ; TTY=%s ; PWD=%s ; COMMAND=",
|
||||||
|
TRIES_FOR_PASSWORD, tty, cwd);
|
||||||
#if (LOGGING & SLOG_SYSLOG)
|
#if (LOGGING & SLOG_SYSLOG)
|
||||||
pri = Syslog_priority_NO;
|
pri = Syslog_priority_NO;
|
||||||
#endif /* LOGGING & SLOG_SYSLOG */
|
#endif /* LOGGING & SLOG_SYSLOG */
|
||||||
@@ -234,8 +247,9 @@ void log_error(code)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SPOOF_ATTEMPT:
|
case SPOOF_ATTEMPT:
|
||||||
(void) sprintf(p, "probable spoofing attempt; PWD=%s ; COMMAND=",
|
(void) sprintf(p,
|
||||||
cwd);
|
"probable spoofing attempt; TTY=%s ; PWD=%s ; COMMAND=",
|
||||||
|
tty, cwd);
|
||||||
#if (LOGGING & SLOG_SYSLOG)
|
#if (LOGGING & SLOG_SYSLOG)
|
||||||
pri = Syslog_priority_NO;
|
pri = Syslog_priority_NO;
|
||||||
#endif /* LOGGING & SLOG_SYSLOG */
|
#endif /* LOGGING & SLOG_SYSLOG */
|
||||||
|
Reference in New Issue
Block a user