Re: [PATCH] tftpd: strip leading slashes from the requested file name
Guillermo Rodriguez Garcia via busybox <[email protected]>
| Newsgroups | gmane.linux.busybox |
|---|---|
| Message-ID | <CABDcavad1Geg39yftOEmnYxT3UG1b3VrGLafhgqhz90=2TfLYw@mail.gmail.com> |
El mar, 18 ago 2026 a las 0:44, Ali Ahmet Memis (<[email protected]>) escribió: > > That's intentional. > > Without DIR tftpd doesn't chroot. So an absolute request like /etc/shadow is currently taken as an absolute path. > > TFTP only gives us a filename. There is no separate root on the TFTP side. The CWD or chroot is what decides where that filename is resolved. > > With DIR nothing really changes. xchroot() puts the process in that directory. So /foo and foo already refer to the same file there. > > The change matters in the no-DIR case. /pxelinux.0 can escape the directory the server was started in. After stripping the leading slash it stays relative to CWD. That's also what is needed for the PXE case in bug 4874. > > Another option would be to reject leading / when DIR is not set. That would be reasonable too. But then no-DIR PXE setups would have to pass DIR explicitly. > > If that's the behavior you prefer then I think that's a different fix. Otherwise I think stripping the slash is fine here. In the no-DIR case, where there's no chroot, I don't think that absolute pathnames should be blindly converted to relative. Note also that tftpd-hpa for example, if --secure is not used, absolute pathnames allowed (even though they still need to match one of the allowed DIRs). Best regards, Guillermo Rodriguez Garcia [email protected] _______________________________________________ busybox mailing list [email protected] https://lists.busybox.net/mailman/listinfo/busybox