Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!xanth!cs.odu.edu!tadguy From: tadguy@cs.odu.edu (Tad Guy) Newsgroups: comp.unix.wizards Subject: Re: anonymous ftp, and chroot Summary: connecting unix datagram sockets works in 4.3BSD Message-ID: <6840@xanth.cs.odu.edu> Date: 14 Dec 88 14:30:52 GMT Sender: news@xanth.cs.odu.edu Reply-To: tadguy@cs.odu.edu (Tad Guy) Organization: Old Dominion University, Norfolk, VA Lines: 63 Supersedes: <6834@xanth.cs.odu.edu> [ My apologies if you've seen this article more than once. I keep finding errors in it and keep superseding it. What a great feature... ] In article <3024@watale.waterloo.edu>, daemon@watale.waterloo.edu writes: >> [ describes how logging info from ftpd is lost after the chroot() ] In article <1379@mcgill-vision.UUCP>, mouse@mcgill-vision (der Mouse) writes: >That's a sendto(), which passes the address ("/dev/log") at the >time of the sendto(), which is after the chroot. And after the chroot, >there is no /dev/log. > ... >What we need is a syslogd that allows tcp connections, or perhaps a >connect() on a datagram socket (I think this might work now). Yes, this does work in 4.3BSD. >The proper fix is to rework syslog() and syslogd so they can be made to >work even after the client chroot()s. This is probably beyond most >people. I don't see any simple fix. What I did was give ftpd its own copy of syslog.c, which I modified to connect() the datagram socket to "/dev/log" at the time of openlog() if LOG_NDELAY was specified, then just use send(). Don't forget to add LOG_NDELAY to the openlog() call in ftpd.c. A more generic solution is needed, but this works fine for ftpd. My diffs (your line numbers may vary): *** /usr/src/lib/libc/gen/syslog.c Wed May 7 18:18:50 1986 --- syslog.c Tue Dec 6 20:02:27 1988 *************** *** 120,126 **** c = MAXLINE; /* output the message to the local logger */ ! if (sendto(LogFile, outline, c, 0, &SyslogAddr, sizeof SyslogAddr) >= 0) return; if (!(LogStat & LOG_CONS)) return; --- 120,126 ---- c = MAXLINE; /* output the message to the local logger */ ! if (send(LogFile, outline, c, 0) >= 0) return; if (!(LogStat & LOG_CONS)) return; *************** *** 167,172 **** --- 167,173 ---- strncpy(SyslogAddr.sa_data, logname, sizeof SyslogAddr.sa_data); if (LogStat & LOG_NDELAY) { LogFile = socket(AF_UNIX, SOCK_DGRAM, 0); + connect(LogFile, &SyslogAddr, sizeof SyslogAddr); fcntl(LogFile, F_SETFD, 1); } } -- Tad Guy Comp Sci, Old Dominion University, Norfolk, VA 23529-0162 tadguy@cs.odu.edu tadguy@xanth.cs.odu.edu [128.82.8.1] tadguy@xanth.uucp "Think twice before speaking, but don't say `think think click click'." -- John Owens