Bug 14126

Summary: resolvconf incompatible with busybox flock
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Robert Berger <pokylinux>
Component: coreAssignee: Randy MacLeod <randy.macleod>
Status: NEW --- QA Contact:
Severity: normal    
Priority: Medium+ CC: kai.kang, meta.mr.watcher, meta.watcher, randy.macleod, richard.purdie, tgamblin
Version: 3.1.4   
Target Milestone: Future   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Robert Berger 2020-11-14 10:19:50 UTC
It looks like this was introduced to /bin/resolvconf:

git log --source -S 'flock' -- resolvconf
commit ad69ba122e69f96d10349bea82400e96ad6f0942   HEAD (tag: ubuntu/1.79ubuntu13)
Author: Alfonso Sanchez-Beato (email Canonical) <alfonso.sanchez-beato@canonical.com>
Date:   Wed Apr 17 16:53:53 2019 +0200

    bin/resolvconf: use flock so resolvconf can be called in parallel safely
    
    LP: #1825194
    
    (resolvconf 1.79ubuntu13)

----

in the code:

# Make sure that we do not end up with a broken resolv.conf if resolvconf
# is invoked in parallel.
LOCK_WAIT_S=10
flock -w $LOCK_WAIT_S 9 ||
        { report_err "Run lock held by another process for longer than $LOCK_WAIT_S seconds"; exit 1; }


...but...

the busybox version of flock does not contain the -w flag.

This means that if you want to use resolvconf e.g. with core-image-minimal it won't work.

One solution would be to use a more complete version of flock like the one util-linux provides.

I suggest adding something like this to

./meta/recipes-connectivity/resolvconf/resolvconf_1.82.bb

RDEPENDS_${PN} = "util-linux-flock"
Comment 1 Kai Kang 2021-03-26 01:24:38 UTC
I suppose it is the right fix.
Comment 2 Kai Kang 2021-03-26 02:00:17 UTC
(In reply to comment #0)
> It looks like this was introduced to /bin/resolvconf:
> 
> git log --source -S 'flock' -- resolvconf
> commit ad69ba122e69f96d10349bea82400e96ad6f0942   HEAD (tag:
> ubuntu/1.79ubuntu13)
> Author: Alfonso Sanchez-Beato (email Canonical)
> <alfonso.sanchez-beato@canonical.com>
> Date:   Wed Apr 17 16:53:53 2019 +0200
> 
>     bin/resolvconf: use flock so resolvconf can be called in parallel safely
>     
>     LP: #1825194
>     
>     (resolvconf 1.79ubuntu13)
> 
> ----

Hi Robert,

Which branch are you working on? I didn't see this patch in master and dunfell.

Regards,
Kai
Comment 3 Richard Purdie 2021-04-22 15:26:47 UTC
Question of whether busybox can support the -w and we need to change config or whether we should depend on util-linux. Someone needs to invetigate.
Comment 4 Robert Berger 2021-04-26 13:42:19 UTC
1) resolvconf wants:

# Make sure that we do not end up with a broken resolv.conf if resolvconf
# is invoked in parallel.
LOCK_WAIT_S=10
flock -w $LOCK_WAIT_S 9

2) standard flock(1)[1] supports -w:

-w, --wait, --timeout seconds
              Fail if the lock cannot be acquired within seconds.
              Decimal fractional values are allowed.  See the -E option
              for the exit status used. The zero number of seconds is
              interpreted as --nonblock.

3) busybox does not seem to support anything like that out of the box:

opt = getopt32long(argv, "^+" "sxnu" "\0" "-1", flock_longopts);

[1] https://man7.org/linux/man-pages/man1/flock.1.html 
[2] https://git.busybox.net/busybox/tree/util-linux/flock.c#n16

So I would say that we 
*) either need to implement -w in busybox or 
*) use util-linux-flock instead - 
*) or change the resolconf script in some way which does not need it.
Comment 5 Robert Berger 2021-04-26 13:57:27 UTC
With the latest and greatest master branch I just made a resolvconf_1.87.bbappend file and added:

RDEPENDS_${PN} = "util-linux-flock"

But now I also get:

ERROR: resolvconf-1.87-r0 do_package_qa: QA Issue: /lib/resolvconf/list-records contained in package resolvconf requires /bin/bash, but no providers found in RDEPENDS_resolvconf? [file-rdeps]

which means we also need bash:

RDEPENDS_${PN} = "util-linux-flock bash"
Comment 6 Robert Berger 2021-04-26 14:49:03 UTC
and the party goes on:

in runtime:

echo "nameserver 1.1.1.1" | resolvconf -a dummy.if
readlink: invalid option -- 'm'
BusyBox v1.33.0 () multi-call binary.

Usage: readlink [-fnv] FILE
/etc/resolvconf/update.d/libc: Warning: /etc/resolv.conf is not a symbolic link to /run/resolvconf/resolv.conf
Comment 7 Robert Berger 2021-04-26 17:15:25 UTC
after adding this, which made it work:
RDEPENDS_${PN} = "util-linux-flock bash coreutils"

the image size of something like a core-image-minimal grew from:
IMAGESIZE = 51116 --> IMAGESIZE = 56312

4399	KiB	coreutils
289	KiB	libgmp10
35	KiB	coreutils-stdbuf
22	KiB	util-linux-flock
21	KiB	libacl1

... not sure this is what we want ;)

RP?
Comment 8 Randy MacLeod 2021-10-28 17:51:22 UTC
Robert, best way to find out if RP likes the change is to send a patch to the list...
Comment 9 Randy MacLeod 2022-04-11 22:29:06 UTC
Still no -w option for busybox flock
Comment 10 Randy MacLeod 2023-07-26 21:29:36 UTC
Bulk move to 4.3 M3.
Comment 11 Trevor Gamblin 2023-09-14 16:55:30 UTC
Moved to M4.
Comment 12 Randy MacLeod 2024-04-25 01:07:07 UTC
Still no -w option for busybox flock
Move to 5.99 since no one is actively working on this.
Comment 13 Randy MacLeod 2025-02-20 16:28:49 UTC
Apply patch then it becomes an enhancement.