[6807] in Athena Bugs
olcd changes
daemon@ATHENA.MIT.EDU (daemon@ATHENA.MIT.EDU)
Sun Jan 6 16:10:51 1991
To: bugs@ATHENA.MIT.EDU
Date: Sun, 06 Jan 91 16:10:38 EST
From: John Carr <jfc@ATHENA.MIT.EDU>
1. The olc include files require that "KERBEROS" is defined. If olc
depends on kerberos, nothing should require "KERBEROS" to be defined.
If olc is not supposed to require kerberos, there is a bug.
Example:
% cc -O -c lumberjack.c -I/source/athena/usr.athena/olc/include -I/source/athena/usr.athena/olc/server+
E "/source/athena/usr.athena/olc/include/olc/structs.h",L31/C14: ANAME_SZ: Identifier is undeclared.
E "/source/athena/usr.athena/olc/include/olc/structs.h",L31/C8: pname: Type of struct member is an array of zero length.
E "/source/athena/usr.athena/olc/include/olc/structs.h",L32/C14: INST_SZ: Identifier is undeclared.
E "/source/athena/usr.athena/olc/include/olc/structs.h",L32/C8: pinst: Type of struct member is an array of zero length.
E "/source/athena/usr.athena/olc/include/olc/structs.h",L33/C15: REALM_SZ: Identifier is undeclared.
E "/source/athena/usr.athena/olc/include/olc/structs.h",L29/C9: Structure has no contents (is of size zero).
E "/source/athena/usr.athena/olc/include/olc/structs.h",L44/C17: REALM_SZ: Identifier is undeclared.
E "/source/athena/usr.athena/olc/include/olc/structs.h",L44/C11: realm: Type of struct member is an array of zero length.
E "/source/athena/usr.athena/olc/include/olc/structs.h",L45/C16: INST_SZ: Identifier is undeclared.
E "/source/athena/usr.athena/olc/include/olc/structs.h",L45/C11: inst: Type of struct member is an array of zero length.
2. Changes to lumberjack.c. These use fork and exec instead of system,
allowing topic names with quotes. I have not tested these. One bug I did
not fix: the olc discuss server name is compiled into the program. It
should be an option, or at least moved to a site-specific include file.
*** /source/athena/usr.athena/olc/server+/lumberjack.c Wed Sep 12 01:12:31 1990
--- lumberjack.c Sun Jan 6 16:07:01 1991
***************
*** 20,25 ****
--- 20,31 ----
#include <sys/dir.h>
#include <sys/file.h>
#include <stdio.h>
+ #include <sys/wait.h>
+ #if !defined(_AIX) && !defined(SYSV) && !defined(WEXITSTATUS)
+ /* BSD, need to define macro to get at exit status */
+ #define WEXITSTATUS(st) (st).w_retcode
+ #define WTERMSIG(st) (st).w_termsig
+ #endif
#include <olc/olc.h>
#include <olcd.h>
***************
*** 27,32 ****
--- 33,39 ----
#include "lumberjack.h" /* contains the name of the dir we want */
#define DSPIPE "/usr/athena/dspipe" /* name of program to send off logs */
+ #define DSPAV0 "dspipe" /* argv[0] for DSPIPE */
#ifdef OLX
#define PREFIX "FIONAVAR.MIT.EDU:/usr/spool/discuss/ot" /* meeting prefix */
***************
*** 36,42 ****
#define LOCKFILE "lockfile" /* name of lockfile */
! #define SIZE 1024
main (argc, argv)
int argc;
--- 43,49 ----
#define LOCKFILE "lockfile" /* name of lockfile */
! #define SIZE 256
main (argc, argv)
int argc;
***************
*** 48,53 ****
--- 55,65 ----
int fd; /* file descriptor of control file */
int retval; /* Error code returned by system */
FILE *file; /* file stream used to read control file */
+ #if !defined(_AIX) && !defined(SYSV)
+ union wait status;
+ #else
+ int status;
+ #endif
char logname[SIZE]; /* name of log file */
char title[SIZE]; /* title assigned to log */
***************
*** 54,64 ****
char topic[SIZE]; /* topic of question, also meeting name */
char username[SIZE]; /* name of person that asked the question */
- char syscmd[SIZE]; /* buffer for constructing sys call */
-
- char *temp; /* pointer used for walking over title to */
- /* remove 's */
-
/*
* Chdir to the directory containing the done'd logs, in case we dump
* core or something.
--- 66,71 ----
***************
*** 75,81 ****
* If we can't open/create the lock file and lock it, exit.
*/
! if ((lock_fd = open(LOCKFILE, O_CREAT, 0)) <= 0)
{
fprintf(stderr, "lumberjack: unable to create/open file %s.\n", LOCKFILE);
exit(-1);
--- 82,88 ----
* If we can't open/create the lock file and lock it, exit.
*/
! if ((lock_fd = open(LOCKFILE, O_CREAT, 0666)) <= 0)
{
fprintf(stderr, "lumberjack: unable to create/open file %s.\n", LOCKFILE);
exit(-1);
***************
*** 130,142 ****
}
title[strlen(title) - 1] = '\0';
- temp = title;
- while (*temp != '\0') {
- if (*temp == '\'') *temp = '\"';
- temp++;
- }
-
-
if (fgets(topic, SIZE, file) == NULL) {
fprintf(stderr, "lumberjack: unable to get topic from file %s.\n",
next->d_name);
--- 137,142 ----
***************
*** 157,176 ****
/* If we've made it this far, we've got everything we need to ship to
* discuss.
*/
! sprintf(syscmd, "%s %s%s -t \'%s: %s\' < %s",
! DSPIPE, PREFIX, topic, username, title, logname);
! retval = system(syscmd);
! /* dspipe sometimes looses and returns a bogus error value (36096) */
! if (retval != 0)
! fprintf(stderr, "lumberjack: bad exit status %d occurred in:\n\t%s\n",retval, syscmd);
! else
! {
unlink(logname);
unlink(next->d_name);
}
}
}
!
closedir(dirp);
flock(lock_fd, LOCK_UN);
}
--- 157,209 ----
/* If we've made it this far, we've got everything we need to ship to
* discuss.
*/
! #if defined(_AIX) || defined(SYSV)
! retval = fork();
! #else
! retval = vfork();
! #endif
! if (retval == -1) {
! perror("lumberjack: fork");
! continue;
! }
! if (retval == 0) {
! char av1[SIZE], av3[SIZE];
! int fd = open(logname, O_RDONLY);
! if (fd == -1) {
! perror("lumberjack: open");
! return -errno;
! }
! if (dup2(fd, 2) == -1) {
! perror("lumberjack: dup2");
! return -errno;
! }
! sprintf (av1, "%s%s", PREFIX, topic);
! sprintf (av3, "%s: %s", username, title);
! retval = execl(DSPIPE, DSPAV0, av1, "-t", av3, NULL);
! perror("lumberjack: fork");
! return -retval;
! }
! /* Assume dspipe is the only child */
! retval = wait(&status);
! if (retval == -1) {
! perror("lumberjack: wait");
! continue;
! }
! if (WIFEXITED(status)) {
! /* dspipe sometimes loses and returns a bogus error value (36096) */
! if (WEXITCODE(status) != 0) {
! fprintf(stderr, "lumberjack: %s exited %d\n", DSPIPE,
! WEXITCODE(status));
! } else {
unlink(logname);
unlink(next->d_name);
}
+ } else /* signal */ {
+ fprintf(stderr, "lumberjack: %s exited with signal %d\n",
+ DSPIPE, WTERMSIG(status));
}
}
! }
closedir(dirp);
flock(lock_fd, LOCK_UN);
}