diff options
author | John Hood <cgull@glup.org> | 2017-03-24 22:37:02 -0400 |
---|---|---|
committer | John Hood <cgull@glup.org> | 2017-04-24 22:40:30 -0400 |
commit | 32b1e6ee4be0706e4047d6927cf73e6333c01774 (patch) | |
tree | 309ee92a8d16c1e8605c7344371fbbfb647185e3 | |
parent | 3f0ac51071d08c860a9ee70d8a6a4b830850e414 (diff) |
Print {,/var}/run/motd.dynamic on Ubuntu.
-rw-r--r-- | src/frontend/mosh-server.cc | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/frontend/mosh-server.cc b/src/frontend/mosh-server.cc index 349a129..b90738f 100644 --- a/src/frontend/mosh-server.cc +++ b/src/frontend/mosh-server.cc @@ -118,7 +118,7 @@ static void print_usage( FILE *stream, const char *argv0 ) fprintf( stream, "Usage: %s new [-s] [-v] [-i LOCALADDR] [-p PORT[:PORT2]] [-c COLORS] [-l NAME=VALUE] [-- COMMAND...]\n", argv0 ); } -static void print_motd( void ); +static bool print_motd( const char *filename ); static void chdir_homedir( void ); static bool motd_hushed( void ); static void warn_unattached( const string & ignore_entry ); @@ -554,9 +554,19 @@ static int run_server( const char *desired_ip, const char *desired_port, chdir_homedir(); if ( with_motd && (!motd_hushed()) ) { + // On illumos motd is printed by /etc/profile. #ifndef __sun -/* On illumos motd is printed by /etc/profile */ - print_motd(); + // For Ubuntu, try and print one of {,/var}/run/motd.dynamic. + // This file is only updated when pam_motd is run, but when + // mosh-server is run in the usual way with ssh via the script, + // this always happens. + // XXX Hackish knowledge of Ubuntu PAM configuration. + // But this seems less awful than build-time detection with autoconf. + if (!print_motd("/run/motd.dynamic")) { + print_motd("/var/run/motd.dynamic"); + } + // Always print traditional /etc/motd. + print_motd("/etc/motd"); #endif warn_unattached( utmp_entry ); } @@ -880,12 +890,12 @@ static void serve( int host_fd, Terminal::Complete &terminal, ServerConnection & } } -/* OpenSSH prints the motd on startup, so we will too */ -static void print_motd( void ) +/* Print the motd from a given file, if available */ +static bool print_motd( const char *filename ) { - FILE *motd = fopen( "/etc/motd", "r" ); + FILE *motd = fopen( filename, "r" ); if ( !motd ) { - return; /* don't report error on missing or forbidden motd */ + return false; } const int BUFSIZE = 256; @@ -903,6 +913,7 @@ static void print_motd( void ) } fclose( motd ); + return true; } static void chdir_homedir( void ) |