UNIX System Administration Handbook - Evi Nemeth [307]
The notify command takes a list of email addresses as its argument. rdist sends mail to these addresses whenever a file is updated. Any addresses that do not contain an at sign (@) are suffixed with the name of the destination host. For example, rdist would expand “pete” to “pete@anchor” when reporting a list of files updated on host anchor.
The except and except_pat commands remove pathnames from the list of files to be copied. Arguments to except are matched literally, and those of except_pat are interpreted as regular expressions. These exception commands are useful because rdist, like make, allows macros to be defined at the beginning of its control file. You might want to use a similar list of files for several statements, specifying only the additions and deletions for each host.
The special command executes an sh command (the string argument, which should be quoted) on each remote host. If a pathlist is present, rdist executes the command once after copying each of the specified files. Without a pathlist, rdist executes the command after every file. There is unfortunately no way to execute a command after all files have been copied.
Here’s a simple example of a Distfile:
SYS_FILES = (/etc/passwd /etc/group /etc/mail/aliases)
GET_ALL = (chimchim lollipop barkadon)
GET_SOME = (whammo spiff)
all: ${SYS_FILES} -> ${GET_ALL}
notify barb;
special /etc/mail/aliases "/usr/bin/newaliases";
some: ${SYS_FILES} -> ${GET_SOME}
except /etc/mail/aliases;
notify eddie@spiff;
See page 557 for more information about newaliases.
This configuration replicates the three listed system files on chimchim, lollipop, and barkadon and sends mail to barb@destination describing any updates or errors that occur. After /etc/mail/aliases is copied, rdist runs newaliases on each destination. Only two files are copied to whammo and spiff. newaliases is not run, and a report is mailed to eddie@spiff.
rsync: push files more securely
rsync, written by Andrew Tridgell and Paul Mackerras, is similar in spirit to rdist but with a somewhat different focus. It does not use a control file. It’s more like a souped-up version of rcp that is scrupulous about preserving links, modification times, and permissions. rsync is more network-efficient than rdist because it looks inside of individual files and attempts to transmit only the differences between versions.
rsync is available from rsync.samba.org.
From our perspective, the main advantage of rsync is the fact that receiving machines can run the remote side as a server process out of inetd. The server (actually just a different mode of rsync, which must be installed on both the master and the clients) is quite configurable: it can restrict remote access to a set of given directories and can require the master to prove its identity with a password. Since no rsh access is necessary, you can set up rsync to distribute system files without making too many security compromises. (However, if you prefer to use rsh or ssh instead of an inetd-based server process, rsync lets you do that too.)
Since rsync uses no configuration file on the sending side, it must be run repeatedly to transfer a set of files to multiple hosts. For example, the command
#rsync -gopt --password-file=/etc/rsync.pwd /etc/passwd lollipop::sysfiles
transfers the /etc/passwd file to the machine lollipop. The -gopt options preserve the permissions, ownerships, and modification times of the file. The double colon in lollipop::sysfiles makes rsync contact the remote rsync directly on port 873 instead of using rsh. The password stored in /etc/rsync.pwd authenticates the connection.[2
]
Several steps are necessary to set up an rsync server on each client machine (that is, each machine that is receiving files. From rsync’s perspective, these “clients” are really more like servers):
• Add the rsync port number to /etc/services.
• Add the server (rsync --daemon) to /etc/inetd.conf.
• Store authentication passwords in /etc/rsyncd.secrets.