/*
- * The Remote User Information Daemon 1.8
+ * The Remote User Information Daemon 1.9
*
- * (c) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1997--2001 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
*
* This software may be freely distributed and used according to the terms
* of the GNU General Public License. See file COPYING in any of the GNU packages.
#include <arpa/inet.h>
#include <syslog.h>
#include <sys/stat.h>
+#include <time.h>
#include <utmp.h>
#include <signal.h>
#include <dirent.h>
name[9] = 0;
strcpy(h->name, name);
h->login_time = htonl(now - u->ut_time);
- if (u->ut_id[0])
- {
- h->con[0] = u->ut_id[0];
- h->con[1] = u->ut_id[1];
- h->con[2] = 0;
- }
- else
- {
- char *z = u->ut_line;
- if (!strncmp(z, "tty", 3))
- z += 3;
- sprintf(h->con, "%.3s", z);
- }
+ sprintf(h->con, "%.7s", u->ut_line);
sprintf(device, "/dev/%s", u->ut_line);
if (stat(device, &st) < 0)
{
make_pkt(struct rywho_pkt *pkt)
{
bzero(pkt, sizeof(pkt));
+ pkt->magic = htonl(NWHO_MAGIC);
pkt->local_time = htonl(now);
scan_utmp(pkt, now);
scan_load(pkt);
return;
}
+ if (pkt.magic != htonl(NWHO_MAGIC))
+ {
+ syslog(LOG_WARNING, "Received ancient nwho packet from %s", inet_ntoa(sa.sin_addr));
+ return;
+ }
+
for(e=first_host; e; e=e->next)
if (e->addr == sa.sin_addr.s_addr)
break;
static struct sigaction sigact;
net_init(NULL);
- if (chdir(YWHO_SPOOL_DIR) < 0)
- die("chdir(" YWHO_SPOOL_DIR "): %m");
+ if (chdir(NWHO_SPOOL_DIR) < 0)
+ die("chdir(" NWHO_SPOOL_DIR "): %m");
cleanup();
bzero(&sigact, sizeof(sigact));
sigact.sa_handler = tick;