home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / next / sysadmin / 7066 < prev    next >
Encoding:
Text File  |  1992-12-15  |  4.6 KB  |  127 lines

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!menudo.uh.edu!menudo.uh.edu!usenet
  2. From: sears@tree.egr.uh.edu (Paul S. Sears)
  3. Newsgroups: comp.sys.next.sysadmin
  4. Subject: Re: having problem with MOTD
  5. Date: 15 Dec 1992 16:04:10 GMT
  6. Organization: University of Houston
  7. Lines: 114
  8. Message-ID: <1gkvlqINNqbi@menudo.uh.edu>
  9. References: <1992Dec13.030652.4636@moksha.uucp>
  10. Reply-To: sears@tree.egr.uh.edu
  11. NNTP-Posting-Host: thanatos.egr.uh.edu
  12.  
  13. In article <1992Dec13.030652.4636@moksha.uucp> mgb@moksha.uucp (Michael  
  14. Branton) writes:
  15. #In article <1992Dec11.113707.24229@dmu.ac.uk> sfch@dmu.ac.uk (Simon  
  16. Harwood)  
  17. #writes:
  18. #> In article <1992Dec7.010703.3457@utagraph.uta.edu> root@mecad.uta.edu  
  19. #(Operator) writes:
  20. #> >
  21. #> There is a MOTD application which you can anonymous ftp available on
  22. #> sonata.cc.purdue.edu. There are at least 2 versions available which are
  23. #> 
  24. #>     pub/next/2.0-release/source/MOTD.tar.Z
  25. #> and
  26. #>     pub/next/1.0-release/source/MOTD.tar.Z
  27. #> 
  28. #>         Simon..
  29. #
  30. #
  31. #I've got this. It worked fine under 2.0, but under 3.0, it seems be  
  32. broken. I  
  33. #get notification of new mail, but not the motd.  Anyone else have this  
  34. problem  
  35. #? Anyone know how to fix it ?
  36. #
  37.  
  38. Yes.  There is a bug in MOTD_main.m that has to do with the OnlyOnce  
  39. default.
  40.  
  41. I have included the revelant section of code in MOTD_main.m.  The hack is  
  42. commented in the code.  This is main() from MOTD_main.m.  However, this is  
  43. just a quick hack, and it has the side effect of causing MOTD to _always_  
  44. display the motd messages on every login.  For my site, this is a good  
  45. thing, as sometimes news changes quite often, plus we have some class  
  46. accounts and not everyone was seeing the messages before...
  47.  
  48. void main(int argc, char *argv[])
  49. {
  50.         FILE *f_utmp;
  51.         struct stat s_stat;
  52.         struct utmp s_utmp;
  53.         struct passwd *p_passwd;
  54.         BOOL flag, do_motdL = YES;
  55.         MailLevel maillevelL = NONE;
  56.         char pathnamebuf[MAXPATHLEN];
  57.  
  58.         NXApp = [MOTD new];
  59.     
  60.         if (!(flag = (--argc && (p_passwd = getpwnam(argv[argc])) !=  
  61. NULL))) p_passwd = getpwuid((int) getuid());
  62.  
  63.         [[[NXApp setLoginHook:flag] setMailLevel:maillevelL]  
  64. setDo_Motd:do_motdL];
  65.  
  66.         if (p_passwd != NULL) {
  67.                 [[NXApp setUserName:p_passwd->pw_name]  
  68. setUID:p_passwd->pw_uid];                
  69.                 if (flag) { /* only check if LoginHook */
  70.                         (void) strcpy(pathnamebuf, MAILDIR); /* check for  
  71. mail arrival */
  72.                         (void) strcat(pathnamebuf, [NXApp getUserName]);
  73.                         if (stat(pathnamebuf, &s_stat) != CERROR &&  
  74. s_stat.st_size != 0)
  75.                         [NXApp setMailLevel:(maillevelL = (s_stat.st_atime  
  76. <= s_stat.st_mtime) ? NEW : OLD)];
  77.                         }
  78.  
  79.                 if (strncmp(getDefault("OnlyOnce"), "Yes", 1) == EQ &&
  80.                         stat([NXApp getFile], &s_stat) != CERROR &&  
  81. (f_utmp = fopen(WTMPFILE, "r")) != NULL) {
  82.                         while(fread(&s_utmp, sizeof(s_utmp), 1, f_utmp))
  83.                                 if (s_stat.st_mtime < s_utmp.ut_time &&
  84.                                         strncmp(s_utmp.ut_name, [NXApp  
  85. getUserName], sizeof(s_utmp.ut_name)) == EQ)
  86.                                         if ((flag &&  
  87. strncmp(s_utmp.ut_line, TTYDEVICE, sizeof(s_utmp.ut_line)) == EQ) ||
  88.                                                 (strncmp(s_utmp.ut_line,  
  89. FTPPREFIX, sizeof(s_utmp.ut_line)) != EQ)) {
  90. /* Modified for NS 3.0.  MOTD is always display
  91.    when a user logs on.  To revert to original
  92.    state, change do_motdL = YES to do_motdL = NO
  93. */
  94.                                                 [NXApp  
  95. setDo_Motd:(do_motdL = YES)];
  96.                                                 break; /* while() */
  97.                                                 }
  98.                         (void) fclose(f_utmp);
  99.                         }
  100.                 }
  101.  
  102.       
  103.         if (do_motdL || maillevelL != NONE) { /* if motd file not seen yet  
  104. OR if there is mail */
  105.                 [NXApp loadNibSection:"MOTD.nib" owner:NXApp];
  106.                 if (do_motdL) [[NXApp getCancelButton] setEnabled:flag];    
  107.                 [[NXApp run] free];
  108.                 }
  109.         else [NXApp free];
  110.         exit(EXIT_SUCCESS);     
  111. }
  112.  
  113.  
  114. #-Michael
  115. #  mgb@moksha.UUCP
  116. #  mgb@stetson.BITNET
  117. #
  118. #  NeXT mail welcome !
  119.  
  120. --
  121. Paul S. Sears                *  sears@uh.edu (NeXT Mail OK)
  122. The University of Houston    *  suggestions@tree.egr.uh.edu (NeXT
  123. Engineering Computing Center *  comments, complaints, questions)
  124. NeXT System Administration   *  DoD#1967 '83 NightHawk 650SC 
  125.           >>> SSI Diving Certification #755020059 <<<
  126. "Programming is like sex: One mistake and you support it a lifetime."
  127.