These are a set of patches to the Ultrix 4.2 mountd that allow it to log (via a 4.3 BSD style syslog, although that shouldn't be very important) attempts (successful and not) to mount NFS filesystems. They're extracted from our full set of patches, but I believe that they should apply cleanly. As usual, the standard disclaimer: "No warranties whatsoever -- we stoutly deny any possibility that this may actually compile to anything resembling working binaries on any given system." - Chris Siebenmann (cks@sys.utoronto.ca), Jan 7th 1994 *** mountd.c.orig Thu Apr 25 14:24:51 1991 --- mountd.c Fri Mar 26 14:11:34 1993 *************** *** 333,339 **** usage(); } } ! if (openlog("mountd", LOG_PID) < 0) fprintf(stderr, "mountd: openlog failed\n"); syslog(LOG_ERR, "startup"); --- 334,366 ---- usage(); } } ! #ifndef DEBUG ! /* relocated to BEFORE we open syslog. */ ! { ! int t; ! ! for (t = 0; t < 20; t++) ! if (t != fd) ! (void) close(t); ! open("/", 0); ! dup2(0, 1); ! dup2(0, 2); ! } ! #endif DEBUG ! #ifndef DEBUG ! { ! int pid; ! ! pid = fork(); ! if (pid < 0) { ! syslog(LOG_ERR, "Cannot fork: %m"); ! exit(1); ! } ! if (pid != 0) ! exit(0); ! } ! #endif DEBUG ! if (openlog("mountd", LOG_PID, LOG_USER) < 0) fprintf(stderr, "mountd: openlog failed\n"); syslog(LOG_ERR, "startup"); *************** *** 375,388 **** int len = sizeof(struct sockaddr_in); int pid; - #ifndef DEBUG - for (t = 0; t < 20; t++) - if (t != fd) - (void) close(t); - open("/", 0); - dup2(0, 1); - dup2(0, 2); - #endif DEBUG if ((s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { syslog(LOG_ERR, "socket: %m"); exit(1); --- 402,407 ---- *************** *** 406,420 **** syslog(LOG_ERR, "dup2: %m"); exit(1); } - #ifndef DEBUG - pid = fork(); - if (pid < 0) { - syslog(LOG_ERR, "Cannot fork: %m"); - exit(1); - } - if (pid != 0) - exit(0); - #endif DEBUG } /* End chunk to remove if running under inetd. */ --- 425,430 ---- *************** *** 721,726 **** --- 734,740 ---- perror("mountd"); (void)fprintf(stderr, "Realpath failed on %s\n", path); #endif DEBUG + syslog(LOG_DEBUG, "failed to expand %s to real path", path); fhs.fhs_status = EACCES; goto done; } *************** *** 902,907 **** --- 916,927 ---- */ dupcache_enter(addr.sin_addr, statbuf.st_dev, statbuf.st_ino, statbuf.st_gennum, anc_name); + if (strcmp(path, rpath) != 0) + syslog(LOG_INFO, "%s mounted %s (really %s) via entry %s", + client->h_name, path, rpath, anc_name); + else + syslog(LOG_INFO, "%s mounted %s via entry %s", + client->h_name, path, anc_name); done: #ifdef DEBUG (void) fprintf(stderr, "*** ng cache and export list ***\n"); *************** *** 910,915 **** --- 930,940 ---- #endif DEBUG (void) close(fd); + if (fhs.fhs_status != 0) { + errno = fhs.fhs_status; + syslog(LOG_INFO, "%s failed to mount %s: %m", client->h_name, path); + } + if (!svc_sendreply(transp, xdr_fhstatus, &fhs)) { syslog(LOG_ERR, "couldn't reply to MOUNT rpc call"); mtd_abort();