home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume17 / contest-prog / part01 / README < prev    next >
Encoding:
Text File  |  1989-02-06  |  7.7 KB  |  169 lines

  1.  
  2. This is a set of ACM-style Programming Contest software that I wrote
  3. for our this year's (1988)'s "Local Programming Contest".  We could not
  4. afford to field a team to go to the Regional Contest, so we just
  5. Po'Boy-ed it here at home.
  6.  
  7. This software is provided without any warranty whatsoever.  It's free
  8. and free of copyright.  It's just what I did for our contest.  It'll
  9. certainly require some version of unix, either BSD4.2 or SysV, or
  10. compatible.  I've tested it on our Sequent B8 (BSD4.2, or very close,
  11. NS32032), and on each of our SysV boxes, one running SysV2.1 (3b2/300)
  12. and the other running SysV3.1 (3b2/310?) (don't ask why they're not
  13. both running 3.1, it's a long bloody story...). No Suns available to me
  14. (isn't that incredible?).
  15.  
  16. What we have here is a combination of shell (Bourne) scripts and
  17. C-programs which I found useful in being a "judge" in our local
  18. "Programming Contest".  We discussed trying to field a team to go to
  19. the Regionals, and decided we 1) couldn't afford the gas, and 2)
  20. couldn't win anyway.
  21.  
  22. Anyway, this software is being put on the net (if it gets past the
  23. moderator) just to possibly inspire others to sorta goad their defunct
  24. ACM/CS student groups (ours died with the dues increase) to come back
  25. alive.
  26.  
  27. Installation:
  28.  
  29. Add a user to your system; his name probably should be "judges" (well,
  30. of course, cousin, you gotta be root to do this... trust me!).  Make
  31. sure his .profile or .login or .whatever sets his umask to 077.  The
  32. group of user judges should be the same as his uid.  The group of the
  33. teams should be their uids also. But, at least on Berkeley, the group
  34. of the directories of the teams should be the same as the group of the
  35. judges.  More on this later.
  36.  
  37. Log in as judges.  (No root privileges needed, nor desired).
  38.  
  39. Copy all this stuff from wherever you were reading it into the
  40. "judges" directory (which is where you should be now).
  41.  
  42. Unshar the Parts.
  43.  
  44. Look at Makefile, to see if there are any pathname dependencies
  45. I missed.  On our system, users are in /usr1, /usr2, and /usr3,
  46. and I put judges in /usr2.  More traditional systems will
  47. have /u, /v, etc., I guess.
  48.  
  49. Make a directory called /usr/contest with 0777 permissions; don't
  50. worry, we're only putting easily reconstituted stuff there.  The
  51. "score" program, for example, needs to live in a directory which
  52. is in each of the teams' PATHs; it will be setuid judges, so it
  53. can read the scoreboard, which will be in the judges' protected
  54. directory.
  55.  
  56. Look at Makefile to see if you can stand P=& (parallel make).
  57.  
  58. Type
  59. % make all
  60.  
  61. This should compile the necessary C-language programs (score, compare,
  62. digits, seconds, and shorten) and place score and seconds into the
  63. contest directory, along with judge, which is a shell script.
  64.  
  65. Make accounts of the form teamxx, where xx is either a single digit, or
  66. is a double digit.  What I mean is: team2, not team02.  Insure that
  67. their PATH includes /usr/contest.  Insure that they can mail to judges
  68. and that judges can mail to each of them.  Insure that they can read
  69. /tmp. (If I'm not talking to a root-priv person, forget it, and go send
  70. all this stuff to your local administrator).  Make their passwords
  71. whatever you want, but something you can tell them in the poop-session
  72. before the start of the contest.
  73.  
  74. Type
  75. % make install
  76.  
  77. If all goes well, you should be ready to go.  What I did was run
  78. shutofflogins a half-hour before the start of the contest.  It
  79. messes with /etc/passwd by only allowing our magic system accounts,
  80. selected faculty, and judges, and teamxx to survive, and all others
  81. are taken out.  It needs "nawk" to work.  This step is probably
  82. not necessary;  I was just paranoid.  And, of course, needs to be
  83. root to mess with /etc/passwd.
  84.  
  85. Long before start-time, edit the file "sf" to reflect the names of
  86. your teams.  Four man teams may not fit.  Truncate them accordingly.
  87.  
  88. At start time, type
  89. % start < sf
  90. which will set up the scoreboard and start- and end-time files.
  91.  
  92. Teams submit judged runs by
  93. % judge probX.pas
  94.  
  95. for example.  The digit(s) (represented by X above) in the filename
  96. must reflect the problem number.  Extensions currently supported are
  97. .c, .f, .p, and .pas .
  98.  
  99. The judges' account must be able to read the teams' directories and
  100. programs.  This is why the teams directories should be readable by
  101. group judges, but not readable by any other group, especially other
  102. teams.  Only judges should be in group judges; and only owner and group
  103. judges should be able to read team directories and files.
  104.  
  105. The shell-script "gr" is actually the heart of this whole deal.  It
  106. attempts to compile and execute the teams' submissions and to grade the
  107. output either right or wrong.  The program "compare" was written to
  108. fill the void caused by diff -b not working the way I wanted when one
  109. of the lines did not begin with a blank.  Also, our fortran generates
  110. gratuitious output when a 'stop' statement is executed.  I have not
  111. fixed this problem.  What we did was tell those teams using fortran to
  112. avoid use of the 'stop' statement.  Running off the end of main is much
  113. nicer.
  114.  
  115. The little C-program chexec8.c simply executes the teams' submitted
  116. programs after compiling them into a small subdirectory.  The "8"
  117. refers to the eighth version of this little thing.  What made this not
  118. just a simple chdir, chroot, and exec program was a rather incredible
  119. back-and-forth between me and a couple of my students in an advanced
  120. class:  "I can steal the input, and I can also steal other teams'
  121. output".  "How?" "A daemon which never exits and looks in the current
  122. directory for interesting stuff and copies it into its internal guts
  123. (remember that it belongs to you, "judges"), and when judges sends mail
  124. to the other teams that somebody has solved a problem, it waits for
  125. another instance of turkey, and then sends to the correctly named
  126. files, an output from its own guts, properly named, as if it were the
  127. output of a correct run of that particular problem.  First iteration
  128. simply did the chroot.  Second piped input from above and output to
  129. above, doing about all it could except protecting against fork().  ...
  130. etc.  What we finally decided was: judges should run the team-program,
  131. and should INSURE that no process owned by judges should be allowed to
  132. live after the "first-child" of the judging chexec8 program exits.  I
  133. currently have that simple-mindedly just issuing kill(...,9) calls to
  134. the next 200 processes.  This will not be sufficient on a busy system,
  135. but thats' where I left it for this time around.  The culprit would 
  136. seem to be fork().  Really paranoid sysadmins would just remove
  137. fork() from the system library, insure that no students who had
  138. ever in the past been allowed to login on this system had make
  139. copies of fork(), and ... etc.
  140.  
  141. This latter iteration on the possibility of stealing the input and or
  142. the output of other teams' runs was what caused this software to be
  143. more than several weeks late, and why other work, such as grading
  144. papers, has gone undone.  Comments are solicited; versions 1 thru 7 of
  145. chexec.c are probably floating around somewhere.  Thanks to Steve
  146. Perry, David McGough, and Chris Spell for playing the Devil's Advocate
  147. for chexec.
  148.  
  149. The "solutions" provided are entirely by me; some of the other judges
  150. submitted much nicer programs, but mine were written in a semi-contest
  151. situation of "quick and dirty", 'cause I had to write all twelve
  152. solutions one Saturday.  Really, folks, this is not my best code ...
  153. They are all in C, although I did re-write a few of them in Pascal and
  154. Fortran just for testing, I then threw those versions away. (No bigotry
  155. around here ...).
  156.  
  157.  
  158. Bugs and flames to
  159. nelson@ecsvax.uucp
  160. ...mcnc!ecsvax!nelson
  161. (too bad it's not ...mcnc!ecsvax!uncw!nelson just yet ... we're
  162. trying)
  163.  
  164. Jim Nelson
  165. Mathematical Sciences Dept.
  166. Univ. of NC at Wilmington
  167. Wilmington, NC 28403
  168. 919-395-3300 direct, or 919-395-3290 dept. office
  169.