[2853] in Release_Engineering
xlogin fix
daemon@ATHENA.MIT.EDU (Mark Rosenstein)
Wed Jun 3 16:00:34 1992
Date: Wed, 3 Jun 92 16:00:15 -0400
From: Mark Rosenstein <mar@MIT.EDU>
To: rel-eng@MIT.EDU
OK, here's the fix, tested and everything (but not audited). It now
supports two different motd files and behaves sanely if the motd will
not fit on the screen. I'll update the release notes myself.
-Mark
*** /source/athena/athena.etc/xdm/xlogin/xlogin.c Fri May 29 13:56:02 1992
--- ./xlogin.c Wed Jun 3 15:39:01 1992
***************
*** 6,11 ****
--- 6,12 ----
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/stat.h>
+ #include <sys/file.h>
#include <utmp.h>
#include <fcntl.h>
#include <X11/Intrinsic.h>
***************
*** 99,104 ****
--- 100,106 ----
Boolean blankAll;
Boolean showMotd;
String motdFile;
+ String motd2File;
} XLoginResources;
/*
***************
*** 122,130 ****
{"-fp", "*fontPath", XrmoptionSepArg, NULL},
{"-blankall", "*blankAll", XrmoptionNoArg, (caddr_t) "on"},
{"-noblankall","*blankAll", XrmoptionNoArg, (caddr_t) "off"},
- #ifdef MOTD_TEST
{"-motdfile", "*motdFile", XrmoptionSepArg, NULL},
! #endif
};
/*
--- 124,131 ----
{"-fp", "*fontPath", XrmoptionSepArg, NULL},
{"-blankall", "*blankAll", XrmoptionNoArg, (caddr_t) "on"},
{"-noblankall","*blankAll", XrmoptionNoArg, (caddr_t) "off"},
{"-motdfile", "*motdFile", XrmoptionSepArg, NULL},
! {"-motd2file","*motd2File", XrmoptionSepArg, NULL},
};
/*
***************
*** 167,176 ****
Offset(blankAll), XtRImmediate, (caddr_t) True},
{"showMotd", XtCBoolean, XtRBoolean, sizeof(Boolean),
Offset(showMotd), XtRImmediate, (caddr_t) True},
- #ifdef MOTD_TEST
{"motdFile", XtCString, XtRString, sizeof(String),
Offset(motdFile), XtRImmediate, (caddr_t) MOTD_FILENAME },
! #endif
};
#undef Offset
--- 168,177 ----
Offset(blankAll), XtRImmediate, (caddr_t) True},
{"showMotd", XtCBoolean, XtRBoolean, sizeof(Boolean),
Offset(showMotd), XtRImmediate, (caddr_t) True},
{"motdFile", XtCString, XtRString, sizeof(String),
Offset(motdFile), XtRImmediate, (caddr_t) MOTD_FILENAME },
! {"motd2File", XtCString, XtRString, sizeof(String),
! Offset(motd2File), XtRImmediate, (caddr_t) "" },
};
#undef Offset
***************
*** 444,451 ****
XtSetArg(args[1], XtNheight, &y_max);
XtGetValues(ins, args, 2);
! x_max = WidthOfScreen(XtScreen(ins)) - x_max;
! y_max = HeightOfScreen(XtScreen(ins)) - y_max;
}
x = random() % x_max;
--- 445,459 ----
XtSetArg(args[1], XtNheight, &y_max);
XtGetValues(ins, args, 2);
! if (WidthOfScreen(XtScreen(ins)) < x_max + 1)
! x_max = 1;
! else
! x_max = WidthOfScreen(XtScreen(ins)) - x_max;
! if (HeightOfScreen(XtScreen(ins)) < y_max + 1)
! y_max = 1;
! else
! y_max = HeightOfScreen(XtScreen(ins)) - y_max;
!
}
x = random() % x_max;
***************
*** 613,620 ****
do_motd()
{
static Widget motdtext = NULL;
! static time_t modtime = 0;
! struct stat stbuf;
Arg args[1];
char buf[10000], *temp, *s, *d;
int fid, len;
--- 621,628 ----
do_motd()
{
static Widget motdtext = NULL;
! static time_t modtime = 0, modtime2 = 0;
! struct stat stbuf, stbuf2;
Arg args[1];
char buf[10000], *temp, *s, *d;
int fid, len;
***************
*** 621,629 ****
if (!motdtext) {
motdtext = WcFullNameToWidget(appShell, "*motd");
- #ifndef MOTD_TEST
- resources.motdFile = MOTD_FILENAME;
- #endif
/* Initialize motdtext to NULL in case it never gets set.
This happens in the case of a bad stat on the motd
--- 629,634 ----
***************
*** 634,647 ****
}
if (resources.showMotd && resources.motdFile != NULL) {
! if (!stat(resources.motdFile, &stbuf) &&
! stbuf.st_mtime > modtime) {
/* time to update the motd */
modtime = stbuf.st_mtime;
/* read the new motd */
! if ((fid = open(resources.motdFile, O_RDONLY)) < 0) return;
! len = read(fid, buf, sizeof(buf));
! close(fid);
buf[len] = 0;
/* de-tabbify the motd (label widgets don't do tabs) */
--- 639,663 ----
}
if (resources.showMotd && resources.motdFile != NULL) {
! if ((!stat(resources.motdFile, &stbuf) &&
! stbuf.st_mtime > modtime) ||
! (*resources.motd2File &&
! !stat(resources.motd2File, &stbuf2) &&
! stbuf2.st_mtime > modtime2)) {
/* time to update the motd */
modtime = stbuf.st_mtime;
+ modtime2 = stbuf2.st_mtime;
/* read the new motd */
! len = 0;
! if ((fid = open(resources.motdFile, O_RDONLY)) >= 0) {
! len = read(fid, buf, sizeof(buf));
! close(fid);
! }
! if (*resources.motd2File &&
! (fid = open(resources.motd2File, O_RDONLY)) >= 0) {
! len += read(fid, &(buf[len]), sizeof(buf) - len);
! close(fid);
! }
buf[len] = 0;
/* de-tabbify the motd (label widgets don't do tabs) */