#endif lint
#include <mit-copyright.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include <krb.h>
#include <errno.h>
#include "query.h"
do_client(cp)
client *cp;
{
+ struct stat stbuf;
+
free_rtn_tuples(cp);
if (OP_STATUS(cp->pending_op) == OP_CANCELLED) {
com_err(whoami, 0, "Closed connection (now %d client%s, %d new queries, %d old)",
newqueries,
oldqueries);
clist_delete(cp);
+ /* if we no longer have any clients, and we're supposed to
+ * go down, then go down now.
+ */
+ if ((dormant == AWAKE) && (nclients == 0) &&
+ (stat(SMS_MOTD_FILE, &stbuf) == 0)) {
+ com_err(whoami, 0, "motd file exists, slumbertime");
+ dormant = SLEEPY;
+ }
return;
}
switch (cp->action) {
"shutdown",
"query",
"access",
+ "dcm",
+ "motd",
};
else if (log_flags & LOG_REQUESTS)
com_err(whoami, 0, "%s", procnames[pn]);
+ if ((dormant == ASLEEP || dormant == GROGGY) &&
+ pn != SMS_NOOP && pn != SMS_MOTD) {
+ cl->reply.sms_status = SMS_DOWN;
+ if (log_flags & LOG_RES)
+ com_err(whoami, SMS_DOWN, "(query refused)");
+ return;
+ }
+
switch(pn) {
case SMS_NOOP:
cl->reply.sms_status = 0;
case SMS_DO_UPDATE:
trigger_dcm(0, 0, cl);
return;
+
+ case SMS_MOTD:
+ get_motd(cl);
+ return;
}
}
}
}
+
+get_motd(cl)
+client *cl;
+{
+ FILE *motd;
+ char buffer[1024];
+ char *arg[1];
+
+ arg[0] = buffer;
+ cl->reply.sms_status = 0;
+ motd = fopen(SMS_MOTD_FILE, "r");
+ if (motd == NULL) return;
+ fgets(buffer, sizeof(buffer), motd);
+ fclose(motd);
+ retr_callback(1, arg, cl);
+ cl->reply.sms_status = 0;
+}