Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 417263

Summary: sys-apps/busybox[make-symlinks] should not overwrite existing files
Product: Gentoo Linux Reporter: Maksim 'max_posedon' Melnikau <maxposedon>
Component: Current packagesAssignee: Embedded Gentoo Team <embedded>
Status: RESOLVED FIXED    
Severity: normal CC: jsmolic, rafdev, sam
Priority: Normal Keywords: PATCH, PullRequest
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://github.com/gentoo/gentoo/pull/21353
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: cp -n (--no-clobber) is not destructive
force cp to be nondestructive
Make USE=make-symlinks safer

Description Maksim 'max_posedon' Melnikau 2012-05-23 12:30:35 UTC
For small/embedded systems busybox can be used as big part of the system (USE="make-symlinks"), but sometimes its important to have regular tools (kbd/util-linux/shadow/etc). In this case updating busybox's symlinks overwrite important parts of the system.

I suggest use tar "keep-old-files" mode for creating symlinks (tar -k)

Reproducible: Always
Comment 1 Maksim 'max_posedon' Melnikau 2012-06-24 22:31:02 UTC
Created attachment 316189 [details, diff]
cp -n (--no-clobber) is not destructive

This patch makes ebuild less destructive, in cases when you want use busybox for most, but not all system components.
Comment 2 SpanKY gentoo-dev 2012-06-28 04:01:46 UTC
Comment on attachment 316189 [details, diff]
cp -n (--no-clobber) is not destructive

i don't think that'll work as that flag isn't in POSIX :/

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/cp.html
Comment 3 Chris Slycord 2020-02-09 04:44:43 UTC
Created attachment 612890 [details, diff]
force cp to be nondestructive

Posix compliant workaround for non-destructive cp
Comment 4 Raffaello D. Di Napoli 2020-11-29 06:00:47 UTC
Created attachment 675667 [details, diff]
Make USE=make-symlinks safer

Here’s another approach: only install an applet symlink if that name cannot be found in the usual /usr/sbin:/usr/bin:/sbin:/bin .

This guarantees the user can’t screw their system up, because it prevents a BB applet from both overwriting and hiding the “full” program (by installing a symlink in a different directory).
Comment 5 Larry the Git Cow gentoo-dev 2021-08-16 16:36:11 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=50b3efe86028e0e7d184d3a5c4a36c11f3388b6f

commit 50b3efe86028e0e7d184d3a5c4a36c11f3388b6f
Author:     Jakov Smolic <jakov.smolic@sartura.hr>
AuthorDate: 2021-08-16 16:31:47 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2021-08-16 16:35:39 +0000

    sys-apps/busybox: Don't overwrite existing files when using make-symlinks
    
    Closes: https://bugs.gentoo.org/417263
    Signed-off-by: Jakov Smolic <jakov.smolic@sartura.hr>
    Closes: https://github.com/gentoo/gentoo/pull/21353
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-apps/busybox/busybox-1.33.1-r1.ebuild | 343 ++++++++++++++++++++++++++++++
 sys-apps/busybox/busybox-9999.ebuild      |   2 +-
 2 files changed, 344 insertions(+), 1 deletion(-)