ironpeakservices / iron-alpine

Hardened alpine linux baseimage for Docker.
https://github.com/ironPeakServices/iron-alpine
Apache License 2.0
132 stars 12 forks source link

Recompile busybox #127

Open vladmiller opened 9 months ago

vladmiller commented 9 months ago

It seems like technically is not really different to remove commands like sh, because all those commands are implemented in busybox anyways.

Maybe there is a way to compile busybox on the fly and then replace the original binary with the stripped down version?

~ $ busybox
BusyBox v1.36.1 (2023-11-06 11:32:24 UTC) multi-call binary.
BusyBox is copyrighted by many authors between 1998-2015.
Licensed under GPLv2. See source distribution for detailed
copyright notices.

Usage: busybox [function [arguments]...]
   or: busybox --list[-full]
   or: busybox --install [-s] [DIR]
   or: function [arguments]...

    BusyBox is a multi-call binary that combines many common Unix
    utilities into a single executable.  Most people will create a
    link to busybox for each function they wish to use and BusyBox
    will act like whatever it was invoked as.

Currently defined functions:
    [, [[, acpid, add-shell, addgroup, adduser, adjtimex, arch, arp, arping, ash, awk, base64, basename, bbconfig, bc, beep, blkdiscard, blkid, blockdev,
    brctl, bunzip2, bzcat, bzip2, cal, cat, chattr, chgrp, chmod, chown, chpasswd, chroot, chvt, cksum, clear, cmp, comm, cp, cpio, crond, crontab, cryptpw,
    cut, date, dc, dd, deallocvt, delgroup, deluser, depmod, df, diff, dirname, dmesg, dnsdomainname, dos2unix, du, dumpkmap, echo, ed, egrep, eject, env,
    ether-wake, expand, expr, factor, fallocate, false, fatattr, fbset, fbsplash, fdflush, fdisk, fgrep, find, findfs, flock, fold, free, fsck, fstrim,
    fsync, fuser, getopt, getty, grep, groups, gunzip, gzip, halt, hd, head, hexdump, hostid, hostname, hwclock, id, ifconfig, ifdown, ifenslave, ifup,
    init, inotifyd, insmod, install, ionice, iostat, ip, ipaddr, ipcalc, ipcrm, ipcs, iplink, ipneigh, iproute, iprule, iptunnel, kbd_mode, kill, killall,
    killall5, klogd, last, less, link, linux32, linux64, ln, loadfont, loadkmap, logger, login, logread, losetup, ls, lsattr, lsmod, lsof, lsusb, lzcat,
    lzma, lzop, lzopcat, makemime, md5sum, mdev, mesg, microcom, mkdir, mkdosfs, mkfifo, mkfs.vfat, mknod, mkpasswd, mkswap, mktemp, modinfo, modprobe,
    more, mount, mountpoint, mpstat, mv, nameif, nanddump, nandwrite, nbd-client, nc, netstat, nice, nl, nmeter, nohup, nologin, nproc, nsenter, nslookup,
    ntpd, od, openvt, partprobe, passwd, paste, pgrep, pidof, ping, ping6, pipe_progress, pivot_root, pkill, pmap, poweroff, printenv, printf, ps, pscan,
    pstree, pwd, pwdx, raidautorun, rdate, rdev, readahead, readlink, realpath, reboot, reformime, remove-shell, renice, reset, resize, rev, rfkill, rm,
    rmdir, rmmod, route, run-parts, sed, sendmail, seq, setconsole, setfont, setkeycodes, setlogcons, setpriv, setserial, setsid, sh, sha1sum, sha256sum,
    sha3sum, sha512sum, showkey, shred, shuf, slattach, sleep, sort, split, stat, strings, stty, su, sum, swapoff, swapon, switch_root, sync, sysctl,
    syslogd, tac, tail, tar, tee, test, time, timeout, top, touch, tr, traceroute, traceroute6, tree, true, truncate, tty, ttysize, tunctl, udhcpc, udhcpc6,
    umount, uname, unexpand, uniq, unix2dos, unlink, unlzma, unlzop, unshare, unxz, unzip, uptime, usleep, uudecode, uuencode, vconfig, vi, vlock, volname,
    watch, watchdog, wc, wget, which, who, whoami, whois, xargs, xxd, xzcat, yes, zcat, zcip
~ $ cat /etc/os-release
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.18.4
PRETTY_NAME="Alpine Linux v3.18"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues"