[Aboriginal] Oy I am behind.
Denys Vlasenko
vda.linux at googlemail.com
Tue Oct 13 04:56:40 PDT 2015
On Tue, Oct 13, 2015 at 5:16 AM, Rob Landley <rob at landley.net> wrote:
> On 10/12/2015 06:48 PM, Denys Vlasenko wrote:
>> On Wed, Aug 26, 2015 at 9:40 AM, Rob Landley <rob at landley.net> wrote:
>>> And that's on top of the nommu support stuff I've been doing for $DAYJOB...
>>
>> Rob, please note that hush had a nommu bug discovered recently.
>
> Sigh. Ok, updating to current busybox.
>
>> Testcase is a bit convoluted:
>>
>> func()
>> {
>> while read p; do echo "$p"; done
>> }
>> pipe_to_func()
>> {
>> # We had a NOMMU bug which caused "echo Ok |" part to be lost
>> echo Ok | func
>> }
>> pipe_to_func | cat
>> echo $?
>>
>> And also, there is an embarrassing simple bug: "umask N"
>> actually sets umask ~N.
>>
>> I released busybox-1.24.0 with both fixed.
>
> Updating broke
> http://landley.net/hg/aboriginal/file/tip/sources/patches/busybox-ftpd.patch
> which looks like it's still needed...
You want "ftpd DIR" to work also for non-root.
Well, this can't be made to work _exactly_ as for root
(where DIR becomes new rootdir), and I thought that
to have a discrepancy is bad.
I take your and other people's emails as an indication that
in real world, it's acceptable for non-root invocation to simply
chdir instead.
Fixed in git.
BTW, let me know if ftpd doesn't work in NOMMU,
it had to do some weird stuff to avoid fork()
http://git.busybox.net/busybox/commit/?id=f7ad927c2059ef9cd1cd6befeb43f26b92f6369f
diff --git a/networking/ftpd.c b/networking/ftpd.c
index 7735b72..8345ae6 100644
--- a/networking/ftpd.c
+++ b/networking/ftpd.c
@@ -1223,11 +1223,26 @@ int ftpd_main(int argc UNUSED_PARAM, char **argv)
#endif
argv += optind;
if (argv[0]) {
+ const char *basedir = argv[0];
#if !BB_MMU
G.root_fd = xopen("/", O_RDONLY | O_DIRECTORY);
close_on_exec_on(G.root_fd);
#endif
- xchroot(argv[0]);
+ if (chroot(basedir) == 0)
+ basedir = "/";
+#if !BB_MMU
+ else {
+ close(G.root_fd);
+ G.root_fd = -1;
+ }
+#endif
+ /*
+ * If chroot failed, assume that we aren't root,
+ * and at least chdir to the specified DIR
+ * (older versions were dying with error message).
+ * If chroot worked, move current dir to new "/":
+ */
+ xchdir(basedir);
}
#if ENABLE_FEATURE_FTP_AUTHENTICATION
More information about the Aboriginal
mailing list