Merge pull request #206 from edneville/123_log_ssh_original_command_in_nologin

Adding logging of SSH_ORIGINAL_COMMAND to nologin.
This commit is contained in:
Serge Hallyn 2020-01-11 14:47:57 -06:00 committed by GitHub
commit ef095ceef1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -72,6 +72,9 @@
<citerefentry><refentrytitle>nologin</refentrytitle><manvolnum>5</manvolnum> <citerefentry><refentrytitle>nologin</refentrytitle><manvolnum>5</manvolnum>
</citerefentry>. </citerefentry>.
</para> </para>
<para>
If <command>SSH_ORIGINAL_COMMAND</command> is populated it will be logged.
</para>
</refsect1> </refsect1>
<refsect1 id='see_also'> <refsect1 id='see_also'>

View File

@ -45,9 +45,14 @@ int main (void)
if (NULL == user) { if (NULL == user) {
user = "UNKNOWN"; user = "UNKNOWN";
} }
char *ssh_origcmd = getenv("SSH_ORIGINAL_COMMAND");
uid = getuid (); /* getuid() is always successful */ uid = getuid (); /* getuid() is always successful */
openlog ("nologin", LOG_CONS, LOG_AUTH); openlog ("nologin", LOG_CONS, LOG_AUTH);
syslog (LOG_CRIT, "Attempted login by %s (UID: %d) on %s", user, uid, tty); syslog (LOG_CRIT, "Attempted login by %s (UID: %d) on %s%s%s",
user, uid, tty,
(ssh_origcmd ? " SSH_ORIGINAL_COMMAND=" : ""),
(ssh_origcmd ? ssh_origcmd : ""));
closelog (); closelog ();
printf ("%s", "This account is currently not available.\n"); printf ("%s", "This account is currently not available.\n");