On Sun, 9 Jun 2019 at 00:54, Denys Vlasenko <vda.li...@googlemail.com> wrote:
>
> Imagining myself in the situation where I need to download
> executables over tftp, the first solution which comes to mind
> is to just chmod them after download.
>
> Why that does not work for you?

I am working on a reference root file system that is used internally
and possibly also by customers. Unbeknownst to me, for years we had an
internal hack to TFTP that caused the TFTP client to apply execute
permissions to transferred files. Presumably this was a user request
at some point.

A recent root file system modernization did away with this TFTP
customization, which promptly triggered a regression being filed
against TFTP. Since I had to come up with a new way to apply our old
patch, I figured I'd share it with the community in case it is useful
to others.

To answer the question why running "chmod" doesn't work in this case,
our users would say, "It used to work without. It should continue to
work without."

Regards,
-Markus

> On Tue, Apr 30, 2019 at 8:07 PM Markus Mayer <mma...@broadcom.com> wrote:
> >
> > On Tue, 30 Apr 2019 at 10:22, Markus Mayer <mma...@broadcom.com> wrote:
> > >
> > > We allow the umask being used by TFTP to be configurable. This way it is
> > > easy to make files transferred via TFTP executable by default if that is
> > > desired by the user.
> > >
> > > Signed-off-by: Markus Mayer <mma...@broadcom.com>
> > > ---
> > >  networking/tftp.c | 15 +++++++++++++--
> > >  1 file changed, 13 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/networking/tftp.c b/networking/tftp.c
> > > index d20d4ca4bd3c..c13683251a2c 100644
> > > --- a/networking/tftp.c
> > > +++ b/networking/tftp.c
> > > @@ -70,6 +70,17 @@
> > >  //config:      Allow tftp to specify block size, and tftpd to understand
> > >  //config:      "blksize" and "tsize" options.
> > >  //config:
> > > +//config:config FEATURE_TFTP_UMASK
> > > +//config:      hex "UMASK for TFTP client and server to use"
> > > +//config:      default 0x1b6
> > > +//config:      depends on TFTP || TFTPD
> > > +//config:      help
> > > +//config:      Specify the UMASK to be used for new being files 
> > > transferred
> >
> > That should be "...new files being...", of course.
> >
> > > +//config:      via TFTP. Defaults to 0x1b6 (0666). Use 0x1ff (0777) if 
> > > you
> > > +//config:      want execute permissions on transferred files.
> > > +//config:      (Must be specified in hex, since Kconfig doesn't support 
> > > octal
> > > +//config:      fields.)
> > > +//config:
> > >  //config:config TFTP_DEBUG
> > >  //config:      bool "Enable debug"
> > >  //config:      default n
> > > @@ -394,7 +405,7 @@ static int tftp_protocol(
> > >
> > >         if (!ENABLE_TFTP || our_lsa) { /* tftpd */
> > >                 /* Open file (must be after changing user) */
> > > -               local_fd = open(local_file, open_mode, 0666);
> > > +               local_fd = open(local_file, open_mode, 
> > > CONFIG_FEATURE_TFTP_UMASK);
> > >                 if (local_fd < 0) {
> > >                         G_error_pkt_reason = ERR_NOFILE;
> > >                         strcpy(G_error_pkt_str, "can't open file");
> > > @@ -421,7 +432,7 @@ static int tftp_protocol(
> > >                 /* Open file (must be after changing user) */
> > >                 local_fd = CMD_GET(option_mask32) ? STDOUT_FILENO : 
> > > STDIN_FILENO;
> > >                 if (NOT_LONE_DASH(local_file))
> > > -                       local_fd = xopen(local_file, open_mode);
> > > +                       local_fd = xopen3(local_file, open_mode, 
> > > CONFIG_FEATURE_TFTP_UMASK);
> > >  /* Removing #if, or using if() statement instead of #if may lead to
> > >   * "warning: null argument where non-null required": */
> > >  #if ENABLE_TFTP
> > > --
> > > 2.17.1
> > >
> > _______________________________________________
> > busybox mailing list
> > busybox@busybox.net
> > http://lists.busybox.net/mailman/listinfo/busybox
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to