Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 417263 - sys-apps/busybox[make-symlinks] should not overwrite existing files
Summary: sys-apps/busybox[make-symlinks] should not overwrite existing files
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Embedded Gentoo Team
Keywords: PATCH, PullRequest
Depends on:
Reported: 2012-05-23 12:30 UTC by Maksim 'max_posedon' Melnikau
Modified: 2021-08-16 16:36 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---

cp -n (--no-clobber) is not destructive (busybox-1.20.1.ebuild.patch,411 bytes, patch)
2012-06-24 22:31 UTC, Maksim 'max_posedon' Melnikau
Details | Diff
force cp to be nondestructive (busybox-1.30.1.ebuild.patch,498 bytes, patch)
2020-02-09 04:44 UTC, Chris Slycord
Details | Diff
Make USE=make-symlinks safer (busybox-1.31.1-r3.ebuild-safe-make-symlinks.patch,1.40 KB, patch)
2020-11-29 06:00 UTC, Raffaello D. Di Napoli
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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 :/
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):

commit 50b3efe86028e0e7d184d3a5c4a36c11f3388b6f
Author:     Jakov Smolic <>
AuthorDate: 2021-08-16 16:31:47 +0000
Commit:     Sam James <>
CommitDate: 2021-08-16 16:35:39 +0000

    sys-apps/busybox: Don't overwrite existing files when using make-symlinks
    Signed-off-by: Jakov Smolic <>
    Signed-off-by: Sam James <>

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