Print {,/var}/run/motd.dynamic on Ubuntu.
This commit is contained in:
@@ -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 );
|
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 void chdir_homedir( void );
|
||||||
static bool motd_hushed( void );
|
static bool motd_hushed( void );
|
||||||
static void warn_unattached( const string & ignore_entry );
|
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();
|
chdir_homedir();
|
||||||
|
|
||||||
if ( with_motd && (!motd_hushed()) ) {
|
if ( with_motd && (!motd_hushed()) ) {
|
||||||
|
// On illumos motd is printed by /etc/profile.
|
||||||
#ifndef __sun
|
#ifndef __sun
|
||||||
/* On illumos motd is printed by /etc/profile */
|
// For Ubuntu, try and print one of {,/var}/run/motd.dynamic.
|
||||||
print_motd();
|
// 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
|
#endif
|
||||||
warn_unattached( utmp_entry );
|
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 */
|
/* Print the motd from a given file, if available */
|
||||||
static void print_motd( void )
|
static bool print_motd( const char *filename )
|
||||||
{
|
{
|
||||||
FILE *motd = fopen( "/etc/motd", "r" );
|
FILE *motd = fopen( filename, "r" );
|
||||||
if ( !motd ) {
|
if ( !motd ) {
|
||||||
return; /* don't report error on missing or forbidden motd */
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int BUFSIZE = 256;
|
const int BUFSIZE = 256;
|
||||||
@@ -903,6 +913,7 @@ static void print_motd( void )
|
|||||||
}
|
}
|
||||||
|
|
||||||
fclose( motd );
|
fclose( motd );
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void chdir_homedir( void )
|
static void chdir_homedir( void )
|
||||||
|
|||||||
Reference in New Issue
Block a user