anonymous ftp, and chroot
Tad Guy
tadguy at cs.odu.edu
Thu Dec 15 00:30:52 AEST 1988
[ 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 at watale.waterloo.edu>, daemon at watale.waterloo.edu writes:
>> [ describes how logging info from ftpd is lost after the chroot() ]
In article <1379 at mcgill-vision.UUCP>, mouse at 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 at cs.odu.edu tadguy at xanth.cs.odu.edu [128.82.8.1] tadguy at xanth.uucp
"Think twice before speaking, but don't say `think think click click'."
-- John Owens
More information about the Comp.unix.wizards
mailing list