|
|
1.1 ! root 1: /* ! 2: * This function initializes all the strings used for the various ! 3: * filenames. They cannot be compiled into the program, since that ! 4: * would be non-portable. With this convention, the netnews sub-system ! 5: * can be owned by any non-priviledged user. It is also possible ! 6: * to work when the administration randomly moves users from one ! 7: * filesystem to another. The convention is that a particular user ! 8: * (HOME, see Makefile) is searched for in /etc/passwd and all files ! 9: * are presumed relative to there. This method also allows one copy ! 10: * of the object code to be used on ANY machine. (this code runs ! 11: * un-modified on 50+ machines at IH!!) ! 12: * ! 13: * The disadvantage to using this method is that all netnews programs ! 14: * (inews, readnews, rnews, checknews) must first search /etc/passwd ! 15: * before they can start up. This can cause significant overhead if ! 16: * you have a big password file. ! 17: * ! 18: * Some games are played with ifdefs to get three .o files out of this ! 19: * one source file. INEW is defined for inews, READ for readnews, ! 20: * and CHKN for checknews. ! 21: */ ! 22: static char *sccsid = "@(#)pathinit.c 1.2 3/30/83"; ! 23: ! 24: #ifdef INEW ! 25: #include "iparams.h" ! 26: #endif ! 27: ! 28: #ifdef READ ! 29: #include "rparams.h" ! 30: extern char MAILPARSER[]; ! 31: #endif ! 32: ! 33: #ifdef CHKN ! 34: #include <stdio.h> ! 35: extern char SPOOL[]; ! 36: extern char LIB[]; ! 37: extern char ACTIVE[]; ! 38: #endif ! 39: ! 40: #ifdef EXP ! 41: #include <stdio.h> ! 42: extern char SPOOL[]; ! 43: extern char LIB[]; ! 44: extern char ACTIVE[]; ! 45: extern char OLDNEWS[]; ! 46: #endif ! 47: ! 48: struct passwd *getpwname(); ! 49: char *rindex(); ! 50: ! 51: pathinit() ! 52: { ! 53: struct passwd *pw; /* struct for pw lookup */ ! 54: FILE *nfd; /* notify file descriptor */ ! 55: char *p; ! 56: #if INEW || READ ! 57: struct utsname ubuf; ! 58: ! 59: uname(&ubuf); ! 60: strcpy(FULLSYSNAME, ubuf.nodename); ! 61: strcpy(SYSNAME, ubuf.nodename); ! 62: SYSNAME[SNLN] = '\0'; ! 63: #endif ! 64: ! 65: #ifdef HOME ! 66: /* Relative to the home directory of user HOME */ ! 67: sprintf(SPOOL, "%s/%s", logdir(HOME), SPOOLDIR); ! 68: sprintf(LIB, "%s/%s", logdir(HOME), LIBDIR); ! 69: #else ! 70: /* Fixed paths defined in Makefile */ ! 71: strcpy(SPOOL, SPOOLDIR); ! 72: strcpy(LIB, LIBDIR); ! 73: #endif ! 74: ! 75: sprintf(ACTIVE, "%s/active", LIB); ! 76: ! 77: #ifdef EXP ! 78: strcpy(OLDNEWS, SPOOL); ! 79: p = rindex(OLDNEWS, '/'); ! 80: if (p) ! 81: strcpy(++p, "oldnews"); ! 82: #endif ! 83: ! 84: #if INEW || READ ! 85: sprintf(LOCKFILE, "%s/LOCK", LIB); ! 86: sprintf(SEQFILE, "%s/seq", LIB); ! 87: sprintf(NGFILE, "%s/ngfile", LIB); ! 88: sprintf(SUBFILE, "%s/sys", LIB); ! 89: sprintf(ARTFILE, "%s/history", LIB); ! 90: # ifdef INEW ! 91: sprintf(ARTICLE, "%s/.arXXXXXX", SPOOL); ! 92: sprintf(INFILE, "%s/.inXXXXXX", SPOOL); ! 93: sprintf(logfname, "%s/log", LIB); ! 94: sprintf(STASH, "%s/junk", LIB); ! 95: # endif ! 96: # ifdef READ ! 97: sprintf(HELPFILE, "%s/help", LIB); ! 98: sprintf(CAESAR, "%s/caesar", LIB); ! 99: sprintf(USERS, "%s/users", LIB); ! 100: #ifdef SENDMAIL ! 101: strcpy(MAILPARSER, SENDMAIL); /* SENDMAIL includes -t */ ! 102: #else ! 103: sprintf(MAILPARSER, "%s/recmail", LIB); ! 104: #endif ! 105: # endif ! 106: ! 107: /* ! 108: * The person notified by the netnews sub-system. Again, no name is ! 109: * compiled in, but instead the information is taken from a file. ! 110: * If the file does not exist, a "default" person will get the mail. ! 111: * If the file exists, but is empty, nobody will get the mail. This ! 112: * may seem backwards, but is a better fail-safe. ! 113: */ ! 114: # ifdef NOTIFY ! 115: sprintf(TELLFILE, "%s/notify", LIB); ! 116: nfd = fopen(TELLFILE, "r"); ! 117: if (nfd == NULL) ! 118: sprintf(TELLME, "%s", NOTIFY); ! 119: else if (fscanf(nfd, "%s", TELLME) == EOF) ! 120: strcpy(TELLME, ""); ! 121: # endif ! 122: ! 123: /* ! 124: * Since the netnews owner's id number is different on different ! 125: * systems, we'll extract it from the /etc/passwd file. If no entry, ! 126: * default to root. This id number seems to only be used to control who ! 127: * can input certain control messages or cancel any message. Note that ! 128: * entry is the name from the "notify" file as found above if possible. ! 129: * Defining ROOTID in defs.h hardwires in a number and avoids ! 130: * another search of /etc/passwd. ! 131: */ ! 132: # ifndef ROOTID ! 133: if ((pw = getpwname(TELLME)) != NULL) ! 134: ROOTID = pw->pw_uid; ! 135: else if ((pw = getpwname(HOME)) != NULL) ! 136: ROOTID = pw->pw_uid; ! 137: else ! 138: ROOTID = 0; /* nobody left, let only root */ ! 139: # endif ROOTID ! 140: #endif INEW || READ ! 141: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.