-o option for start-stop-daemon

Louai Al-Khanji louai at astranis.com
Tue Nov 7 19:37:07 UTC 2023


Apologies for the spam, the previous patch had bad whitespace. Fixed here.

On Tue, Nov 7, 2023 at 11:34 AM Louai Al-Khanji <louai at astranis.com> wrote:
>
> Hi all,
>
> V3 attached.
>
> Rebased against master to account for the -d option. Moves the output
> variable from the globals struct to be local to main.
>
> Thanks,
> Louai
>
> On Tue, Nov 7, 2023 at 10:27 AM Louai Al-Khanji <louai at astranis.com> wrote:
> >
> > On Tue, Nov 7, 2023 at 8:03 AM Denys Vlasenko <vda.linux at googlemail.com> wrote:
> > >
> > > On Fri, Nov 3, 2023 at 11:31 PM Louai Al-Khanji <louai at astranis.com> wrote:
> > > >
> > > > On Wed, Nov 1, 2023 at 11:53 PM Louai Al-Khanji <louai at astranis.com> wrote:
> > > > >
> > > > > Hi,
> > > > >
> > > > > I am interested in implementing the -o|--output option that the Debian start-stop-daemon supports. Might such a patch be considered for upstreaming?
> > > > >
> > > > > Thanks,
> > > > > Louai
> > > >
> > > > Hello,
> > > >
> > > > Attached is a proposed patch. Any feedback would be appreciated.
> > >
> > > My experiments with ssd version 1.21.22 show that the file is opened with
> > > O_CREAT|O_APPEND, and it does not allow -O without -b.
> > >
> > > If execv fails, error message goes to this file.
> > > IOW: there is no need to save/restore old stderr fd. Just replace it
> > > with the new fd
> > > (and don't forget to not leak any extra open fds).
> >
> > Thank you for the feedback everyone. New version attached.
> >
> > It looked a little tricky to me to add the logic around
> > bb_daemon_helper() since it closes open fds. Maybe I am missing
> > something.
> >
> > The code now checks the args more strictly and prints usage if -O is
> > given without -b.
> >
> > I dropped restoring of the stdout/stderr fds. I believe this patch
> > cannot leak fds.
> >
> > One question I have is whether it's okay to lose error messages. On
> > failure to open the output file I believe the error message currently
> > goes into the void. Same if any of the dup2 calls or the close call
> > fails.
> >
> > BTW I noticed that bb_daemon_helper() internally calls setsid()
> > already, so the extra call in start_stop_daemon.c seems superfluous. I
> > didn't however touch that in this patch.
> >
> > Thanks,
> > Louai

-- 


________
This email and any attachments may contain Astranis confidential 
and/or proprietary information governed by a non-disclosure agreement, and 
are intended solely for the individual or entity specified by the message.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-start-stop-daemon-implement-option-O-output.patch
Type: text/x-patch
Size: 4136 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20231107/b6352808/attachment.bin>


More information about the busybox mailing list