If the command was run in a chroot, add it to the log.

This commit is contained in:
Todd C. Miller
2020-09-02 16:57:55 -06:00
parent 226307591c
commit fd06e588ee
2 changed files with 18 additions and 0 deletions

View File

@@ -59,6 +59,7 @@
#define LL_HOST_STR "HOST="
#define LL_TTY_STR "TTY="
#define LL_CHROOT_STR "CHROOT="
#define LL_CWD_STR "PWD="
#define LL_USER_STR "USER="
#define LL_GROUP_STR "GROUP="
@@ -114,6 +115,8 @@ new_logline(const char *message, const char *errstr,
len += strlen(errstr) + 3;
len += sizeof(LL_HOST_STR) + 2 + strlen(details->submithost);
len += sizeof(LL_TTY_STR) + 2 + strlen(details->ttyname);
if (details->runchroot != NULL)
len += sizeof(LL_CHROOT_STR) + 2 + strlen(details->runchroot);
len += sizeof(LL_CWD_STR) + 2 + strlen(details->runcwd);
if (details->runuser != NULL)
len += sizeof(LL_USER_STR) + 2 + strlen(details->runuser);
@@ -174,6 +177,12 @@ new_logline(const char *message, const char *errstr,
strlcat(line, details->ttyname, len) >= len ||
strlcat(line, " ; ", len) >= len)
goto toobig;
if (details->runchroot != NULL) {
if (strlcat(line, LL_CHROOT_STR, len) >= len ||
strlcat(line, details->runchroot, len) >= len ||
strlcat(line, " ; ", len) >= len)
goto toobig;
}
if (strlcat(line, LL_CWD_STR, len) >= len ||
strlcat(line, details->runcwd, len) >= len ||
strlcat(line, " ; ", len) >= len)

View File

@@ -923,6 +923,7 @@ should_mail(int status)
}
#define LL_TTY_STR "TTY="
#define LL_CHROOT_STR "CHROOT="
#define LL_CWD_STR "PWD=" /* XXX - should be CWD= */
#define LL_USER_STR "USER="
#define LL_GROUP_STR "GROUP="
@@ -978,6 +979,8 @@ new_logline(const char *message, const char *errstr)
if (errstr != NULL)
len += strlen(errstr) + 3;
len += sizeof(LL_TTY_STR) + 2 + strlen(user_tty);
if (user_runchroot != NULL)
len += sizeof(LL_CHROOT_STR) + 2 + strlen(user_runchroot);
len += sizeof(LL_CWD_STR) + 2 + strlen(user_runcwd);
if (runas_pw != NULL)
len += sizeof(LL_USER_STR) + 2 + strlen(runas_pw->pw_name);
@@ -1032,6 +1035,12 @@ new_logline(const char *message, const char *errstr)
strlcat(line, user_tty, len) >= len ||
strlcat(line, " ; ", len) >= len)
goto toobig;
if (user_runchroot != NULL) {
if (strlcat(line, LL_CHROOT_STR, len) >= len ||
strlcat(line, user_runchroot, len) >= len ||
strlcat(line, " ; ", len) >= len)
goto toobig;
}
if (strlcat(line, LL_CWD_STR, len) >= len ||
strlcat(line, user_runcwd, len) >= len ||
strlcat(line, " ; ", len) >= len)