Bug 14450 - update-rc.d: Errors in enabling/disabling startup links
Summary: update-rc.d: Errors in enabling/disabling startup links
Status: RESOLVED FIXED
Alias: None
Product: General Runtime
Classification: Runtime
Component: General Runtime (show other bugs)
Version: unspecified
Hardware: All Multiple
: Medium+ minor
Target Milestone: 3.4 M3
Assignee: Einar Gunnarsson
QA Contact:
URL: https://git.yoctoproject.org/cgit/cg...
Whiteboard:
Depends on:
Blocks:
 
Reported: 2021-06-24 16:20 UTC by Einar Gunnarsson
Modified: 2021-07-15 00:48 UTC (History)
1 user (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments
Patch that should fix this. (1.16 KB, application/octet-stream)
2021-06-24 16:20 UTC, Einar Gunnarsson
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Einar Gunnarsson 2021-06-24 16:20:10 UTC
Created attachment 4809 [details]
Patch that should fix this.

The shell script /usr/sbin/update-rc.d has a couple of issues in line 117.

    newnn=$[100-$oldnn]

https://git.yoctoproject.org/cgit/cgit.cgi/update-rc.d/tree/update-rc.d#n117

1) $[] is only known by bash. Running 'update-rc.d script enable' with a POSIX shell creates the links 'S$[100-12]script' instead of 'S88script'. 
   - Running 'update-rc.d script enable' a second time encounters more issues, since the $oldnn just grabs the second and third letter of the symlinks, which are now '$['.
   - This is an issue since many embedded boards only have busybox shell.

2)  $oldnn is parsed as a number, but a leading 0 means octal so that 08 and 09 fail. Running 'update-rc.d weston disable' does not work even when using bash, because S09weston results in $[100-09], which gives errors in any shell.

Both issues could be handled by using $(()), and stripping the leading 0.

     $((100-${oldnn#0})) # oldnn is guaranteed to be 2 chars

Shellcheck also reports 50+ other issues, but the others don't seem to break anything.
Comment 1 Randy MacLeod 2021-07-01 14:37:05 UTC
Einar, Are you able to send the patch to the email list: openembedded-core@lists.openembedded.org

https://www.openembedded.org/wiki/How_to_submit_a_patch_to_OpenEmbedded

I am usually available to help but I'm on vacation for a week. - Randy
Comment 2 Einar Gunnarsson 2021-07-02 13:37:51 UTC
Done.
https://lists.openembedded.org/g/openembedded-core/message/153466
Comment 3 Einar Gunnarsson 2021-07-07 08:35:50 UTC
Merged...

https://git.yoctoproject.org/cgit/cgit.cgi/update-rc.d/commit/?id=8636cf478d426b568c1be11dbd9346f67e03adac

Still needs to be tagged and bumped into poky
Comment 5 Randy MacLeod 2021-07-15 00:48:18 UTC
Thanks Einar!