xmotd 1.16

from Sep 2002 - Aug 2003

«Mankind is the animal that makes tools. In each generation, only a few people get a chance to create new tools. Very, very few get to contribute to making a tool that changes the lives of first hundreds, then thousands, then tens of thousands, and someday millions of people.»

—John Walker, Autodesk

1.17.3 Beta Released July 1st, 2003

What is it?

xmotd is a utility program for network administrators, that can be used to "broadcast" messages to users logged in across a network. xmotd runs on each user's workstation when they login and periodically checks whether a message file has been modified and pops up and displays the contents of the file, if it has.

Why is this useful you may ask? Well, let's say that 100GB disk array you ordered has finally arrived and you want to let everyone on your network know that the server will be going down for a bit, while you install the array. If you had xmotd installed on your network, you would simply update a message file that xmotd was "watching" and in a few seconds, xmotd would pop-up on everyone's screens notifing them of the scheduled down-time.

xmotd has many features allowing it to be customized for your particular site. For example, you can replace the default logo, that appears in the top left corner, with your company logo; the title text can also be customized. xmotd can "watch" a single file, more than one file or it can scan a whole directory where files are added or removed.

xmotd typically runs when the user logs in and displays any messages. However, if you have users that never logout, xmotd can be configured to run as a background daemon and periodically wake-ups and check files for modifications. xmotd can be run by xdm, CDE or startx (and from ~/.login when your users call-in via dial-up). xmotd can be optionally compiled to display HTML messages.

What's new with the latest release:

  • The 1.17.3 beta is a bug-fix release. xmotd will now detect that a document has been modified while xmotd was popped-up and re-display it at the next time-out.

Java port

Wed Sep 26 18:26:51 2001
A Java port of xmotd is available. This was a student project, so the complete functionality of 1.16 is not available. It was tested under both Windows 98 and Solaris 2.6 with Sun's Java Runtime (1.3). We use Samba to export the Unix file-system, to our Windows boxen.

Andy Roosen's patch

Mon Dec 22 12:41:13 2003: In April 2003, Andy Roosen (NIST) submitted a patch with some bug fixes and new features. I have not had the time to incorporate this patch into the distro but if you want the features, you can apply the patch:
  • The first bug is that (with the current version), the .xmotd doesn't get updated except in revisitMessagesAndDisplay, so it doesn't get updated on the initial message run through (or ever, if -wakeup isn't used.
  • The second bug (at least, I think it is a bug) is that the warning file will pop-up and display each and every time xmotd wakes up if -paranoid is set. I can't imagine that this would be desired behavior except for the TRULY paranoid :). I want to warn users when they first log in, but not every hour thereafter. Arguably the way to preserve the current behavior would be to have an optional argument to -paranoid that defaults to the current behavior.
  • If the argument to -atom is 'none', then no atom is set. Helpful for debugging. BTW, there appears to be a bug in that the atom remains set even when xmotd exits/is killed, so no other can be started. I dunno enough about X programming to fix this problem.
  • Added a '-fork' flag that gives the user more choice about how xmotd forks itself into the background. there are four options: 0=never forks, 1=forks only after the first run-through even if -wakeup is set (I wanted this so that users would have to acknowledge the warning message before continuing with the login process), 2=current (default) behavior (forks immediately if -wakeup is set), 3=forks immediately.
  • Added a '-locfile' flag to indicate how xmotd should decide if the user is still logged in. On my systems, /dev/console is never given over to the user, so it was always exiting right away. OTOH, an SSH agent is always started, so I use '-locfile $SSH_AUTH_SOCK'. I also change the 'checking' code to do a 'stat' on the locfile and check the UID instead of trying to open the file (the 'open' always fails on the SSH_AUTH_SOCK).
  • I removed the 1-minute minimum for -wakeup for ease of debugging, which breaks compatability.
  • With this setup, I will have Xsession run: xmotd -wakeup 1 -locfile $SSH_AUTH_SOCK -fork 1 -warnfile /etc/warning -paranoid /var/news before starting the 'real' session.

Compiling for Solaris 8

Thu May 3 19:33:13 EDT 2001: Jay G. Scott (University of Texas at Austin) submitted a patch for building xmotd for Solaris 8 (E450, Solaris 8, 64 bit kernel) because, "the 32 bit version acted weird".

This is what the patch does:

  • "...changes stat() to stat64()";
  • "...adds back the -usehostnames option, which appears to have been an ARL-ism from the start";
  • "...prototypes everything";
  • "...kludges the -xarch=v9 switches in the Makefile (the -xildoff flag to ld may not be necessary for everyone; all it does is turn the incremental loader off)".

What do I need to compile it?

Xmotd requires, a C compiler and at minimum, X11R5 including Xt (the X Toolkit) for the resource and command-line parsing functions, and the Athena widget (Xaw) libraries. Optionally, Xm, the Motif toolkit (LessTif will do just fine too), is needed if you wish to compile the Motif version; the Xpm library should be installed if you wish to compile-in support for colour logos. xmotd can be built in 4 different flavours:
  • with the Athena widget library (default), or;
  • with Athena & HTML widget, or;
  • with the Motif widget library, or;
  • with Motif and HTML widget.
All the flavours can be built from the single distribution. It's just a matter of defining the correct parameters in the Imakefile and building (autoconf coming in the next release).

The main distribution is about 180K and contains the HTML widget; the HTML widget library is not included with the 'lite' distribution.

If you report any problems you encounter I will help you solve them.

NOTE:To build the Motif+HTML flavour on Solaris systems you have to fiddle with the Imakefile (detailed instructions included) because Sun moved Motif to /usr/dt/ and this change has to be propagated to the HTML-library Makefile from the top-level Makefile.

What platforms does it run on?

xmotd and the HTML widget lib have been sucessfully compiled here for Solaris 2.5.1, 2.6, 2.8 and GNU/Linux 2.4.18

xmotd has also been reported to successfully compile on the following platforms:

  • HP 9000/735 running HP-UX 9.03 (X11R5)
  • IBM RS/6000 model C10 (PowerPC) running AIX v3.2.5.
  • Intel x86 running Gnu/Linux 2.x (X11R6)
  • Intel x86 running FreeBSD (X11R6; available in the ports)
  • Sun SPARCstations running SunOS 4.1.1B & 4.1.4 (X11R6) and UltraSPARCs running Solaris 2.5.1, 2.6, 2.7 and 2.8 (X11R6)
  • Silicon Graphics INDY running Irix 5.3 (X11R5)
  • Mips/CDC (running EPIX) and PCS/M68030 (running MUNIX/SysV).

How does it work?

When xmotd runs (under both X11 and dumb-terminals), it creates a time-stamp file (called ".xmotd", by default) in the user's home-directory. It uses the date of this file to check whether the motd has changed. If the date of the message-file(s) is later than the date on the ~/.xmotd time-stamp file, then xmotd will display the message; otherwise it will silently exit.

Running xmotd from the system Xsession file (via xdm or CDE)

xmotd is meant to be run automatically from the system Xsession file by xdm (the X display manager), after a successful login. The Xsession file is in


(where $ProjectRoot is /usr/X11R6 or /usr).

Put a script that runs xmotd into /etc/dt/config/Xsession.d for systems running CDE (thanks to Dave Carrigan for posting this solution).

The message-of-the-day file is passed to xmotd as the last option after any other command-line options:

xmotd -geometry +20+20 /usr/local/motd

When xmotd is supplied with more than one file on the command-line, it will selectively display only those files, from the list, which have a modification date later than that of the time-stamp.

In the following example, all the files in /usr/local/messages/ will be checked for modification times greater than the time-stamp and only those files will be displayed:

xmotd -geometry +20+20 -wakeup 1 /usr/local/messages/

When more than one file is to be displayed, the user is obliged to press the "Next Message" button to view the next message. When the last message is displayed, the button changes to read "Dismiss". After all the files are displayed, and the user presses "Dismiss" xmotd will sleep for one hour (-wakeup 1), then wakeup and check the directory for changes and pop-up again if any of the files have changed (or new files have been added).

It can also be configured to pop-down automatically, without user-intervention, after a specified delay (in seconds) using the -popdown option.

Please consult the manual page for details about other options.

Running xmotd from ~/.xinitrc

For sites that do not use xdm, xmotd may be run from user's ~/.xinitrc. Note, however, that with this approach it is possible for (knowledgeable) users to remove the command from their ~/.xinitrc file either accidently or with malice aforethought.

Running xmotd from ~/.login

xmotd can also be run from a user's ~/.login file. xmotd defaults to text-mode mode when it fails to connect with an X server (i.e. the DISPLAY environment variable is not set). Note that only -stampfile and -wakeup are recognized in text-only mode.

Can I customize it?

Most everything, including the logo, the fonts, the pop-down timeout period and the colours, can be customized via the supplied app-defaults file, via editres or via command-line resources.

The simplest customization is the logo. Use xv to create a mono bitmap or colour pixmap (if xpm support is compiled in), save it in (for example) /usr/local/logo.xbm and run:

xmotd -bitmaplogo /usr/local/logo.xbm /usr/local/motd
This example (names blanked out to protect the guilty) illustrates a more complex on-the-fly command-line customization of xmotd (it's all one line that's been split-up to make it easier to read):
/usr/X11/bin/xmotd -always \
-xrm "*title.label: Top 10 Disk Hogs\n As of midnight\n" \
-xrm "*title.foreground: yellow" \
-xrm "*form.background: red" \
-xrm "*title.background: red" \
-xrm "*logo.background: pink" \
-xrm "*text*font: -adobe-times-bold-*-normal-*-*-180-*" \
-geometry 500x650-1-1 \
-bitmaplogo /usr/common/choke.xbm \
/usr/common/accounting/top &

Wish-list (future versions)

  • a port to Gnome (GTK widgets);
  • autoconf build;
  • use XmHTML widget (supports inline images and HTML 3.2) when it is stable;
  • automatically switch between HTML and text widget when HTML support is compiled: detect if 1st char is "<" and assume HTML tag (add -dumb or -forcetext to force textmode even if 1st char is "<");
  • be able to specify a different pixmap for each file displayed; e.g. for emergency "The system is going down NOW !!!" messages the icon should be something more attention getting than the "X"; the pixmap name is the same as the filename.
  • option to allow the filename label to be placed beside the "Dismiss" button rather than below;
Mail me any other suggestions on the condition that if I implement them, you are expected to test them.

xmotd / luis fernandes <elf@ee.ryerson.ca>

Last Modified: Tue Jul 01 00:26:34 2003