diff options
Diffstat (limited to 'package/utils')
115 files changed, 4555 insertions, 2563 deletions
diff --git a/package/utils/adb/Makefile b/package/utils/adb/Makefile index 0482a40da15..c207c333b24 100644 --- a/package/utils/adb/Makefile +++ b/package/utils/adb/Makefile @@ -13,6 +13,7 @@ PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_SOURCE_VERSION) PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.xz PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_SOURCE_SUBDIR) PKG_MAINTAINER:=Henryk Heisig <hyniu@o2.pl> +PKG_CPE_ID:=cpe:/a:google:android_debug_bridge include $(INCLUDE_DIR)/package.mk diff --git a/package/utils/bcm27xx-userland/Makefile b/package/utils/bcm27xx-userland/Makefile deleted file mode 100644 index 098c039f1f9..00000000000 --- a/package/utils/bcm27xx-userland/Makefile +++ /dev/null @@ -1,71 +0,0 @@ -# -# Copyright (C) 2019-2020 OpenWrt.org -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -include $(TOPDIR)/rules.mk - -PKG_NAME:=bcm27xx-userland -PKG_VERSION:=4a0a19b88b43e48c6b51b526b9378289fb712a4c -PKG_RELEASE:=1 - -PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_SOURCE_URL:=https://codeload.github.com/raspberrypi/userland/tar.gz/$(PKG_VERSION)? -PKG_HASH:=0f42d48095d1f680cbe8781c2e974b76bdd0507aaef64cce8b8b472ca3a09588 - -PKG_FLAGS:=nonshared - -PKG_MAINTAINER:=Álvaro Fernández Rojas <noltari@gmail.com> - -CMAKE_INSTALL:=1 -CMAKE_OPTIONS+=-DVMCS_INSTALL_PREFIX=/usr - -ifeq ($(ARCH),aarch64) - CMAKE_OPTIONS+=-DARM64=ON -else - CMAKE_OPTIONS+=-DARM64=OFF -endif - -include $(INCLUDE_DIR)/package.mk -include $(INCLUDE_DIR)/cmake.mk - -TAR_OPTIONS:=--strip-components 1 $(TAR_OPTIONS) -TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS) - -define Package/bcm27xx-userland - SECTION:=utils - CATEGORY:=Utilities - DEPENDS:=@TARGET_bcm27xx - TITLE:=BCM27xx userland tools - DEFAULT:=y if TARGET_bcm27xx -endef - -define Package/bcm27xx-userland/description - BCM27xx userland tools including vcgencmd and tvservice. -endef - -define Package/bcm27xx-userland/install - $(INSTALL_DIR) $(1)/usr/bin - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/dtmerge $(1)/usr/bin - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/dtparam $(1)/usr/bin - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/dtoverlay $(1)/usr/bin -ifneq ($(ARCH),aarch64) - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/raspistill $(1)/usr/bin - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/raspivid $(1)/usr/bin - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/raspividyuv $(1)/usr/bin - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/raspiyuv $(1)/usr/bin -endif - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/tvservice $(1)/usr/bin - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/vcgencmd $(1)/usr/bin - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/vcmailbox $(1)/usr/bin - - $(INSTALL_DIR) $(1)/usr/include - $(CP) $(PKG_INSTALL_DIR)/usr/include/ $(1)/usr/ - - $(INSTALL_DIR) $(1)/usr/lib - $(CP) $(PKG_INSTALL_DIR)/usr/lib/ $(1)/usr/ -endef - -$(eval $(call BuildPackage,bcm27xx-userland)) diff --git a/package/utils/bcm27xx-utils/Makefile b/package/utils/bcm27xx-utils/Makefile new file mode 100644 index 00000000000..ec41b70c306 --- /dev/null +++ b/package/utils/bcm27xx-utils/Makefile @@ -0,0 +1,64 @@ +# SPDX-License-Identifier: GPL-2.0-only + +include $(TOPDIR)/rules.mk + +PKG_NAME:=bcm27xx-utils +PKG_VERSION:=2024-01-18 +PKG_RELEASE:=1 + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL:=https://github.com/raspberrypi/utils.git +PKG_SOURCE_VERSION:=e65f5ec102e74218cda7da9fdc8b1caa0fd1127d +PKG_MIRROR_HASH:=14f4aa1a8115240d702251bc399b53cbfa0928813f70a73ca27b22da94b696d2 + +PKG_FLAGS:=nonshared +PKG_BUILD_FLAGS:=no-lto + +PKG_LICENSE:=BSD-3-Clause +PKG_LICENSE_FILES:=LICENCE + +CMAKE_INSTALL:=1 + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +define Package/bcm27xx-utils + SECTION:=utils + CATEGORY:=Utilities + DEPENDS:=@TARGET_bcm27xx +libfdt + TITLE:=BCM27xx scripts and simple applications + PROVIDES:=bcm27xx-userland +endef + +define Package/bcm27xx-utils/description + BCM27xx scripts and simple applications. + Replaces bcm27xx-userland scripts and applications. +endef + +define Package/bcm27xx-utils/install + $(INSTALL_DIR) $(1)/usr/bin + + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/dtmerge $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/dtoverlay $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/dtparam $(1)/usr/bin + + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/eepdump $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/eepflash.sh $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/eepmake $(1)/usr/bin + + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/otpset $(1)/usr/bin + + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/overlaycheck $(1)/usr/bin + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/bin/overlaycheck_exclusions.txt $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/ovmerge $(1)/usr/bin + + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/pinctrl $(1)/usr/bin + + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/raspinfo $(1)/usr/bin + + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/vcgencmd $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/vclog $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/vcmailbox $(1)/usr/bin +endef + +$(eval $(call BuildPackage,bcm27xx-utils)) diff --git a/package/utils/bcm27xx-utils/patches/0001-raspinfo-adapt-to-OpenWrt.patch b/package/utils/bcm27xx-utils/patches/0001-raspinfo-adapt-to-OpenWrt.patch new file mode 100644 index 00000000000..9dd6d99626e --- /dev/null +++ b/package/utils/bcm27xx-utils/patches/0001-raspinfo-adapt-to-OpenWrt.patch @@ -0,0 +1,255 @@ +From 0db3fb3119eda8c2360454c2a01f84602a879c38 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= <noltari@gmail.com> +Date: Tue, 16 Jan 2024 15:32:12 +0100 +Subject: [PATCH] raspinfo: adapt to OpenWrt +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> +--- + raspinfo/raspinfo | 186 ++++------------------------------------------ + 1 file changed, 13 insertions(+), 173 deletions(-) + +--- a/raspinfo/raspinfo ++++ b/raspinfo/raspinfo +@@ -1,4 +1,4 @@ +-#!/bin/bash ++#!/bin/sh + + # Some of the regex's used in sed + # Catch basic IP6 address "s/\([0-9a-fA-F]\{1,4\}:\)\{7,7\}[0-9a-fA-F]\{1,4\}/y.y.y.y.y.y.y.y/g" +@@ -6,147 +6,6 @@ + # IP4 d.d.d.d decimal "s/\([0-9]\{1,3\}\.\)\{3,3\}[0-9]\{1,3\}/x.x.x.x/g" + # mac address "s/\([0-9a-fA-F]\{2,2\}\:\)\{5,5\}[0-9a-fA-F]\{2,2\}/m.m.m.m/g" + +- +-display_info_drm() { +- # If running X then can use xrandr, otherwise +- # dump the /sys/class entries for the displays +- if command -v xrandr > /dev/null && +- DISPLAY=${DISPLAY:-:0} xrandr --listmonitors &>/dev/null; +- then +- echo "Running (F)KMS and X" +- echo +- +- DISPLAY=${DISPLAY:-:0} xrandr --verbose +- else +- echo "Running (F)KMS, console" +- echo +- +- for card in /sys/class/drm/card[0-9]-*; +- do +- echo $card +- +- # if kmsprint isn't installed print basic mode info +- if ! command -v kmsprint > /dev/null; then +- if [ -f $card/modes ]; +- then +- cat $card/modes +- else +- echo "No modes found" +- fi +- fi +- +- if [ -f $card/edid ]; +- then +- base64 $card/edid +- else +- echo "No EDID found" +- fi +- echo +- done +- fi +- +- # kmsprint is more useful, but not always installed +- echo +- if command -v kmsprint > /dev/null; then +- kmsprint +- echo +- kmsprint -m +- else +- echo "kmsprint is not installed. Install with: sudo apt install kms++-utils" +- fi +- +- echo +- +- # dump the /sys/class entries for the displays +- cardfound=0 +- for card in `seq 0 9`; +- do +- if sudo test -f "/sys/kernel/debug/dri/${card}/state"; +- then +- for hdmi in 0 1; +- do +- if sudo test -f "/sys/kernel/debug/dri/${card}/hdmi${hdmi}_regs"; +- then +- echo "HDMI${hdmi}: $(sudo cat /sys/kernel/debug/dri/$card/hdmi${hdmi}_regs | grep HOTPLUG)" +- fi +- done +- echo +- echo "/sys/kernel/debug/dri/$card/state:" +- sudo cat "/sys/kernel/debug/dri/$card/state" +- echo +- cardfound=1 +- fi +- done +- if [ "$cardfound" == "0" ]; +- then +- echo "kms state not found" +- fi +- echo +- +-} +- +-display_info_legacy() { +- # Legacy mode +- echo "Running Legacy framebuffer" +- echo +- +- for card in `seq 0 9`; +- do +- F="/dev/fb${card}" +- if test -e $F; +- then +- echo Framebuffer: $F +- fbset -s -fb $F +- fi +- done +- +- disps=`tvservice -l | awk '/Display Number/{print substr($3,1,1)}'` +- +- tmp=$(mktemp) +- +- for display in $disps +- do +- echo +- echo "Display: " $display +- +- tvservice -v $display -s +- tvservice -v $display -n +- tvservice -v $display -m CEA +- tvservice -v $display -m DMT +- +- echo +- tvservice -v $display -d $tmp > /dev/null +- base64 $tmp +- done +- +- rm $tmp +-} +- +-display_info() { +- # Check if we are running a KMS/DRM system +- +- if [ -d "/dev/dri" ]; +- then +- display_info_drm +- else +- display_info_legacy +- fi +-} +- +-audio_info() { +- aplay -l +- echo +- aplay -L +- echo +- systemctl --user status pipewire.socket pipewire.service pulseaudio.service pulseaudio.socket +- echo +- if command -v pactl > /dev/null; then +- pactl info +- else +- echo pactl not installed +- fi +-} +- + OUT=raspinfo.txt + + rm -f $OUT +@@ -163,8 +22,6 @@ echo + cat /etc/os-release | head -4 + echo + +-cat /etc/rpi-issue +-echo + uname -a + + cat /proc/cpuinfo | tail -3 +@@ -190,17 +47,6 @@ echo + cat /proc/swaps + + echo +-echo "Package version information" +-echo "---------------------------" +- +-apt-cache policy raspberrypi-ui-mods | head -2 +-apt-cache policy raspberrypi-sys-mods | head -2 +-apt-cache policy openbox | head -2 +-apt-cache policy lxpanel | head -2 +-apt-cache policy pcmanfm | head -2 +-apt-cache policy rpd-plym-splash | head -2 +- +-echo + echo "Networking Information" + echo "----------------------" + echo +@@ -212,21 +58,11 @@ echo "USB Information" + echo "---------------" + echo + +-lsusb -t +- +-echo +-echo "Display Information" +-echo "-------------------" +-echo +- +-display_info +- +-echo +-echo "Audio Information" +-echo "-------------------" +-echo +- +-audio_info ++if command -v lsusb > /dev/null; then ++ lsusb -t ++else ++ echo usbutils not installed ++fi + + echo + echo "config.txt" +@@ -250,7 +86,7 @@ echo "-----------------" + echo + + if command -v pinctrl > /dev/null; then +- sudo pinctrl 2>&1 ++ pinctrl 2>&1 + elif command -v raspi-gpio > /dev/null; then + raspi-gpio get 2>&1 + else +@@ -263,9 +99,9 @@ echo "------------------" + echo + + if command -v vcdbg > /dev/null; then +- sudo vcdbg log msg 2>&1 ++ vcdbg log msg 2>&1 + elif command -v vclog > /dev/null; then +- sudo vclog --msg 2>&1 ++ vclog --msg 2>&1 + else + echo "vcdbg not found" + fi +@@ -284,5 +120,9 @@ echo + echo "EEPROM" + echo "------" + echo +-sudo rpi-eeprom-update ++if command -v rpi-eeprom-update > /dev/null; then ++ rpi-eeprom-update ++else ++ echo bcm27xx-eeprom not installed ++fi + fi diff --git a/package/utils/bcm4908img/Makefile b/package/utils/bcm4908img/Makefile index c18ac958f8d..fbb91fba73c 100644 --- a/package/utils/bcm4908img/Makefile +++ b/package/utils/bcm4908img/Makefile @@ -3,7 +3,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=bcm4908img -PKG_RELEASE:=1 +PKG_RELEASE:=3 PKG_FLAGS:=nonshared diff --git a/package/utils/bcm4908img/src/bcm4908img.c b/package/utils/bcm4908img/src/bcm4908img.c index 402d3171908..240fe895d95 100644 --- a/package/utils/bcm4908img/src/bcm4908img.c +++ b/package/utils/bcm4908img/src/bcm4908img.c @@ -77,13 +77,14 @@ struct bcm4908img_tail { * 4. padding ├─ firmware * 5. rootfs ─┘ * 6. BCM4908 tail + * 7. (Optional) vendor tail */ struct bcm4908img_info { - size_t file_size; size_t cferom_offset; size_t bootfs_offset; size_t padding_offset; size_t rootfs_offset; + size_t tail_offset; uint32_t crc32; /* Calculated checksum */ struct bcm4908img_tail tail; }; @@ -219,7 +220,7 @@ static int bcm4908img_calc_crc32(FILE *fp, struct bcm4908img_info *info) { fseek(fp, info->cferom_offset, SEEK_SET); info->crc32 = 0xffffffff; - length = info->file_size - info->cferom_offset - sizeof(struct bcm4908img_tail); + length = info->tail_offset - info->cferom_offset; while (length && (bytes = fread(buf, 1, bcm4908img_min(sizeof(buf), length), fp)) > 0) { info->crc32 = bcm4908img_crc32(info->crc32, buf, bytes); length -= bytes; @@ -249,6 +250,16 @@ struct chk_header { char board_id[0]; }; +struct linksys_tail { + char magic[9]; + uint8_t version[8]; + char model[15]; + uint32_t crc32; + uint8_t padding[9]; + uint8_t signature[16]; + uint8_t reserved[192]; +}; + static bool bcm4908img_is_all_ff(const void *buf, size_t length) { const uint8_t *in = buf; @@ -264,9 +275,11 @@ static bool bcm4908img_is_all_ff(const void *buf, size_t length) static int bcm4908img_parse(FILE *fp, struct bcm4908img_info *info) { struct bcm4908img_tail *tail = &info->tail; + struct linksys_tail *linksys; struct chk_header *chk; struct stat st; uint8_t buf[1024]; + size_t file_size; uint16_t tmp16; size_t length; size_t bytes; @@ -281,7 +294,9 @@ static int bcm4908img_parse(FILE *fp, struct bcm4908img_info *info) { fprintf(stderr, "Failed to fstat: %d\n", err); return err; } - info->file_size = st.st_size; + file_size = st.st_size; + + info->tail_offset = file_size - sizeof(*tail); /* Vendor formats */ @@ -294,10 +309,20 @@ static int bcm4908img_parse(FILE *fp, struct bcm4908img_info *info) { if (be32_to_cpu(chk->magic) == 0x2a23245e) info->cferom_offset = be32_to_cpu(chk->header_len); + fseek(fp, -sizeof(buf), SEEK_END); + if (fread(buf, 1, sizeof(buf), fp) != sizeof(buf)) { + fprintf(stderr, "Failed to read file header\n"); + return -EIO; + } + linksys = (void *)(buf + sizeof(buf) - sizeof(*linksys)); + if (!memcmp(linksys->magic, ".LINKSYS.", sizeof(linksys->magic))) { + info->tail_offset -= sizeof(*linksys); + } + /* Offsets */ for (info->bootfs_offset = info->cferom_offset; - info->bootfs_offset < info->file_size; + info->bootfs_offset < info->tail_offset; info->bootfs_offset += 0x20000) { if (fseek(fp, info->bootfs_offset, SEEK_SET)) { err = -errno; @@ -311,13 +336,13 @@ static int bcm4908img_parse(FILE *fp, struct bcm4908img_info *info) { if (be16_to_cpu(tmp16) == 0x8519) break; } - if (info->bootfs_offset >= info->file_size) { + if (info->bootfs_offset >= info->tail_offset) { fprintf(stderr, "Failed to find bootfs offset\n"); return -EPROTO; } for (info->rootfs_offset = info->bootfs_offset; - info->rootfs_offset < info->file_size; + info->rootfs_offset < info->tail_offset; info->rootfs_offset += 0x20000) { uint32_t *magic = (uint32_t *)&buf[0]; @@ -340,7 +365,7 @@ static int bcm4908img_parse(FILE *fp, struct bcm4908img_info *info) { if (be32_to_cpu(*magic) == UBI_EC_HDR_MAGIC) break; } - if (info->rootfs_offset >= info->file_size) { + if (info->rootfs_offset >= info->tail_offset) { fprintf(stderr, "Failed to find rootfs offset\n"); return -EPROTO; } @@ -351,7 +376,7 @@ static int bcm4908img_parse(FILE *fp, struct bcm4908img_info *info) { fseek(fp, info->cferom_offset, SEEK_SET); info->crc32 = 0xffffffff; - length = info->file_size - info->cferom_offset - sizeof(*tail); + length = info->tail_offset - info->cferom_offset; while (length && (bytes = fread(buf, 1, bcm4908img_min(sizeof(buf), length), fp)) > 0) { info->crc32 = bcm4908img_crc32(info->crc32, buf, bytes); length -= bytes; @@ -617,10 +642,10 @@ static int bcm4908img_extract(int argc, char **argv) { length = (info.padding_offset ? info.padding_offset : info.rootfs_offset) - offset; } else if (!strcmp(type, "rootfs")) { offset = info.rootfs_offset; - length = info.file_size - offset - sizeof(struct bcm4908img_tail); + length = info.tail_offset - offset; } else if (!strcmp(type, "firmware")) { offset = info.bootfs_offset; - length = info.file_size - offset - sizeof(struct bcm4908img_tail); + length = info.tail_offset - offset; } else { err = -EINVAL; fprintf(stderr, "Unsupported extract type: %s\n", type); diff --git a/package/utils/bsdiff/Makefile b/package/utils/bsdiff/Makefile index db1f3208720..d86be2dc0c6 100644 --- a/package/utils/bsdiff/Makefile +++ b/package/utils/bsdiff/Makefile @@ -9,15 +9,16 @@ include $(TOPDIR)/rules.mk PKG_NAME:=bsdiff PKG_VERSION:=4.3 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_SOURCE_URL:=http://www.daemonology.net/bsdiff/ +PKG_SOURCE_URL:=https://www.daemonology.net/bsdiff/ PKG_HASH:=18821588b2dc5bf159aa37d3bcb7b885d85ffd1e19f23a0c57a58723fea85f48 PKG_MAINTAINER:=Hauke Mehrtens <hauke@hauke-m.de> HOST_BUILD_DEPENDS:=bzip2/host PKG_LICENSE:=BSD-2-Clause +PKG_CPE_ID:=cpe:/a:daemonology:bsdiff include $(INCLUDE_DIR)/host-build.mk include $(INCLUDE_DIR)/package.mk @@ -27,7 +28,7 @@ define Package/bsdiff CATEGORY:=Utilities DEPENDS:=+libbz2 TITLE:=Binary diff tool - URL:=http://www.daemonology.net/bsdiff/ + URL:=https://www.daemonology.net/bsdiff/ endef define Package/bspatch @@ -35,7 +36,7 @@ define Package/bspatch CATEGORY:=Utilities DEPENDS:=+libbz2 TITLE:=Binary patch tool - URL:=http://www.daemonology.net/bsdiff/ + URL:=https://www.daemonology.net/bsdiff/ endef diff --git a/package/utils/bsdiff/patches/001-musl.patch b/package/utils/bsdiff/patches/001-musl.patch index 5232bc1fe78..1eeb1140c00 100644 --- a/package/utils/bsdiff/patches/001-musl.patch +++ b/package/utils/bsdiff/patches/001-musl.patch @@ -1,6 +1,6 @@ ---- a/bsdiff.c 2005-08-17 00:13:52.000000000 +0200 -+++ b/bsdiff.c 2016-02-21 01:39:31.157915765 +0100 -@@ -101,7 +101,7 @@ +--- a/bsdiff.c ++++ b/bsdiff.c +@@ -101,7 +101,7 @@ static void split(off_t *I,off_t *V,off_ if(start+len>kk) split(I,V,kk,start+len-kk,h); } @@ -9,7 +9,7 @@ { off_t buckets[256]; off_t i,h,len; -@@ -139,7 +139,7 @@ +@@ -139,7 +139,7 @@ static void qsufsort(off_t *I,off_t *V,u for(i=0;i<oldsize+1;i++) I[V[i]]=i; } @@ -18,7 +18,7 @@ { off_t i; -@@ -149,8 +149,8 @@ +@@ -149,8 +149,8 @@ static off_t matchlen(u_char *old,off_t return i; } @@ -29,7 +29,7 @@ { off_t x,y; -@@ -175,7 +175,7 @@ +@@ -175,7 +175,7 @@ static off_t search(off_t *I,u_char *old }; } @@ -38,7 +38,7 @@ { off_t y; -@@ -196,7 +196,7 @@ +@@ -196,7 +196,7 @@ static void offtout(off_t x,u_char *buf) int main(int argc,char *argv[]) { int fd; @@ -47,7 +47,7 @@ off_t oldsize,newsize; off_t *I,*V; off_t scan,pos,len; -@@ -206,9 +206,9 @@ +@@ -206,9 +206,9 @@ int main(int argc,char *argv[]) off_t overlap,Ss,lens; off_t i; off_t dblen,eblen; @@ -60,9 +60,9 @@ FILE * pf; BZFILE * pfbz2; int bz2err; ---- a/bspatch.c 2005-08-17 00:14:00.000000000 +0200 -+++ b/bspatch.c 2016-02-21 01:39:29.753859970 +0100 -@@ -36,7 +36,7 @@ +--- a/bspatch.c ++++ b/bspatch.c +@@ -36,7 +36,7 @@ __FBSDID("$FreeBSD: src/usr.bin/bsdiff/b #include <unistd.h> #include <fcntl.h> @@ -71,7 +71,7 @@ { off_t y; -@@ -62,8 +62,8 @@ +@@ -62,8 +62,8 @@ int main(int argc,char * argv[]) int fd; ssize_t oldsize,newsize; ssize_t bzctrllen,bzdatalen; diff --git a/package/utils/bsdiff/patches/020-CVE-2014-9862.patch b/package/utils/bsdiff/patches/020-CVE-2014-9862.patch new file mode 100644 index 00000000000..98a49312f3b --- /dev/null +++ b/package/utils/bsdiff/patches/020-CVE-2014-9862.patch @@ -0,0 +1,37 @@ +From: The FreeBSD Project +Bug: https://security-tracker.debian.org/tracker/CVE-2014-9862 +Subject: CVE-2014-9862 - check for a negative value on numbers of bytes + The implementation of bspatch does not check for a negative value on numbers + of bytes read from the diff and extra streams, allowing an attacker who + can control the patch file to write at arbitrary locations in the heap. + . + bspatch's main loop reads three numbers from the "control" stream in + the patch: X, Y and Z. The first two are the number of bytes to read + from "diff" and "extra" (and thus only non-negative), while the + third one could be positive or negative and moves the oldpos pointer + on the source image. These 3 values are 64bits signed ints (encoded + somehow on the file) that are later passed the function that reads + from the streams, but those values are not verified to be + non-negative. + . + Official report https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-9862 + The patch was downloaded from a link pointed by + https://security.freebsd.org/advisories/FreeBSD-SA-16:25.bsp + +--- + bspatch.c | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/bspatch.c ++++ b/bspatch.c +@@ -152,6 +152,10 @@ int main(int argc,char * argv[]) + }; + + /* Sanity-check */ ++ if ((ctrl[0] < 0) || (ctrl[1] < 0)) ++ errx(1,"Corrupt patch\n"); ++ ++ /* Sanity-check */ + if(newpos+ctrl[0]>newsize) + errx(1,"Corrupt patch\n"); + diff --git a/package/utils/bsdiff/patches/033-CVE-2020-14315.patch b/package/utils/bsdiff/patches/033-CVE-2020-14315.patch new file mode 100644 index 00000000000..975cb181dcd --- /dev/null +++ b/package/utils/bsdiff/patches/033-CVE-2020-14315.patch @@ -0,0 +1,383 @@ +Description: patch for CVE-2020-14315 + A memory corruption vulnerability is present in bspatch as shipped in + Colin Percival’s bsdiff tools version 4.3. Insufficient checks when + handling external inputs allows an attacker to bypass the sanity checks + in place and write out of a dynamically allocated buffer boundaries. +Source: https://svnweb.freebsd.org/base/head/usr.bin/bsdiff/bspatch/bspatch.c?revision=352742&view=co +Author: tony mancill <tmancill@debian.org> +Comment: The patch was created by comparing the Debian sources to the + "Confirmed Patched Version" [1] documented in the + X41 D-SEC GmbH Security Advisory: X41-2020-006 [2]. + References to FreeBSD capsicum have been dropped. Definitions for + TYPE_MINIMUM and TYPE_MAXIMUM have been borrowed from the Debian + coreutils package sources but originate in gnulib [3] and are used to + define OFF_MIN and OFF_MAX (limits of off_t). Whitespace changes from + the confirmed patched version are also included and keep the difference + between the Debian sources and the confirmed patched version minimal. + . + [1] https://svnweb.freebsd.org/base/head/usr.bin/bsdiff/bspatch/bspatch.c?revision=352742&view=co + [2] https://www.openwall.com/lists/oss-security/2020/07/09/2 + [3] https://www.gnu.org/software/gnulib/ +Last-Update: 2021-04-03 +Forwarded: not-needed +Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=964796 + +--- a/bspatch.c ++++ b/bspatch.c +@@ -1,4 +1,6 @@ + /*- ++ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD ++ * + * Copyright 2003-2005 Colin Percival + * All rights reserved + * +@@ -25,55 +27,147 @@ + */ + + #if 0 +-__FBSDID("$FreeBSD: src/usr.bin/bsdiff/bspatch/bspatch.c,v 1.1 2005/08/06 01:59:06 cperciva Exp $"); ++__FBSDID("$FreeBSD$"); + #endif + + #include <bzlib.h> +-#include <stdlib.h> ++#include <err.h> ++#include <fcntl.h> ++#include <libgen.h> ++#include <limits.h> ++#include <stdint.h> + #include <stdio.h> ++#include <stdlib.h> + #include <string.h> +-#include <err.h> + #include <unistd.h> +-#include <fcntl.h> ++ ++#ifndef O_BINARY ++#define O_BINARY 0 ++#endif ++#define HEADER_SIZE 32 ++ ++/* TYPE_MINIMUM and TYPE_MAXIMUM taken from coreutils */ ++#ifndef TYPE_MINIMUM ++#define TYPE_MINIMUM(t) \ ++ ((t) ((t) 0 < (t) -1 ? (t) 0 : ~ TYPE_MAXIMUM (t))) ++#endif ++#ifndef TYPE_MAXIMUM ++#define TYPE_MAXIMUM(t) \ ++ ((t) ((t) 0 < (t) -1 \ ++ ? (t) -1 \ ++ : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1))) ++#endif ++ ++#ifndef OFF_MAX ++#define OFF_MAX TYPE_MAXIMUM(off_t) ++#endif ++ ++#ifndef OFF_MIN ++#define OFF_MIN TYPE_MINIMUM(off_t) ++#endif ++ ++static char *newfile; ++static int dirfd = -1; ++ ++static void ++exit_cleanup(void) ++{ ++ ++ if (dirfd != -1 && newfile != NULL) ++ if (unlinkat(dirfd, newfile, 0)) ++ warn("unlinkat"); ++} ++ ++static inline off_t ++add_off_t(off_t a, off_t b) ++{ ++ off_t result; ++ ++#if __GNUC__ >= 5 || \ ++ (defined(__has_builtin) && __has_builtin(__builtin_add_overflow)) ++ if (__builtin_add_overflow(a, b, &result)) ++ errx(1, "Corrupt patch"); ++#else ++ if ((b > 0 && a > OFF_MAX - b) || (b < 0 && a < OFF_MIN - b)) ++ errx(1, "Corrupt patch"); ++ result = a + b; ++#endif ++ return result; ++} + + static off_t offtin(unsigned char *buf) + { + off_t y; + +- y=buf[7]&0x7F; +- y=y*256;y+=buf[6]; +- y=y*256;y+=buf[5]; +- y=y*256;y+=buf[4]; +- y=y*256;y+=buf[3]; +- y=y*256;y+=buf[2]; +- y=y*256;y+=buf[1]; +- y=y*256;y+=buf[0]; ++ y = buf[7] & 0x7F; ++ y = y * 256; y += buf[6]; ++ y = y * 256; y += buf[5]; ++ y = y * 256; y += buf[4]; ++ y = y * 256; y += buf[3]; ++ y = y * 256; y += buf[2]; ++ y = y * 256; y += buf[1]; ++ y = y * 256; y += buf[0]; + +- if(buf[7]&0x80) y=-y; ++ if (buf[7] & 0x80) ++ y = -y; + +- return y; ++ return (y); + } + +-int main(int argc,char * argv[]) ++static void ++usage(void) + { +- FILE * f, * cpf, * dpf, * epf; +- BZFILE * cpfbz2, * dpfbz2, * epfbz2; ++ ++ fprintf(stderr, "usage: bspatch oldfile newfile patchfile\n"); ++ exit(1); ++} ++ ++int main(int argc, char *argv[]) ++{ ++ FILE *f, *cpf, *dpf, *epf; ++ BZFILE *cpfbz2, *dpfbz2, *epfbz2; ++ char *directory, *namebuf; + int cbz2err, dbz2err, ebz2err; +- int fd; +- ssize_t oldsize,newsize; +- ssize_t bzctrllen,bzdatalen; +- unsigned char header[32],buf[8]; ++ int newfd, oldfd; ++ off_t oldsize, newsize; ++ off_t bzctrllen, bzdatalen; ++ unsigned char header[HEADER_SIZE], buf[8]; + unsigned char *old, *new; +- off_t oldpos,newpos; ++ off_t oldpos, newpos; + off_t ctrl[3]; +- off_t lenread; +- off_t i; ++ off_t i, lenread, offset; + +- if(argc!=4) errx(1,"usage: %s oldfile newfile patchfile\n",argv[0]); ++ if (argc != 4) ++ usage(); + + /* Open patch file */ +- if ((f = fopen(argv[3], "r")) == NULL) ++ if ((f = fopen(argv[3], "rb")) == NULL) ++ err(1, "fopen(%s)", argv[3]); ++ /* Open patch file for control block */ ++ if ((cpf = fopen(argv[3], "rb")) == NULL) ++ err(1, "fopen(%s)", argv[3]); ++ /* open patch file for diff block */ ++ if ((dpf = fopen(argv[3], "rb")) == NULL) + err(1, "fopen(%s)", argv[3]); ++ /* open patch file for extra block */ ++ if ((epf = fopen(argv[3], "rb")) == NULL) ++ err(1, "fopen(%s)", argv[3]); ++ /* open oldfile */ ++ if ((oldfd = open(argv[1], O_RDONLY | O_BINARY, 0)) < 0) ++ err(1, "open(%s)", argv[1]); ++ /* open directory where we'll write newfile */ ++ if ((namebuf = strdup(argv[2])) == NULL || ++ (directory = dirname(namebuf)) == NULL || ++ (dirfd = open(directory, O_DIRECTORY)) < 0) ++ err(1, "open %s", argv[2]); ++ free(namebuf); ++ if ((newfile = basename(argv[2])) == NULL) ++ err(1, "basename"); ++ /* open newfile */ ++ if ((newfd = openat(dirfd, newfile, ++ O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0666)) < 0) ++ err(1, "open(%s)", argv[2]); ++ atexit(exit_cleanup); + + /* + File format: +@@ -90,104 +184,104 @@ int main(int argc,char * argv[]) + */ + + /* Read header */ +- if (fread(header, 1, 32, f) < 32) { ++ if (fread(header, 1, HEADER_SIZE, f) < HEADER_SIZE) { + if (feof(f)) +- errx(1, "Corrupt patch\n"); ++ errx(1, "Corrupt patch"); + err(1, "fread(%s)", argv[3]); + } + + /* Check for appropriate magic */ + if (memcmp(header, "BSDIFF40", 8) != 0) +- errx(1, "Corrupt patch\n"); ++ errx(1, "Corrupt patch"); + + /* Read lengths from header */ +- bzctrllen=offtin(header+8); +- bzdatalen=offtin(header+16); +- newsize=offtin(header+24); +- if((bzctrllen<0) || (bzdatalen<0) || (newsize<0)) +- errx(1,"Corrupt patch\n"); ++ bzctrllen = offtin(header + 8); ++ bzdatalen = offtin(header + 16); ++ newsize = offtin(header + 24); ++ if (bzctrllen < 0 || bzctrllen > OFF_MAX - HEADER_SIZE || ++ bzdatalen < 0 || bzctrllen + HEADER_SIZE > OFF_MAX - bzdatalen || ++ newsize < 0 || newsize > SSIZE_MAX) ++ errx(1, "Corrupt patch"); + + /* Close patch file and re-open it via libbzip2 at the right places */ + if (fclose(f)) + err(1, "fclose(%s)", argv[3]); +- if ((cpf = fopen(argv[3], "r")) == NULL) +- err(1, "fopen(%s)", argv[3]); +- if (fseeko(cpf, 32, SEEK_SET)) +- err(1, "fseeko(%s, %lld)", argv[3], +- (long long)32); ++ offset = HEADER_SIZE; ++ if (fseeko(cpf, offset, SEEK_SET)) ++ err(1, "fseeko(%s, %jd)", argv[3], (intmax_t)offset); + if ((cpfbz2 = BZ2_bzReadOpen(&cbz2err, cpf, 0, 0, NULL, 0)) == NULL) + errx(1, "BZ2_bzReadOpen, bz2err = %d", cbz2err); +- if ((dpf = fopen(argv[3], "r")) == NULL) +- err(1, "fopen(%s)", argv[3]); +- if (fseeko(dpf, 32 + bzctrllen, SEEK_SET)) +- err(1, "fseeko(%s, %lld)", argv[3], +- (long long)(32 + bzctrllen)); ++ offset = add_off_t(offset, bzctrllen); ++ if (fseeko(dpf, offset, SEEK_SET)) ++ err(1, "fseeko(%s, %jd)", argv[3], (intmax_t)offset); + if ((dpfbz2 = BZ2_bzReadOpen(&dbz2err, dpf, 0, 0, NULL, 0)) == NULL) + errx(1, "BZ2_bzReadOpen, bz2err = %d", dbz2err); +- if ((epf = fopen(argv[3], "r")) == NULL) +- err(1, "fopen(%s)", argv[3]); +- if (fseeko(epf, 32 + bzctrllen + bzdatalen, SEEK_SET)) +- err(1, "fseeko(%s, %lld)", argv[3], +- (long long)(32 + bzctrllen + bzdatalen)); ++ offset = add_off_t(offset, bzdatalen); ++ if (fseeko(epf, offset, SEEK_SET)) ++ err(1, "fseeko(%s, %jd)", argv[3], (intmax_t)offset); + if ((epfbz2 = BZ2_bzReadOpen(&ebz2err, epf, 0, 0, NULL, 0)) == NULL) + errx(1, "BZ2_bzReadOpen, bz2err = %d", ebz2err); + +- if(((fd=open(argv[1],O_RDONLY,0))<0) || +- ((oldsize=lseek(fd,0,SEEK_END))==-1) || +- ((old=malloc(oldsize+1))==NULL) || +- (lseek(fd,0,SEEK_SET)!=0) || +- (read(fd,old,oldsize)!=oldsize) || +- (close(fd)==-1)) err(1,"%s",argv[1]); +- if((new=malloc(newsize+1))==NULL) err(1,NULL); +- +- oldpos=0;newpos=0; +- while(newpos<newsize) { ++ if ((oldsize = lseek(oldfd, 0, SEEK_END)) == -1 || ++ oldsize > SSIZE_MAX || ++ (old = malloc(oldsize)) == NULL || ++ lseek(oldfd, 0, SEEK_SET) != 0 || ++ read(oldfd, old, oldsize) != oldsize || ++ close(oldfd) == -1) ++ err(1, "%s", argv[1]); ++ if ((new = malloc(newsize)) == NULL) ++ err(1, NULL); ++ ++ oldpos = 0; ++ newpos = 0; ++ while (newpos < newsize) { + /* Read control data */ +- for(i=0;i<=2;i++) { ++ for (i = 0; i <= 2; i++) { + lenread = BZ2_bzRead(&cbz2err, cpfbz2, buf, 8); + if ((lenread < 8) || ((cbz2err != BZ_OK) && + (cbz2err != BZ_STREAM_END))) +- errx(1, "Corrupt patch\n"); +- ctrl[i]=offtin(buf); +- }; ++ errx(1, "Corrupt patch"); ++ ctrl[i] = offtin(buf); ++ } + + /* Sanity-check */ +- if ((ctrl[0] < 0) || (ctrl[1] < 0)) +- errx(1,"Corrupt patch\n"); ++ if (ctrl[0] < 0 || ctrl[0] > INT_MAX || ++ ctrl[1] < 0 || ctrl[1] > INT_MAX) ++ errx(1, "Corrupt patch"); + + /* Sanity-check */ +- if(newpos+ctrl[0]>newsize) +- errx(1,"Corrupt patch\n"); ++ if (add_off_t(newpos, ctrl[0]) > newsize) ++ errx(1, "Corrupt patch"); + + /* Read diff string */ + lenread = BZ2_bzRead(&dbz2err, dpfbz2, new + newpos, ctrl[0]); + if ((lenread < ctrl[0]) || + ((dbz2err != BZ_OK) && (dbz2err != BZ_STREAM_END))) +- errx(1, "Corrupt patch\n"); ++ errx(1, "Corrupt patch"); + + /* Add old data to diff string */ +- for(i=0;i<ctrl[0];i++) +- if((oldpos+i>=0) && (oldpos+i<oldsize)) +- new[newpos+i]+=old[oldpos+i]; ++ for (i = 0; i < ctrl[0]; i++) ++ if (add_off_t(oldpos, i) < oldsize) ++ new[newpos + i] += old[oldpos + i]; + + /* Adjust pointers */ +- newpos+=ctrl[0]; +- oldpos+=ctrl[0]; ++ newpos = add_off_t(newpos, ctrl[0]); ++ oldpos = add_off_t(oldpos, ctrl[0]); + + /* Sanity-check */ +- if(newpos+ctrl[1]>newsize) +- errx(1,"Corrupt patch\n"); ++ if (add_off_t(newpos, ctrl[1]) > newsize) ++ errx(1, "Corrupt patch"); + + /* Read extra string */ + lenread = BZ2_bzRead(&ebz2err, epfbz2, new + newpos, ctrl[1]); + if ((lenread < ctrl[1]) || + ((ebz2err != BZ_OK) && (ebz2err != BZ_STREAM_END))) +- errx(1, "Corrupt patch\n"); ++ errx(1, "Corrupt patch"); + + /* Adjust pointers */ +- newpos+=ctrl[1]; +- oldpos+=ctrl[2]; +- }; ++ newpos = add_off_t(newpos, ctrl[1]); ++ oldpos = add_off_t(oldpos, ctrl[2]); ++ } + + /* Clean up the bzip2 reads */ + BZ2_bzReadClose(&cbz2err, cpfbz2); +@@ -197,12 +291,13 @@ int main(int argc,char * argv[]) + err(1, "fclose(%s)", argv[3]); + + /* Write the new file */ +- if(((fd=open(argv[2],O_CREAT|O_TRUNC|O_WRONLY,0666))<0) || +- (write(fd,new,newsize)!=newsize) || (close(fd)==-1)) +- err(1,"%s",argv[2]); ++ if (write(newfd, new, newsize) != newsize || close(newfd) == -1) ++ err(1, "%s", argv[2]); ++ /* Disable atexit cleanup */ ++ newfile = NULL; + + free(new); + free(old); + +- return 0; ++ return (0); + } diff --git a/package/utils/busybox/Config-defaults.in b/package/utils/busybox/Config-defaults.in index d078a399541..515bea3d1d7 100644 --- a/package/utils/busybox/Config-defaults.in +++ b/package/utils/busybox/Config-defaults.in @@ -208,18 +208,36 @@ config BUSYBOX_DEFAULT_PASSWORD_MINLEN config BUSYBOX_DEFAULT_MD5_SMALL int default 1 +config BUSYBOX_DEFAULT_SHA1_SMALL + int + default 3 +config BUSYBOX_DEFAULT_SHA1_HWACCEL + bool + default y +config BUSYBOX_DEFAULT_SHA256_HWACCEL + bool + default y config BUSYBOX_DEFAULT_SHA3_SMALL int default 1 -config BUSYBOX_DEFAULT_FEATURE_FAST_TOP +config BUSYBOX_DEFAULT_FEATURE_NON_POSIX_CP bool default y -config BUSYBOX_DEFAULT_FEATURE_ETC_NETWORKS +config BUSYBOX_DEFAULT_FEATURE_VERBOSE_CP_MESSAGE bool default n -config BUSYBOX_DEFAULT_FEATURE_ETC_SERVICES +config BUSYBOX_DEFAULT_FEATURE_USE_SENDFILE bool - default n + default y +config BUSYBOX_DEFAULT_FEATURE_COPYBUF_KB + int + default 4 +config BUSYBOX_DEFAULT_MONOTONIC_SYSCALL + bool + default y +config BUSYBOX_DEFAULT_IOCTL_HEX2STR_ERROR + bool + default y config BUSYBOX_DEFAULT_FEATURE_EDITING bool default y @@ -289,30 +307,15 @@ config BUSYBOX_DEFAULT_UNICODE_NEUTRAL_TABLE config BUSYBOX_DEFAULT_UNICODE_PRESERVE_BROKEN bool default n -config BUSYBOX_DEFAULT_FEATURE_NON_POSIX_CP - bool - default y -config BUSYBOX_DEFAULT_FEATURE_VERBOSE_CP_MESSAGE +config BUSYBOX_DEFAULT_LOOP_CONFIGURE bool default n -config BUSYBOX_DEFAULT_FEATURE_USE_SENDFILE - bool - default y -config BUSYBOX_DEFAULT_FEATURE_COPYBUF_KB - int - default 4 -config BUSYBOX_DEFAULT_FEATURE_SKIP_ROOTFS +config BUSYBOX_DEFAULT_NO_LOOP_CONFIGURE bool default n -config BUSYBOX_DEFAULT_MONOTONIC_SYSCALL +config BUSYBOX_DEFAULT_TRY_LOOP_CONFIGURE bool default y -config BUSYBOX_DEFAULT_IOCTL_HEX2STR_ERROR - bool - default y -config BUSYBOX_DEFAULT_FEATURE_HWIB - bool - default n config BUSYBOX_DEFAULT_FEATURE_SEAMLESS_XZ bool default n @@ -381,7 +384,7 @@ config BUSYBOX_DEFAULT_BZIP2_SMALL default 0 config BUSYBOX_DEFAULT_FEATURE_BZIP2_DECOMPRESS bool - default y + default n config BUSYBOX_DEFAULT_CPIO bool default n @@ -391,6 +394,12 @@ config BUSYBOX_DEFAULT_FEATURE_CPIO_O config BUSYBOX_DEFAULT_FEATURE_CPIO_P bool default n +config BUSYBOX_DEFAULT_FEATURE_CPIO_IGNORE_DEVNO + bool + default n +config BUSYBOX_DEFAULT_FEATURE_CPIO_RENUMBER_INODES + bool + default n config BUSYBOX_DEFAULT_DPKG bool default n @@ -484,6 +493,18 @@ config BUSYBOX_DEFAULT_FEATURE_UNZIP_XZ config BUSYBOX_DEFAULT_FEATURE_LZMA_FAST bool default n +config BUSYBOX_DEFAULT_FEATURE_VERBOSE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_TIMEZONE + bool + default n +config BUSYBOX_DEFAULT_FEATURE_PRESERVE_HARDLINKS + bool + default y +config BUSYBOX_DEFAULT_FEATURE_HUMAN_READABLE + bool + default y config BUSYBOX_DEFAULT_BASENAME bool default y @@ -514,6 +535,9 @@ config BUSYBOX_DEFAULT_CHROOT config BUSYBOX_DEFAULT_CKSUM bool default n +config BUSYBOX_DEFAULT_CRC32 + bool + default n config BUSYBOX_DEFAULT_COMM bool default n @@ -529,6 +553,9 @@ config BUSYBOX_DEFAULT_FEATURE_CP_REFLINK config BUSYBOX_DEFAULT_CUT bool default y +config BUSYBOX_DEFAULT_FEATURE_CUT_REGEX + bool + default n config BUSYBOX_DEFAULT_DATE bool default y @@ -562,6 +589,9 @@ config BUSYBOX_DEFAULT_DF config BUSYBOX_DEFAULT_FEATURE_DF_FANCY bool default n +config BUSYBOX_DEFAULT_FEATURE_SKIP_ROOTFS + bool + default n config BUSYBOX_DEFAULT_DIRNAME bool default y @@ -829,9 +859,6 @@ config BUSYBOX_DEFAULT_TIMEOUT config BUSYBOX_DEFAULT_TOUCH bool default y -config BUSYBOX_DEFAULT_FEATURE_TOUCH_NODEREF - bool - default n config BUSYBOX_DEFAULT_FEATURE_TOUCH_SUSV3 bool default y @@ -851,6 +878,9 @@ config BUSYBOX_DEFAULT_TRUNCATE bool default y if TARGET_bcm53xx default n +config BUSYBOX_DEFAULT_TSORT + bool + default n config BUSYBOX_DEFAULT_TTY bool default n @@ -905,15 +935,6 @@ config BUSYBOX_DEFAULT_WHOAMI config BUSYBOX_DEFAULT_YES bool default y -config BUSYBOX_DEFAULT_FEATURE_VERBOSE - bool - default n -config BUSYBOX_DEFAULT_FEATURE_PRESERVE_HARDLINKS - bool - default y -config BUSYBOX_DEFAULT_FEATURE_HUMAN_READABLE - bool - default y config BUSYBOX_DEFAULT_CHVT bool default n @@ -961,7 +982,7 @@ config BUSYBOX_DEFAULT_RESET default y config BUSYBOX_DEFAULT_RESIZE bool - default n + default y config BUSYBOX_DEFAULT_FEATURE_RESIZE_PRINT bool default n @@ -1058,6 +1079,9 @@ config BUSYBOX_DEFAULT_FEATURE_VI_8BIT config BUSYBOX_DEFAULT_FEATURE_VI_COLON bool default y +config BUSYBOX_DEFAULT_FEATURE_VI_COLON_EXPAND + bool + default n config BUSYBOX_DEFAULT_FEATURE_VI_YANKMARK bool default y @@ -1097,6 +1121,9 @@ config BUSYBOX_DEFAULT_FEATURE_VI_UNDO_QUEUE config BUSYBOX_DEFAULT_FEATURE_VI_UNDO_QUEUE_MAX int default 0 +config BUSYBOX_DEFAULT_FEATURE_VI_VERBOSE_STATUS + bool + default n config BUSYBOX_DEFAULT_FEATURE_ALLOW_EXEC bool default y @@ -1109,9 +1136,21 @@ config BUSYBOX_DEFAULT_FEATURE_FIND_PRINT0 config BUSYBOX_DEFAULT_FEATURE_FIND_MTIME bool default y +config BUSYBOX_DEFAULT_FEATURE_FIND_ATIME + bool + default n +config BUSYBOX_DEFAULT_FEATURE_FIND_CTIME + bool + default n config BUSYBOX_DEFAULT_FEATURE_FIND_MMIN bool default y +config BUSYBOX_DEFAULT_FEATURE_FIND_AMIN + bool + default n +config BUSYBOX_DEFAULT_FEATURE_FIND_CMIN + bool + default n config BUSYBOX_DEFAULT_FEATURE_FIND_PERM bool default y @@ -1133,6 +1172,9 @@ config BUSYBOX_DEFAULT_FEATURE_FIND_NEWER config BUSYBOX_DEFAULT_FEATURE_FIND_INUM bool default n +config BUSYBOX_DEFAULT_FEATURE_FIND_SAMEFILE + bool + default n config BUSYBOX_DEFAULT_FEATURE_FIND_EXEC bool default y @@ -1291,7 +1333,7 @@ config BUSYBOX_DEFAULT_USE_BB_CRYPT default n config BUSYBOX_DEFAULT_USE_BB_CRYPT_SHA bool - default n + default y config BUSYBOX_DEFAULT_ADD_SHELL bool default n @@ -1324,7 +1366,7 @@ config BUSYBOX_DEFAULT_CHPASSWD default n config BUSYBOX_DEFAULT_FEATURE_DEFAULT_PASSWD_ALGO string - default "md5" + default "sha256" config BUSYBOX_DEFAULT_CRYPTPW bool default n @@ -1780,13 +1822,13 @@ config BUSYBOX_DEFAULT_SWITCH_ROOT default y config BUSYBOX_DEFAULT_TASKSET bool - default n + default y config BUSYBOX_DEFAULT_FEATURE_TASKSET_FANCY bool - default n + default y config BUSYBOX_DEFAULT_FEATURE_TASKSET_CPULIST bool - default n + default y config BUSYBOX_DEFAULT_UEVENT bool default n @@ -1895,6 +1937,9 @@ config BUSYBOX_DEFAULT_FEATURE_VOLUMEID_XFS config BUSYBOX_DEFAULT_ADJTIMEX bool default n +config BUSYBOX_DEFAULT_ASCII + bool + default n config BUSYBOX_DEFAULT_BBCONFIG bool default n @@ -2138,6 +2183,9 @@ config BUSYBOX_DEFAULT_RUNLEVEL config BUSYBOX_DEFAULT_RX bool default n +config BUSYBOX_DEFAULT_SEEDRNG + bool + default n config BUSYBOX_DEFAULT_SETFATTR bool default n @@ -2150,6 +2198,9 @@ config BUSYBOX_DEFAULT_STRINGS config BUSYBOX_DEFAULT_TIME bool default y +config BUSYBOX_DEFAULT_TREE + bool + default n config BUSYBOX_DEFAULT_TS bool default n @@ -2183,6 +2234,9 @@ config BUSYBOX_DEFAULT_VOLNAME config BUSYBOX_DEFAULT_WATCHDOG bool default n +config BUSYBOX_DEFAULT_FEATURE_WATCHDOG_OPEN_TWICE + bool + default n config BUSYBOX_DEFAULT_FEATURE_IPV6 bool default y if IPV6 @@ -2196,6 +2250,15 @@ config BUSYBOX_DEFAULT_FEATURE_PREFER_IPV4_ADDRESS config BUSYBOX_DEFAULT_VERBOSE_RESOLUTION_ERRORS bool default y +config BUSYBOX_DEFAULT_FEATURE_ETC_NETWORKS + bool + default n +config BUSYBOX_DEFAULT_FEATURE_ETC_SERVICES + bool + default n +config BUSYBOX_DEFAULT_FEATURE_HWIB + bool + default n config BUSYBOX_DEFAULT_FEATURE_TLS_SHA1 bool default n @@ -2250,6 +2313,9 @@ config BUSYBOX_DEFAULT_DNSDOMAINNAME config BUSYBOX_DEFAULT_HTTPD bool default n +config BUSYBOX_DEFAULT_FEATURE_HTTPD_PORT_DEFAULT + int + default 80 config BUSYBOX_DEFAULT_FEATURE_HTTPD_RANGES bool default n @@ -2529,6 +2595,9 @@ config BUSYBOX_DEFAULT_TELNETD config BUSYBOX_DEFAULT_FEATURE_TELNETD_STANDALONE bool default n +config BUSYBOX_DEFAULT_FEATURE_TELNETD_PORT_DEFAULT + int + default 23 config BUSYBOX_DEFAULT_FEATURE_TELNETD_INETD_WAIT bool default n @@ -2589,6 +2658,9 @@ config BUSYBOX_DEFAULT_FEATURE_WGET_LONG_OPTIONS config BUSYBOX_DEFAULT_FEATURE_WGET_STATUSBAR bool default n +config BUSYBOX_DEFAULT_FEATURE_WGET_FTP + bool + default n config BUSYBOX_DEFAULT_FEATURE_WGET_AUTHENTICATION bool default n @@ -2637,6 +2709,9 @@ config BUSYBOX_DEFAULT_FEATURE_UDHCPC_SANITIZEOPT config BUSYBOX_DEFAULT_UDHCPC_DEFAULT_SCRIPT string default "/usr/share/udhcpc/default.script" +config BUSYBOX_DEFAULT_UDHCPC6_DEFAULT_SCRIPT + string + default "" config BUSYBOX_DEFAULT_UDHCPC6 bool default n @@ -2652,6 +2727,9 @@ config BUSYBOX_DEFAULT_FEATURE_UDHCPC6_RFC4833 config BUSYBOX_DEFAULT_FEATURE_UDHCPC6_RFC5970 bool default n +config BUSYBOX_DEFAULT_UDHCPC_DEFAULT_INTERFACE + string + default "" config BUSYBOX_DEFAULT_FEATURE_UDHCP_PORT bool default n @@ -2679,6 +2757,9 @@ config BUSYBOX_DEFAULT_LPR config BUSYBOX_DEFAULT_LPQ bool default n +config BUSYBOX_DEFAULT_FEATURE_MIME_CHARSET + string + default "" config BUSYBOX_DEFAULT_MAKEMIME bool default n @@ -2697,9 +2778,12 @@ config BUSYBOX_DEFAULT_FEATURE_REFORMIME_COMPAT config BUSYBOX_DEFAULT_SENDMAIL bool default n -config BUSYBOX_DEFAULT_FEATURE_MIME_CHARSET - string - default "" +config BUSYBOX_DEFAULT_FEATURE_FAST_TOP + bool + default y +config BUSYBOX_DEFAULT_FEATURE_SHOW_THREADS + bool + default n config BUSYBOX_DEFAULT_FREE bool default y @@ -2814,9 +2898,6 @@ config BUSYBOX_DEFAULT_FEATURE_UPTIME_UTMP_SUPPORT config BUSYBOX_DEFAULT_WATCH bool default n -config BUSYBOX_DEFAULT_FEATURE_SHOW_THREADS - bool - default n config BUSYBOX_DEFAULT_CHPST bool default n @@ -2942,7 +3023,7 @@ config BUSYBOX_DEFAULT_ASH_ALIAS default y config BUSYBOX_DEFAULT_ASH_RANDOM_SUPPORT bool - default n + default y config BUSYBOX_DEFAULT_ASH_EXPAND_PRMT bool default y @@ -2961,6 +3042,9 @@ config BUSYBOX_DEFAULT_ASH_PRINTF config BUSYBOX_DEFAULT_ASH_TEST bool default y +config BUSYBOX_DEFAULT_ASH_SLEEP + bool + default n config BUSYBOX_DEFAULT_ASH_HELP bool default n @@ -2985,10 +3069,10 @@ config BUSYBOX_DEFAULT_HUSH_BASH_COMPAT config BUSYBOX_DEFAULT_HUSH_BRACE_EXPANSION bool default n -config BUSYBOX_DEFAULT_HUSH_LINENO_VAR +config BUSYBOX_DEFAULT_HUSH_BASH_SOURCE_CURDIR bool default n -config BUSYBOX_DEFAULT_HUSH_BASH_SOURCE_CURDIR +config BUSYBOX_DEFAULT_HUSH_LINENO_VAR bool default n config BUSYBOX_DEFAULT_HUSH_INTERACTIVE diff --git a/package/utils/busybox/Makefile b/package/utils/busybox/Makefile index 32f0d2c7559..4bddd5201d8 100644 --- a/package/utils/busybox/Makefile +++ b/package/utils/busybox/Makefile @@ -5,22 +5,20 @@ include $(TOPDIR)/rules.mk PKG_NAME:=busybox -PKG_VERSION:=1.33.1 -PKG_RELEASE:=$(AUTORELEASE) +PKG_VERSION:=1.36.1 +PKG_RELEASE:=1 PKG_FLAGS:=essential PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=https://www.busybox.net/downloads \ http://sources.buildroot.net -PKG_HASH:=12cec6bd2b16d8a9446dd16130f2b92982f1819f6e1c5f5887b6db03f5660d28 +PKG_HASH:=b8cc24c9574d809e7279c3be349795c5d5ceb6fdf19ca709f80cde50e47de314 PKG_BUILD_DEPENDS:=BUSYBOX_CONFIG_PAM:libpam PKG_BUILD_PARALLEL:=1 +PKG_BUILD_FLAGS:=lto PKG_CHECK_FORMAT_SECURITY:=0 -#Busybox use it's own PIE config flag and LDFLAGS are used with ld, not gcc. -PKG_ASLR_PIE:=0 - PKG_LICENSE:=GPL-2.0 PKG_LICENSE_FILES:=LICENSE archival/libarchive/bz/LICENSE PKG_CPE_ID:=cpe:/a:busybox:busybox @@ -106,9 +104,6 @@ ifeq ($(BUILD_VARIANT),selinux) LDLIBS += selinux sepol endif -TARGET_CFLAGS += -flto -TARGET_LDFLAGS += -flto=jobserver -fuse-linker-plugin - MAKE_VARS := MAKE_FLAGS += \ EXTRA_CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \ diff --git a/package/utils/busybox/config/archival/Config.in b/package/utils/busybox/config/archival/Config.in index ea167a46af9..ac2b3d20562 100644 --- a/package/utils/busybox/config/archival/Config.in +++ b/package/utils/busybox/config/archival/Config.in @@ -204,6 +204,20 @@ config BUSYBOX_CONFIG_FEATURE_CPIO_P depends on BUSYBOX_CONFIG_FEATURE_CPIO_O help Passthrough mode. Rarely used. + +config BUSYBOX_CONFIG_FEATURE_CPIO_IGNORE_DEVNO + bool "Support --ignore-devno like GNU cpio" + default BUSYBOX_DEFAULT_FEATURE_CPIO_IGNORE_DEVNO + depends on BUSYBOX_CONFIG_FEATURE_CPIO_O && BUSYBOX_CONFIG_LONG_OPTS + help + Optionally ignore device numbers when creating archives. + +config BUSYBOX_CONFIG_FEATURE_CPIO_RENUMBER_INODES + bool "Support --renumber-inodes like GNU cpio" + default BUSYBOX_DEFAULT_FEATURE_CPIO_RENUMBER_INODES + depends on BUSYBOX_CONFIG_FEATURE_CPIO_O && BUSYBOX_CONFIG_LONG_OPTS + help + Optionally renumber inodes when creating archives. config BUSYBOX_CONFIG_DPKG bool "dpkg (43 kb)" default BUSYBOX_DEFAULT_DPKG diff --git a/package/utils/busybox/config/coreutils/Config.in b/package/utils/busybox/config/coreutils/Config.in index e256ca36f5e..983740be6ed 100644 --- a/package/utils/busybox/config/coreutils/Config.in +++ b/package/utils/busybox/config/coreutils/Config.in @@ -6,6 +6,47 @@ menu "Coreutils" +config BUSYBOX_CONFIG_FEATURE_VERBOSE + bool "Support verbose options (usually -v) for various applets" + default BUSYBOX_DEFAULT_FEATURE_VERBOSE + help + Enable cp -v, rm -v and similar messages. + Also enables long option (--verbose) if it exists. + Without this option, -v is accepted but ignored. + +comment "Common options for date and touch" + +config BUSYBOX_CONFIG_FEATURE_TIMEZONE + bool "Allow timezone in dates" + default BUSYBOX_DEFAULT_FEATURE_TIMEZONE + depends on BUSYBOX_CONFIG_DESKTOP + help + Permit the use of timezones when parsing user-provided data + strings, e.g. '1996-04-09 12:45:00 -0500'. + + This requires support for the '%z' extension to strptime() which + may not be available in all implementations. + +comment "Common options for cp and mv" + depends on BUSYBOX_CONFIG_CP || BUSYBOX_CONFIG_MV + +config BUSYBOX_CONFIG_FEATURE_PRESERVE_HARDLINKS + bool "Preserve hard links" + default BUSYBOX_DEFAULT_FEATURE_PRESERVE_HARDLINKS + depends on BUSYBOX_CONFIG_CP || BUSYBOX_CONFIG_MV + help + Allow cp and mv to preserve hard links. + +comment "Common options for df, du, ls" + depends on BUSYBOX_CONFIG_DF || BUSYBOX_CONFIG_DU || BUSYBOX_CONFIG_LS + +config BUSYBOX_CONFIG_FEATURE_HUMAN_READABLE + bool "Support human readable output (example 13k, 23M, 235G)" + default BUSYBOX_DEFAULT_FEATURE_HUMAN_READABLE + depends on BUSYBOX_CONFIG_DF || BUSYBOX_CONFIG_DU || BUSYBOX_CONFIG_LS + help + Allow df, du, and ls to have human readable output. + config BUSYBOX_CONFIG_BASENAME bool "basename (438 bytes)" default BUSYBOX_DEFAULT_BASENAME @@ -63,8 +104,10 @@ config BUSYBOX_CONFIG_CHROOT config BUSYBOX_CONFIG_CKSUM bool "cksum (4.1 kb)" default BUSYBOX_DEFAULT_CKSUM - help - cksum is used to calculate the CRC32 checksum of a file. + +config BUSYBOX_CONFIG_CRC32 + bool "crc32 (4.1 kb)" + default BUSYBOX_DEFAULT_CRC32 config BUSYBOX_CONFIG_COMM bool "comm (4.2 kb)" default BUSYBOX_DEFAULT_COMM @@ -95,6 +138,13 @@ config BUSYBOX_CONFIG_CUT help cut is used to print selected parts of lines from each file to stdout. + +config BUSYBOX_CONFIG_FEATURE_CUT_REGEX + bool "cut -F" + default BUSYBOX_DEFAULT_FEATURE_CUT_REGEX + depends on BUSYBOX_CONFIG_CUT + help + Allow regex based delimiters. config BUSYBOX_CONFIG_DATE bool "date (7 kb)" default BUSYBOX_DEFAULT_DATE @@ -191,6 +241,26 @@ config BUSYBOX_CONFIG_FEATURE_DF_FANCY -a Show all filesystems -i Inodes -B <SIZE> Blocksize + +config BUSYBOX_CONFIG_FEATURE_SKIP_ROOTFS + bool "Skip rootfs in mount table" + default BUSYBOX_DEFAULT_FEATURE_SKIP_ROOTFS + depends on BUSYBOX_CONFIG_DF + help + Ignore rootfs entry in mount table. + + In Linux, kernel has a special filesystem, rootfs, which is initially + mounted on /. It contains initramfs data, if kernel is configured + to have one. Usually, another file system is mounted over / early + in boot process, and therefore most tools which manipulate + mount table, such as df, will skip rootfs entry. + + However, some systems do not mount anything on /. + If you need to configure busybox for one of these systems, + you may find it useful to turn this option off to make df show + initramfs statistics. + + Otherwise, choose Y. config BUSYBOX_CONFIG_DIRNAME bool "dirname (329 bytes)" default BUSYBOX_DEFAULT_DIRNAME @@ -583,7 +653,7 @@ config BUSYBOX_CONFIG_SORT sort is used to sort lines of text in specified files. config BUSYBOX_CONFIG_FEATURE_SORT_BIG - bool "Full SuSv3 compliant sort (support -ktcbdfiogM)" + bool "Full SuSv3 compliant sort (support -ktcbdfioghM)" default BUSYBOX_DEFAULT_FEATURE_SORT_BIG depends on BUSYBOX_CONFIG_SORT help @@ -739,16 +809,8 @@ config BUSYBOX_CONFIG_TOUCH touch is used to create or change the access and/or modification timestamp of specified files. -config BUSYBOX_CONFIG_FEATURE_TOUCH_NODEREF - bool "Add support for -h" - default BUSYBOX_DEFAULT_FEATURE_TOUCH_NODEREF - depends on BUSYBOX_CONFIG_TOUCH - help - Enable touch to have the -h option. - This requires libc support for lutimes() function. - config BUSYBOX_CONFIG_FEATURE_TOUCH_SUSV3 - bool "Add support for SUSV3 features (-d -t -r)" + bool "Add support for SUSV3 features (-a -d -m -t -r)" default BUSYBOX_DEFAULT_FEATURE_TOUCH_SUSV3 depends on BUSYBOX_CONFIG_TOUCH help @@ -789,6 +851,11 @@ config BUSYBOX_CONFIG_TRUNCATE help truncate truncates files to a given size. If a file does not exist, it is created unless told otherwise. +config BUSYBOX_CONFIG_TSORT + bool "tsort (0.7 kb)" + default BUSYBOX_DEFAULT_TSORT + help + tsort performs a topological sort. config BUSYBOX_CONFIG_TTY bool "tty (3.6 kb)" default BUSYBOX_DEFAULT_TTY @@ -895,34 +962,4 @@ config BUSYBOX_CONFIG_YES yes is used to repeatedly output a specific string, or the default string 'y'. -comment "Common options" - -config BUSYBOX_CONFIG_FEATURE_VERBOSE - bool "Support verbose options (usually -v) for various applets" - default BUSYBOX_DEFAULT_FEATURE_VERBOSE - help - Enable cp -v, rm -v and similar messages. - Also enables long option (--verbose) if it exists. - Without this option, -v is accepted but ignored. - -comment "Common options for cp and mv" - depends on BUSYBOX_CONFIG_CP || BUSYBOX_CONFIG_MV - -config BUSYBOX_CONFIG_FEATURE_PRESERVE_HARDLINKS - bool "Preserve hard links" - default BUSYBOX_DEFAULT_FEATURE_PRESERVE_HARDLINKS - depends on BUSYBOX_CONFIG_CP || BUSYBOX_CONFIG_MV - help - Allow cp and mv to preserve hard links. - -comment "Common options for df, du, ls" - depends on BUSYBOX_CONFIG_DF || BUSYBOX_CONFIG_DU || BUSYBOX_CONFIG_LS - -config BUSYBOX_CONFIG_FEATURE_HUMAN_READABLE - bool "Support human readable output (example 13k, 23M, 235G)" - default BUSYBOX_DEFAULT_FEATURE_HUMAN_READABLE - depends on BUSYBOX_CONFIG_DF || BUSYBOX_CONFIG_DU || BUSYBOX_CONFIG_LS - help - Allow df, du, and ls to have human readable output. - endmenu diff --git a/package/utils/busybox/config/editors/Config.in b/package/utils/busybox/config/editors/Config.in index 16d08bc0f85..dc80a4ec0df 100644 --- a/package/utils/busybox/config/editors/Config.in +++ b/package/utils/busybox/config/editors/Config.in @@ -110,6 +110,14 @@ config BUSYBOX_CONFIG_FEATURE_VI_COLON Enable a limited set of colon commands. This does not provide an "ex" mode. +config BUSYBOX_CONFIG_FEATURE_VI_COLON_EXPAND + bool "Expand \"%\" and \"#\" in colon commands" + default BUSYBOX_DEFAULT_FEATURE_VI_COLON_EXPAND + depends on BUSYBOX_CONFIG_FEATURE_VI_COLON + help + Expand the special characters \"%\" (current filename) + and \"#\" (alternate filename) in colon commands. + config BUSYBOX_CONFIG_FEATURE_VI_YANKMARK bool "Enable yank/put commands and mark cmds" default BUSYBOX_DEFAULT_FEATURE_VI_YANKMARK @@ -126,7 +134,7 @@ config BUSYBOX_CONFIG_FEATURE_VI_SEARCH config BUSYBOX_CONFIG_FEATURE_VI_REGEX_SEARCH bool "Enable regex in search and replace" - default BUSYBOX_DEFAULT_FEATURE_VI_REGEX_SEARCH + default BUSYBOX_DEFAULT_FEATURE_VI_REGEX_SEARCH # Uses GNU regex, which may be unavailable. FIXME depends on BUSYBOX_CONFIG_FEATURE_VI_SEARCH depends on USE_GLIBC help @@ -218,6 +226,14 @@ config BUSYBOX_CONFIG_FEATURE_VI_UNDO_QUEUE_MAX Unless you want more (or less) frequent "undo points" while typing, you should probably leave this unchanged. +config BUSYBOX_CONFIG_FEATURE_VI_VERBOSE_STATUS + bool "Enable verbose status reporting" + default BUSYBOX_DEFAULT_FEATURE_VI_VERBOSE_STATUS + depends on BUSYBOX_CONFIG_VI + help + Enable more verbose reporting of the results of yank, change, + delete, undo and substitution commands. + config BUSYBOX_CONFIG_FEATURE_ALLOW_EXEC bool "Allow vi and awk to execute shell commands" default BUSYBOX_DEFAULT_FEATURE_ALLOW_EXEC diff --git a/package/utils/busybox/config/findutils/Config.in b/package/utils/busybox/config/findutils/Config.in index 89901ca59d0..805d44f149e 100644 --- a/package/utils/busybox/config/findutils/Config.in +++ b/package/utils/busybox/config/findutils/Config.in @@ -23,21 +23,53 @@ config BUSYBOX_CONFIG_FEATURE_FIND_PRINT0 interpreted by other programs. config BUSYBOX_CONFIG_FEATURE_FIND_MTIME - bool "Enable -mtime: modified time matching" + bool "Enable -mtime: modification time matching" default BUSYBOX_DEFAULT_FEATURE_FIND_MTIME depends on BUSYBOX_CONFIG_FIND help Allow searching based on the modification time of files, in days. +config BUSYBOX_CONFIG_FEATURE_FIND_ATIME + bool "Enable -atime: access time matching" + default BUSYBOX_DEFAULT_FEATURE_FIND_ATIME + depends on BUSYBOX_CONFIG_FEATURE_FIND_MTIME + help + Allow searching based on the access time of + files, in days. + +config BUSYBOX_CONFIG_FEATURE_FIND_CTIME + bool "Enable -ctime: status change timestamp matching" + default BUSYBOX_DEFAULT_FEATURE_FIND_CTIME + depends on BUSYBOX_CONFIG_FEATURE_FIND_MTIME + help + Allow searching based on the status change timestamp of + files, in days. + config BUSYBOX_CONFIG_FEATURE_FIND_MMIN - bool "Enable -mmin: modified time matching by minutes" + bool "Enable -mmin: modification time matching by minutes" default BUSYBOX_DEFAULT_FEATURE_FIND_MMIN depends on BUSYBOX_CONFIG_FIND help Allow searching based on the modification time of files, in minutes. +config BUSYBOX_CONFIG_FEATURE_FIND_AMIN + bool "Enable -amin: access time matching by minutes" + default BUSYBOX_DEFAULT_FEATURE_FIND_AMIN + depends on BUSYBOX_CONFIG_FEATURE_FIND_MMIN + help + Allow searching based on the access time of + files, in minutes. + +config BUSYBOX_CONFIG_FEATURE_FIND_CMIN + bool "Enable -cmin: status change timestamp matching by minutes" + default BUSYBOX_DEFAULT_FEATURE_FIND_CMIN + depends on BUSYBOX_CONFIG_FEATURE_FIND_MMIN + help + Allow searching based on the status change timestamp of + files, in minutes. + config BUSYBOX_CONFIG_FEATURE_FIND_PERM bool "Enable -perm: permissions matching" default BUSYBOX_DEFAULT_FEATURE_FIND_PERM @@ -79,6 +111,13 @@ config BUSYBOX_CONFIG_FEATURE_FIND_INUM default BUSYBOX_DEFAULT_FEATURE_FIND_INUM depends on BUSYBOX_CONFIG_FIND +config BUSYBOX_CONFIG_FEATURE_FIND_SAMEFILE + bool "Enable -samefile: reference file matching" + default BUSYBOX_DEFAULT_FEATURE_FIND_SAMEFILE + depends on BUSYBOX_CONFIG_FIND + help + Support the 'find -samefile' option for searching by a reference file. + config BUSYBOX_CONFIG_FEATURE_FIND_EXEC bool "Enable -exec: execute commands" default BUSYBOX_DEFAULT_FEATURE_FIND_EXEC diff --git a/package/utils/busybox/config/klibc-utils/Config.in b/package/utils/busybox/config/klibc-utils/Config.in index 408c9f695d4..06b9681bc92 100644 --- a/package/utils/busybox/config/klibc-utils/Config.in +++ b/package/utils/busybox/config/klibc-utils/Config.in @@ -13,7 +13,7 @@ config BUSYBOX_CONFIG_MINIPS Alias to "ps". config BUSYBOX_CONFIG_NUKE bool "nuke (2.9 kb)" - default BUSYBOX_DEFAULT_NUKE + default BUSYBOX_DEFAULT_NUKE # off by default: too "accidentally destructive" help Alias to "rm -rf". config BUSYBOX_CONFIG_RESUME diff --git a/package/utils/busybox/config/libbb/Config.in b/package/utils/busybox/config/libbb/Config.in index 906649c5c9a..b3a83b9b085 100644 --- a/package/utils/busybox/config/libbb/Config.in +++ b/package/utils/busybox/config/libbb/Config.in @@ -98,51 +98,118 @@ config BUSYBOX_CONFIG_MD5_SMALL default BUSYBOX_DEFAULT_MD5_SMALL # all "fast or small" options default to small range 0 3 help - Trade binary size versus speed for the md5sum algorithm. + Trade binary size versus speed for the md5 algorithm. Approximate values running uClibc and hashing linux-2.4.4.tar.bz2 were: - value user times (sec) text size (386) - 0 (fastest) 1.1 6144 - 1 1.4 5392 - 2 3.0 5088 - 3 (smallest) 5.1 4912 + value user times (sec) text size (386) + 0 (fastest) 1.1 6144 + 1 1.4 5392 + 2 3.0 5088 + 3 (smallest) 5.1 4912 + +config BUSYBOX_CONFIG_SHA1_SMALL + int "SHA1: Trade bytes for speed (0:fast, 3:slow)" + default BUSYBOX_DEFAULT_SHA1_SMALL # all "fast or small" options default to small + range 0 3 + help + Trade binary size versus speed for the sha1 algorithm. + With FEATURE_COPYBUF_KB=64: + throughput MB/s size of sha1_process_block64 + value 486 x86-64 486 x86-64 + 0 440 485 3481 3502 + 1 265 265 641 696 + 2,3 220 210 342 364 + +config BUSYBOX_CONFIG_SHA1_HWACCEL + bool "SHA1: Use hardware accelerated instructions if possible" + default BUSYBOX_DEFAULT_SHA1_HWACCEL + help + On x86, this adds ~590 bytes of code. Throughput + is about twice as fast as fully-unrolled generic code. + +config BUSYBOX_CONFIG_SHA256_HWACCEL + bool "SHA256: Use hardware accelerated instructions if possible" + default BUSYBOX_DEFAULT_SHA256_HWACCEL + help + On x86, this adds ~1k bytes of code. config BUSYBOX_CONFIG_SHA3_SMALL int "SHA3: Trade bytes for speed (0:fast, 1:slow)" default BUSYBOX_DEFAULT_SHA3_SMALL # all "fast or small" options default to small range 0 1 help - Trade binary size versus speed for the sha3sum algorithm. + Trade binary size versus speed for the sha3 algorithm. SHA3_SMALL=0 compared to SHA3_SMALL=1 (approximate): 64-bit x86: +270 bytes of code, 45% faster 32-bit x86: +450 bytes of code, 75% faster -config BUSYBOX_CONFIG_FEATURE_FAST_TOP - bool "Faster /proc scanning code (+100 bytes)" - default BUSYBOX_DEFAULT_FEATURE_FAST_TOP # all "fast or small" options default to small +config BUSYBOX_CONFIG_FEATURE_NON_POSIX_CP + bool "Non-POSIX, but safer, copying to special nodes" + default BUSYBOX_DEFAULT_FEATURE_NON_POSIX_CP + help + With this option, "cp file symlink" will delete symlink + and create a regular file. This does not conform to POSIX, + but prevents a symlink attack. + Similarly, "cp file device" will not send file's data + to the device. (To do that, use "cat file >device") + +config BUSYBOX_CONFIG_FEATURE_VERBOSE_CP_MESSAGE + bool "Give more precise messages when copy fails (cp, mv etc)" + default BUSYBOX_DEFAULT_FEATURE_VERBOSE_CP_MESSAGE + help + Error messages with this feature enabled: + + $ cp file /does_not_exist/file + cp: cannot create '/does_not_exist/file': Path does not exist + $ cp file /vmlinuz/file + cp: cannot stat '/vmlinuz/file': Path has non-directory component + + If this feature is not enabled, they will be, respectively: + + cp: cannot create '/does_not_exist/file': No such file or directory + cp: cannot stat '/vmlinuz/file': Not a directory + + This will cost you ~60 bytes. + +config BUSYBOX_CONFIG_FEATURE_USE_SENDFILE + bool "Use sendfile system call" + default BUSYBOX_DEFAULT_FEATURE_USE_SENDFILE + help + When enabled, busybox will use the kernel sendfile() function + instead of read/write loops to copy data between file descriptors + (for example, cp command does this a lot). + If sendfile() doesn't work, copying code falls back to read/write + loop. sendfile() was originally implemented for faster I/O + from files to sockets, but since Linux 2.6.33 it was extended + to work for many more file types. + +config BUSYBOX_CONFIG_FEATURE_COPYBUF_KB + int "Copy buffer size, in kilobytes" + range 1 1024 + default BUSYBOX_DEFAULT_FEATURE_COPYBUF_KB help - This option makes top and ps ~20% faster (or 20% less CPU hungry), - but code size is slightly bigger. + Size of buffer used by cp, mv, install, wget etc. + Buffers which are 4 kb or less will be allocated on stack. + Bigger buffers will be allocated with mmap, with fallback to 4 kb + stack buffer if mmap fails. -config BUSYBOX_CONFIG_FEATURE_ETC_NETWORKS - bool "Support /etc/networks" - default BUSYBOX_DEFAULT_FEATURE_ETC_NETWORKS +config BUSYBOX_CONFIG_MONOTONIC_SYSCALL + bool "Use clock_gettime(CLOCK_MONOTONIC) syscall" + default BUSYBOX_DEFAULT_MONOTONIC_SYSCALL help - Enable support for network names in /etc/networks. This is - a rarely used feature which allows you to use names - instead of IP/mask pairs in route command. + Use clock_gettime(CLOCK_MONOTONIC) syscall for measuring + time intervals (time, ping, traceroute etc need this). + Probably requires Linux 2.6+. If not selected, gettimeofday + will be used instead (which gives wrong results if date/time + is reset). -config BUSYBOX_CONFIG_FEATURE_ETC_SERVICES - bool "Consult /etc/services even for well-known ports" - default BUSYBOX_DEFAULT_FEATURE_ETC_SERVICES +config BUSYBOX_CONFIG_IOCTL_HEX2STR_ERROR + bool "Use ioctl names rather than hex values in error messages" + default BUSYBOX_DEFAULT_IOCTL_HEX2STR_ERROR help - Look up e.g. "telnet" and "http" in /etc/services file - instead of assuming ports 23 and 80. - This is almost never necessary (everybody uses standard ports), - and it makes sense to avoid reading this file. - If you disable this option, in the cases where port is explicitly - specified as a service name (e.g. "telnet HOST PORTNAME"), - it will still be looked up in /etc/services. + Use ioctl names rather than hex values in error messages + (e.g. VT_DISALLOCATE rather than 0x5608). If disabled this + saves about 1400 bytes. config BUSYBOX_CONFIG_FEATURE_EDITING bool "Command line editing" @@ -359,95 +426,24 @@ config BUSYBOX_CONFIG_UNICODE_PRESERVE_BROKEN at shell prompt will list file named 0xff (single char name with char value 255), not file named '?'. -config BUSYBOX_CONFIG_FEATURE_NON_POSIX_CP - bool "Non-POSIX, but safer, copying to special nodes" - default BUSYBOX_DEFAULT_FEATURE_NON_POSIX_CP - help - With this option, "cp file symlink" will delete symlink - and create a regular file. This does not conform to POSIX, - but prevents a symlink attack. - Similarly, "cp file device" will not send file's data - to the device. (To do that, use "cat file >device") - -config BUSYBOX_CONFIG_FEATURE_VERBOSE_CP_MESSAGE - bool "Give more precise messages when copy fails (cp, mv etc)" - default BUSYBOX_DEFAULT_FEATURE_VERBOSE_CP_MESSAGE - help - Error messages with this feature enabled: - - $ cp file /does_not_exist/file - cp: cannot create '/does_not_exist/file': Path does not exist - $ cp file /vmlinuz/file - cp: cannot stat '/vmlinuz/file': Path has non-directory component - - If this feature is not enabled, they will be, respectively: - - cp: cannot create '/does_not_exist/file': No such file or directory - cp: cannot stat '/vmlinuz/file': Not a directory - - This will cost you ~60 bytes. - -config BUSYBOX_CONFIG_FEATURE_USE_SENDFILE - bool "Use sendfile system call" - default BUSYBOX_DEFAULT_FEATURE_USE_SENDFILE - help - When enabled, busybox will use the kernel sendfile() function - instead of read/write loops to copy data between file descriptors - (for example, cp command does this a lot). - If sendfile() doesn't work, copying code falls back to read/write - loop. sendfile() was originally implemented for faster I/O - from files to sockets, but since Linux 2.6.33 it was extended - to work for many more file types. - -config BUSYBOX_CONFIG_FEATURE_COPYBUF_KB - int "Copy buffer size, in kilobytes" - range 1 1024 - default BUSYBOX_DEFAULT_FEATURE_COPYBUF_KB - help - Size of buffer used by cp, mv, install, wget etc. - Buffers which are 4 kb or less will be allocated on stack. - Bigger buffers will be allocated with mmap, with fallback to 4 kb - stack buffer if mmap fails. - -config BUSYBOX_CONFIG_FEATURE_SKIP_ROOTFS - bool "Skip rootfs in mount table" - default BUSYBOX_DEFAULT_FEATURE_SKIP_ROOTFS +choice + prompt "Use LOOP_CONFIGURE for losetup and loop mounts" + default BUSYBOX_CONFIG_TRY_LOOP_CONFIGURE help - Ignore rootfs entry in mount table. - - In Linux, kernel has a special filesystem, rootfs, which is initially - mounted on /. It contains initramfs data, if kernel is configured - to have one. Usually, another file system is mounted over / early - in boot process, and therefore most tools which manipulate - mount table, such as df, will skip rootfs entry. + LOOP_CONFIGURE is added to Linux 5.8 + https://lwn.net/Articles/820408/ + This allows userspace to completely setup a loop device with a single + ioctl, removing the in-between state where the device can be partially + configured - eg the loop device has a backing file associated with it, + but is reading from the wrong offset. - However, some systems do not mount anything on /. - If you need to configure busybox for one of these systems, - you may find it useful to turn this option off to make df show - initramfs statistics. +config BUSYBOX_CONFIG_LOOP_CONFIGURE + bool "use LOOP_CONFIGURE, needs kernel >= 5.8" - Otherwise, choose Y. - -config BUSYBOX_CONFIG_MONOTONIC_SYSCALL - bool "Use clock_gettime(CLOCK_MONOTONIC) syscall" - default BUSYBOX_DEFAULT_MONOTONIC_SYSCALL - help - Use clock_gettime(CLOCK_MONOTONIC) syscall for measuring - time intervals (time, ping, traceroute etc need this). - Probably requires Linux 2.6+. If not selected, gettimeofday - will be used instead (which gives wrong results if date/time - is reset). +config BUSYBOX_CONFIG_NO_LOOP_CONFIGURE + bool "use LOOP_SET_FD + LOOP_SET_STATUS" -config BUSYBOX_CONFIG_IOCTL_HEX2STR_ERROR - bool "Use ioctl names rather than hex values in error messages" - default BUSYBOX_DEFAULT_IOCTL_HEX2STR_ERROR - help - Use ioctl names rather than hex values in error messages - (e.g. VT_DISALLOCATE rather than 0x5608). If disabled this - saves about 1400 bytes. +config BUSYBOX_CONFIG_TRY_LOOP_CONFIGURE + bool "try LOOP_CONFIGURE, fall back to LOOP_SET_FD + LOOP_SET_STATUS" -config BUSYBOX_CONFIG_FEATURE_HWIB - bool "Support infiniband HW" - default BUSYBOX_DEFAULT_FEATURE_HWIB - help - Support for printing infiniband addresses in network applets. +endchoice diff --git a/package/utils/busybox/config/mailutils/Config.in b/package/utils/busybox/config/mailutils/Config.in index a8632471a86..ea7ae6d6495 100644 --- a/package/utils/busybox/config/mailutils/Config.in +++ b/package/utils/busybox/config/mailutils/Config.in @@ -1,6 +1,13 @@ # DO NOT EDIT. This file is generated from Config.src menu "Mail Utilities" +config BUSYBOX_CONFIG_FEATURE_MIME_CHARSET + string "Default charset" + default BUSYBOX_DEFAULT_FEATURE_MIME_CHARSET + depends on BUSYBOX_CONFIG_MAKEMIME || BUSYBOX_CONFIG_REFORMIME || BUSYBOX_CONFIG_SENDMAIL + help + Default charset of the message. + config BUSYBOX_CONFIG_MAKEMIME bool "makemime (5.4 kb)" default BUSYBOX_DEFAULT_MAKEMIME @@ -41,11 +48,4 @@ config BUSYBOX_CONFIG_SENDMAIL help Barebones sendmail. -config BUSYBOX_CONFIG_FEATURE_MIME_CHARSET - string "Default charset" - default BUSYBOX_DEFAULT_FEATURE_MIME_CHARSET - depends on BUSYBOX_CONFIG_MAKEMIME || BUSYBOX_CONFIG_REFORMIME || BUSYBOX_CONFIG_SENDMAIL - help - Default charset of the message. - endmenu diff --git a/package/utils/busybox/config/miscutils/Config.in b/package/utils/busybox/config/miscutils/Config.in index f3b29787d1d..e15e318fe07 100644 --- a/package/utils/busybox/config/miscutils/Config.in +++ b/package/utils/busybox/config/miscutils/Config.in @@ -12,6 +12,12 @@ config BUSYBOX_CONFIG_ADJTIMEX help Adjtimex reads and optionally sets adjustment parameters for the Linux clock adjustment algorithm. +config BUSYBOX_CONFIG_ASCII + bool "ascii" + default BUSYBOX_DEFAULT_ASCII + help + Print ascii table. + config BUSYBOX_CONFIG_BBCONFIG bool "bbconfig (9.7 kb)" default BUSYBOX_DEFAULT_BBCONFIG @@ -698,6 +704,13 @@ config BUSYBOX_CONFIG_RX default BUSYBOX_DEFAULT_RX help Receive files using the Xmodem protocol. +config BUSYBOX_CONFIG_SEEDRNG + bool "seedrng (1.3 kb)" + default BUSYBOX_DEFAULT_SEEDRNG + help + Seed the kernel RNG from seed files, meant to be called + once during startup, once during shutdown, and optionally + at some periodic interval in between. config BUSYBOX_CONFIG_SETFATTR bool "setfattr (3.7 kb)" default BUSYBOX_DEFAULT_SETFATTR @@ -721,6 +734,11 @@ config BUSYBOX_CONFIG_TIME The time command runs the specified program with the given arguments. When the command finishes, time writes a message to standard output giving timing statistics about this program run. +config BUSYBOX_CONFIG_TREE + bool "tree (0.6 kb)" + default BUSYBOX_DEFAULT_TREE + help + List files and directories in a tree structure. config BUSYBOX_CONFIG_TS bool "ts (450 bytes)" default BUSYBOX_DEFAULT_TS @@ -788,4 +806,19 @@ config BUSYBOX_CONFIG_WATCHDOG certain amount of time, the watchdog device assumes the system has hung, and will cause the hardware to reboot. +config BUSYBOX_CONFIG_FEATURE_WATCHDOG_OPEN_TWICE + bool "Open watchdog device twice, closing it gracefully in between" + depends on BUSYBOX_CONFIG_WATCHDOG + default BUSYBOX_DEFAULT_FEATURE_WATCHDOG_OPEN_TWICE # this behavior was essentially a hack for a broken driver + help + When enabled, the watchdog device is opened and then immediately + magic-closed, before being opened a second time. This may be necessary + for some watchdog devices, but can cause spurious warnings in the + kernel log if the nowayout feature is enabled. If this workaround + is really needed for you machine to work properly, consider whether + it should be fixed in the kernel driver instead. Even when disabled, + the behaviour is easily emulated with a "printf 'V' > /dev/watchdog" + immediately before starting the busybox watchdog daemon. Say n unless + you know that you absolutely need this. + endmenu diff --git a/package/utils/busybox/config/networking/Config.in b/package/utils/busybox/config/networking/Config.in index 3e1c4c4c04b..861e4f9bbfa 100644 --- a/package/utils/busybox/config/networking/Config.in +++ b/package/utils/busybox/config/networking/Config.in @@ -47,6 +47,32 @@ config BUSYBOX_CONFIG_VERBOSE_RESOLUTION_ERRORS "can't resolve 'hostname.com'" and want to know more. This may increase size of your executable a bit. +config BUSYBOX_CONFIG_FEATURE_ETC_NETWORKS + bool "Support /etc/networks" + default BUSYBOX_DEFAULT_FEATURE_ETC_NETWORKS + help + Enable support for network names in /etc/networks. This is + a rarely used feature which allows you to use names + instead of IP/mask pairs in route command. + +config BUSYBOX_CONFIG_FEATURE_ETC_SERVICES + bool "Consult /etc/services even for well-known ports" + default BUSYBOX_DEFAULT_FEATURE_ETC_SERVICES + help + Look up e.g. "telnet" and "http" in /etc/services file + instead of assuming ports 23 and 80. + This is almost never necessary (everybody uses standard ports), + and it makes sense to avoid reading this file. + If you disable this option, in the cases where port is explicitly + specified as a service name (e.g. "telnet HOST PORTNAME"), + it will still be looked up in /etc/services. + +config BUSYBOX_CONFIG_FEATURE_HWIB + bool "Support infiniband HW" + default BUSYBOX_DEFAULT_FEATURE_HWIB + help + Support for printing infiniband addresses in network applets. + config BUSYBOX_CONFIG_FEATURE_TLS_SHA1 bool "In TLS code, support ciphers which use deprecated SHA1" depends on BUSYBOX_CONFIG_TLS @@ -173,6 +199,12 @@ config BUSYBOX_CONFIG_HTTPD help HTTP server. +config BUSYBOX_CONFIG_FEATURE_HTTPD_PORT_DEFAULT + int "Default port" + default BUSYBOX_DEFAULT_FEATURE_HTTPD_PORT_DEFAULT + range 1 65535 + depends on BUSYBOX_CONFIG_HTTPD + config BUSYBOX_CONFIG_FEATURE_HTTPD_RANGES bool "Support 'Ranges:' header" default BUSYBOX_DEFAULT_FEATURE_HTTPD_RANGES @@ -774,7 +806,6 @@ config BUSYBOX_CONFIG_FEATURE_NSLOOKUP_LONG_OPTIONS bool "Enable long options" default BUSYBOX_DEFAULT_FEATURE_NSLOOKUP_LONG_OPTIONS depends on BUSYBOX_CONFIG_FEATURE_NSLOOKUP_BIG && BUSYBOX_CONFIG_LONG_OPTS - config BUSYBOX_CONFIG_NTPD bool "ntpd (22 kb)" default BUSYBOX_DEFAULT_NTPD @@ -945,6 +976,12 @@ config BUSYBOX_CONFIG_FEATURE_TELNETD_STANDALONE help Selecting this will make telnetd able to run standalone. +config BUSYBOX_CONFIG_FEATURE_TELNETD_PORT_DEFAULT + int "Default port" + default BUSYBOX_DEFAULT_FEATURE_TELNETD_PORT_DEFAULT + range 1 65535 + depends on BUSYBOX_CONFIG_FEATURE_TELNETD_STANDALONE + config BUSYBOX_CONFIG_FEATURE_TELNETD_INETD_WAIT bool "Support -w SEC option (inetd wait mode)" default BUSYBOX_DEFAULT_FEATURE_TELNETD_INETD_WAIT @@ -1092,6 +1129,13 @@ config BUSYBOX_CONFIG_FEATURE_WGET_STATUSBAR default BUSYBOX_DEFAULT_FEATURE_WGET_STATUSBAR depends on BUSYBOX_CONFIG_WGET +config BUSYBOX_CONFIG_FEATURE_WGET_FTP + bool "Enable FTP protocol (+1k)" + default BUSYBOX_DEFAULT_FEATURE_WGET_FTP + depends on BUSYBOX_CONFIG_WGET + help + To support FTPS, enable FEATURE_WGET_HTTPS as well. + config BUSYBOX_CONFIG_FEATURE_WGET_AUTHENTICATION bool "Enable HTTP authentication" default BUSYBOX_DEFAULT_FEATURE_WGET_AUTHENTICATION @@ -1120,6 +1164,7 @@ config BUSYBOX_CONFIG_FEATURE_WGET_HTTPS select BUSYBOX_CONFIG_TLS help wget will use internal TLS code to connect to https:// URLs. + It also enables FTPS support, but it's not well tested yet. Note: On NOMMU machines, ssl_helper applet should be available in the $PATH for this to work. Make sure to select that applet. diff --git a/package/utils/busybox/config/networking/udhcp/Config.in b/package/utils/busybox/config/networking/udhcp/Config.in index 9bede614991..6757f1efc9c 100644 --- a/package/utils/busybox/config/networking/udhcp/Config.in +++ b/package/utils/busybox/config/networking/udhcp/Config.in @@ -93,12 +93,17 @@ config BUSYBOX_CONFIG_FEATURE_UDHCPC_SANITIZEOPT config BUSYBOX_CONFIG_UDHCPC_DEFAULT_SCRIPT string "Absolute path to config script" default BUSYBOX_DEFAULT_UDHCPC_DEFAULT_SCRIPT - depends on BUSYBOX_CONFIG_UDHCPC || BUSYBOX_CONFIG_UDHCPC6 + depends on BUSYBOX_CONFIG_UDHCPC help This script is called after udhcpc receives an answer. See examples/udhcp for a working example. Normally it is safe to leave this untouched. +config BUSYBOX_CONFIG_UDHCPC6_DEFAULT_SCRIPT + string "Absolute path to config script for IPv6" + default BUSYBOX_DEFAULT_UDHCPC6_DEFAULT_SCRIPT + depends on BUSYBOX_CONFIG_UDHCPC6 + # udhcpc6 config is inserted here: config BUSYBOX_CONFIG_UDHCPC6 bool "udhcpc6 (21 kb)" @@ -142,6 +147,14 @@ config BUSYBOX_CONFIG_FEATURE_UDHCPC6_RFC5970 comment "Common options for DHCP applets" depends on BUSYBOX_CONFIG_UDHCPD || BUSYBOX_CONFIG_UDHCPC || BUSYBOX_CONFIG_UDHCPC6 || BUSYBOX_CONFIG_DHCPRELAY +config BUSYBOX_CONFIG_UDHCPC_DEFAULT_INTERFACE + string "Default interface name" + default BUSYBOX_DEFAULT_UDHCPC_DEFAULT_INTERFACE + depends on BUSYBOX_CONFIG_UDHCPC || BUSYBOX_CONFIG_UDHCPC6 + help + The interface that will be used if no other interface is + specified on the commandline. + config BUSYBOX_CONFIG_FEATURE_UDHCP_PORT bool "Enable '-P port' option for udhcpd and udhcpc" default BUSYBOX_DEFAULT_FEATURE_UDHCP_PORT diff --git a/package/utils/busybox/config/procps/Config.in b/package/utils/busybox/config/procps/Config.in index e6c32712540..0501daf8fd2 100644 --- a/package/utils/busybox/config/procps/Config.in +++ b/package/utils/busybox/config/procps/Config.in @@ -6,6 +6,21 @@ menu "Process Utilities" +config BUSYBOX_CONFIG_FEATURE_FAST_TOP + bool "Faster /proc scanning code (+100 bytes)" + default BUSYBOX_DEFAULT_FEATURE_FAST_TOP # all "fast or small" options default to small + help + This option makes top and ps ~20% faster (or 20% less CPU hungry), + but code size is slightly bigger. + +config BUSYBOX_CONFIG_FEATURE_SHOW_THREADS + bool "Support thread display in ps/pstree/top" + default BUSYBOX_DEFAULT_FEATURE_SHOW_THREADS + depends on BUSYBOX_CONFIG_PS || BUSYBOX_CONFIG_TOP || BUSYBOX_CONFIG_PSTREE + help + Enables the ps -T option, showing of threads in pstree, + and 'h' command in top. + config BUSYBOX_CONFIG_FREE bool "free (3.1 kb)" default BUSYBOX_DEFAULT_FREE @@ -259,12 +274,4 @@ config BUSYBOX_CONFIG_WATCH watch is used to execute a program periodically, showing output to the screen. -config BUSYBOX_CONFIG_FEATURE_SHOW_THREADS - bool "Support thread display in ps/pstree/top" - default BUSYBOX_DEFAULT_FEATURE_SHOW_THREADS - depends on BUSYBOX_CONFIG_PS || BUSYBOX_CONFIG_TOP || BUSYBOX_CONFIG_PSTREE - help - Enables the ps -T option, showing of threads in pstree, - and 'h' command in top. - endmenu diff --git a/package/utils/busybox/config/shell/Config.in b/package/utils/busybox/config/shell/Config.in index cb43bcd84c8..a68e9114ef7 100644 --- a/package/utils/busybox/config/shell/Config.in +++ b/package/utils/busybox/config/shell/Config.in @@ -201,6 +201,11 @@ config BUSYBOX_CONFIG_ASH_TEST default BUSYBOX_DEFAULT_ASH_TEST depends on BUSYBOX_CONFIG_SHELL_ASH +config BUSYBOX_CONFIG_ASH_SLEEP + bool "sleep builtin" + default BUSYBOX_DEFAULT_ASH_SLEEP + depends on BUSYBOX_CONFIG_SHELL_ASH + config BUSYBOX_CONFIG_ASH_HELP bool "help builtin" default BUSYBOX_DEFAULT_ASH_HELP @@ -299,11 +304,6 @@ config BUSYBOX_CONFIG_HUSH_BRACE_EXPANSION help Enable {abc,def} extension. -config BUSYBOX_CONFIG_HUSH_LINENO_VAR - bool "$LINENO variable" - default BUSYBOX_DEFAULT_HUSH_LINENO_VAR - depends on BUSYBOX_CONFIG_HUSH_BASH_COMPAT - config BUSYBOX_CONFIG_HUSH_BASH_SOURCE_CURDIR bool "'source' and '.' builtins search current directory after $PATH" default BUSYBOX_DEFAULT_HUSH_BASH_SOURCE_CURDIR # do not encourage non-standard behavior @@ -311,6 +311,11 @@ config BUSYBOX_CONFIG_HUSH_BASH_SOURCE_CURDIR help This is not compliant with standards. Avoid if possible. +config BUSYBOX_CONFIG_HUSH_LINENO_VAR + bool "$LINENO variable (bashism)" + default BUSYBOX_DEFAULT_HUSH_LINENO_VAR + depends on BUSYBOX_CONFIG_SHELL_HUSH + config BUSYBOX_CONFIG_HUSH_INTERACTIVE bool "Interactive mode" default BUSYBOX_DEFAULT_HUSH_INTERACTIVE diff --git a/package/utils/busybox/patches/200-udhcpc_reduce_msgs.patch b/package/utils/busybox/patches/200-udhcpc_reduce_msgs.patch index 2e67009224f..c0f234ee421 100644 --- a/package/utils/busybox/patches/200-udhcpc_reduce_msgs.patch +++ b/package/utils/busybox/patches/200-udhcpc_reduce_msgs.patch @@ -1,18 +1,18 @@ --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c -@@ -712,6 +712,7 @@ static int bcast_or_ucast(struct dhcp_pa - static NOINLINE int send_discover(uint32_t xid, uint32_t requested) +@@ -722,6 +722,7 @@ static int bcast_or_ucast(struct dhcp_pa + static NOINLINE int send_discover(uint32_t requested) { struct dhcp_packet packet; + static int msgs = 0; /* Fill in: op, htype, hlen, cookie, chaddr fields, - * random xid field (we override it below), -@@ -729,6 +730,7 @@ static NOINLINE int send_discover(uint32 + * xid field, message type option: +@@ -736,6 +737,7 @@ static NOINLINE int send_discover(uint32 */ add_client_options(&packet); + if (msgs++ < 3) - bb_info_msg("sending %s", "discover"); + bb_simple_info_msg("broadcasting discover"); return raw_bcast_from_client_data_ifindex(&packet, INADDR_ANY); } diff --git a/package/utils/busybox/patches/201-udhcpc_changed_ifindex.patch b/package/utils/busybox/patches/201-udhcpc_changed_ifindex.patch index 875f2ce5fc4..a4bda992c42 100644 --- a/package/utils/busybox/patches/201-udhcpc_changed_ifindex.patch +++ b/package/utils/busybox/patches/201-udhcpc_changed_ifindex.patch @@ -1,8 +1,8 @@ --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c -@@ -1415,6 +1415,12 @@ int udhcpc_main(int argc UNUSED_PARAM, c - /* silence "uninitialized!" warning */ - unsigned timestamp_before_wait = timestamp_before_wait; +@@ -1384,6 +1384,12 @@ int udhcpc_main(int argc UNUSED_PARAM, c + struct pollfd pfds[2]; + struct dhcp_packet packet; + /* When running on a bridge, the ifindex may have changed (e.g. if + * member interfaces were added/removed or if the status of the diff --git a/package/utils/busybox/patches/203-udhcpc_renew_no_deconfig.patch b/package/utils/busybox/patches/203-udhcpc_renew_no_deconfig.patch deleted file mode 100644 index 88a98c0a1c8..00000000000 --- a/package/utils/busybox/patches/203-udhcpc_renew_no_deconfig.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/networking/udhcp/dhcpc.c -+++ b/networking/udhcp/dhcpc.c -@@ -1125,7 +1125,6 @@ static void perform_renew(void) - client_data.state = RENEW_REQUESTED; - break; - case RENEW_REQUESTED: /* impatient are we? fine, square 1 */ -- udhcp_run_script(NULL, "deconfig"); - case REQUESTING: - case RELEASED: - change_listen_mode(LISTEN_RAW); diff --git a/package/utils/busybox/patches/205-udhcpc_allow_zero_length_options.patch b/package/utils/busybox/patches/205-udhcpc_allow_zero_length_options.patch deleted file mode 100644 index abe8baf54f3..00000000000 --- a/package/utils/busybox/patches/205-udhcpc_allow_zero_length_options.patch +++ /dev/null @@ -1,49 +0,0 @@ -From 7eed119b84b0f7efb7ef351940dd895dc2379eb3 Mon Sep 17 00:00:00 2001 -From: Russell Senior <russell@personaltelco.net> -Date: Mon, 15 Mar 2021 23:27:58 -0700 -Subject: [PATCH v2] udhcpc: ignore zero-length DHCP options - -Discovered that the DHCP server on a TrendNet router (unknown model) -provides a zero-length option 12 (Host Name) in the DHCP ACK message. This -has the effect of causing udhcpc to drop the rest of the options, including -option 51 (IP Address Lease Time), 3 (Router), and 6 (Domain Name Server), -most importantly leaving the OpenWrt device with no default gateway. - -The TrendNet behavior violates RFC 2132, which in Section 3.14 declares that -option 12 has a miniumum length of 1 octet. It is perhaps not a cosmic coincidence -that I found this behavior on Pi Day. - -This patch allows zero length options without bailing out, by simply skipping them. - -v2 changelog: -* advance the optionptr by two bytes, not one; -* add a message to warn about the rfc violation; - -Signed-off-by: Russell Senior <russell@personaltelco.net> ---- - networking/udhcp/common.c | 9 +++++++-- - 1 file changed, 7 insertions(+), 2 deletions(-) - -diff --git a/networking/udhcp/common.c b/networking/udhcp/common.c -index 4bc719001..a16fd85d0 100644 ---- a/networking/udhcp/common.c -+++ b/networking/udhcp/common.c -@@ -277,8 +277,13 @@ uint8_t* FAST_FUNC udhcp_scan_options(struct dhcp_packet *packet, struct dhcp_sc - goto complain; /* complain and return NULL */ - len = 2 + scan_state->optionptr[OPT_LEN]; - scan_state->rem -= len; -- /* So far no valid option with length 0 known. */ -- if (scan_state->rem < 0 || scan_state->optionptr[OPT_LEN] == 0) -+ /* skip any options with zero length */ -+ if (scan_state->optionptr[OPT_LEN] == 0) { -+ scan_state->optionptr += 2; -+ bb_simple_error_msg("warning: zero length DHCP option violates rfc2132, skipping"); -+ continue; -+ } -+ if (scan_state->rem < 0) - goto complain; /* complain and return NULL */ - - if (scan_state->optionptr[OPT_CODE] == DHCP_OPTION_OVERLOAD) { --- -2.30.1 - diff --git a/package/utils/busybox/patches/220-add_lock_util.patch b/package/utils/busybox/patches/220-add_lock_util.patch index 4e46b74f0e7..579b705f346 100644 --- a/package/utils/busybox/patches/220-add_lock_util.patch +++ b/package/utils/busybox/patches/220-add_lock_util.patch @@ -72,9 +72,9 @@ + +static int do_lock(void) +{ -+ int pid; ++ pid_t pid; + int flags; -+ char pidstr[8]; ++ char pidstr[12]; + + if ((fd = open(file, O_RDWR | O_CREAT | O_EXCL, 0700)) < 0) { + if ((fd = open(file, O_RDWR)) < 0) { @@ -109,7 +109,7 @@ + if (!waitonly) { + lseek(fd, 0, SEEK_SET); + ftruncate(fd, 0); -+ sprintf(pidstr, "%d\n", pid); ++ snprintf(pidstr, sizeof(pidstr), "%d\n", pid); + write(fd, pidstr, strlen(pidstr)); + close(fd); + } diff --git a/package/utils/busybox/patches/301-ip-link-fix-netlink-msg-size.patch b/package/utils/busybox/patches/301-ip-link-fix-netlink-msg-size.patch index f7cd2322c90..f4c0a809225 100644 --- a/package/utils/busybox/patches/301-ip-link-fix-netlink-msg-size.patch +++ b/package/utils/busybox/patches/301-ip-link-fix-netlink-msg-size.patch @@ -1,6 +1,6 @@ --- a/networking/libiproute/iplink.c +++ b/networking/libiproute/iplink.c -@@ -652,7 +652,7 @@ static int do_add_or_delete(char **argv, +@@ -683,7 +683,7 @@ static int do_add_or_delete(char **argv, } xrtnl_open(&rth); ll_init_map(&rth); diff --git a/package/utils/busybox/patches/530-nslookup-ensure-unique-transaction-IDs-for-the-DNS-queries.patch b/package/utils/busybox/patches/530-nslookup-ensure-unique-transaction-IDs-for-the-DNS-queries.patch new file mode 100644 index 00000000000..caa5ee78f35 --- /dev/null +++ b/package/utils/busybox/patches/530-nslookup-ensure-unique-transaction-IDs-for-the-DNS-queries.patch @@ -0,0 +1,42 @@ +From: Uwe Kleine-König <uwe@kleine-koenig.org> +Date: Sat, 8 Oct 2022 19:22:52 +0200 +Subject: [PATCH] nslookup: ensure unique transaction IDs for the DNS queries + +The transaction IDs generated by res_mkquery() for both glibc and musl only +depends on the state of the monotonic clock. +For some machines (here: a TP-Link RE200 powered by a MediaTek MT7620A) +the monotonic clock has a coarse resolution (here: 20 µs) and it can happen +that the requests for A and AAAA share the same transaction ID. + +In that case the mapping from received responses to the sent queries +doesn't work and name resolution fails as follows: + + # /bin/busybox nslookup heise.de + Server: 127.0.0.1 + Address: 127.0.0.1:53 + + Non-authoritative answer: + Name: heise.de + Address: 193.99.144.80 + + *** Can't find heise.de: No answer + +because the AAAA reply is dropped as a duplicate reply to the A query. + +To prevent this make sure the transaction IDs are unique. + +Forwarded: http://lists.busybox.net/pipermail/busybox/2022-October/089911.html +--- +--- a/networking/nslookup.c ++++ b/networking/nslookup.c +@@ -978,6 +978,10 @@ int nslookup_main(int argc UNUSED_PARAM, + } + } + ++ /* Ensure the Transaction IDs are unique */ ++ for (rc = 1; rc < G.query_count; rc++) ++ G.query[rc].query[1] = G.query[rc - 1].query[1] + 1; ++ + for (rc = 0; rc < G.serv_count;) { + int c; + diff --git a/package/utils/busybox/patches/530-use-SOURCE_DATE_EPOCH-for-timestamp-if-available.patch b/package/utils/busybox/patches/530-use-SOURCE_DATE_EPOCH-for-timestamp-if-available.patch deleted file mode 100644 index af473622ed2..00000000000 --- a/package/utils/busybox/patches/530-use-SOURCE_DATE_EPOCH-for-timestamp-if-available.patch +++ /dev/null @@ -1,80 +0,0 @@ -From 59f773ee81a8945321f4aa20abc5e9577e6483e4 Mon Sep 17 00:00:00 2001 -From: Paul Spooren <mail@aparcar.org> -Date: Thu, 13 May 2021 11:25:34 +0200 -Subject: [PATCH] use SOURCE_DATE_EPOCH for timestamp if available - -The SOURCE_DATE_EPOCH is an effort of the Reproducible Builds -organization to make timestamps/build dates in compiled tools -deterministic over several repetitive builds. - -Busybox shows by default the build date timestamp which changes whenever -compiled. To have a reasonable accurate build date while staying -reproducible, it's possible to use the *date of last source -modification* rather than the current time and date. - -Further information on SOURCE_DATE_EPOCH are available online [1]. - -This patch modifies `confdata.c` so that the content of the -SOURCE_DATE_EPOCH env variable is used as timestamp. - -To be independent of different timezones between builds, whenever -SOURCE_DATE_EPOCH is defined the GMT time is used. - -[1]: https://reproducible-builds.org/docs/source-date-epoch/ - -Signed-off-by: Paul Spooren <mail@aparcar.org> ---- - scripts/kconfig/confdata.c | 17 ++++++++++++++--- - 1 file changed, 14 insertions(+), 3 deletions(-) - -diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c -index b05b96e45..73c25e3a8 100644 ---- a/scripts/kconfig/confdata.c -+++ b/scripts/kconfig/confdata.c -@@ -342,6 +342,8 @@ int conf_write(const char *name) - time_t now; - int use_timestamp = 1; - char *env; -+ char *source_date_epoch; -+ struct tm *build_time; - - dirname[0] = 0; - if (name && name[0]) { -@@ -378,7 +380,16 @@ int conf_write(const char *name) - } - sym = sym_lookup("KERNELVERSION", 0); - sym_calc_value(sym); -- time(&now); -+ -+ source_date_epoch = getenv("SOURCE_DATE_EPOCH"); -+ if (source_date_epoch && *source_date_epoch) { -+ now = strtoull(source_date_epoch, NULL, 10); -+ build_time = gmtime(&now); -+ } else { -+ time(&now); -+ build_time = localtime(&now); -+ } -+ - env = getenv("KCONFIG_NOTIMESTAMP"); - if (env && *env) - use_timestamp = 0; -@@ -398,14 +409,14 @@ int conf_write(const char *name) - if (use_timestamp) { - size_t ret = \ - strftime(buf, sizeof(buf), "#define AUTOCONF_TIMESTAMP " -- "\"%Y-%m-%d %H:%M:%S %Z\"\n", localtime(&now)); -+ "\"%Y-%m-%d %H:%M:%S %Z\"\n", build_time); - /* if user has Factory timezone or some other odd install, the - * %Z above will overflow the string leaving us with undefined - * results ... so let's try again without the timezone. - */ - if (ret == 0) - strftime(buf, sizeof(buf), "#define AUTOCONF_TIMESTAMP " -- "\"%Y-%m-%d %H:%M:%S\"\n", localtime(&now)); -+ "\"%Y-%m-%d %H:%M:%S\"\n", build_time); - } else { /* bbox */ - strcpy(buf, "#define AUTOCONF_TIMESTAMP \"\"\n"); - } --- -2.30.2 - diff --git a/package/utils/busybox/patches/540-nslookup-mention-QUERY_TYPE-SRV.patch b/package/utils/busybox/patches/540-nslookup-mention-QUERY_TYPE-SRV.patch deleted file mode 100644 index ac9afa34ef7..00000000000 --- a/package/utils/busybox/patches/540-nslookup-mention-QUERY_TYPE-SRV.patch +++ /dev/null @@ -1,30 +0,0 @@ -From a0136f24f788e8bfc4ab74a647b27e115a25d9fb Mon Sep 17 00:00:00 2001 -From: Paul Spooren <mail@aparcar.org> -Date: Wed, 19 May 2021 00:55:21 +0200 -Subject: [PATCH] nslookup: mention QUERY_TYPE SRV - -SRV lookups are supported since "6b4960155 nslookup: implement support -for SRV records" and should therefore be mentioned as a possible -QUERY_TYPE in the help message. - -Signed-off-by: Paul Spooren <mail@aparcar.org> ---- - networking/nslookup.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/networking/nslookup.c b/networking/nslookup.c -index dda22de0e..2ae8d391c 100644 ---- a/networking/nslookup.c -+++ b/networking/nslookup.c -@@ -25,7 +25,7 @@ - //usage:#define nslookup_full_usage "\n\n" - //usage: "Query DNS about HOST" - //usage: IF_FEATURE_NSLOOKUP_BIG("\n") --//usage: IF_FEATURE_NSLOOKUP_BIG("\nQUERY_TYPE: soa,ns,a,"IF_FEATURE_IPV6("aaaa,")"cname,mx,txt,ptr,any") -+//usage: IF_FEATURE_NSLOOKUP_BIG("\nQUERY_TYPE: soa,ns,a,"IF_FEATURE_IPV6("aaaa,")"cname,mx,txt,ptr,srv,any") - //usage:#define nslookup_example_usage - //usage: "$ nslookup localhost\n" - //usage: "Server: default\n" --- -2.30.2 - diff --git a/package/utils/checkpolicy/Makefile b/package/utils/checkpolicy/Makefile index 206bf201c07..4ebf97bb3f9 100644 --- a/package/utils/checkpolicy/Makefile +++ b/package/utils/checkpolicy/Makefile @@ -6,12 +6,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=checkpolicy -PKG_VERSION:=3.2 +PKG_VERSION:=3.5 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_SOURCE_URL:=https://github.com/SELinuxProject/selinux/releases/download/3.2 -PKG_HASH:=9b1c81fa86fe3867842164448d90c8e7ea94b2987497809c65d4caa87a5c5bc8 +PKG_SOURCE_URL:=https://github.com/SELinuxProject/selinux/releases/download/$(PKG_VERSION) +PKG_HASH:=7aa48ab2222a0b9881111d6d7f70c3014d3d9338827d9e02df105a68c0df5dbc PKG_INSTALL:=1 PKG_BUILD_DEPENDS:=libselinux HOST_BUILD_DEPENDS:=libselinux/host diff --git a/package/utils/debugcc/Makefile b/package/utils/debugcc/Makefile new file mode 100644 index 00000000000..2a72f177306 --- /dev/null +++ b/package/utils/debugcc/Makefile @@ -0,0 +1,32 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=debugcc +PKG_RELEASE:=1 + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL=https://github.com/linux-msm/debugcc.git +PKG_SOURCE_DATE:=2023-11-10 +PKG_SOURCE_VERSION:=d15bea7c05f224a85dd1fcec24b0f153dbad9f6e +PKG_MIRROR_HASH:=b6bd181db4992cf429343cd7d0fdde0f937a8f1811f5fe9e7855a0d76b0d88a0 + +PKG_LICENSE:=BSD-3-Clause +PKG_LICENSE_FILES:=LICENSE + +PKG_MAINTAINER:=Christian Marangi <ansuelsmth@gmail.com> + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/meson.mk + +define Package/debugcc + SECTION:=utils + CATEGORY:=Utilities + TITLE:=QCOM debugcc utility + DEPENDS:=@KERNEL_DEVMEM @(TARGET_qualcommax||TARGET_ipq806x||TARGET_ipq40xx) +endef + +define Package/debugcc/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(MESON_BUILD_DIR)/debugcc $(1)/usr/bin/ +endef + +$(eval $(call BuildPackage,debugcc)) diff --git a/package/utils/dtc/Makefile b/package/utils/dtc/Makefile new file mode 100644 index 00000000000..afec6fbae54 --- /dev/null +++ b/package/utils/dtc/Makefile @@ -0,0 +1,106 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright (C) 2016-2019 Yousong Zhou <yszhou4tech@gmail.com> + +include $(TOPDIR)/rules.mk + +PKG_NAME:=dtc +PKG_VERSION:=1.7.0 +PKG_RELEASE:=2 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_HASH:=29edce3d302a15563d8663198bbc398c5a0554765c83830d0d4c0409d21a16c4 +PKG_SOURCE_URL:=@KERNEL/software/utils/dtc + +PKG_MAINTAINER:=Yousong Zhou <yszhou4tech@gmail.com> +PKG_LICENSE:=GPL-2.0-only +PKG_LICENSE_FILES:=GPL +PKG_CPE_ID:=cpe:/a:dtc_project:dtc + +PKG_INSTALL:=1 + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/meson.mk + +define Package/dtc + SECTION:=utils + CATEGORY:=Utilities + TITLE:=Device Tree Compiler + URL:=https://git.kernel.org/pub/scm/utils/dtc/dtc.git +endef + +define Package/dtc/description + Device Tree Compiler for Flat Device Trees Device Tree Compiler, dtc, takes + as input a device-tree in a given format and outputs a device-tree in another + format for booting kernels on embedded systems. +endef + +define Package/dtc/config + config DTC_STATIC_BUILD + depends on PACKAGE_dtc + bool "Build dtc as static binary" + default n + help + Builds dtc as a static binary. + This is usefull in order to export live DTS from a device running + various vendor modified OpenWrt versions. +endef + +define Package/dtc/install + $(INSTALL_DIR) $(1)/usr/bin + $(CP) $(PKG_INSTALL_DIR)/usr/bin/dtc $(1)/usr/bin +endef + + +# See Documentation/manual.txt for details about each utility +define Package/fdt-utils + SECTION:=utils + CATEGORY:=Utilities + TITLE:=Flat Device Tree Utilities + URL:=https://git.kernel.org/pub/scm/utils/dtc/dtc.git + DEPENDS:=+libfdt +endef + +define Package/fdt-utils/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/convert-dtsv0 $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/fdtdump $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/fdtget $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/fdtput $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/fdtoverlay $(1)/usr/bin +endef + + +define Package/libfdt + SECTION:=libs + CATEGORY:=Libraries + TITLE:=a utility library for reading and manipulating dtb files + URL:=https://git.kernel.org/pub/scm/utils/dtc/dtc.git +endef + +define Package/libfdt/description + This is a library containing functions for manipulating Flat Device Trees. +endef + +define Package/libfdt/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libfdt*.so* $(1)/usr/lib +endef + +MESON_ARGS += \ + -Dtools=true \ + -Dyaml=disabled \ + -Dvalgrind=disabled \ + -Dpython=disabled \ + -Dstatic-build=$(if $(CONFIG_DTC_STATIC_BUILD),true,false) + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/lib + $(INSTALL_DIR) $(1)/usr/include + $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include + $(CP) $(PKG_INSTALL_DIR)/usr/lib/* $(1)/usr/lib +endef + +$(eval $(call BuildPackage,dtc)) +$(eval $(call BuildPackage,fdt-utils)) +$(eval $(call BuildPackage,libfdt)) diff --git a/package/utils/e2fsprogs/Makefile b/package/utils/e2fsprogs/Makefile index 3d64fab587d..2657077a16b 100644 --- a/package/utils/e2fsprogs/Makefile +++ b/package/utils/e2fsprogs/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=e2fsprogs -PKG_VERSION:=1.45.6 +PKG_VERSION:=1.47.0 PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@KERNEL/linux/kernel/people/tytso/e2fsprogs/v$(PKG_VERSION)/ -PKG_HASH:=ffa7ae6954395abdc50d0f8605d8be84736465afc53b8938ef473fcf7ff44256 +PKG_HASH:=144af53f2bbd921cef6f8bea88bb9faddca865da3fbc657cc9b4d2001097d5db PKG_LICENSE:=GPL-2.0 PKG_LICENSE_FILES:=NOTICE @@ -23,6 +23,7 @@ PKG_BUILD_DEPENDS:=util-linux e2fsprogs/host PKG_INSTALL:=1 PKG_BUILD_PARALLEL:=1 +PKG_BUILD_FLAGS:=gc-sections lto include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/host-build.mk @@ -142,10 +143,7 @@ $(call Package/e2fsprogs) DEPENDS:= +e2fsprogs endef -TARGET_CFLAGS += $(FPIC) -ffunction-sections -fdata-sections -flto - -TARGET_LDFLAGS += $(if $(CONFIG_USE_GLIBC),-lrt) -TARGET_LDFLAGS += -flto +TARGET_CFLAGS += $(FPIC) CONFIGURE_ARGS += \ --disable-testio-debug \ @@ -158,6 +156,10 @@ CONFIGURE_ARGS += \ --disable-rpath \ --disable-fuse2fs +ifneq ($(CONFIG_USE_MUSL),) + CONFIGURE_VARS += ac_cv_func_lseek64=yes +endif + define Build/Prepare $(call Build/Prepare/Default) $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(PKG_BUILD_DIR)/config/ @@ -172,7 +174,6 @@ define Build/Compile V=$(if $(findstring c,$(OPENWRT_VERBOSE)),1,) \ subst +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \ - LDFLAGS=-Wl,--gc-sections \ BUILDCC="$(HOSTCC)" \ DESTDIR="$(PKG_INSTALL_DIR)" \ ELF_OTHER_LIBS="$(TARGET_LDFLAGS) -luuid" \ @@ -266,7 +267,6 @@ endef define Package/tune2fs/install $(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/tune2fs $(1)/usr/sbin/ - $(LN) tune2fs $(1)/usr/sbin/findfs endef define Package/resize2fs/install diff --git a/package/utils/e2fsprogs/patches/001-com_err_version.patch b/package/utils/e2fsprogs/patches/001-com_err_version.patch index 62f1e08e71d..c80896344bd 100644 --- a/package/utils/e2fsprogs/patches/001-com_err_version.patch +++ b/package/utils/e2fsprogs/patches/001-com_err_version.patch @@ -1,6 +1,6 @@ --- a/lib/et/Makefile.in +++ b/lib/et/Makefile.in -@@ -25,8 +25,8 @@ SHARE_FILES= et_c.awk et_h.awk +@@ -26,8 +26,8 @@ SHARE_FILES= et_c.awk et_h.awk LIBRARY= libcom_err LIBDIR= et diff --git a/package/utils/e2fsprogs/patches/003-build-Add-SYSLIBS-to-e4crypt-linking.patch b/package/utils/e2fsprogs/patches/003-build-Add-SYSLIBS-to-e4crypt-linking.patch deleted file mode 100644 index dad71cf0b33..00000000000 --- a/package/utils/e2fsprogs/patches/003-build-Add-SYSLIBS-to-e4crypt-linking.patch +++ /dev/null @@ -1,28 +0,0 @@ -From e33ecf1595e390b2657018442c68ae824b3e13b4 Mon Sep 17 00:00:00 2001 -From: Hauke Mehrtens <hauke@hauke-m.de> -Date: Tue, 15 Dec 2020 23:58:53 +0100 -Subject: [PATCH e2fsprogs] build: Add SYSLIBS to e4crypt linking - -The $(SYSLIBS) was missing when linking the e4crypt application. This is -available in the e4crypt.profiled variant, so I assume this was just -missing in the normal variant and is not left out intentionally. - -This fixes building e2fsprogrs with -fsanitize=undefined in the global -CFLAGS nad LDFLAGS. - -Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> ---- - misc/Makefile.in | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- a/misc/Makefile.in -+++ b/misc/Makefile.in -@@ -242,7 +242,7 @@ e4defrag: $(E4DEFRAG_OBJS) $(DEPLIBS) - e4crypt: $(E4CRYPT_OBJS) $(DEPLIBS) $(DEPSTATIC_LIBUUID) - $(E) " LD $@" - $(Q) $(CC) $(ALL_LDFLAGS) -o e4crypt $(E4CRYPT_OBJS) \ -- $(LIBUUID) $(LIBS) -+ $(LIBUUID) $(LIBS) $(SYSLIBS) - - e4defrag.profiled: $(E4DEFRAG_OBJS) $(PROFILED_DEPLIBS) - $(E) " LD $@" diff --git a/package/utils/f2fs-tools/Makefile b/package/utils/f2fs-tools/Makefile index 0d243302c23..d5dc1a6d782 100644 --- a/package/utils/f2fs-tools/Makefile +++ b/package/utils/f2fs-tools/Makefile @@ -8,16 +8,17 @@ include $(TOPDIR)/rules.mk PKG_NAME:=f2fs-tools -PKG_VERSION:=1.14.0 -PKG_RELEASE:=1 +PKG_VERSION:=1.16.0 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs-tools.git/snapshot/ -PKG_HASH:=619263d4e2022152a1472c1d912eaae104f20bd227ce0bb9d41d1d6608094bd1 +PKG_HASH:=208c7a07e95383fbd7b466b5681590789dcb41f41bf197369c41a95383b57c5e PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> PKG_LICENSE:=GPL-2.0-only PKG_LICENSE_FILES:=COPYING +PKG_CPE_ID:=cpe:/a:f2fs-tools_project:f2fs-tools PKG_FIXUP:=autoreconf PKG_BUILD_PARALLEL:=1 @@ -85,6 +86,7 @@ define Package/libf2fs DEPENDS:=+libuuid ABI_VERSION:=6 CONFLICTS:=libf2fs-selinux + VARIANT:=default endef define Package/libf2fs-selinux @@ -93,11 +95,14 @@ define Package/libf2fs-selinux TITLE:=Library for Flash-Friendly File System (F2FS) tools with SELinux support DEPENDS:=+libuuid +libselinux ABI_VERSION:=6 + VARIANT:=selinux endef CONFIGURE_ARGS += \ --disable-static \ - --without-blkid + --without-blkid \ + --without-lzo2 \ + --without-lz4 ifneq ($(BUILD_VARIANT),selinux) CONFIGURE_ARGS += --without-selinux @@ -106,6 +111,10 @@ endif CONFIGURE_VARS += \ ac_cv_file__git=no +ifneq ($(CONFIG_USE_MUSL),) + CONFIGURE_VARS += ac_cv_func_lseek64=yes +endif + define Package/libf2fs/install $(INSTALL_DIR) $(1)/usr/lib $(CP) \ @@ -124,17 +133,16 @@ Package/mkf2fs-selinux/install = $(Package/mkf2fs/install) define Package/f2fsck/install $(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/fsck.f2fs $(1)/usr/sbin - ln -s /usr/sbin/fsck.f2fs $(1)/usr/sbin/defrag.f2fs - ln -s /usr/sbin/fsck.f2fs $(1)/usr/sbin/dump.f2fs - ln -s /usr/sbin/fsck.f2fs $(1)/usr/sbin/sload.f2fs - ln -s /usr/sbin/fsck.f2fs $(1)/usr/sbin/resize.f2fs + $(LN) ../sbin/fsck.f2fs $(1)/usr/sbin/defrag.f2fs + $(LN) ../sbin/fsck.f2fs $(1)/usr/sbin/dump.f2fs + $(LN) ../sbin/fsck.f2fs $(1)/usr/sbin/sload.f2fs + $(LN) ../sbin/fsck.f2fs $(1)/usr/sbin/resize.f2fs endef Package/f2fsck-selinux/install = $(Package/f2fsck/install) define Package/f2fs-tools/install $(INSTALL_DIR) $(1)/usr/sbin - $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/f2fstat $(1)/usr/sbin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/fibmap.f2fs $(1)/usr/sbin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/parse.f2fs $(1)/usr/sbin endef diff --git a/package/utils/firmware-utils/Makefile b/package/utils/firmware-utils/Makefile new file mode 100644 index 00000000000..5e5f57e5a07 --- /dev/null +++ b/package/utils/firmware-utils/Makefile @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: GPL-2.0-only + +include $(TOPDIR)/rules.mk + +PKG_NAME:=firmware-utils +PKG_RELEASE:=1 + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL=$(PROJECT_GIT)/project/firmware-utils.git +PKG_SOURCE_DATE:=2023-11-22 +PKG_SOURCE_VERSION:=d87b6c4b6423201e595459840f51d0dced04a4eb +PKG_MIRROR_HASH:=f34fbf4dc4bd13d18ea94e6e25090b57cde11b3dc7133e46f6ce3bb9164ab8fb + +PKG_BUILD_DEPENDS:=openssl zlib + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +define Package/default + SECTION:=utils + CATEGORY:=Base system + TITLE:=Firmware utility $(1) + DEPENDS:=$(2) +endef + +Package/oseama = $(call Package/default,oseama,@TARGET_bcm53xx) + +define Package/oseama/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/oseama $(1)/usr/bin/ +endef + +Package/otrx = $(call Package/default,otrx,@(TARGET_bcm47xx||TARGET_bcm53xx)) + +define Package/otrx/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/otrx $(1)/usr/bin/ +endef + +$(eval $(call BuildPackage,oseama)) +$(eval $(call BuildPackage,otrx)) diff --git a/package/utils/fitblk/Makefile b/package/utils/fitblk/Makefile new file mode 100644 index 00000000000..cb9e7ebb400 --- /dev/null +++ b/package/utils/fitblk/Makefile @@ -0,0 +1,41 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=fitblk +PKG_RELEASE:=1 +PKG_LICENSE:=GPL-2.0-only +PKG_MAINTAINER:=Daniel Golle <daniel@makrotopia.org> + +PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) + +PKG_FLAGS:=nonshared + +include $(INCLUDE_DIR)/package.mk + +define Package/fitblk + HIDDEN:=1 + SECTION:=base + CATEGORY:=Base system + TITLE:=fitblk firmware release tool + DEPENDS:=@LINUX_6_1 +endef + +define Package/fitblk/description +Release uImage.FIT block devices using ioctl. +endef + +define Build/Configure +endef + +define Build/Compile + $(MAKE) -C $(PKG_BUILD_DIR) \ + CC="$(TARGET_CC)" \ + CFLAGS="$(TARGET_CFLAGS) -Wall -Werror" \ + LDFLAGS="$(TARGET_LDFLAGS)" +endef + +define Package/fitblk/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/fitblk $(1)/usr/sbin/ +endef + +$(eval $(call BuildPackage,fitblk)) diff --git a/package/utils/fitblk/src/Makefile b/package/utils/fitblk/src/Makefile new file mode 100644 index 00000000000..064764c17d2 --- /dev/null +++ b/package/utils/fitblk/src/Makefile @@ -0,0 +1,7 @@ +all: fitblk + +fitblk: + $(CC) $(CFLAGS) -o $@ fitblk.c $(LDFLAGS) + +clean: + rm -f fitblk diff --git a/package/utils/fitblk/src/fitblk.c b/package/utils/fitblk/src/fitblk.c new file mode 100644 index 00000000000..059ba6098ce --- /dev/null +++ b/package/utils/fitblk/src/fitblk.c @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include <stdio.h> +#include <errno.h> +#include <fcntl.h> +#include <string.h> +#include <unistd.h> +#include <sys/ioctl.h> +#include <linux/fitblk.h> + +static int fitblk_release(char *device) +{ + int fd, ret; + + fd = open(device, O_RDONLY); + if (fd == -1) + return errno; + + ret = ioctl(fd, FITBLK_RELEASE, NULL); + close(fd); + + if (ret == -1) + return errno; + + return 0; +} + +int main(int argc, char *argp[]) +{ + int ret; + + if (argc != 2) { + fprintf(stderr, "Release uImage.FIT sub-image block device\n"); + fprintf(stderr, "Syntax: %s /dev/fitXXX\n", argp[0]); + return -EINVAL; + } + + ret = fitblk_release(argp[1]); + if (ret) + fprintf(stderr, "fitblk: error releasing %s: %s\n", argp[1], + strerror(ret)); + else + fprintf(stderr, "fitblk: %s released\n", argp[1]); + + return ret; +} diff --git a/package/utils/fritz-tools/Makefile b/package/utils/fritz-tools/Makefile index a4d69bdf719..6e20b56ff8a 100644 --- a/package/utils/fritz-tools/Makefile +++ b/package/utils/fritz-tools/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=fritz-tools -PKG_RELEASE:=1 +PKG_RELEASE:=2 CMAKE_INSTALL:=1 include $(INCLUDE_DIR)/package.mk diff --git a/package/utils/fritz-tools/src/fritz_cal_extract.c b/package/utils/fritz-tools/src/fritz_cal_extract.c index 8156dfd1a79..2978d86e0cc 100644 --- a/package/utils/fritz-tools/src/fritz_cal_extract.c +++ b/package/utils/fritz-tools/src/fritz_cal_extract.c @@ -210,7 +210,7 @@ int main(int argc, char **argv) if (argc > 1 && optind <= argc) { in = fopen(argv[optind], "r"); if (!in) { - perror("Failed to create output file"); + perror("Failed to open input file"); goto out_bad; } } @@ -253,7 +253,9 @@ out_bad: ret = EXIT_FAILURE; out: - fclose(in); - fclose(out); + if (in) + fclose(in); + if (out) + fclose(out); return ret; } diff --git a/package/utils/fritz-tools/src/fritz_tffs_nand_read.c b/package/utils/fritz-tools/src/fritz_tffs_nand_read.c index ded0577cf3f..05179bb423b 100644 --- a/package/utils/fritz-tools/src/fritz_tffs_nand_read.c +++ b/package/utils/fritz-tools/src/fritz_tffs_nand_read.c @@ -73,21 +73,18 @@ static uint8_t readbuf[TFFS_SECTOR_SIZE]; static uint8_t oobbuf[TFFS_SECTOR_OOB_SIZE]; static uint32_t blocksize; static int mtdfd; -struct tffs_sectors *sectors; - -struct tffs_sectors { - uint32_t num_sectors; - uint8_t sectors[0]; -}; +static uint32_t num_sectors; +static uint8_t *sectors; +static uint32_t *sector_ids; static inline void sector_mark_bad(int num) { - sectors->sectors[num / 8] &= ~(0x80 >> (num % 8)); + sectors[num / 8] &= ~(0x80 >> (num % 8)); }; static inline uint8_t sector_get_good(int num) { - return sectors->sectors[num / 8] & 0x80 >> (num % 8); + return sectors[num / 8] & 0x80 >> (num % 8); }; struct tffs_entry_segment { @@ -139,6 +136,8 @@ static int read_sector(off_t pos) return -1; } + sector_ids[pos / TFFS_SECTOR_SIZE] = read_uint32(readbuf, 0x00); + return 0; } @@ -176,25 +175,39 @@ static int find_entry(uint32_t id, struct tffs_entry *entry) off_t pos = 0; uint8_t block_end = 0; - for (uint32_t sector = 0; sector < sectors->num_sectors; sector++, pos += TFFS_SECTOR_SIZE) { + for (uint32_t sector = 0; sector < num_sectors; sector++, pos += TFFS_SECTOR_SIZE) { if (block_end) { if (pos % blocksize == 0) { block_end = 0; } } else if (sector_get_good(sector)) { + if (sector_ids[sector]) { + if (sector_ids[sector] == TFFS_ID_END) { + /* no more entries in this block */ + block_end = 1; + continue; + } + + if (sector_ids[sector] != id) + continue; + } + if (read_sectoroob(pos) || read_sector(pos)) { fprintf(stderr, "ERROR: sector isn't readable, but has been previously!\n"); exit(EXIT_FAILURE); } - uint32_t oob_id = read_uint32(oobbuf, 0x02); - uint32_t oob_len = read_uint32(oobbuf, 0x06); - uint32_t oob_rev = read_uint32(oobbuf, 0x0a); uint32_t read_id = read_uint32(readbuf, 0x00); uint32_t read_len = read_uint32(readbuf, 0x04); uint32_t read_rev = read_uint32(readbuf, 0x0c); - if (read_oob_sector_health && (oob_id != read_id || oob_len != read_len || oob_rev != read_rev)) { - fprintf(stderr, "Warning: sector has inconsistent metadata\n"); - continue; + if (read_oob_sector_health) { + uint32_t oob_id = read_uint32(oobbuf, 0x02); + uint32_t oob_len = read_uint32(oobbuf, 0x06); + uint32_t oob_rev = read_uint32(oobbuf, 0x0a); + + if (oob_id != read_id || oob_len != read_len || oob_rev != read_rev) { + fprintf(stderr, "Warning: sector has inconsistent metadata\n"); + continue; + } } if (read_id == TFFS_ID_END) { /* no more entries in this block */ @@ -340,7 +353,7 @@ static int show_matching_key_value(struct tffs_key_name_table *key_names) for (uint32_t i = 0; i < key_names->size; i++) { name = key_names->entries[i].val; - if (strncmp(name, name_filter, strlen(name)) == 0) { + if (strcmp(name, name_filter) == 0) { if (find_entry(key_names->entries[i].id, &tmp)) { print_entry_value(&tmp); printf("\n"); @@ -414,13 +427,14 @@ static int scan_mtd(void) blocksize = info.erasesize; - sectors = malloc(sizeof(*sectors) + (info.size / TFFS_SECTOR_SIZE + 7) / 8); - if (sectors == NULL) { + num_sectors = info.size / TFFS_SECTOR_SIZE; + sectors = malloc((num_sectors + 7) / 8); + sector_ids = calloc(num_sectors, sizeof(uint32_t)); + if (!sectors || !sector_ids) { fprintf(stderr, "ERROR: memory allocation failed!\n"); exit(EXIT_FAILURE); } - sectors->num_sectors = info.size / TFFS_SECTOR_SIZE; - memset(sectors->sectors, 0xff, (info.size / TFFS_SECTOR_SIZE + 7) / 8); + memset(sectors, 0xff, (num_sectors + 7) / 8); uint32_t sector = 0, valid_blocks = 0; uint8_t block_ok = 0; @@ -564,6 +578,7 @@ int main(int argc, char *argv[]) out_free_entry: free(name_table.val); out_free_sectors: + free(sector_ids); free(sectors); out_close: close(mtdfd); diff --git a/package/utils/fritz-tools/src/fritz_tffs_read.c b/package/utils/fritz-tools/src/fritz_tffs_read.c index d1b3038e63a..256c34c4142 100644 --- a/package/utils/fritz-tools/src/fritz_tffs_read.c +++ b/package/utils/fritz-tools/src/fritz_tffs_read.c @@ -204,7 +204,7 @@ static int show_matching_key_value(uint8_t *buffer, for (i = 0; i < key_names->size; i++) { name = key_names->entries[i].val; - if (strncmp(name, name_filter, strlen(name)) == 0) { + if (strcmp(name, name_filter) == 0) { id = to_entry_header_id(*key_names->entries[i].id); if (find_entry(buffer, id, &tmp)) { diff --git a/package/utils/jsonfilter/Makefile b/package/utils/jsonfilter/Makefile index 6b7557b38cf..fda66bbfb4b 100644 --- a/package/utils/jsonfilter/Makefile +++ b/package/utils/jsonfilter/Makefile @@ -5,9 +5,9 @@ PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/jsonpath.git -PKG_SOURCE_DATE:=2018-02-04 -PKG_SOURCE_VERSION:=c7e938d6582a436dddc938539e72dd1320625c54 -PKG_MIRROR_HASH:=0601b4d7aa5ee096e99388a57cb0701673ab58fccd6ed2984a2abbd4f846e045 +PKG_SOURCE_DATE:=2024-01-23 +PKG_SOURCE_VERSION:=594cfa86469c005972ba750614f5b3f1af84d0f6 +PKG_MIRROR_HASH:=70d2e0870b746920af4569631218c38c1dddfee4f5d029ec8ea0a67999bdafcd CMAKE_INSTALL:=1 PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io> @@ -21,7 +21,7 @@ define Package/jsonfilter CATEGORY:=Base system DEPENDS:=+libubox +libjson-c TITLE:=OpenWrt JSON filter utility - URL:=http://git.openwrt.org/?p=project/jsonpath.git + URL:=$(PKG_SOURCE_URL) endef define Package/jsonfilter/install diff --git a/package/utils/lua/Makefile b/package/utils/lua/Makefile index e15142d8d26..36d332f1c76 100644 --- a/package/utils/lua/Makefile +++ b/package/utils/lua/Makefile @@ -9,16 +9,19 @@ include $(TOPDIR)/rules.mk PKG_NAME:=lua PKG_VERSION:=5.1.5 -PKG_RELEASE:=9 +PKG_RELEASE:=11 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_SOURCE_URL:=http://www.lua.org/ftp/ \ - http://www.tecgraf.puc-rio.br/lua/ftp/ +PKG_SOURCE_URL:=https://www.lua.org/ftp/ \ + https://www.tecgraf.puc-rio.br/lua/ftp/ PKG_HASH:=2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333 PKG_BUILD_PARALLEL:=1 PKG_LICENSE:=MIT PKG_LICENSE_FILES:=COPYRIGHT +PKG_CPE_ID:=cpe:/a:lua:lua + +PKG_BUILD_FLAGS:=no-lto HOST_PATCH_DIR := ./patches-host @@ -30,7 +33,7 @@ define Package/lua/Default SECTION:=lang CATEGORY:=Languages TITLE:=Lua programming language - URL:=http://www.lua.org/ + URL:=https://www.lua.org/ MAINTAINER:=Jo-Philipp Wich <jo@mein.io> endef @@ -99,7 +102,7 @@ define Build/Compile RANLIB="$(TARGET_CROSS)ranlib" \ INSTALL_ROOT=/usr \ CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \ - MYLDFLAGS="$(TARGET_LDFLAGS) $(if $(CONFIG_USE_GLIBC),-lm -ldl)" \ + MYLDFLAGS="$(TARGET_LDFLAGS)" \ PKG_VERSION=$(PKG_VERSION) \ linux rm -rf $(PKG_INSTALL_DIR) @@ -125,7 +128,7 @@ endif define Host/Compile $(MAKE) -C $(HOST_BUILD_DIR) \ - CC="$(HOSTCC) -std=gnu99" \ + CC="$(HOSTCC) $(HOST_FPIC) -std=gnu99" \ $(LUA_OS) endef diff --git a/package/utils/lua/patches-host/001-include-version-number.patch b/package/utils/lua/patches-host/001-include-version-number.patch index f769e607367..806d37003ed 100644 --- a/package/utils/lua/patches-host/001-include-version-number.patch +++ b/package/utils/lua/patches-host/001-include-version-number.patch @@ -8,7 +8,6 @@ Including it allows multiple lua versions to coexist. Signed-off-by: Rafał Miłecki <rafal@milecki.pl> --- -diff --git a/Makefile b/Makefile --- a/Makefile +++ b/Makefile @@ -41,10 +41,10 @@ RANLIB= ranlib @@ -42,7 +41,7 @@ rename to doc/luac5.1.1 diff --git a/src/Makefile b/src/Makefile --- a/src/Makefile +++ b/src/Makefile -@@ -29,10 +29,10 @@ CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \ +@@ -29,10 +29,10 @@ CORE_O= lapi.o lcode.o ldebug.o ldo.o ld LIB_O= lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o \ lstrlib.o loadlib.o linit.o diff --git a/package/utils/lua/patches-host/010-lua-5.1.3-lnum-full-260308.patch b/package/utils/lua/patches-host/010-lua-5.1.3-lnum-full-260308.patch index 4530edd1812..fd398c28d11 100644 --- a/package/utils/lua/patches-host/010-lua-5.1.3-lnum-full-260308.patch +++ b/package/utils/lua/patches-host/010-lua-5.1.3-lnum-full-260308.patch @@ -1600,18 +1600,18 @@ + * (and doing them). + */ +int try_addint( lua_Integer *r, lua_Integer ib, lua_Integer ic ) { -+ lua_Integer v= ib+ic; /* may overflow */ -+ if (ib>0 && ic>0) { if (v < 0) return 0; /*overflow, use floats*/ } -+ else if (ib<0 && ic<0) { if (v >= 0) return 0; } -+ *r= v; ++ /* Signed int overflow is undefined behavior, so catch it without causing it. */ ++ if (ic>0) { if (ib > LUA_INTEGER_MAX - ic) return 0; /*overflow, use floats*/ } ++ else { if (ib < LUA_INTEGER_MIN - ic) return 0; } ++ *r = ib + ic; + return 1; +} + +int try_subint( lua_Integer *r, lua_Integer ib, lua_Integer ic ) { -+ lua_Integer v= ib-ic; /* may overflow */ -+ if (ib>=0 && ic<0) { if (v < 0) return 0; /*overflow, use floats*/ } -+ else if (ib<0 && ic>0) { if (v >= 0) return 0; } -+ *r= v; ++ /* Signed int overflow is undefined behavior, so catch it without causing it. */ ++ if (ic>0) { if (ib < LUA_INTEGER_MIN + ic) return 0; /*overflow, use floats*/ } ++ else { if (ib > LUA_INTEGER_MAX + ic) return 0; } ++ *r = ib - ic; + return 1; +} + diff --git a/package/utils/lua/patches-host/013-lnum-strtoul-parsing-fixes.patch b/package/utils/lua/patches-host/013-lnum-strtoul-parsing-fixes.patch index 7f00c8c3a2d..8887229589d 100644 --- a/package/utils/lua/patches-host/013-lnum-strtoul-parsing-fixes.patch +++ b/package/utils/lua/patches-host/013-lnum-strtoul-parsing-fixes.patch @@ -1,8 +1,6 @@ -diff --git a/src/lnum.c b/src/lnum.c -index 1456b6a2ed23..b0632b04c2b7 100644 --- a/src/lnum.c +++ b/src/lnum.c -@@ -127,6 +127,8 @@ static int luaO_str2i (const char *s, lua_Integer *res, char **endptr_ref) { +@@ -127,6 +127,8 @@ static int luaO_str2i (const char *s, lu #else return 0; /* Reject the number */ #endif @@ -11,7 +9,7 @@ index 1456b6a2ed23..b0632b04c2b7 100644 } } else if ((v > LUA_INTEGER_MAX) || (*endptr && (!isspace(*endptr)))) { return TK_NUMBER; /* not in signed range, or has '.', 'e' etc. trailing */ -@@ -310,3 +312,13 @@ int try_unmint( lua_Integer *r, lua_Integer ib ) { +@@ -310,3 +312,13 @@ int try_unmint( lua_Integer *r, lua_Inte return 0; } @@ -25,8 +23,6 @@ index 1456b6a2ed23..b0632b04c2b7 100644 + return (unsigned LUA_INTEGER)v; +} +#endif -diff --git a/src/lnum_config.h b/src/lnum_config.h -index 19d7a4231a49..1092eead6629 100644 --- a/src/lnum_config.h +++ b/src/lnum_config.h @@ -141,7 +141,12 @@ @@ -43,6 +39,3 @@ index 19d7a4231a49..1092eead6629 100644 #endif #ifndef LUA_INTEGER_MIN # define LUA_INTEGER_MIN (-LUA_INTEGER_MAX -1) /* -2^16|32 */ --- -1.9.1 - diff --git a/package/utils/lua/patches-host/100-no_readline.patch b/package/utils/lua/patches-host/100-no_readline.patch index 209c302bb72..700114e43cd 100644 --- a/package/utils/lua/patches-host/100-no_readline.patch +++ b/package/utils/lua/patches-host/100-no_readline.patch @@ -10,7 +10,7 @@ #if defined(LUA_USE_MACOSX) --- a/src/Makefile +++ b/src/Makefile -@@ -17,6 +17,7 @@ +@@ -17,6 +17,7 @@ LIBS= -lm $(MYLIBS) MYCFLAGS= MYLDFLAGS= MYLIBS= @@ -18,7 +18,7 @@ # == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE ========= -@@ -75,7 +76,7 @@ +@@ -75,7 +76,7 @@ echo: @echo "MYLIBS = $(MYLIBS)" # convenience targets for popular platforms @@ -27,7 +27,7 @@ none: @echo "Please choose a platform:" @echo " $(PLATS)" -@@ -90,16 +91,16 @@ +@@ -90,16 +91,16 @@ bsd: $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-Wl,-E" freebsd: diff --git a/package/utils/lua/patches-host/400-CVE-2014-5461.patch b/package/utils/lua/patches-host/400-CVE-2014-5461.patch new file mode 100644 index 00000000000..cce73ff96bd --- /dev/null +++ b/package/utils/lua/patches-host/400-CVE-2014-5461.patch @@ -0,0 +1,19 @@ +From: Enrico Tassi <gareuselesinge@debian.org> +Date: Tue, 26 Aug 2014 16:20:55 +0200 +Subject: Fix stack overflow in vararg functions + +--- + src/ldo.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/src/ldo.c ++++ b/src/ldo.c +@@ -274,7 +274,7 @@ int luaD_precall (lua_State *L, StkId fu + CallInfo *ci; + StkId st, base; + Proto *p = cl->p; +- luaD_checkstack(L, p->maxstacksize); ++ luaD_checkstack(L, p->maxstacksize + p->numparams); + func = restorestack(L, funcr); + if (!p->is_vararg) { /* no varargs? */ + base = func + 1; diff --git a/package/utils/lua/patches/001-include-version-number.patch b/package/utils/lua/patches/001-include-version-number.patch index f769e607367..806d37003ed 100644 --- a/package/utils/lua/patches/001-include-version-number.patch +++ b/package/utils/lua/patches/001-include-version-number.patch @@ -8,7 +8,6 @@ Including it allows multiple lua versions to coexist. Signed-off-by: Rafał Miłecki <rafal@milecki.pl> --- -diff --git a/Makefile b/Makefile --- a/Makefile +++ b/Makefile @@ -41,10 +41,10 @@ RANLIB= ranlib @@ -42,7 +41,7 @@ rename to doc/luac5.1.1 diff --git a/src/Makefile b/src/Makefile --- a/src/Makefile +++ b/src/Makefile -@@ -29,10 +29,10 @@ CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \ +@@ -29,10 +29,10 @@ CORE_O= lapi.o lcode.o ldebug.o ldo.o ld LIB_O= lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o \ lstrlib.o loadlib.o linit.o diff --git a/package/utils/lua/patches/010-lua-5.1.3-lnum-full-260308.patch b/package/utils/lua/patches/010-lua-5.1.3-lnum-full-260308.patch index ac0722c7073..58cc894e1c8 100644 --- a/package/utils/lua/patches/010-lua-5.1.3-lnum-full-260308.patch +++ b/package/utils/lua/patches/010-lua-5.1.3-lnum-full-260308.patch @@ -1589,18 +1589,18 @@ + * (and doing them). + */ +int try_addint( lua_Integer *r, lua_Integer ib, lua_Integer ic ) { -+ lua_Integer v= ib+ic; /* may overflow */ -+ if (ib>0 && ic>0) { if (v < 0) return 0; /*overflow, use floats*/ } -+ else if (ib<0 && ic<0) { if (v >= 0) return 0; } -+ *r= v; ++ /* Signed int overflow is undefined behavior, so catch it without causing it. */ ++ if (ic>0) { if (ib > LUA_INTEGER_MAX - ic) return 0; /*overflow, use floats*/ } ++ else { if (ib < LUA_INTEGER_MIN - ic) return 0; } ++ *r = ib + ic; + return 1; +} + +int try_subint( lua_Integer *r, lua_Integer ib, lua_Integer ic ) { -+ lua_Integer v= ib-ic; /* may overflow */ -+ if (ib>=0 && ic<0) { if (v < 0) return 0; /*overflow, use floats*/ } -+ else if (ib<0 && ic>0) { if (v >= 0) return 0; } -+ *r= v; ++ /* Signed int overflow is undefined behavior, so catch it without causing it. */ ++ if (ic>0) { if (ib < LUA_INTEGER_MIN + ic) return 0; /*overflow, use floats*/ } ++ else { if (ib > LUA_INTEGER_MAX + ic) return 0; } ++ *r = ib - ic; + return 1; +} + diff --git a/package/utils/lua/patches/013-lnum-strtoul-parsing-fixes.patch b/package/utils/lua/patches/013-lnum-strtoul-parsing-fixes.patch index 7f00c8c3a2d..8887229589d 100644 --- a/package/utils/lua/patches/013-lnum-strtoul-parsing-fixes.patch +++ b/package/utils/lua/patches/013-lnum-strtoul-parsing-fixes.patch @@ -1,8 +1,6 @@ -diff --git a/src/lnum.c b/src/lnum.c -index 1456b6a2ed23..b0632b04c2b7 100644 --- a/src/lnum.c +++ b/src/lnum.c -@@ -127,6 +127,8 @@ static int luaO_str2i (const char *s, lua_Integer *res, char **endptr_ref) { +@@ -127,6 +127,8 @@ static int luaO_str2i (const char *s, lu #else return 0; /* Reject the number */ #endif @@ -11,7 +9,7 @@ index 1456b6a2ed23..b0632b04c2b7 100644 } } else if ((v > LUA_INTEGER_MAX) || (*endptr && (!isspace(*endptr)))) { return TK_NUMBER; /* not in signed range, or has '.', 'e' etc. trailing */ -@@ -310,3 +312,13 @@ int try_unmint( lua_Integer *r, lua_Integer ib ) { +@@ -310,3 +312,13 @@ int try_unmint( lua_Integer *r, lua_Inte return 0; } @@ -25,8 +23,6 @@ index 1456b6a2ed23..b0632b04c2b7 100644 + return (unsigned LUA_INTEGER)v; +} +#endif -diff --git a/src/lnum_config.h b/src/lnum_config.h -index 19d7a4231a49..1092eead6629 100644 --- a/src/lnum_config.h +++ b/src/lnum_config.h @@ -141,7 +141,12 @@ @@ -43,6 +39,3 @@ index 19d7a4231a49..1092eead6629 100644 #endif #ifndef LUA_INTEGER_MIN # define LUA_INTEGER_MIN (-LUA_INTEGER_MAX -1) /* -2^16|32 */ --- -1.9.1 - diff --git a/package/utils/lua/patches/400-CVE-2014-5461.patch b/package/utils/lua/patches/400-CVE-2014-5461.patch new file mode 100644 index 00000000000..cce73ff96bd --- /dev/null +++ b/package/utils/lua/patches/400-CVE-2014-5461.patch @@ -0,0 +1,19 @@ +From: Enrico Tassi <gareuselesinge@debian.org> +Date: Tue, 26 Aug 2014 16:20:55 +0200 +Subject: Fix stack overflow in vararg functions + +--- + src/ldo.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/src/ldo.c ++++ b/src/ldo.c +@@ -274,7 +274,7 @@ int luaD_precall (lua_State *L, StkId fu + CallInfo *ci; + StkId st, base; + Proto *p = cl->p; +- luaD_checkstack(L, p->maxstacksize); ++ luaD_checkstack(L, p->maxstacksize + p->numparams); + func = restorestack(L, funcr); + if (!p->is_vararg) { /* no varargs? */ + base = func + 1; diff --git a/package/utils/lua5.3/Makefile b/package/utils/lua5.3/Makefile index c9e9bebb1ac..405fa901455 100644 --- a/package/utils/lua5.3/Makefile +++ b/package/utils/lua5.3/Makefile @@ -9,16 +9,17 @@ include $(TOPDIR)/rules.mk PKG_NAME:=lua PKG_VERSION:=5.3.5 -PKG_RELEASE:=4 +PKG_RELEASE:=6 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_SOURCE_URL:=http://www.lua.org/ftp/ \ - http://www.tecgraf.puc-rio.br/lua/ftp/ +PKG_SOURCE_URL:=https://www.lua.org/ftp/ \ + https://www.tecgraf.puc-rio.br/lua/ftp/ PKG_HASH:=0c2eed3f960446e1a3e4b9a1ca2f3ff893b6ce41942cf54d5dd59ab4b3b058ac PKG_BUILD_PARALLEL:=1 PKG_LICENSE:=MIT PKG_LICENSE_FILES:=COPYRIGHT +PKG_CPE_ID:=cpe:/a:lua:lua HOST_PATCH_DIR := ./patches-host @@ -29,8 +30,8 @@ define Package/lua5.3/Default SUBMENU:=Lua SECTION:=lang CATEGORY:=Languages - TITLE:=Lua programming language - URL:=http://www.lua.org/ + TITLE:=Lua programming language (version 5.3) + URL:=https://www.lua.org/ MAINTAINER:=Jo-Philipp Wich <jo@mein.io> endef @@ -41,7 +42,7 @@ define Package/lua5.3/Default/description endef define Package/liblua5.3 -$(call Package/lua53/Default) +$(call Package/lua5.3/Default) SUBMENU:= SECTION:=libs CATEGORY:=Libraries @@ -50,7 +51,7 @@ $(call Package/lua53/Default) endef define Package/liblua5.3/description -$(call Package/lua53/Default/description) +$(call Package/lua5.3/Default/description) This package contains the Lua shared libraries, needed by other programs. endef @@ -110,7 +111,7 @@ endif define Host/Compile $(MAKE) -C $(HOST_BUILD_DIR) \ - CC="$(HOSTCC) -std=gnu99" \ + CC="$(HOSTCC) $(HOST_FPIC) -std=gnu99" \ $(LUA_OS) endef diff --git a/package/utils/lua5.3/patches-host/001-include-version-number.patch b/package/utils/lua5.3/patches-host/001-include-version-number.patch index 78f00549607..1c9fdb250b5 100644 --- a/package/utils/lua5.3/patches-host/001-include-version-number.patch +++ b/package/utils/lua5.3/patches-host/001-include-version-number.patch @@ -8,7 +8,6 @@ Including it allows multiple lua versions to coexist. Signed-off-by: Rafał Miłecki <rafal@milecki.pl> --- -diff --git a/Makefile b/Makefile --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ PLAT= none diff --git a/package/utils/lua5.3/patches-host/200-CVE-2019-6706.patch b/package/utils/lua5.3/patches-host/200-CVE-2019-6706.patch new file mode 100644 index 00000000000..8024d414cc8 --- /dev/null +++ b/package/utils/lua5.3/patches-host/200-CVE-2019-6706.patch @@ -0,0 +1,51 @@ +From 89aee84cbc9224f638f3b7951b306d2ee8ecb71e Mon Sep 17 00:00:00 2001 +From: Roberto Ierusalimschy <roberto@inf.puc-rio.br> +Date: Wed, 27 Mar 2019 14:30:12 -0300 +Subject: [PATCH] Fixed bug in 'lua_upvaluejoin' + +Bug-fix: joining an upvalue with itself could cause a use-after-free +crash. +--- + src/lapi.c | 12 +++++------ + 1 file changed, 41 insertions(+), 39 deletions(-) + +--- a/src/lapi.c ++++ b/src/lapi.c +@@ -1254,13 +1254,12 @@ LUA_API const char *lua_setupvalue (lua_ + } + + +-static UpVal **getupvalref (lua_State *L, int fidx, int n, LClosure **pf) { ++static UpVal **getupvalref (lua_State *L, int fidx, int n) { + LClosure *f; + StkId fi = index2addr(L, fidx); + api_check(L, ttisLclosure(fi), "Lua function expected"); + f = clLvalue(fi); + api_check(L, (1 <= n && n <= f->p->sizeupvalues), "invalid upvalue index"); +- if (pf) *pf = f; + return &f->upvals[n - 1]; /* get its upvalue pointer */ + } + +@@ -1269,7 +1268,7 @@ LUA_API void *lua_upvalueid (lua_State * + StkId fi = index2addr(L, fidx); + switch (ttype(fi)) { + case LUA_TLCL: { /* lua closure */ +- return *getupvalref(L, fidx, n, NULL); ++ return *getupvalref(L, fidx, n); + } + case LUA_TCCL: { /* C closure */ + CClosure *f = clCvalue(fi); +@@ -1286,9 +1285,10 @@ LUA_API void *lua_upvalueid (lua_State * + + LUA_API void lua_upvaluejoin (lua_State *L, int fidx1, int n1, + int fidx2, int n2) { +- LClosure *f1; +- UpVal **up1 = getupvalref(L, fidx1, n1, &f1); +- UpVal **up2 = getupvalref(L, fidx2, n2, NULL); ++ UpVal **up1 = getupvalref(L, fidx1, n1); ++ UpVal **up2 = getupvalref(L, fidx2, n2); ++ if (*up1 == *up2) ++ return; + luaC_upvdeccount(L, *up1); + *up1 = *up2; + (*up1)->refcount++; diff --git a/package/utils/lua5.3/patches/001-include-version-number.patch b/package/utils/lua5.3/patches/001-include-version-number.patch index 78f00549607..1c9fdb250b5 100644 --- a/package/utils/lua5.3/patches/001-include-version-number.patch +++ b/package/utils/lua5.3/patches/001-include-version-number.patch @@ -8,7 +8,6 @@ Including it allows multiple lua versions to coexist. Signed-off-by: Rafał Miłecki <rafal@milecki.pl> --- -diff --git a/Makefile b/Makefile --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ PLAT= none diff --git a/package/utils/lua5.3/patches/020-shared_liblua.patch b/package/utils/lua5.3/patches/020-shared_liblua.patch index 7fa9652290b..a462fa4f1e3 100644 --- a/package/utils/lua5.3/patches/020-shared_liblua.patch +++ b/package/utils/lua5.3/patches/020-shared_liblua.patch @@ -1,5 +1,5 @@ ---- a/Makefile 2019-07-02 09:24:57.554332875 -0600 -+++ b/Makefile 2019-07-02 09:25:42.626694604 -0600 +--- a/Makefile ++++ b/Makefile @@ -41,7 +41,7 @@ PLATS= aix bsd c89 freebsd generic linux # What to install. TO_BIN= lua$V luac$V @@ -19,8 +19,8 @@ cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN) uninstall: ---- a/src/ldo.h 2017-04-19 11:20:42.000000000 -0600 -+++ b/src/ldo.h 2019-07-02 09:25:42.626694604 -0600 +--- a/src/ldo.h ++++ b/src/ldo.h @@ -47,8 +47,8 @@ LUAI_FUNC int luaD_pcall (lua_State *L, LUAI_FUNC int luaD_poscall (lua_State *L, CallInfo *ci, StkId firstResult, int nres); @@ -32,8 +32,8 @@ LUAI_FUNC void luaD_inctop (lua_State *L); LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode); ---- a/src/lfunc.h 2017-04-19 11:39:34.000000000 -0600 -+++ b/src/lfunc.h 2019-07-02 09:25:42.630694635 -0600 +--- a/src/lfunc.h ++++ b/src/lfunc.h @@ -47,14 +47,14 @@ struct UpVal { #define upisopen(up) ((up)->v != &(up)->u.value) @@ -55,8 +55,8 @@ int pc); ---- a/src/lgc.h 2017-04-19 11:39:34.000000000 -0600 -+++ b/src/lgc.h 2019-07-02 09:25:42.634694666 -0600 +--- a/src/lgc.h ++++ b/src/lgc.h @@ -133,11 +133,11 @@ LUAI_FUNC void luaC_fix (lua_State *L, GCObject *o); @@ -71,8 +71,8 @@ LUAI_FUNC void luaC_barrierback_ (lua_State *L, Table *o); LUAI_FUNC void luaC_upvalbarrier_ (lua_State *L, UpVal *uv); LUAI_FUNC void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt); ---- a/src/llex.h 2017-04-19 11:20:42.000000000 -0600 -+++ b/src/llex.h 2019-07-02 09:25:42.630694635 -0600 +--- a/src/llex.h ++++ b/src/llex.h @@ -73,13 +73,13 @@ typedef struct LexState { @@ -92,8 +92,8 @@ #endif ---- a/src/lmem.h 2017-04-19 11:20:42.000000000 -0600 -+++ b/src/lmem.h 2019-07-02 09:25:42.630694635 -0600 +--- a/src/lmem.h ++++ b/src/lmem.h @@ -56,12 +56,12 @@ #define luaM_reallocvector(L, v,oldn,n,t) \ ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) @@ -110,8 +110,8 @@ size_t size_elem, int limit, const char *what); ---- a/src/lobject.h 2017-04-19 11:39:34.000000000 -0600 -+++ b/src/lobject.h 2019-07-02 09:25:42.630694635 -0600 +--- a/src/lobject.h ++++ b/src/lobject.h @@ -525,7 +525,7 @@ typedef struct Table { #define luaO_nilobject (&luaO_nilobject_) @@ -141,8 +141,8 @@ #endif ---- a/src/lopcodes.h 2017-04-19 11:20:42.000000000 -0600 -+++ b/src/lopcodes.h 2019-07-02 09:25:42.630694635 -0600 +--- a/src/lopcodes.h ++++ b/src/lopcodes.h @@ -278,7 +278,7 @@ enum OpArgMask { OpArgK /* argument is a constant or register/constant */ }; @@ -161,8 +161,8 @@ /* number of list items to accumulate before a SETLIST instruction */ ---- a/src/lstate.h 2017-04-19 11:39:34.000000000 -0600 -+++ b/src/lstate.h 2019-07-02 09:25:42.630694635 -0600 +--- a/src/lstate.h ++++ b/src/lstate.h @@ -244,9 +244,9 @@ union GCUnion { LUAI_FUNC void luaE_setdebt (global_State *g, l_mem debt); @@ -176,8 +176,8 @@ #endif ---- a/src/lstring.h 2017-04-19 11:20:42.000000000 -0600 -+++ b/src/lstring.h 2019-07-02 09:25:42.630694635 -0600 +--- a/src/lstring.h ++++ b/src/lstring.h @@ -35,15 +35,15 @@ LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); @@ -198,8 +198,8 @@ #endif ---- a/src/ltable.h 2018-05-24 13:39:05.000000000 -0600 -+++ b/src/ltable.h 2019-07-02 09:25:42.630694635 -0600 +--- a/src/ltable.h ++++ b/src/ltable.h @@ -41,14 +41,14 @@ @@ -218,8 +218,8 @@ LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize, unsigned int nhsize); LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize); ---- a/src/ltm.h 2017-04-19 11:20:42.000000000 -0600 -+++ b/src/ltm.h 2019-07-02 09:25:42.634694666 -0600 +--- a/src/ltm.h ++++ b/src/ltm.h @@ -55,10 +55,10 @@ typedef enum { LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS]; @@ -245,8 +245,8 @@ const TValue *p2, TMS event); ---- a/src/lundump.h 2017-04-19 11:20:42.000000000 -0600 -+++ b/src/lundump.h 2019-07-02 09:25:42.634694666 -0600 +--- a/src/lundump.h ++++ b/src/lundump.h @@ -23,10 +23,10 @@ #define LUAC_FORMAT 0 /* this is the official format */ @@ -260,8 +260,8 @@ void* data, int strip); #endif ---- a/src/lzio.h 2017-04-19 11:20:42.000000000 -0600 -+++ b/src/lzio.h 2019-07-02 09:25:42.634694666 -0600 +--- a/src/lzio.h ++++ b/src/lzio.h @@ -61,6 +61,6 @@ struct Zio { }; @@ -270,8 +270,8 @@ +LUA_API int luaZ_fill (ZIO *z); #endif ---- a/src/Makefile 2019-07-02 09:24:57.554332875 -0600 -+++ b/src/Makefile 2019-07-02 09:25:42.630694635 -0600 +--- a/src/Makefile ++++ b/src/Makefile @@ -29,6 +29,7 @@ MYOBJS= PLATS= aix bsd c89 freebsd generic linux macosx mingw posix solaris diff --git a/package/utils/lua5.3/patches/200-CVE-2019-6706.patch b/package/utils/lua5.3/patches/200-CVE-2019-6706.patch new file mode 100644 index 00000000000..8024d414cc8 --- /dev/null +++ b/package/utils/lua5.3/patches/200-CVE-2019-6706.patch @@ -0,0 +1,51 @@ +From 89aee84cbc9224f638f3b7951b306d2ee8ecb71e Mon Sep 17 00:00:00 2001 +From: Roberto Ierusalimschy <roberto@inf.puc-rio.br> +Date: Wed, 27 Mar 2019 14:30:12 -0300 +Subject: [PATCH] Fixed bug in 'lua_upvaluejoin' + +Bug-fix: joining an upvalue with itself could cause a use-after-free +crash. +--- + src/lapi.c | 12 +++++------ + 1 file changed, 41 insertions(+), 39 deletions(-) + +--- a/src/lapi.c ++++ b/src/lapi.c +@@ -1254,13 +1254,12 @@ LUA_API const char *lua_setupvalue (lua_ + } + + +-static UpVal **getupvalref (lua_State *L, int fidx, int n, LClosure **pf) { ++static UpVal **getupvalref (lua_State *L, int fidx, int n) { + LClosure *f; + StkId fi = index2addr(L, fidx); + api_check(L, ttisLclosure(fi), "Lua function expected"); + f = clLvalue(fi); + api_check(L, (1 <= n && n <= f->p->sizeupvalues), "invalid upvalue index"); +- if (pf) *pf = f; + return &f->upvals[n - 1]; /* get its upvalue pointer */ + } + +@@ -1269,7 +1268,7 @@ LUA_API void *lua_upvalueid (lua_State * + StkId fi = index2addr(L, fidx); + switch (ttype(fi)) { + case LUA_TLCL: { /* lua closure */ +- return *getupvalref(L, fidx, n, NULL); ++ return *getupvalref(L, fidx, n); + } + case LUA_TCCL: { /* C closure */ + CClosure *f = clCvalue(fi); +@@ -1286,9 +1285,10 @@ LUA_API void *lua_upvalueid (lua_State * + + LUA_API void lua_upvaluejoin (lua_State *L, int fidx1, int n1, + int fidx2, int n2) { +- LClosure *f1; +- UpVal **up1 = getupvalref(L, fidx1, n1, &f1); +- UpVal **up2 = getupvalref(L, fidx2, n2, NULL); ++ UpVal **up1 = getupvalref(L, fidx1, n1); ++ UpVal **up2 = getupvalref(L, fidx2, n2); ++ if (*up1 == *up2) ++ return; + luaC_upvdeccount(L, *up1); + *up1 = *up2; + (*up1)->refcount++; diff --git a/package/utils/mdadm/Makefile b/package/utils/mdadm/Makefile index f20a58b7046..8070003394f 100644 --- a/package/utils/mdadm/Makefile +++ b/package/utils/mdadm/Makefile @@ -8,17 +8,18 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mdadm -PKG_VERSION:=4.1 +PKG_VERSION:=4.2 PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@KERNEL/linux/utils/raid/mdadm -PKG_HASH:=ab7688842908d3583a704d491956f31324c3a5fc9f6a04653cb75d19f1934f4a +PKG_HASH:=461c215670864bb74a4d1a3620684aa2b2f8296dffa06743f26dda5557acf01d PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> PKG_CPE_ID:=cpe:/a:mdadm_project:mdadm PKG_BUILD_PARALLEL:=1 +PKG_BUILD_FLAGS:=gc-sections include $(INCLUDE_DIR)/package.mk @@ -43,16 +44,19 @@ define Package/mdadm/conffiles endef TARGET_CFLAGS += \ - -ffunction-sections -fdata-sections \ -DHAVE_STDINT_H -DNO_COROSYNC -DNO_DLM -DUSE_PTHREADS \ -DCONFFILE='\"/var/etc/mdadm.conf\"' \ -DMAP_DIR='\"/var/run/mdadm\"' \ -DMDMON_DIR='\"/var/run/mdadm\"' \ - -DFAILED_SLOTS_DIR='\"/var/run/mdadm/failed-slots\"' + -DFAILED_SLOTS_DIR='\"/var/run/mdadm/failed-slots\"' \ + -DNO_LIBUDEV \ + -D_LARGEFILE64_SOURCE -TARGET_LDFLAGS += -Wl,--gc-sections +TARGET_CXFLAGS = -DNO_LIBUDEV -MAKE_VARS += CHECK_RUN_DIR=0 +MAKE_FLAGS += \ + CHECK_RUN_DIR=0 \ + CXFLAGS="$(TARGET_CXFLAGS)" define Build/Compile $(call Build/Compile/Default,mdadm) diff --git a/package/utils/mdadm/patches/100-cross_compile.patch b/package/utils/mdadm/patches/100-cross_compile.patch index 0a5fa017c6d..790d7755b08 100644 --- a/package/utils/mdadm/patches/100-cross_compile.patch +++ b/package/utils/mdadm/patches/100-cross_compile.patch @@ -1,6 +1,6 @@ --- a/Makefile +++ b/Makefile -@@ -97,7 +97,7 @@ DLM:=$(shell [ -f /usr/include/libdlm.h +@@ -99,7 +99,7 @@ DLM:=$(shell [ -f /usr/include/libdlm.h DIRFLAGS = -DMAP_DIR=\"$(MAP_DIR)\" -DMAP_FILE=\"$(MAP_FILE)\" DIRFLAGS += -DMDMON_DIR=\"$(MDMON_DIR)\" DIRFLAGS += -DFAILED_SLOTS_DIR=\"$(FAILED_SLOTS_DIR)\" diff --git a/package/utils/mdadm/patches/101-mdadm.h-Undefine-dprintf-before-redefining.patch b/package/utils/mdadm/patches/101-mdadm.h-Undefine-dprintf-before-redefining.patch deleted file mode 100644 index 356d0deec84..00000000000 --- a/package/utils/mdadm/patches/101-mdadm.h-Undefine-dprintf-before-redefining.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 6d369e8f226594632ce4260129509daf7030de0a Mon Sep 17 00:00:00 2001 -From: Khem Raj <raj.khem@gmail.com> -Date: Mon, 9 May 2016 22:03:57 +0000 -Subject: [PATCH] mdadm.h: Undefine dprintf before redefining - -dprintf is also defined in libc see -usr/include/bits/stdio2.h, this comes into -play especially when fortify sources is enabled -and compilers like clang reports the override - -In file included from policy.c:25: -./mdadm.h:1562:9: error: 'dprintf' macro redefined [-Werror,-Wmacro-redefined] - ^ -/mnt/oe/openembedded-core/build/tmp-glibc/sysroots/qemux86/usr/include/bits/stdio2.h:145:12: note: previous definition is here - -Signed-off-by: Khem Raj <raj.khem@gmail.com> ---- -Upstream-Status: Pending - - mdadm.h | 2 ++ - 1 file changed, 2 insertions(+) - ---- a/mdadm.h -+++ b/mdadm.h -@@ -1649,11 +1649,13 @@ static inline char *to_subarray(struct m - } - - #ifdef DEBUG -+#undef dprintf - #define dprintf(fmt, arg...) \ - fprintf(stderr, "%s: %s: "fmt, Name, __func__, ##arg) - #define dprintf_cont(fmt, arg...) \ - fprintf(stderr, fmt, ##arg) - #else -+#undef dprintf - #define dprintf(fmt, arg...) \ - ({ if (0) fprintf(stderr, "%s: %s: " fmt, Name, __func__, ##arg); 0; }) - #define dprintf_cont(fmt, arg...) \ diff --git a/package/utils/mdadm/patches/102-Add-missing-include-file-sys-sysmacros.h.patch b/package/utils/mdadm/patches/102-Add-missing-include-file-sys-sysmacros.h.patch deleted file mode 100644 index 891b5c62f03..00000000000 --- a/package/utils/mdadm/patches/102-Add-missing-include-file-sys-sysmacros.h.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 452dc4d13a012cdcb05088c0dbc699959c4d6c73 Mon Sep 17 00:00:00 2001 -From: Baruch Siach <baruch@tkos.co.il> -Date: Tue, 6 Aug 2019 16:05:23 +0300 -Subject: mdadm.h: include sysmacros.h unconditionally - -musl libc now also requires sys/sysmacros.h for the major/minor macros. -All supported libc implementations carry sys/sysmacros.h, including -diet-libc, klibc, and uclibc-ng. - -Cc: Hauke Mehrtens <hauke@hauke-m.de> -Signed-off-by: Baruch Siach <baruch@tkos.co.il> -Signed-off-by: Jes Sorensen <jsorensen@fb.com> ---- - mdadm.h | 2 -- - 1 file changed, 2 deletions(-) - ---- a/mdadm.h -+++ b/mdadm.h -@@ -45,10 +45,8 @@ extern __off64_t lseek64 __P ((int __fd, - #include <errno.h> - #include <string.h> - #include <syslog.h> --#ifdef __GLIBC__ - /* Newer glibc requires sys/sysmacros.h directly for makedev() */ - #include <sys/sysmacros.h> --#endif - #ifdef __dietlibc__ - #include <strings.h> - /* dietlibc has deprecated random and srandom!! */ diff --git a/package/utils/mdadm/patches/200-reduce_size.patch b/package/utils/mdadm/patches/200-reduce_size.patch index 6905c2ccfee..163e125c22d 100644 --- a/package/utils/mdadm/patches/200-reduce_size.patch +++ b/package/utils/mdadm/patches/200-reduce_size.patch @@ -1,19 +1,19 @@ --- a/Incremental.c +++ b/Incremental.c -@@ -1619,6 +1619,10 @@ static int Incremental_container(struct - if (ra_all == ra_blocked) - return 0; +@@ -983,6 +983,10 @@ static int array_try_spare(char *devname + goto next; + } -+#ifndef MDADM_FULL -+ return 0; -+#endif ++ #ifndef MDADM_FULL ++ return 0; ++ #endif + - /* Now move all suitable spares from spare container */ - domains = domain_from_array(list, st->ss->name); - memcpy(suuid, uuid_zero, sizeof(int[4])); + dl = domain_from_array(sra, st2->ss->name); + if (domain_test(dl, pol, st2->ss->name) != 1) { + /* domain test fails */ --- a/util.c +++ b/util.c -@@ -1220,7 +1220,9 @@ void wait_for(char *dev, int fd) +@@ -1147,7 +1147,9 @@ void wait_for(char *dev, int fd) struct superswitch *superlist[] = { &super0, &super1, diff --git a/package/utils/mtd-utils/Makefile b/package/utils/mtd-utils/Makefile index 5a4b03da96f..fd1cb75e51e 100644 --- a/package/utils/mtd-utils/Makefile +++ b/package/utils/mtd-utils/Makefile @@ -8,22 +8,24 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mtd-utils -PKG_VERSION:=2.1.2 +PKG_VERSION:=2.1.6 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 -PKG_SOURCE_URL:=ftp://ftp.infradead.org/pub/mtd-utils/ -PKG_HASH:=8ad4c5f34716d40646aa28724a2f5616d325a6f119254f914e26976f1f76e9d6 +PKG_SOURCE_URL:=https://infraroot.at/pub/mtd/ +PKG_HASH:=c1d853bc4adf83bcabd2792fc95af33bdd8643c97e8f7b3f0180af36af76f0e5 PKG_INSTALL:=1 PKG_FIXUP:=autoreconf PKG_FLAGS:=nonshared +PKG_BUILD_FLAGS:=gc-sections PKG_BUILD_DEPENDS:=util-linux PKG_LICENSE:=GPLv2 PKG_LICENSE_FILES:= +PKG_CPE_ID:=cpe:/a:mtd-utils_project:mtd-utils PKG_MAINTAINER:=John Crispin <john@phrozen.org> @@ -63,9 +65,6 @@ CONFIGURE_ARGS += \ --without-zstd \ --without-lzo -TARGET_CFLAGS += -ffunction-sections -fdata-sections -TARGET_LDFLAGS += -Wl,--gc-sections - define Package/ubi-utils/install $(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_BIN) \ diff --git a/package/utils/mtd-utils/patches/130-lzma_jffs2.patch b/package/utils/mtd-utils/patches/130-lzma_jffs2.patch index 9778aa6d0ad..db683063d58 100644 --- a/package/utils/mtd-utils/patches/130-lzma_jffs2.patch +++ b/package/utils/mtd-utils/patches/130-lzma_jffs2.patch @@ -1,6 +1,6 @@ --- a/jffsX-utils/Makemodule.am +++ b/jffsX-utils/Makemodule.am -@@ -4,11 +4,19 @@ mkfs_jffs2_SOURCES = \ +@@ -4,7 +4,10 @@ mkfs_jffs2_SOURCES = \ jffsX-utils/compr_zlib.c \ jffsX-utils/compr.h \ jffsX-utils/rbtree.c \ @@ -10,7 +10,12 @@ + jffsX-utils/lzma/LzmaEnc.c \ + jffsX-utils/lzma/LzmaDec.c \ jffsX-utils/compr.c \ - jffsX-utils/compr_rtime.c + jffsX-utils/compr_rtime.c \ + jffsX-utils/compr.h \ +@@ -12,8 +15,13 @@ mkfs_jffs2_SOURCES = \ + jffsX-utils/summary.h \ + include/linux/jffs2.h \ + include/mtd/jffs2-user.h + +if !WITHOUT_LZO +mkfs_jffs2_SOURCES += jffsX-utils/compr_lzo.c @@ -20,7 +25,7 @@ -mkfs_jffs2_CPPFLAGS = $(AM_CPPFLAGS) $(ZLIB_CFLAGS) $(LZO_CFLAGS) +mkfs_jffs2_CPPFLAGS = $(AM_CPPFLAGS) $(ZLIB_CFLAGS) $(LZO_CFLAGS) -I./include/linux/lzma - jffs2reader_SOURCES = jffsX-utils/jffs2reader.c + jffs2reader_SOURCES = jffsX-utils/jffs2reader.c include/mtd/jffs2-user.h jffs2reader_LDADD = libmtd.a $(ZLIB_LIBS) $(LZO_LIBS) --- a/jffsX-utils/compr.c +++ b/jffsX-utils/compr.c @@ -5015,7 +5020,7 @@ +} --- a/jffsX-utils/mkfs.jffs2.c +++ b/jffsX-utils/mkfs.jffs2.c -@@ -1667,11 +1667,11 @@ int main(int argc, char **argv) +@@ -1668,11 +1668,11 @@ int main(int argc, char **argv) } erase_block_size *= units; diff --git a/package/utils/nvram/Makefile b/package/utils/nvram/Makefile index 863b304d0d5..8547bfa2d6c 100644 --- a/package/utils/nvram/Makefile +++ b/package/utils/nvram/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=nvram -PKG_RELEASE:=10 +PKG_RELEASE:=12 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) @@ -44,7 +44,11 @@ define Package/nvram/install $(INSTALL_BIN) $(PKG_BUILD_DIR)/nvram $(1)/usr/sbin/ ifneq ($(CONFIG_TARGET_bcm47xx),) $(INSTALL_DIR) $(1)/etc/init.d - $(INSTALL_BIN) ./files/nvram.init $(1)/etc/init.d/nvram + $(INSTALL_BIN) ./files/nvram-bcm47xx.init $(1)/etc/init.d/nvram +endif +ifneq ($(CONFIG_TARGET_bcm53xx),) + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/nvram-bcm53xx.init $(1)/etc/init.d/nvram endif endef diff --git a/package/utils/nvram/files/nvram.init b/package/utils/nvram/files/nvram-bcm47xx.init index 467ab28195f..4a2bcd16fee 100755 --- a/package/utils/nvram/files/nvram.init +++ b/package/utils/nvram/files/nvram-bcm47xx.init @@ -1,7 +1,7 @@ #!/bin/sh /etc/rc.common # NVRAM setup # -# This file handles the NVRAM quirks of various hardware. +# This file handles the NVRAM quirks of various hardware of the bcm47xx target. START=02 alias debug=${DEBUG:-:} @@ -71,7 +71,7 @@ fixup_linksys() { esac } -start() { +boot() { # Don't do any fixups on the WGT634U [ "$(cat /proc/diag/model)" = "Netgear WGT634U" ] && return diff --git a/package/utils/nvram/files/nvram-bcm53xx.init b/package/utils/nvram/files/nvram-bcm53xx.init new file mode 100755 index 00000000000..f47c944897c --- /dev/null +++ b/package/utils/nvram/files/nvram-bcm53xx.init @@ -0,0 +1,42 @@ +#!/bin/sh /etc/rc.common +# NVRAM setup +# +# This file handles the NVRAM quirks of various hardware of the bcm53xx target. + +START=02 + +clear_partialboots() { + # clear partialboots + + case $(board_name) in + linksys,ea9200|\ + linksys,panamera) + COMMIT=1 + nvram set partialboots=0 + ;; + esac +} + +set_wireless_led_behaviour() { + # set Broadcom wireless LED behaviour for both radios + # 0:ledbh9 -> Behaviour of 2.4GHz LED + # 1:ledbh9 -> Behaviour of 5GHz LED + # 0x7 makes the wireless LEDs on, when radios are enabled, and blink when there's activity + + case $(board_name) in + asus,rt-ac3100|\ + asus,rt-ac88u) + COMMIT=1 + nvram set 0:ledbh9=0x7 set 1:ledbh9=0x7 + ;; + esac +} + +boot() { + . /lib/functions.sh + + clear_partialboots + set_wireless_led_behaviour + + [ "$COMMIT" = "1" ] && nvram commit +} diff --git a/package/utils/oseama/Makefile b/package/utils/oseama/Makefile deleted file mode 100644 index 7d9303b92d5..00000000000 --- a/package/utils/oseama/Makefile +++ /dev/null @@ -1,40 +0,0 @@ -# -# Copyright (C) 2016 Rafał Miłecki <zajec5@gmail.com> -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -include $(TOPDIR)/rules.mk - -PKG_NAME:=oseama -PKG_RELEASE:=1 - -PKG_FLAGS:=nonshared - -include $(INCLUDE_DIR)/package.mk - -define Package/oseama - SECTION:=utils - CATEGORY:=Base system - TITLE:=Utility for handling Seama firmware images - MAINTAINER:=Rafał Miłecki <zajec5@gmail.com> - DEPENDS:=@TARGET_bcm53xx -endef - -define Package/oseama/description - This package contains an utility that allows handling Seama images. -endef - -define Build/Compile - $(MAKE) -C $(PKG_BUILD_DIR) \ - CC="$(TARGET_CC)" \ - CFLAGS="$(TARGET_CFLAGS) -Wall" -endef - -define Package/oseama/install - $(INSTALL_DIR) $(1)/usr/bin - $(INSTALL_BIN) $(PKG_BUILD_DIR)/oseama $(1)/usr/bin/ -endef - -$(eval $(call BuildPackage,oseama)) diff --git a/package/utils/oseama/src/Makefile b/package/utils/oseama/src/Makefile deleted file mode 100644 index ca35e6ee99d..00000000000 --- a/package/utils/oseama/src/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -all: oseama - -oseama: - $(CC) $(CFLAGS) -Wall oseama.c md5.c -o $@ $^ - -clean: - rm -f oseama diff --git a/package/utils/oseama/src/md5.c b/package/utils/oseama/src/md5.c deleted file mode 100644 index 52d96accd30..00000000000 --- a/package/utils/oseama/src/md5.c +++ /dev/null @@ -1,296 +0,0 @@ -/* - * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc. - * MD5 Message-Digest Algorithm (RFC 1321). - * - * Homepage: - * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5 - * - * Author: - * Alexander Peslyak, better known as Solar Designer <solar at openwall.com> - * - * This software was written by Alexander Peslyak in 2001. No copyright is - * claimed, and the software is hereby placed in the public domain. - * In case this attempt to disclaim copyright and place the software in the - * public domain is deemed null and void, then the software is - * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the - * general public under the following terms: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted. - * - * There's ABSOLUTELY NO WARRANTY, express or implied. - * - * (This is a heavily cut-down "BSD license".) - * - * This differs from Colin Plumb's older public domain implementation in that - * no exactly 32-bit integer data type is required (any 32-bit or wider - * unsigned integer data type will do), there's no compile-time endianness - * configuration, and the function prototypes match OpenSSL's. No code from - * Colin Plumb's implementation has been reused; this comment merely compares - * the properties of the two independent implementations. - * - * The primary goals of this implementation are portability and ease of use. - * It is meant to be fast, but not as fast as possible. Some known - * optimizations are not included to reduce source code size and avoid - * compile-time configuration. - */ - -#ifndef HAVE_OPENSSL - -#include <string.h> - -#include "md5.h" - -/* - * The basic MD5 functions. - * - * F and G are optimized compared to their RFC 1321 definitions for - * architectures that lack an AND-NOT instruction, just like in Colin Plumb's - * implementation. - */ -#define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) -#define G(x, y, z) ((y) ^ ((z) & ((x) ^ (y)))) -#define H(x, y, z) (((x) ^ (y)) ^ (z)) -#define H2(x, y, z) ((x) ^ ((y) ^ (z))) -#define I(x, y, z) ((y) ^ ((x) | ~(z))) - -/* - * The MD5 transformation for all four rounds. - */ -#define STEP(f, a, b, c, d, x, t, s) \ - (a) += f((b), (c), (d)) + (x) + (t); \ - (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \ - (a) += (b); - -/* - * SET reads 4 input bytes in little-endian byte order and stores them - * in a properly aligned word in host byte order. - * - * The check for little-endian architectures that tolerate unaligned - * memory accesses is just an optimization. Nothing will break if it - * doesn't work. - */ -#if defined(__i386__) || defined(__x86_64__) || defined(__vax__) -#define SET(n) \ - (*(MD5_u32plus *)&ptr[(n) * 4]) -#define GET(n) \ - SET(n) -#else -#define SET(n) \ - (ctx->block[(n)] = \ - (MD5_u32plus)ptr[(n) * 4] | \ - ((MD5_u32plus)ptr[(n) * 4 + 1] << 8) | \ - ((MD5_u32plus)ptr[(n) * 4 + 2] << 16) | \ - ((MD5_u32plus)ptr[(n) * 4 + 3] << 24)) -#define GET(n) \ - (ctx->block[(n)]) -#endif - -/* - * This processes one or more 64-byte data blocks, but does NOT update - * the bit counters. There are no alignment requirements. - */ -static const void *body(MD5_CTX *ctx, const void *data, unsigned long size) -{ - const unsigned char *ptr; - MD5_u32plus a, b, c, d; - MD5_u32plus saved_a, saved_b, saved_c, saved_d; - - ptr = (const unsigned char *)data; - - a = ctx->a; - b = ctx->b; - c = ctx->c; - d = ctx->d; - - do { - saved_a = a; - saved_b = b; - saved_c = c; - saved_d = d; - -/* Round 1 */ - STEP(F, a, b, c, d, SET(0), 0xd76aa478, 7) - STEP(F, d, a, b, c, SET(1), 0xe8c7b756, 12) - STEP(F, c, d, a, b, SET(2), 0x242070db, 17) - STEP(F, b, c, d, a, SET(3), 0xc1bdceee, 22) - STEP(F, a, b, c, d, SET(4), 0xf57c0faf, 7) - STEP(F, d, a, b, c, SET(5), 0x4787c62a, 12) - STEP(F, c, d, a, b, SET(6), 0xa8304613, 17) - STEP(F, b, c, d, a, SET(7), 0xfd469501, 22) - STEP(F, a, b, c, d, SET(8), 0x698098d8, 7) - STEP(F, d, a, b, c, SET(9), 0x8b44f7af, 12) - STEP(F, c, d, a, b, SET(10), 0xffff5bb1, 17) - STEP(F, b, c, d, a, SET(11), 0x895cd7be, 22) - STEP(F, a, b, c, d, SET(12), 0x6b901122, 7) - STEP(F, d, a, b, c, SET(13), 0xfd987193, 12) - STEP(F, c, d, a, b, SET(14), 0xa679438e, 17) - STEP(F, b, c, d, a, SET(15), 0x49b40821, 22) - -/* Round 2 */ - STEP(G, a, b, c, d, GET(1), 0xf61e2562, 5) - STEP(G, d, a, b, c, GET(6), 0xc040b340, 9) - STEP(G, c, d, a, b, GET(11), 0x265e5a51, 14) - STEP(G, b, c, d, a, GET(0), 0xe9b6c7aa, 20) - STEP(G, a, b, c, d, GET(5), 0xd62f105d, 5) - STEP(G, d, a, b, c, GET(10), 0x02441453, 9) - STEP(G, c, d, a, b, GET(15), 0xd8a1e681, 14) - STEP(G, b, c, d, a, GET(4), 0xe7d3fbc8, 20) - STEP(G, a, b, c, d, GET(9), 0x21e1cde6, 5) - STEP(G, d, a, b, c, GET(14), 0xc33707d6, 9) - STEP(G, c, d, a, b, GET(3), 0xf4d50d87, 14) - STEP(G, b, c, d, a, GET(8), 0x455a14ed, 20) - STEP(G, a, b, c, d, GET(13), 0xa9e3e905, 5) - STEP(G, d, a, b, c, GET(2), 0xfcefa3f8, 9) - STEP(G, c, d, a, b, GET(7), 0x676f02d9, 14) - STEP(G, b, c, d, a, GET(12), 0x8d2a4c8a, 20) - -/* Round 3 */ - STEP(H, a, b, c, d, GET(5), 0xfffa3942, 4) - STEP(H2, d, a, b, c, GET(8), 0x8771f681, 11) - STEP(H, c, d, a, b, GET(11), 0x6d9d6122, 16) - STEP(H2, b, c, d, a, GET(14), 0xfde5380c, 23) - STEP(H, a, b, c, d, GET(1), 0xa4beea44, 4) - STEP(H2, d, a, b, c, GET(4), 0x4bdecfa9, 11) - STEP(H, c, d, a, b, GET(7), 0xf6bb4b60, 16) - STEP(H2, b, c, d, a, GET(10), 0xbebfbc70, 23) - STEP(H, a, b, c, d, GET(13), 0x289b7ec6, 4) - STEP(H2, d, a, b, c, GET(0), 0xeaa127fa, 11) - STEP(H, c, d, a, b, GET(3), 0xd4ef3085, 16) - STEP(H2, b, c, d, a, GET(6), 0x04881d05, 23) - STEP(H, a, b, c, d, GET(9), 0xd9d4d039, 4) - STEP(H2, d, a, b, c, GET(12), 0xe6db99e5, 11) - STEP(H, c, d, a, b, GET(15), 0x1fa27cf8, 16) - STEP(H2, b, c, d, a, GET(2), 0xc4ac5665, 23) - -/* Round 4 */ - STEP(I, a, b, c, d, GET(0), 0xf4292244, 6) - STEP(I, d, a, b, c, GET(7), 0x432aff97, 10) - STEP(I, c, d, a, b, GET(14), 0xab9423a7, 15) - STEP(I, b, c, d, a, GET(5), 0xfc93a039, 21) - STEP(I, a, b, c, d, GET(12), 0x655b59c3, 6) - STEP(I, d, a, b, c, GET(3), 0x8f0ccc92, 10) - STEP(I, c, d, a, b, GET(10), 0xffeff47d, 15) - STEP(I, b, c, d, a, GET(1), 0x85845dd1, 21) - STEP(I, a, b, c, d, GET(8), 0x6fa87e4f, 6) - STEP(I, d, a, b, c, GET(15), 0xfe2ce6e0, 10) - STEP(I, c, d, a, b, GET(6), 0xa3014314, 15) - STEP(I, b, c, d, a, GET(13), 0x4e0811a1, 21) - STEP(I, a, b, c, d, GET(4), 0xf7537e82, 6) - STEP(I, d, a, b, c, GET(11), 0xbd3af235, 10) - STEP(I, c, d, a, b, GET(2), 0x2ad7d2bb, 15) - STEP(I, b, c, d, a, GET(9), 0xeb86d391, 21) - - a += saved_a; - b += saved_b; - c += saved_c; - d += saved_d; - - ptr += 64; - } while (size -= 64); - - ctx->a = a; - ctx->b = b; - ctx->c = c; - ctx->d = d; - - return ptr; -} - -void MD5_Init(MD5_CTX *ctx) -{ - ctx->a = 0x67452301; - ctx->b = 0xefcdab89; - ctx->c = 0x98badcfe; - ctx->d = 0x10325476; - - ctx->lo = 0; - ctx->hi = 0; -} - -void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size) -{ - MD5_u32plus saved_lo; - unsigned long used, available; - - saved_lo = ctx->lo; - if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo) - ctx->hi++; - ctx->hi += size >> 29; - - used = saved_lo & 0x3f; - - if (used) { - available = 64 - used; - - if (size < available) { - memcpy(&ctx->buffer[used], data, size); - return; - } - - memcpy(&ctx->buffer[used], data, available); - data = (const unsigned char *)data + available; - size -= available; - body(ctx, ctx->buffer, 64); - } - - if (size >= 64) { - data = body(ctx, data, size & ~(unsigned long)0x3f); - size &= 0x3f; - } - - memcpy(ctx->buffer, data, size); -} - -void MD5_Final(unsigned char *result, MD5_CTX *ctx) -{ - unsigned long used, available; - - used = ctx->lo & 0x3f; - - ctx->buffer[used++] = 0x80; - - available = 64 - used; - - if (available < 8) { - memset(&ctx->buffer[used], 0, available); - body(ctx, ctx->buffer, 64); - used = 0; - available = 64; - } - - memset(&ctx->buffer[used], 0, available - 8); - - ctx->lo <<= 3; - ctx->buffer[56] = ctx->lo; - ctx->buffer[57] = ctx->lo >> 8; - ctx->buffer[58] = ctx->lo >> 16; - ctx->buffer[59] = ctx->lo >> 24; - ctx->buffer[60] = ctx->hi; - ctx->buffer[61] = ctx->hi >> 8; - ctx->buffer[62] = ctx->hi >> 16; - ctx->buffer[63] = ctx->hi >> 24; - - body(ctx, ctx->buffer, 64); - - result[0] = ctx->a; - result[1] = ctx->a >> 8; - result[2] = ctx->a >> 16; - result[3] = ctx->a >> 24; - result[4] = ctx->b; - result[5] = ctx->b >> 8; - result[6] = ctx->b >> 16; - result[7] = ctx->b >> 24; - result[8] = ctx->c; - result[9] = ctx->c >> 8; - result[10] = ctx->c >> 16; - result[11] = ctx->c >> 24; - result[12] = ctx->d; - result[13] = ctx->d >> 8; - result[14] = ctx->d >> 16; - result[15] = ctx->d >> 24; - - memset(ctx, 0, sizeof(*ctx)); -} - -#endif diff --git a/package/utils/oseama/src/md5.h b/package/utils/oseama/src/md5.h deleted file mode 100644 index 2da44bf355a..00000000000 --- a/package/utils/oseama/src/md5.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc. - * MD5 Message-Digest Algorithm (RFC 1321). - * - * Homepage: - * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5 - * - * Author: - * Alexander Peslyak, better known as Solar Designer <solar at openwall.com> - * - * This software was written by Alexander Peslyak in 2001. No copyright is - * claimed, and the software is hereby placed in the public domain. - * In case this attempt to disclaim copyright and place the software in the - * public domain is deemed null and void, then the software is - * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the - * general public under the following terms: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted. - * - * There's ABSOLUTELY NO WARRANTY, express or implied. - * - * See md5.c for more information. - */ - -#ifdef HAVE_OPENSSL -#include <openssl/md5.h> -#elif !defined(_MD5_H) -#define _MD5_H - -/* Any 32-bit or wider unsigned integer data type will do */ -typedef unsigned int MD5_u32plus; - -typedef struct { - MD5_u32plus lo, hi; - MD5_u32plus a, b, c, d; - unsigned char buffer[64]; - MD5_u32plus block[16]; -} MD5_CTX; - -extern void MD5_Init(MD5_CTX *ctx); -extern void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size); -extern void MD5_Final(unsigned char *result, MD5_CTX *ctx); - -#endif diff --git a/package/utils/oseama/src/oseama.c b/package/utils/oseama/src/oseama.c deleted file mode 100644 index 4434b11162e..00000000000 --- a/package/utils/oseama/src/oseama.c +++ /dev/null @@ -1,556 +0,0 @@ -/* - * oseama - * - * Copyright (C) 2016 Rafał Miłecki <zajec5@gmail.com> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - */ - -#include <byteswap.h> -#include <endian.h> -#include <errno.h> -#include <stdint.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#include "md5.h" - -#if !defined(__BYTE_ORDER) -#error "Unknown byte order" -#endif - -#if __BYTE_ORDER == __BIG_ENDIAN -#define cpu_to_be32(x) (x) -#define be32_to_cpu(x) (x) -#define cpu_to_be16(x) (x) -#define be16_to_cpu(x) (x) -#elif __BYTE_ORDER == __LITTLE_ENDIAN -#define cpu_to_be32(x) bswap_32(x) -#define be32_to_cpu(x) bswap_32(x) -#define cpu_to_be16(x) bswap_16(x) -#define be16_to_cpu(x) bswap_16(x) -#else -#error "Unsupported endianness" -#endif - -#define SEAMA_MAGIC 0x5ea3a417 - -struct seama_seal_header { - uint32_t magic; - uint16_t reserved; - uint16_t metasize; - uint32_t imagesize; -} __attribute__ ((packed)); - -struct seama_entity_header { - uint32_t magic; - uint16_t reserved; - uint16_t metasize; - uint32_t imagesize; - uint8_t md5[16]; -} __attribute__ ((packed)); - -char *seama_path; -int entity_idx = -1; -char *out_path; - -static inline size_t oseama_min(size_t x, size_t y) { - return x < y ? x : y; -} - -/************************************************** - * Info - **************************************************/ - -static void oseama_info_parse_options(int argc, char **argv) { - int c; - - while ((c = getopt(argc, argv, "e:")) != -1) { - switch (c) { - case 'e': - entity_idx = atoi(optarg); - break; - } - } -} - -static int oseama_info_entities(FILE *seama) { - struct seama_entity_header hdr; - size_t bytes, metasize, imagesize; - uint8_t buf[1024]; - char *end, *tmp; - int i = 0; - int err = 0; - - while ((bytes = fread(&hdr, 1, sizeof(hdr), seama)) == sizeof(hdr)) { - if (be32_to_cpu(hdr.magic) != SEAMA_MAGIC) { - fprintf(stderr, "Invalid Seama magic: 0x%08x\n", be32_to_cpu(hdr.magic)); - err = -EINVAL; - goto err_out; - } - metasize = be16_to_cpu(hdr.metasize); - imagesize = be32_to_cpu(hdr.imagesize); - - if (entity_idx >= 0 && i != entity_idx) { - fseek(seama, metasize + imagesize, SEEK_CUR); - i++; - continue; - } - - if (metasize >= sizeof(buf)) { - fprintf(stderr, "Too small buffer (%zu B) to read all meta info (%zd B)\n", sizeof(buf), metasize); - err = -EINVAL; - goto err_out; - } - - if (entity_idx < 0) - printf("\n"); - printf("Entity offset:\t%ld\n", ftell(seama) - sizeof(hdr)); - printf("Entity size:\t%zd\n", sizeof(hdr) + metasize + imagesize); - printf("Meta size:\t%zd\n", metasize); - printf("Image size:\t%zd\n", imagesize); - - bytes = fread(buf, 1, metasize, seama); - if (bytes != metasize) { - fprintf(stderr, "Couldn't read %zd B of meta\n", metasize); - err = -EIO; - goto err_out; - } - - end = (char *)&buf[metasize - 1]; - *end = '\0'; - for (tmp = (char *)buf; tmp < end && strlen(tmp); tmp += strlen(tmp) + 1) { - printf("Meta entry:\t%s\n", tmp); - } - - fseek(seama, imagesize, SEEK_CUR); - i++; - } - -err_out: - return err; -} - -static int oseama_info(int argc, char **argv) { - FILE *seama; - struct seama_seal_header hdr; - size_t bytes; - uint16_t metasize; - uint32_t imagesize; - uint8_t buf[1024]; - int err = 0; - - if (argc < 3) { - fprintf(stderr, "No Seama file passed\n"); - err = -EINVAL; - goto out; - } - seama_path = argv[2]; - - optind = 3; - oseama_info_parse_options(argc, argv); - - seama = fopen(seama_path, "r"); - if (!seama) { - fprintf(stderr, "Couldn't open %s\n", seama_path); - err = -EACCES; - goto out; - } - - bytes = fread(&hdr, 1, sizeof(hdr), seama); - if (bytes != sizeof(hdr)) { - fprintf(stderr, "Couldn't read %s header\n", seama_path); - err = -EIO; - goto err_close; - } - metasize = be16_to_cpu(hdr.metasize); - imagesize = be32_to_cpu(hdr.imagesize); - - if (be32_to_cpu(hdr.magic) != SEAMA_MAGIC) { - fprintf(stderr, "Invalid Seama magic: 0x%08x\n", be32_to_cpu(hdr.magic)); - err = -EINVAL; - goto err_close; - } - - if (metasize >= sizeof(buf)) { - fprintf(stderr, "Too small buffer (%zu B) to read all meta info (%d B)\n", sizeof(buf), metasize); - err = -EINVAL; - goto err_close; - } - - if (imagesize) { - fprintf(stderr, "Invalid Seama image size: 0x%08x (should be 0)\n", imagesize); - err = -EINVAL; - goto err_close; - } - - bytes = fread(buf, 1, metasize, seama); - if (bytes != metasize) { - fprintf(stderr, "Couldn't read %d B of meta\n", metasize); - err = -EIO; - goto err_close; - } - - if (entity_idx < 0) { - char *end, *tmp; - - printf("Meta size:\t%d\n", metasize); - printf("Image size:\t%d\n", imagesize); - - end = (char *)&buf[metasize - 1]; - *end = '\0'; - for (tmp = (char *)buf; tmp < end && strlen(tmp); tmp += strlen(tmp) + 1) { - printf("Meta entry:\t%s\n", tmp); - } - } - - oseama_info_entities(seama); - -err_close: - fclose(seama); -out: - return err; -} - -/************************************************** - * Create - **************************************************/ - -static ssize_t oseama_entity_append_file(FILE *seama, const char *in_path) { - FILE *in; - size_t bytes; - ssize_t length = 0; - uint8_t buf[128]; - - in = fopen(in_path, "r"); - if (!in) { - fprintf(stderr, "Couldn't open %s\n", in_path); - return -EACCES; - } - - while ((bytes = fread(buf, 1, sizeof(buf), in)) > 0) { - if (fwrite(buf, 1, bytes, seama) != bytes) { - fprintf(stderr, "Couldn't write %zu B to %s\n", bytes, seama_path); - length = -EIO; - break; - } - length += bytes; - } - - fclose(in); - - return length; -} - -static ssize_t oseama_entity_append_zeros(FILE *seama, size_t length) { - uint8_t *buf; - - buf = malloc(length); - if (!buf) - return -ENOMEM; - memset(buf, 0, length); - - if (fwrite(buf, 1, length, seama) != length) { - fprintf(stderr, "Couldn't write %zu B to %s\n", length, seama_path); - return -EIO; - } - - return length; -} - -static ssize_t oseama_entity_align(FILE *seama, size_t curr_offset, size_t alignment) { - if (curr_offset & (alignment - 1)) { - size_t length = alignment - (curr_offset % alignment); - - return oseama_entity_append_zeros(seama, length); - } - - return 0; -} - -static int oseama_entity_write_hdr(FILE *seama, size_t metasize, size_t imagesize) { - struct seama_entity_header hdr = {}; - uint8_t buf[128]; - size_t length = imagesize; - size_t bytes; - MD5_CTX ctx; - - fseek(seama, sizeof(hdr) + metasize, SEEK_SET); - MD5_Init(&ctx); - while ((bytes = fread(buf, 1, oseama_min(sizeof(buf), length), seama)) > 0) { - MD5_Update(&ctx, buf, bytes); - length -= bytes; - } - MD5_Final(hdr.md5, &ctx); - - hdr.magic = cpu_to_be32(SEAMA_MAGIC); - hdr.metasize = cpu_to_be16(metasize); - hdr.imagesize = cpu_to_be32(imagesize); - - fseek(seama, 0, SEEK_SET); - bytes = fwrite(&hdr, 1, sizeof(hdr), seama); - if (bytes != sizeof(hdr)) { - fprintf(stderr, "Couldn't write Seama entity header to %s\n", seama_path); - return -EIO; - } - - return 0; -} - -static int oseama_entity(int argc, char **argv) { - FILE *seama; - ssize_t sbytes; - size_t curr_offset = sizeof(struct seama_entity_header); - size_t metasize = 0, imagesize = 0; - int c; - int err = 0; - - if (argc < 3) { - fprintf(stderr, "No Seama file passed\n"); - err = -EINVAL; - goto out; - } - seama_path = argv[2]; - - seama = fopen(seama_path, "w+"); - if (!seama) { - fprintf(stderr, "Couldn't open %s\n", seama_path); - err = -EACCES; - goto out; - } - fseek(seama, curr_offset, SEEK_SET); - - optind = 3; - while ((c = getopt(argc, argv, "m:f:b:")) != -1) { - switch (c) { - case 'm': - sbytes = fwrite(optarg, 1, strlen(optarg) + 1, seama); - if (sbytes < 0) { - fprintf(stderr, "Failed to write meta %s\n", optarg); - } else { - curr_offset += sbytes; - metasize += sbytes; - } - - sbytes = oseama_entity_align(seama, curr_offset, 4); - if (sbytes < 0) { - fprintf(stderr, "Failed to append zeros\n"); - } else { - curr_offset += sbytes; - metasize += sbytes; - } - - break; - case 'f': - case 'b': - break; - } - } - - optind = 3; - while ((c = getopt(argc, argv, "m:f:b:")) != -1) { - switch (c) { - case 'm': - break; - case 'f': - sbytes = oseama_entity_append_file(seama, optarg); - if (sbytes < 0) { - fprintf(stderr, "Failed to append file %s\n", optarg); - } else { - curr_offset += sbytes; - imagesize += sbytes; - } - break; - case 'b': - sbytes = strtol(optarg, NULL, 0) - curr_offset; - if (sbytes < 0) { - fprintf(stderr, "Current Seama entity length is 0x%zx, can't pad it with zeros to 0x%lx\n", curr_offset, strtol(optarg, NULL, 0)); - } else { - sbytes = oseama_entity_append_zeros(seama, sbytes); - if (sbytes < 0) { - fprintf(stderr, "Failed to append zeros\n"); - } else { - curr_offset += sbytes; - imagesize += sbytes; - } - } - break; - } - if (err) - break; - } - - oseama_entity_write_hdr(seama, metasize, imagesize); - - fclose(seama); -out: - return err; -} - -/************************************************** - * Extract - **************************************************/ - -static void oseama_extract_parse_options(int argc, char **argv) { - int c; - - while ((c = getopt(argc, argv, "e:o:")) != -1) { - switch (c) { - case 'e': - entity_idx = atoi(optarg); - break; - case 'o': - out_path = optarg; - break; - } - } -} - -static int oseama_extract_entity(FILE *seama, FILE *out) { - struct seama_entity_header hdr; - size_t bytes, metasize, imagesize, length; - uint8_t buf[1024]; - int i = 0; - int err = 0; - - while ((bytes = fread(&hdr, 1, sizeof(hdr), seama)) == sizeof(hdr)) { - if (be32_to_cpu(hdr.magic) != SEAMA_MAGIC) { - fprintf(stderr, "Invalid Seama magic: 0x%08x\n", be32_to_cpu(hdr.magic)); - err = -EINVAL; - break; - } - metasize = be16_to_cpu(hdr.metasize); - imagesize = be32_to_cpu(hdr.imagesize); - - if (i != entity_idx) { - fseek(seama, metasize + imagesize, SEEK_CUR); - i++; - continue; - } - - fseek(seama, -sizeof(hdr), SEEK_CUR); - - length = sizeof(hdr) + metasize + imagesize; - while ((bytes = fread(buf, 1, oseama_min(sizeof(buf), length), seama)) > 0) { - if (fwrite(buf, 1, bytes, out) != bytes) { - fprintf(stderr, "Couldn't write %zu B to %s\n", bytes, out_path); - err = -EIO; - break; - } - length -= bytes; - } - - if (length) { - fprintf(stderr, "Couldn't extract whole entity %d from %s (%zu B left)\n", entity_idx, seama_path, length); - err = -EIO; - break; - } - - break; - } - - return err; -} - -static int oseama_extract(int argc, char **argv) { - FILE *seama; - FILE *out; - struct seama_seal_header hdr; - size_t bytes; - uint16_t metasize; - int err = 0; - - if (argc < 3) { - fprintf(stderr, "No Seama file passed\n"); - err = -EINVAL; - goto out; - } - seama_path = argv[2]; - - optind = 3; - oseama_extract_parse_options(argc, argv); - if (entity_idx < 0) { - fprintf(stderr, "No entity specified\n"); - err = -EINVAL; - goto out; - } else if (!out_path) { - fprintf(stderr, "No output file specified\n"); - err = -EINVAL; - goto out; - } - - seama = fopen(seama_path, "r"); - if (!seama) { - fprintf(stderr, "Couldn't open %s\n", seama_path); - err = -EACCES; - goto out; - } - - out = fopen(out_path, "w"); - if (!out) { - fprintf(stderr, "Couldn't open %s\n", out_path); - err = -EACCES; - goto err_close_seama; - } - - bytes = fread(&hdr, 1, sizeof(hdr), seama); - if (bytes != sizeof(hdr)) { - fprintf(stderr, "Couldn't read %s header\n", seama_path); - err = -EIO; - goto err_close_out; - } - metasize = be16_to_cpu(hdr.metasize); - - fseek(seama, metasize, SEEK_CUR); - - oseama_extract_entity(seama, out); - -err_close_out: - fclose(out); -err_close_seama: - fclose(seama); -out: - return err; -} - -/************************************************** - * Start - **************************************************/ - -static void usage() { - printf("Usage:\n"); - printf("\n"); - printf("Info about Seama seal (container):\n"); - printf("\toseama info <file> [options]\n"); - printf("\t-e\t\t\t\tprint info about specified entity only\n"); - printf("\n"); - printf("Create Seama entity:\n"); - printf("\toseama entity <file> [options]\n"); - printf("\t-m meta\t\t\t\tmeta into to put in header\n"); - printf("\t-f file\t\t\t\tappend content from file\n"); - printf("\t-b offset\t\t\tappend zeros till reaching absolute offset\n"); - printf("\n"); - printf("Extract from Seama seal (container):\n"); - printf("\toseama extract <file> [options]\n"); - printf("\t-e\t\t\t\tindex of entity to extract\n"); - printf("\t-o file\t\t\t\toutput file\n"); -} - -int main(int argc, char **argv) { - if (argc > 1) { - if (!strcmp(argv[1], "info")) - return oseama_info(argc, argv); - else if (!strcmp(argv[1], "entity")) - return oseama_entity(argc, argv); - else if (!strcmp(argv[1], "extract")) - return oseama_extract(argc, argv); - } - - usage(); - return 0; -} diff --git a/package/utils/otrx/Makefile b/package/utils/otrx/Makefile deleted file mode 100644 index 2a3ac731a35..00000000000 --- a/package/utils/otrx/Makefile +++ /dev/null @@ -1,40 +0,0 @@ -# -# Copyright (C) 2015 Rafał Miłecki <zajec5@gmail.com> -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -include $(TOPDIR)/rules.mk - -PKG_NAME:=otrx -PKG_RELEASE:=1 - -PKG_FLAGS:=nonshared - -include $(INCLUDE_DIR)/package.mk - -define Package/otrx - SECTION:=utils - CATEGORY:=Base system - TITLE:=Utility for opening (analyzing) TRX firmware images - MAINTAINER:=Rafał Miłecki <zajec5@gmail.com> - DEPENDS:=@(TARGET_bcm47xx||TARGET_bcm53xx) -endef - -define Package/otrx/description - This package contains an utility that allows validating TRX images. -endef - -define Build/Compile - $(MAKE) -C $(PKG_BUILD_DIR) \ - CC="$(TARGET_CC)" \ - CFLAGS="$(TARGET_CFLAGS) -Wall" -endef - -define Package/otrx/install - $(INSTALL_DIR) $(1)/usr/bin - $(INSTALL_BIN) $(PKG_BUILD_DIR)/otrx $(1)/usr/bin/ -endef - -$(eval $(call BuildPackage,otrx)) diff --git a/package/utils/otrx/src/Makefile b/package/utils/otrx/src/Makefile deleted file mode 100644 index df50ea446d0..00000000000 --- a/package/utils/otrx/src/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -all: otrx - -otrx: - $(CC) $(CFLAGS) -o $@ otrx.c -Wall - -clean: - rm -f otrx diff --git a/package/utils/otrx/src/otrx.c b/package/utils/otrx/src/otrx.c deleted file mode 100644 index 223e032f2b5..00000000000 --- a/package/utils/otrx/src/otrx.c +++ /dev/null @@ -1,592 +0,0 @@ -/* - * otrx - * - * Copyright (C) 2015-2017 Rafał Miłecki <zajec5@gmail.com> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - */ - -#include <byteswap.h> -#include <endian.h> -#include <errno.h> -#include <stdint.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#if !defined(__BYTE_ORDER) -#error "Unknown byte order" -#endif - -#if __BYTE_ORDER == __BIG_ENDIAN -#define cpu_to_le32(x) bswap_32(x) -#define le32_to_cpu(x) bswap_32(x) -#elif __BYTE_ORDER == __LITTLE_ENDIAN -#define cpu_to_le32(x) (x) -#define le32_to_cpu(x) (x) -#else -#error "Unsupported endianness" -#endif - -#define TRX_MAGIC 0x30524448 -#define TRX_FLAGS_OFFSET 12 -#define TRX_MAX_PARTS 3 - -struct trx_header { - uint32_t magic; - uint32_t length; - uint32_t crc32; - uint16_t flags; - uint16_t version; - uint32_t offset[3]; -}; - -char *trx_path; -size_t trx_offset = 0; -char *partition[TRX_MAX_PARTS] = {}; - -static inline size_t otrx_min(size_t x, size_t y) { - return x < y ? x : y; -} - -/************************************************** - * CRC32 - **************************************************/ - -static const uint32_t crc32_tbl[] = { - 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, - 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, - 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, - 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, - 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, - 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, - 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, - 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, - 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, - 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, - 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, - 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, - 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, - 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, - 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, - 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, - 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, - 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, - 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, - 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, - 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, - 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, - 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, - 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, - 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, - 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, - 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, - 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, - 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, - 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, - 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, - 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, - 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, - 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, - 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, - 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, - 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, - 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, - 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, - 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, - 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, - 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, - 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, - 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, - 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, - 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, - 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, - 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, - 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, - 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, - 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, - 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, - 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, - 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, - 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, - 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, - 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, - 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, - 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, - 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, - 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, - 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d, -}; - -uint32_t otrx_crc32(uint32_t crc, uint8_t *buf, size_t len) { - while (len) { - crc = crc32_tbl[(crc ^ *buf) & 0xff] ^ (crc >> 8); - buf++; - len--; - } - - return crc; -} - -/************************************************** - * Check - **************************************************/ - -static void otrx_check_parse_options(int argc, char **argv) { - int c; - - while ((c = getopt(argc, argv, "o:")) != -1) { - switch (c) { - case 'o': - trx_offset = atoi(optarg); - break; - } - } -} - -static int otrx_check(int argc, char **argv) { - FILE *trx; - struct trx_header hdr; - size_t bytes, length; - uint8_t buf[1024]; - uint32_t crc32; - int err = 0; - - if (argc < 3) { - fprintf(stderr, "No TRX file passed\n"); - err = -EINVAL; - goto out; - } - trx_path = argv[2]; - - optind = 3; - otrx_check_parse_options(argc, argv); - - trx = fopen(trx_path, "r"); - if (!trx) { - fprintf(stderr, "Couldn't open %s\n", trx_path); - err = -EACCES; - goto out; - } - - fseek(trx, trx_offset, SEEK_SET); - bytes = fread(&hdr, 1, sizeof(hdr), trx); - if (bytes != sizeof(hdr)) { - fprintf(stderr, "Couldn't read %s header\n", trx_path); - err = -EIO; - goto err_close; - } - - if (le32_to_cpu(hdr.magic) != TRX_MAGIC) { - fprintf(stderr, "Invalid TRX magic: 0x%08x\n", le32_to_cpu(hdr.magic)); - err = -EINVAL; - goto err_close; - } - - length = le32_to_cpu(hdr.length); - if (length < sizeof(hdr)) { - fprintf(stderr, "Length read from TRX too low (%zu B)\n", length); - err = -EINVAL; - goto err_close; - } - - crc32 = 0xffffffff; - fseek(trx, trx_offset + TRX_FLAGS_OFFSET, SEEK_SET); - length -= TRX_FLAGS_OFFSET; - while ((bytes = fread(buf, 1, otrx_min(sizeof(buf), length), trx)) > 0) { - crc32 = otrx_crc32(crc32, buf, bytes); - length -= bytes; - } - - if (length) { - fprintf(stderr, "Couldn't read last %zd B of data from %s\n", length, trx_path); - err = -EIO; - goto err_close; - } - - if (crc32 != le32_to_cpu(hdr.crc32)) { - fprintf(stderr, "Invalid data crc32: 0x%08x instead of 0x%08x\n", crc32, le32_to_cpu(hdr.crc32)); - err = -EINVAL; - goto err_close; - } - - printf("Found a valid TRX version %d\n", le32_to_cpu(hdr.version)); - -err_close: - fclose(trx); -out: - return err; -} - -/************************************************** - * Create - **************************************************/ - -static ssize_t otrx_create_append_file(FILE *trx, const char *in_path) { - FILE *in; - size_t bytes; - ssize_t length = 0; - uint8_t buf[1024]; - - in = fopen(in_path, "r"); - if (!in) { - fprintf(stderr, "Couldn't open %s\n", in_path); - return -EACCES; - } - - while ((bytes = fread(buf, 1, sizeof(buf), in)) > 0) { - if (fwrite(buf, 1, bytes, trx) != bytes) { - fprintf(stderr, "Couldn't write %zu B to %s\n", bytes, trx_path); - length = -EIO; - break; - } - length += bytes; - } - - fclose(in); - - return length; -} - -static ssize_t otrx_create_append_zeros(FILE *trx, size_t length) { - uint8_t *buf; - - buf = malloc(length); - if (!buf) - return -ENOMEM; - memset(buf, 0, length); - - if (fwrite(buf, 1, length, trx) != length) { - fprintf(stderr, "Couldn't write %zu B to %s\n", length, trx_path); - free(buf); - return -EIO; - } - - free(buf); - - return length; -} - -static ssize_t otrx_create_align(FILE *trx, size_t curr_offset, size_t alignment) { - if (curr_offset & (alignment - 1)) { - size_t length = alignment - (curr_offset % alignment); - return otrx_create_append_zeros(trx, length); - } - - return 0; -} - -static int otrx_create_write_hdr(FILE *trx, struct trx_header *hdr) { - size_t bytes, length; - uint8_t buf[1024]; - uint32_t crc32; - - hdr->magic = cpu_to_le32(TRX_MAGIC); - hdr->version = 1; - - fseek(trx, 0, SEEK_SET); - bytes = fwrite(hdr, 1, sizeof(struct trx_header), trx); - if (bytes != sizeof(struct trx_header)) { - fprintf(stderr, "Couldn't write TRX header to %s\n", trx_path); - return -EIO; - } - - length = le32_to_cpu(hdr->length); - - crc32 = 0xffffffff; - fseek(trx, TRX_FLAGS_OFFSET, SEEK_SET); - length -= TRX_FLAGS_OFFSET; - while ((bytes = fread(buf, 1, otrx_min(sizeof(buf), length), trx)) > 0) { - crc32 = otrx_crc32(crc32, buf, bytes); - length -= bytes; - } - hdr->crc32 = cpu_to_le32(crc32); - - fseek(trx, 0, SEEK_SET); - bytes = fwrite(hdr, 1, sizeof(struct trx_header), trx); - if (bytes != sizeof(struct trx_header)) { - fprintf(stderr, "Couldn't write TRX header to %s\n", trx_path); - return -EIO; - } - - return 0; -} - -static int otrx_create(int argc, char **argv) { - FILE *trx; - struct trx_header hdr = {}; - ssize_t sbytes; - size_t curr_idx = 0; - size_t curr_offset = sizeof(hdr); - int c; - int err = 0; - - if (argc < 3) { - fprintf(stderr, "No TRX file passed\n"); - err = -EINVAL; - goto out; - } - trx_path = argv[2]; - - trx = fopen(trx_path, "w+"); - if (!trx) { - fprintf(stderr, "Couldn't open %s\n", trx_path); - err = -EACCES; - goto out; - } - fseek(trx, curr_offset, SEEK_SET); - - optind = 3; - while ((c = getopt(argc, argv, "f:A:a:b:")) != -1) { - switch (c) { - case 'f': - if (curr_idx >= TRX_MAX_PARTS) { - err = -ENOSPC; - fprintf(stderr, "Reached TRX partitions limit, no place for %s\n", optarg); - goto err_close; - } - - sbytes = otrx_create_append_file(trx, optarg); - if (sbytes < 0) { - fprintf(stderr, "Failed to append file %s\n", optarg); - } else { - hdr.offset[curr_idx++] = curr_offset; - curr_offset += sbytes; - } - - sbytes = otrx_create_align(trx, curr_offset, 4); - if (sbytes < 0) - fprintf(stderr, "Failed to append zeros\n"); - else - curr_offset += sbytes; - - break; - case 'A': - sbytes = otrx_create_append_file(trx, optarg); - if (sbytes < 0) { - fprintf(stderr, "Failed to append file %s\n", optarg); - } else { - curr_offset += sbytes; - } - - sbytes = otrx_create_align(trx, curr_offset, 4); - if (sbytes < 0) - fprintf(stderr, "Failed to append zeros\n"); - else - curr_offset += sbytes; - break; - case 'a': - sbytes = otrx_create_align(trx, curr_offset, strtol(optarg, NULL, 0)); - if (sbytes < 0) - fprintf(stderr, "Failed to append zeros\n"); - else - curr_offset += sbytes; - break; - case 'b': - sbytes = strtol(optarg, NULL, 0) - curr_offset; - if (sbytes < 0) { - fprintf(stderr, "Current TRX length is 0x%zx, can't pad it with zeros to 0x%lx\n", curr_offset, strtol(optarg, NULL, 0)); - } else { - sbytes = otrx_create_append_zeros(trx, sbytes); - if (sbytes < 0) - fprintf(stderr, "Failed to append zeros\n"); - else - curr_offset += sbytes; - } - break; - } - if (err) - break; - } - - sbytes = otrx_create_align(trx, curr_offset, 0x1000); - if (sbytes < 0) - fprintf(stderr, "Failed to append zeros\n"); - else - curr_offset += sbytes; - - hdr.length = curr_offset; - otrx_create_write_hdr(trx, &hdr); -err_close: - fclose(trx); -out: - return err; -} - -/************************************************** - * Extract - **************************************************/ - -static void otrx_extract_parse_options(int argc, char **argv) { - int c; - - while ((c = getopt(argc, argv, "c:e:o:1:2:3:")) != -1) { - switch (c) { - case 'o': - trx_offset = atoi(optarg); - break; - case '1': - partition[0] = optarg; - break; - case '2': - partition[1] = optarg; - break; - case '3': - partition[2] = optarg; - break; - } - } -} - -static int otrx_extract_copy(FILE *trx, size_t offset, size_t length, char *out_path) { - FILE *out; - size_t bytes; - uint8_t *buf; - int err = 0; - - out = fopen(out_path, "w"); - if (!out) { - fprintf(stderr, "Couldn't open %s\n", out_path); - err = -EACCES; - goto out; - } - - buf = malloc(length); - if (!buf) { - fprintf(stderr, "Couldn't alloc %zu B buffer\n", length); - err = -ENOMEM; - goto err_close; - } - - fseek(trx, offset, SEEK_SET); - bytes = fread(buf, 1, length, trx); - if (bytes != length) { - fprintf(stderr, "Couldn't read %zu B of data from %s\n", length, trx_path); - err = -ENOMEM; - goto err_free_buf; - }; - - bytes = fwrite(buf, 1, length, out); - if (bytes != length) { - fprintf(stderr, "Couldn't write %zu B to %s\n", length, out_path); - err = -ENOMEM; - goto err_free_buf; - } - - printf("Extracted 0x%zx bytes into %s\n", length, out_path); - -err_free_buf: - free(buf); -err_close: - fclose(out); -out: - return err; -} - -static int otrx_extract(int argc, char **argv) { - FILE *trx; - struct trx_header hdr; - size_t bytes; - int i; - int err = 0; - - if (argc < 3) { - fprintf(stderr, "No TRX file passed\n"); - err = -EINVAL; - goto out; - } - trx_path = argv[2]; - - optind = 3; - otrx_extract_parse_options(argc, argv); - - trx = fopen(trx_path, "r"); - if (!trx) { - fprintf(stderr, "Couldn't open %s\n", trx_path); - err = -EACCES; - goto out; - } - - fseek(trx, trx_offset, SEEK_SET); - bytes = fread(&hdr, 1, sizeof(hdr), trx); - if (bytes != sizeof(hdr)) { - fprintf(stderr, "Couldn't read %s header\n", trx_path); - err = -EIO; - goto err_close; - } - - if (le32_to_cpu(hdr.magic) != TRX_MAGIC) { - fprintf(stderr, "Invalid TRX magic: 0x%08x\n", le32_to_cpu(hdr.magic)); - err = -EINVAL; - goto err_close; - } - - for (i = 0; i < TRX_MAX_PARTS; i++) { - size_t length; - - if (!partition[i]) - continue; - if (!hdr.offset[i]) { - printf("TRX doesn't contain partition %d, can't extract %s\n", i + 1, partition[i]); - continue; - } - - if (i + 1 >= TRX_MAX_PARTS || !hdr.offset[i + 1]) - length = le32_to_cpu(hdr.length) - le32_to_cpu(hdr.offset[i]); - else - length = le32_to_cpu(hdr.offset[i + 1]) - le32_to_cpu(hdr.offset[i]); - - otrx_extract_copy(trx, trx_offset + le32_to_cpu(hdr.offset[i]), length, partition[i]); - } - -err_close: - fclose(trx); -out: - return err; -} - -/************************************************** - * Start - **************************************************/ - -static void usage() { - printf("Usage:\n"); - printf("\n"); - printf("Checking TRX file:\n"); - printf("\totrx check <file> [options]\tcheck if file is a valid TRX\n"); - printf("\t-o offset\t\t\toffset of TRX data in file (default: 0)\n"); - printf("\n"); - printf("Creating new TRX file:\n"); - printf("\totrx create <file> [options] [partitions]\n"); - printf("\t-f file\t\t\t\t[partition] start new partition with content copied from file\n"); - printf("\t-A file\t\t\t\t[partition] append current partition with content copied from file\n"); - printf("\t-a alignment\t\t\t[partition] align current partition\n"); - printf("\t-b offset\t\t\t[partition] append zeros to partition till reaching absolute offset\n"); - printf("\n"); - printf("Extracting from TRX file:\n"); - printf("\totrx extract <file> [options]\textract partitions from TRX file\n"); - printf("\t-o offset\t\t\toffset of TRX data in file (default: 0)\n"); - printf("\t-1 file\t\t\t\tfile to extract 1st partition to (optional)\n"); - printf("\t-2 file\t\t\t\tfile to extract 2nd partition to (optional)\n"); - printf("\t-3 file\t\t\t\tfile to extract 3rd partition to (optional)\n"); -} - -int main(int argc, char **argv) { - if (argc > 1) { - if (!strcmp(argv[1], "check")) - return otrx_check(argc, argv); - else if (!strcmp(argv[1], "create")) - return otrx_create(argc, argv); - else if (!strcmp(argv[1], "extract")) - return otrx_extract(argc, argv); - } - - usage(); - return 0; -} diff --git a/package/utils/policycoreutils/Makefile b/package/utils/policycoreutils/Makefile index 249c2afb945..f5027c5ece0 100644 --- a/package/utils/policycoreutils/Makefile +++ b/package/utils/policycoreutils/Makefile @@ -6,12 +6,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=policycoreutils -PKG_VERSION:=3.2 +PKG_VERSION:=3.5 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_SOURCE_URL:=https://github.com/SELinuxProject/selinux/releases/download/3.2 -PKG_HASH:=d1331c6fa766c547b071c491de90b9f343c8dbffdb119be8a5a7e491199b93a9 +PKG_SOURCE_URL:=https://github.com/SELinuxProject/selinux/releases/download/$(PKG_VERSION) +PKG_HASH:=78453e1529fbbf800e88860094d555e781ce1fba11a7ef77b5aabb43e1173276 PKG_INSTALL:=1 HOST_BUILD_DEPENDS:=libsemanage/host gettext-full/host PKG_BUILD_DEPENDS:=BUSYBOX_CONFIG_PAM:libpam gettext-full/host diff --git a/package/utils/px5g-mbedtls/Makefile b/package/utils/px5g-mbedtls/Makefile index 42ffd39ce32..14c9f684a96 100644 --- a/package/utils/px5g-mbedtls/Makefile +++ b/package/utils/px5g-mbedtls/Makefile @@ -8,10 +8,10 @@ include $(TOPDIR)/rules.mk PKG_NAME:=px5g-mbedtls -PKG_RELEASE:=9 +PKG_RELEASE:=10 PKG_LICENSE:=LGPL-2.1 -PKG_USE_MIPS16:=0 +PKG_BUILD_FLAGS:=no-mips16 PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io> diff --git a/package/utils/px5g-mbedtls/px5g-mbedtls.c b/package/utils/px5g-mbedtls/px5g-mbedtls.c index 0b72154509a..85abe7dc73f 100644 --- a/package/utils/px5g-mbedtls/px5g-mbedtls.c +++ b/package/utils/px5g-mbedtls/px5g-mbedtls.c @@ -20,6 +20,7 @@ */ #include <sys/types.h> +#include <sys/random.h> #include <stdio.h> #include <stdlib.h> @@ -29,8 +30,10 @@ #include <unistd.h> #include <fcntl.h> #include <stdbool.h> +#include <errno.h> #include <mbedtls/bignum.h> +#include <mbedtls/entropy.h> #include <mbedtls/x509_crt.h> #include <mbedtls/ecp.h> #include <mbedtls/rsa.h> @@ -40,19 +43,26 @@ #define PX5G_COPY "Copyright (c) 2009 Steven Barth <steven@midlink.org>" #define PX5G_LICENSE "Licensed under the GNU Lesser General Public License v2.1" -static int urandom_fd; static char buf[16384]; static int _urandom(void *ctx, unsigned char *out, size_t len) { - read(urandom_fd, out, len); + ssize_t ret; + + ret = getrandom(out, len, 0); + if (ret < 0 || (size_t)ret != len) + return MBEDTLS_ERR_ENTROPY_SOURCE_FAILED; + return 0; } -static void write_file(const char *path, int len, bool pem) +static void write_file(const char *path, size_t len, bool pem, bool cert) { - FILE *f = stdout; + mode_t mode = S_IRUSR | S_IWUSR; const char *buf_start = buf; + int fd = STDERR_FILENO; + ssize_t written; + int err; if (!pem) buf_start += sizeof(buf) - len; @@ -61,17 +71,30 @@ static void write_file(const char *path, int len, bool pem) fprintf(stderr, "No data to write\n"); exit(1); } + + if (cert) + mode |= S_IRGRP | S_IROTH; - if (!f) { + if (path) + fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, mode); + + if (fd < 0) { fprintf(stderr, "error: I/O error\n"); exit(1); } + written = write(fd, buf_start, len); + if (written != len) { + fprintf(stderr, "writing key failed with: %s\n", strerror(errno)); + exit(1); + } + err = fsync(fd); + if (err < 0) { + fprintf(stderr, "syncing key failed with: %s\n", strerror(errno)); + exit(1); + } if (path) - f = fopen(path, "w"); - - fwrite(buf_start, 1, len, f); - fclose(f); + close(fd); } static mbedtls_ecp_group_id ecp_curve(const char *name) @@ -104,7 +127,7 @@ static void write_key(mbedtls_pk_context *key, const char *path, bool pem) len = 0; } - write_file(path, len, pem); + write_file(path, len, pem, false); } static void gen_key(mbedtls_pk_context *key, bool rsa, int ksize, int exp, @@ -295,7 +318,7 @@ int selfsigned(char **arg) return 1; } } - write_file(certpath, len, pem); + write_file(certpath, len, pem, true); mbedtls_x509write_crt_free(&cert); mbedtls_mpi_free(&serial); @@ -306,8 +329,6 @@ int selfsigned(char **arg) int main(int argc, char *argv[]) { - urandom_fd = open("/dev/urandom", O_RDONLY); - if (!argv[1]) { //Usage } else if (!strcmp(argv[1], "eckey")) { diff --git a/package/utils/px5g-wolfssl/Makefile b/package/utils/px5g-wolfssl/Makefile index 90296008d68..ba208f6ca59 100644 --- a/package/utils/px5g-wolfssl/Makefile +++ b/package/utils/px5g-wolfssl/Makefile @@ -5,13 +5,15 @@ include $(TOPDIR)/rules.mk PKG_NAME:=px5g-wolfssl -PKG_RELEASE:=$(COMMITCOUNT) +PKG_RELEASE:=9 PKG_LICENSE:=GPL-2.0-or-later -PKG_USE_MIPS16:=0 +PKG_BUILD_FLAGS:=no-mips16 PKG_MAINTAINER:=Paul Spooren <mail@aparcar.org> +PKG_CONFIG_DEPENDS:=CONFIG_WOLFSSL_ALT_NAMES + include $(INCLUDE_DIR)/package.mk define Package/px5g-wolfssl diff --git a/package/utils/px5g-wolfssl/px5g-wolfssl.c b/package/utils/px5g-wolfssl/px5g-wolfssl.c index 763d7b4b710..755d370ba2d 100644 --- a/package/utils/px5g-wolfssl/px5g-wolfssl.c +++ b/package/utils/px5g-wolfssl/px5g-wolfssl.c @@ -7,6 +7,8 @@ #include <stdint.h> #include <stdio.h> #include <string.h> +#include <fcntl.h> +#include <unistd.h> #include <wolfssl/options.h> #include <wolfssl/wolfcrypt/asn.h> #include <wolfssl/wolfcrypt/asn_public.h> @@ -24,27 +26,38 @@ enum { RSA_KEY_TYPE = 1, }; -int write_file(byte *buf, int bufSz, char *path) { - int ret; - FILE *file; +int write_file(byte *buf, int bufSz, char *path, bool cert) { + mode_t mode = S_IRUSR | S_IWUSR; + ssize_t written; + int err; + int fd; + + if (cert) + mode |= S_IRGRP | S_IROTH; + if (path) { - file = fopen(path, "wb"); - if (file == NULL) { + fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, mode); + if (fd < 0) { perror("Error opening file"); exit(1); } } else { - file = stdout; + fd = STDERR_FILENO; } - ret = (int)fwrite(buf, 1, bufSz, file); - if (path) { - fclose(file); + written = write(fd, buf, bufSz); + if (written != bufSz) { + perror("Error write file"); + exit(1); } - if (ret > 0) { - /* ret > 0 indicates a successful file write, set to zero for return */ - ret = 0; + err = fsync(fd); + if (err < 0) { + perror("Error fsync file"); + exit(1); } - return ret; + if (path) { + close(fd); + } + return 0; } int write_key(ecc_key *ecKey, RsaKey *rsaKey, int type, int keySz, char *fName, @@ -73,9 +86,9 @@ int write_key(ecc_key *ecKey, RsaKey *rsaKey, int type, int keySz, char *fName, fprintf(stderr, "DER to PEM failed: %d\n", ret); } pemSz = ret; - ret = write_file(pem, pemSz, fName); + ret = write_file(pem, pemSz, fName, false); } else { - ret = write_file(der, derSz, fName); + ret = write_file(der, derSz, fName, false); } return ret; } @@ -142,42 +155,42 @@ int selfsigned(WC_RNG *rng, char **arg) { newCert.isCA = 0; while (*arg && **arg == '-') { - if (!strncmp(*arg, "-der", 4)) { + if (!strcmp(*arg, "-der")) { pem = false; - } else if (!strncmp(*arg, "-newkey", 6) && arg[1]) { + } else if (!strcmp(*arg, "-newkey") && arg[1]) { if (!strncmp(arg[1], "rsa:", 4)) { type = RSA_KEY_TYPE; - keySz = (unsigned int)atoi(arg[1] + 4); - } else if (!strncmp(arg[1], "ec", 2)) { + keySz = atoi(arg[1] + 4); + } else if (!strcmp(arg[1], "ec")) { type = EC_KEY_TYPE; } else { fprintf(stderr, "error: invalid algorithm\n"); return 1; } arg++; - } else if (!strncmp(*arg, "-days", 5) && arg[1]) { + } else if (!strcmp(*arg, "-days") && arg[1]) { days = (unsigned int)atoi(arg[1]); arg++; - } else if (!strncmp(*arg, "-pkeyopt", 8) && arg[1]) { + } else if (!strcmp(*arg, "-pkeyopt") && arg[1]) { if (strncmp(arg[1], "ec_paramgen_curve:", 18)) { fprintf(stderr, "error: invalid pkey option: %s\n", arg[1]); return 1; } - if (!strncmp(arg[1] + 18, "P-256:", 5)) { + if (!strcmp(arg[1] + 18, "P-256")) { curve = ECC_SECP256R1; - } else if (!strncmp(arg[1] + 18, "P-384:", 5)) { + } else if (!strcmp(arg[1] + 18, "P-384")) { curve = ECC_SECP384R1; - } else if (!strncmp(arg[1] + 18, "P-521:", 5)) { + } else if (!strcmp(arg[1] + 18, "P-521")) { curve = ECC_SECP521R1; } else { fprintf(stderr, "error: invalid curve name: %s\n", arg[1] + 18); return 1; } arg++; - } else if (!strncmp(*arg, "-keyout", 7) && arg[1]) { + } else if (!strcmp(*arg, "-keyout") && arg[1]) { keypath = arg[1]; arg++; - } else if (!strncmp(*arg, "-out", 4) && arg[1]) { + } else if (!strcmp(*arg, "-out") && arg[1]) { certpath = arg[1]; arg++; } else if (!strcmp(*arg, "-subj") && arg[1]) { @@ -203,8 +216,23 @@ int selfsigned(WC_RNG *rng, char **arg) { strncpy(newCert.subject.org, val, CTC_NAME_SIZE); else if (!strcmp(key, "OU")) strncpy(newCert.subject.unit, val, CTC_NAME_SIZE); - else if (!strcmp(key, "CN")) + else if (!strcmp(key, "CN")) { strncpy(newCert.subject.commonName, val, CTC_NAME_SIZE); + +#ifdef WOLFSSL_ALT_NAMES + if(strlen(val) + 2 > 256) { + fprintf(stderr, "error: CN is too long: %s\n", val); + return 1; + } + + newCert.altNames[0] = 0x30; //Sequence with one element + newCert.altNames[1] = strlen(val) + 2; // Length of entire sequence + newCert.altNames[2] = 0x82; //8 - String, 2 - DNS Name + newCert.altNames[3] = strlen(val); //DNS Name length + memcpy(newCert.altNames + 4, val, strlen(val)); //DNS Name + newCert.altNamesSz = strlen(val) + 4; +#endif + } else if (!strcmp(key, "EMAIL")) strncpy(newCert.subject.email, val, CTC_NAME_SIZE); else @@ -216,6 +244,9 @@ int selfsigned(WC_RNG *rng, char **arg) { } newCert.daysValid = days; + newCert.keyUsage = KEYUSE_DIGITAL_SIG | KEYUSE_CONTENT_COMMIT | KEYUSE_KEY_ENCIPHER; + newCert.extKeyUsage = EXTKEYUSE_SERVER_AUTH; + gen_key(rng, &ecKey, &rsaKey, type, keySz, exp, curve); write_key(&ecKey, &rsaKey, type, keySz, keypath, pem); @@ -263,7 +294,7 @@ int selfsigned(WC_RNG *rng, char **arg) { } pemSz = ret; - ret = write_file(pemBuf, pemSz, certpath); + ret = write_file(pemBuf, pemSz, certpath, true); if (ret != 0) { fprintf(stderr, "Write Cert failed: %d\n", ret); return ret; @@ -288,25 +319,25 @@ int dokey(WC_RNG *rng, int type, char **arg) { bool pem = true; while (*arg && **arg == '-') { - if (!strncmp(*arg, "-out", 4) && arg[1]) { + if (!strcmp(*arg, "-out") && arg[1]) { path = arg[1]; arg++; - } else if (!strncmp(*arg, "-3", 2)) { + } else if (!strcmp(*arg, "-3")) { exp = 3; - } else if (!strncmp(*arg, "-der", 4)) { + } else if (!strcmp(*arg, "-der")) { pem = false; } arg++; } if (*arg && type == RSA_KEY_TYPE) { - keySz = (unsigned int)atoi(*arg); + keySz = atoi(*arg); } else if (*arg) { - if (!strncmp(*arg, "P-256", 5)) { + if (!strcmp(*arg, "P-256")) { curve = ECC_SECP256R1; - } else if (!strncmp(*arg, "P-384", 5)) { + } else if (!strcmp(*arg, "P-384")) { curve = ECC_SECP384R1; - } else if (!strncmp(*arg, "P-521", 5)) { + } else if (!strcmp(*arg, "P-521")) { curve = ECC_SECP521R1; } else { fprintf(stderr, "Invalid Curve Name: %s\n", *arg); @@ -338,13 +369,13 @@ int main(int argc, char *argv[]) { } if (argv[1]) { - if (!strncmp(argv[1], "eckey", 5)) + if (!strcmp(argv[1], "eckey")) return dokey(&rng, EC_KEY_TYPE, argv + 2); - if (!strncmp(argv[1], "rsakey", 5)) + if (!strcmp(argv[1], "rsakey")) return dokey(&rng, RSA_KEY_TYPE, argv + 2); - if (!strncmp(argv[1], "selfsigned", 10)) + if (!strcmp(argv[1], "selfsigned")) return selfsigned(&rng, argv + 2); } diff --git a/package/utils/secilc/Makefile b/package/utils/secilc/Makefile index 7ed22615c01..5469039e228 100644 --- a/package/utils/secilc/Makefile +++ b/package/utils/secilc/Makefile @@ -6,12 +6,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=secilc -PKG_VERSION:=3.2 +PKG_VERSION:=3.5 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_SOURCE_URL:=https://github.com/SELinuxProject/selinux/releases/download/3.2 -PKG_HASH:=5f6e6528a281b29ac5e558babffc3d8aab682fd8df8977daff5f266a50292cc3 +PKG_SOURCE_URL:=https://github.com/SELinuxProject/selinux/releases/download/$(PKG_VERSION) +PKG_HASH:=3eebc5a1f97847fa530cf90654b9f3b8f21a13c9ea3d07495325651580cd3373 HOST_BUILD_DEPENDS:=libsepol/host PKG_MAINTAINER:=Dominick Grift <dominick.grift@defensec.nl> diff --git a/package/utils/spidev_test/Makefile b/package/utils/spidev_test/Makefile index 0f288ad0106..fef5c8f6467 100644 --- a/package/utils/spidev_test/Makefile +++ b/package/utils/spidev_test/Makefile @@ -10,7 +10,6 @@ include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=spidev-test PKG_RELEASE:=$(LINUX_VERSION) -PKG_FLAGS:=nonshared PKG_BUILD_DIR:=$(LINUX_DIR)/tools/spi-$(TARGET_DIR_NAME) PKG_BUILD_PARALLEL:=1 @@ -19,7 +18,7 @@ include $(INCLUDE_DIR)/package.mk define Package/spidev-test SECTION:=utils CATEGORY:=Utilities - DEPENDS:=+kmod-spi-dev @!IN_SDK + DEPENDS:=+kmod-spi-dev TITLE:=SPI testing utility VERSION:=$(LINUX_VERSION)-$(PKG_RELEASE) URL:=http://www.kernel.org @@ -30,6 +29,8 @@ define Package/spidev-test/description endef define Build/Prepare + # For SDK: Sources are copied by target/sdk/Makefile's + # USERSPACE_UTILS(_FILES) $(CP) $(LINUX_DIR)/tools/spi/* $(PKG_BUILD_DIR)/ endef diff --git a/package/utils/ucode-mod-bpf/Makefile b/package/utils/ucode-mod-bpf/Makefile new file mode 100644 index 00000000000..a748b9dbbd0 --- /dev/null +++ b/package/utils/ucode-mod-bpf/Makefile @@ -0,0 +1,40 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=ucode-mod-bpf +PKG_RELEASE:=1 +PKG_LICENSE:=ISC +PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name> + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/nls.mk + +define Package/ucode-mod-bpf + SECTION:=utils + CATEGORY:=Utilities + TITLE:=ucode eBPF module + DEPENDS:=+libucode +libbpf +endef + +define Package/ucode-mod-bpf/description +The bpf plugin provides functionality for loading and interacting with +eBPF modules. + +It allows loading full modules and pinned maps/programs and supports +interacting with maps and attaching programs as tc classifiers. +endef + +define Package/ucode-mod-bpf/install + $(INSTALL_DIR) $(1)/usr/lib/ucode + $(CP) $(PKG_BUILD_DIR)/bpf.so $(1)/usr/lib/ucode/ +endef + +define Build/Configure +endef + +define Build/Compile + $(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_LDFLAGS) $(FPIC) \ + -Wall -ffunction-sections -Wl,--gc-sections -shared -Wl,--no-as-needed -lbpf \ + -o $(PKG_BUILD_DIR)/bpf.so $(PKG_BUILD_DIR)/bpf.c +endef + +$(eval $(call BuildPackage,ucode-mod-bpf)) diff --git a/package/utils/ucode-mod-bpf/src/bpf.c b/package/utils/ucode-mod-bpf/src/bpf.c new file mode 100644 index 00000000000..415215e54e1 --- /dev/null +++ b/package/utils/ucode-mod-bpf/src/bpf.c @@ -0,0 +1,814 @@ +#include <sys/resource.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <net/if.h> + +#include <stdint.h> +#include <stdio.h> +#include <errno.h> +#include <unistd.h> + +#include <bpf/bpf.h> +#include <bpf/libbpf.h> + +#include "ucode/module.h" + +#define err_return_int(err, ...) do { set_error(err, __VA_ARGS__); return -1; } while(0) +#define err_return(err, ...) do { set_error(err, __VA_ARGS__); return NULL; } while(0) +#define TRUE ucv_boolean_new(true) + +static uc_resource_type_t *module_type, *map_type, *map_iter_type, *program_type; +static uc_value_t *registry; +static uc_vm_t *debug_vm; + +static struct { + int code; + char *msg; +} last_error; + +struct uc_bpf_fd { + int fd; + bool close; +}; + +struct uc_bpf_map { + struct uc_bpf_fd fd; /* must be first */ + unsigned int key_size, val_size; +}; + +struct uc_bpf_map_iter { + int fd; + unsigned int key_size; + bool has_next; + uint8_t key[]; +}; + +__attribute__((format(printf, 2, 3))) static void +set_error(int errcode, const char *fmt, ...) +{ + va_list ap; + + free(last_error.msg); + + last_error.code = errcode; + last_error.msg = NULL; + + if (fmt) { + va_start(ap, fmt); + xvasprintf(&last_error.msg, fmt, ap); + va_end(ap); + } +} + +static void init_env(void) +{ + static bool init_done = false; + struct rlimit limit = { + .rlim_cur = RLIM_INFINITY, + .rlim_max = RLIM_INFINITY, + }; + + if (init_done) + return; + + setrlimit(RLIMIT_MEMLOCK, &limit); + init_done = true; +} + +static uc_value_t * +uc_bpf_error(uc_vm_t *vm, size_t nargs) +{ + uc_value_t *numeric = uc_fn_arg(0); + const char *msg = last_error.msg; + int code = last_error.code; + uc_stringbuf_t *buf; + const char *s; + + if (last_error.code == 0) + return NULL; + + set_error(0, NULL); + + if (ucv_is_truish(numeric)) + return ucv_int64_new(code); + + buf = ucv_stringbuf_new(); + if (code < 0 && msg) { + ucv_stringbuf_addstr(buf, msg, strlen(msg)); + } else { + s = strerror(code); + ucv_stringbuf_addstr(buf, s, strlen(s)); + if (msg) + ucv_stringbuf_printf(buf, ": %s", msg); + } + + return ucv_stringbuf_finish(buf); +} + +static int +uc_bpf_module_set_opts(struct bpf_object *obj, uc_value_t *opts) +{ + uc_value_t *val; + + if (!opts) + return 0; + + if (ucv_type(opts) != UC_OBJECT) + err_return_int(EINVAL, "options argument"); + + if ((val = ucv_object_get(opts, "rodata", NULL)) != NULL) { + struct bpf_map *map = NULL; + + if (ucv_type(val) != UC_STRING) + err_return_int(EINVAL, "rodata type"); + + while ((map = bpf_object__next_map(obj, map)) != NULL) { + if (!strstr(bpf_map__name(map), ".rodata")) + continue; + + break; + } + + if (!map) + err_return_int(errno, "rodata map"); + + if (bpf_map__set_initial_value(map, ucv_string_get(val), + ucv_string_length(val))) + err_return_int(errno, "rodata"); + } + + if ((val = ucv_object_get(opts, "program-type", NULL)) != NULL) { + if (ucv_type(val) != UC_OBJECT) + err_return_int(EINVAL, "prog_types argument"); + + ucv_object_foreach(val, name, type) { + struct bpf_program *prog; + + if (ucv_type(type) != UC_INTEGER) + err_return_int(EINVAL, "program %s type", name); + + prog = bpf_object__find_program_by_name(obj, name); + if (!prog) + err_return_int(-1, "program %s not found", name); + + bpf_program__set_type(prog, ucv_int64_get(type)); + } + } + + return 0; +} + +static uc_value_t * +uc_bpf_open_module(uc_vm_t *vm, size_t nargs) +{ + DECLARE_LIBBPF_OPTS(bpf_object_open_opts, bpf_opts); + uc_value_t *path = uc_fn_arg(0); + uc_value_t *opts = uc_fn_arg(1); + struct bpf_object *obj; + + if (ucv_type(path) != UC_STRING) + err_return(EINVAL, "module path"); + + init_env(); + obj = bpf_object__open_file(ucv_string_get(path), &bpf_opts); + if (libbpf_get_error(obj)) + err_return(errno, NULL); + + if (uc_bpf_module_set_opts(obj, opts)) { + bpf_object__close(obj); + return NULL; + } + + if (bpf_object__load(obj)) { + bpf_object__close(obj); + err_return(errno, NULL); + } + + return uc_resource_new(module_type, obj); +} + +static uc_value_t * +uc_bpf_map_create(int fd, unsigned int key_size, unsigned int val_size, bool close) +{ + struct uc_bpf_map *uc_map; + + uc_map = xalloc(sizeof(*uc_map)); + uc_map->fd.fd = fd; + uc_map->key_size = key_size; + uc_map->val_size = val_size; + uc_map->fd.close = close; + + return uc_resource_new(map_type, uc_map); +} + +static uc_value_t * +uc_bpf_open_map(uc_vm_t *vm, size_t nargs) +{ + struct bpf_map_info info; + uc_value_t *path = uc_fn_arg(0); + __u32 len = sizeof(info); + int err; + int fd; + + if (ucv_type(path) != UC_STRING) + err_return(EINVAL, "module path"); + + fd = bpf_obj_get(ucv_string_get(path)); + if (fd < 0) + err_return(errno, NULL); + + err = bpf_obj_get_info_by_fd(fd, &info, &len); + if (err) { + close(fd); + err_return(errno, NULL); + } + + return uc_bpf_map_create(fd, info.key_size, info.value_size, true); +} + +static uc_value_t * +uc_bpf_open_program(uc_vm_t *vm, size_t nargs) +{ + uc_value_t *path = uc_fn_arg(0); + struct uc_bpf_fd *f; + int fd; + + if (ucv_type(path) != UC_STRING) + err_return(EINVAL, "module path"); + + fd = bpf_obj_get(ucv_string_get(path)); + if (fd < 0) + err_return(errno, NULL); + + f = xalloc(sizeof(*f)); + f->fd = fd; + f->close = true; + + return uc_resource_new(program_type, f); +} + +static uc_value_t * +uc_bpf_module_get_maps(uc_vm_t *vm, size_t nargs) +{ + struct bpf_object *obj = uc_fn_thisval("bpf.module"); + struct bpf_map *map = NULL; + uc_value_t *rv; + int i = 0; + + if (!obj) + err_return(EINVAL, NULL); + + rv = ucv_array_new(vm); + bpf_object__for_each_map(map, obj) + ucv_array_set(rv, i++, ucv_string_new(bpf_map__name(map))); + + return rv; +} + +static uc_value_t * +uc_bpf_module_get_map(uc_vm_t *vm, size_t nargs) +{ + struct bpf_object *obj = uc_fn_thisval("bpf.module"); + struct bpf_map *map; + uc_value_t *name = uc_fn_arg(0); + int fd; + + if (!obj || ucv_type(name) != UC_STRING) + err_return(EINVAL, NULL); + + map = bpf_object__find_map_by_name(obj, ucv_string_get(name)); + if (!map) + err_return(errno, NULL); + + fd = bpf_map__fd(map); + if (fd < 0) + err_return(EINVAL, NULL); + + return uc_bpf_map_create(fd, bpf_map__key_size(map), bpf_map__value_size(map), false); +} + +static uc_value_t * +uc_bpf_module_get_programs(uc_vm_t *vm, size_t nargs) +{ + struct bpf_object *obj = uc_fn_thisval("bpf.module"); + struct bpf_program *prog = NULL; + uc_value_t *rv; + int i = 0; + + if (!obj) + err_return(EINVAL, NULL); + + rv = ucv_array_new(vm); + bpf_object__for_each_program(prog, obj) + ucv_array_set(rv, i++, ucv_string_new(bpf_program__name(prog))); + + return rv; +} + +static uc_value_t * +uc_bpf_module_get_program(uc_vm_t *vm, size_t nargs) +{ + struct bpf_object *obj = uc_fn_thisval("bpf.module"); + struct bpf_program *prog; + uc_value_t *name = uc_fn_arg(0); + struct uc_bpf_fd *f; + int fd; + + if (!obj || !name || ucv_type(name) != UC_STRING) + err_return(EINVAL, NULL); + + prog = bpf_object__find_program_by_name(obj, ucv_string_get(name)); + if (!prog) + err_return(errno, NULL); + + fd = bpf_program__fd(prog); + if (fd < 0) + err_return(EINVAL, NULL); + + f = xalloc(sizeof(*f)); + f->fd = fd; + + return uc_resource_new(program_type, f); +} + +static void * +uc_bpf_map_arg(uc_value_t *val, const char *kind, unsigned int size) +{ + static union { + uint32_t u32; + uint64_t u64; + } val_int; + + switch (ucv_type(val)) { + case UC_INTEGER: + if (size == 4) + val_int.u32 = ucv_int64_get(val); + else if (size == 8) + val_int.u64 = ucv_int64_get(val); + else + break; + + return &val_int; + case UC_STRING: + if (size != ucv_string_length(val)) + break; + + return ucv_string_get(val); + default: + err_return(EINVAL, "%s type", kind); + } + + err_return(EINVAL, "%s size mismatch (expected: %d)", kind, size); +} + +static uc_value_t * +uc_bpf_map_get(uc_vm_t *vm, size_t nargs) +{ + struct uc_bpf_map *map = uc_fn_thisval("bpf.map"); + uc_value_t *a_key = uc_fn_arg(0); + void *key, *val; + + if (!map) + err_return(EINVAL, NULL); + + key = uc_bpf_map_arg(a_key, "key", map->key_size); + if (!key) + return NULL; + + val = alloca(map->val_size); + if (bpf_map_lookup_elem(map->fd.fd, key, val)) + return NULL; + + return ucv_string_new_length(val, map->val_size); +} + +static uc_value_t * +uc_bpf_map_set(uc_vm_t *vm, size_t nargs) +{ + struct uc_bpf_map *map = uc_fn_thisval("bpf.map"); + uc_value_t *a_key = uc_fn_arg(0); + uc_value_t *a_val = uc_fn_arg(1); + uc_value_t *a_flags = uc_fn_arg(2); + uint64_t flags; + void *key, *val; + + if (!map) + err_return(EINVAL, NULL); + + key = uc_bpf_map_arg(a_key, "key", map->key_size); + if (!key) + return NULL; + + val = uc_bpf_map_arg(a_val, "value", map->val_size); + if (!val) + return NULL; + + if (!a_flags) + flags = BPF_ANY; + else if (ucv_type(a_flags) != UC_INTEGER) + err_return(EINVAL, "flags"); + else + flags = ucv_int64_get(a_flags); + + if (bpf_map_update_elem(map->fd.fd, key, val, flags)) + return NULL; + + return ucv_string_new_length(val, map->val_size); +} + +static uc_value_t * +uc_bpf_map_delete(uc_vm_t *vm, size_t nargs) +{ + struct uc_bpf_map *map = uc_fn_thisval("bpf.map"); + uc_value_t *a_key = uc_fn_arg(0); + uc_value_t *a_return = uc_fn_arg(1); + void *key, *val = NULL; + int ret; + + if (!map) + err_return(EINVAL, NULL); + + key = uc_bpf_map_arg(a_key, "key", map->key_size); + if (!key) + return NULL; + + if (!ucv_is_truish(a_return)) { + ret = bpf_map_delete_elem(map->fd.fd, key); + + return ucv_boolean_new(ret == 0); + } + + val = alloca(map->val_size); + if (bpf_map_lookup_and_delete_elem(map->fd.fd, key, val)) + return NULL; + + return ucv_string_new_length(val, map->val_size); +} + +static uc_value_t * +uc_bpf_map_delete_all(uc_vm_t *vm, size_t nargs) +{ + struct uc_bpf_map *map = uc_fn_thisval("bpf.map"); + uc_value_t *filter = uc_fn_arg(0); + bool has_next; + void *key, *next; + + if (!map) + err_return(EINVAL, NULL); + + key = alloca(map->key_size); + next = alloca(map->key_size); + has_next = !bpf_map_get_next_key(map->fd.fd, NULL, next); + while (has_next) { + bool skip = false; + + memcpy(key, next, map->key_size); + has_next = !bpf_map_get_next_key(map->fd.fd, next, next); + + if (ucv_is_callable(filter)) { + uc_value_t *rv; + + uc_value_push(ucv_get(filter)); + uc_value_push(ucv_string_new_length((const char *)key, map->key_size)); + if (uc_call(1) != EXCEPTION_NONE) + break; + + rv = uc_vm_stack_pop(vm); + if (!rv) + break; + + skip = !ucv_is_truish(rv); + ucv_put(rv); + } + + if (!skip) + bpf_map_delete_elem(map->fd.fd, key); + } + + return TRUE; +} + +static uc_value_t * +uc_bpf_map_iterator(uc_vm_t *vm, size_t nargs) +{ + struct uc_bpf_map *map = uc_fn_thisval("bpf.map"); + struct uc_bpf_map_iter *iter; + + if (!map) + err_return(EINVAL, NULL); + + iter = xalloc(sizeof(*iter) + map->key_size); + iter->fd = map->fd.fd; + iter->key_size = map->key_size; + iter->has_next = !bpf_map_get_next_key(iter->fd, NULL, &iter->key); + + return uc_resource_new(map_iter_type, iter); +} + +static uc_value_t * +uc_bpf_map_iter_next(uc_vm_t *vm, size_t nargs) +{ + struct uc_bpf_map_iter *iter = uc_fn_thisval("bpf.map_iter"); + uc_value_t *rv; + + if (!iter->has_next) + return NULL; + + rv = ucv_string_new_length((const char *)iter->key, iter->key_size); + iter->has_next = !bpf_map_get_next_key(iter->fd, &iter->key, &iter->key); + + return rv; +} + +static uc_value_t * +uc_bpf_map_iter_next_int(uc_vm_t *vm, size_t nargs) +{ + struct uc_bpf_map_iter *iter = uc_fn_thisval("bpf.map_iter"); + uint64_t intval; + uc_value_t *rv; + + if (!iter->has_next) + return NULL; + + if (iter->key_size == 4) + intval = *(uint32_t *)iter->key; + else if (iter->key_size == 8) + intval = *(uint64_t *)iter->key; + else + return NULL; + + rv = ucv_int64_new(intval); + iter->has_next = !bpf_map_get_next_key(iter->fd, &iter->key, &iter->key); + + return rv; +} + +static uc_value_t * +uc_bpf_map_foreach(uc_vm_t *vm, size_t nargs) +{ + struct uc_bpf_map *map = uc_fn_thisval("bpf.map"); + uc_value_t *func = uc_fn_arg(0); + bool has_next; + void *key, *next; + bool ret = false; + + key = alloca(map->key_size); + next = alloca(map->key_size); + has_next = !bpf_map_get_next_key(map->fd.fd, NULL, next); + + while (has_next) { + uc_value_t *rv; + bool stop; + + memcpy(key, next, map->key_size); + has_next = !bpf_map_get_next_key(map->fd.fd, next, next); + + uc_value_push(ucv_get(func)); + uc_value_push(ucv_string_new_length((const char *)key, map->key_size)); + + if (uc_call(1) != EXCEPTION_NONE) + break; + + rv = uc_vm_stack_pop(vm); + stop = (ucv_type(rv) == UC_BOOLEAN && !ucv_boolean_get(rv)); + ucv_put(rv); + + if (stop) + break; + + ret = true; + } + + return ucv_boolean_new(ret); +} + +static uc_value_t * +uc_bpf_obj_pin(uc_vm_t *vm, size_t nargs, const char *type) +{ + struct uc_bpf_fd *f = uc_fn_thisval(type); + uc_value_t *path = uc_fn_arg(0); + + if (ucv_type(path) != UC_STRING) + err_return(EINVAL, NULL); + + if (bpf_obj_pin(f->fd, ucv_string_get(path))) + err_return(errno, NULL); + + return TRUE; +} + +static uc_value_t * +uc_bpf_program_pin(uc_vm_t *vm, size_t nargs) +{ + return uc_bpf_obj_pin(vm, nargs, "bpf.program"); +} + +static uc_value_t * +uc_bpf_map_pin(uc_vm_t *vm, size_t nargs) +{ + return uc_bpf_obj_pin(vm, nargs, "bpf.map"); +} + +static uc_value_t * +uc_bpf_set_tc_hook(uc_value_t *ifname, uc_value_t *type, uc_value_t *prio, + int fd) +{ + DECLARE_LIBBPF_OPTS(bpf_tc_hook, hook); + DECLARE_LIBBPF_OPTS(bpf_tc_opts, attach_tc, + .handle = 1); + const char *type_str; + uint64_t prio_val; + + if (ucv_type(ifname) != UC_STRING || ucv_type(type) != UC_STRING || + ucv_type(prio) != UC_INTEGER) + err_return(EINVAL, NULL); + + prio_val = ucv_int64_get(prio); + if (prio_val > 0xffff) + err_return(EINVAL, NULL); + + type_str = ucv_string_get(type); + if (!strcmp(type_str, "ingress")) + hook.attach_point = BPF_TC_INGRESS; + else if (!strcmp(type_str, "egress")) + hook.attach_point = BPF_TC_EGRESS; + else + err_return(EINVAL, NULL); + + hook.ifindex = if_nametoindex(ucv_string_get(ifname)); + if (!hook.ifindex) + goto error; + + bpf_tc_hook_create(&hook); + attach_tc.priority = prio_val; + if (bpf_tc_detach(&hook, &attach_tc) < 0 && fd < 0) + goto error; + + if (fd < 0) + goto out; + + attach_tc.prog_fd = fd; + if (bpf_tc_attach(&hook, &attach_tc) < 0) + goto error; + +out: + return TRUE; + +error: + if (fd >= 0) + err_return(ENOENT, NULL); + return NULL; +} + +static uc_value_t * +uc_bpf_program_tc_attach(uc_vm_t *vm, size_t nargs) +{ + struct uc_bpf_fd *f = uc_fn_thisval("bpf.program"); + uc_value_t *ifname = uc_fn_arg(0); + uc_value_t *type = uc_fn_arg(1); + uc_value_t *prio = uc_fn_arg(2); + + if (!f) + err_return(EINVAL, NULL); + + return uc_bpf_set_tc_hook(ifname, type, prio, f->fd); +} + +static uc_value_t * +uc_bpf_tc_detach(uc_vm_t *vm, size_t nargs) +{ + uc_value_t *ifname = uc_fn_arg(0); + uc_value_t *type = uc_fn_arg(1); + uc_value_t *prio = uc_fn_arg(2); + + return uc_bpf_set_tc_hook(ifname, type, prio, -1); +} + +static int +uc_bpf_debug_print(enum libbpf_print_level level, const char *format, + va_list args) +{ + char buf[256], *str = NULL; + uc_value_t *val; + va_list ap; + int size; + + va_copy(ap, args); + size = vsnprintf(buf, sizeof(buf), format, ap); + va_end(ap); + + if (size > 0 && (unsigned long)size < ARRAY_SIZE(buf) - 1) { + val = ucv_string_new(buf); + goto out; + } + + if (vasprintf(&str, format, args) < 0) + return 0; + + val = ucv_string_new(str); + free(str); + +out: + uc_vm_stack_push(debug_vm, ucv_get(ucv_array_get(registry, 0))); + uc_vm_stack_push(debug_vm, ucv_int64_new(level)); + uc_vm_stack_push(debug_vm, val); + if (uc_vm_call(debug_vm, false, 2) == EXCEPTION_NONE) + ucv_put(uc_vm_stack_pop(debug_vm)); + + return 0; +} + +static uc_value_t * +uc_bpf_set_debug_handler(uc_vm_t *vm, size_t nargs) +{ + uc_value_t *handler = uc_fn_arg(0); + + if (handler && !ucv_is_callable(handler)) + err_return(EINVAL, NULL); + + debug_vm = vm; + libbpf_set_print(handler ? uc_bpf_debug_print : NULL); + + ucv_array_set(registry, 0, ucv_get(handler)); + + return NULL; +} + +static void +register_constants(uc_vm_t *vm, uc_value_t *scope) +{ +#define ADD_CONST(x) ucv_object_add(scope, #x, ucv_int64_new(x)) + ADD_CONST(BPF_PROG_TYPE_SCHED_CLS); + ADD_CONST(BPF_PROG_TYPE_SCHED_ACT); + + ADD_CONST(BPF_ANY); + ADD_CONST(BPF_NOEXIST); + ADD_CONST(BPF_EXIST); + ADD_CONST(BPF_F_LOCK); +} + +static const uc_function_list_t module_fns[] = { + { "get_map", uc_bpf_module_get_map }, + { "get_maps", uc_bpf_module_get_maps }, + { "get_programs", uc_bpf_module_get_programs }, + { "get_program", uc_bpf_module_get_program }, +}; + +static void module_free(void *ptr) +{ + struct bpf_object *obj = ptr; + + bpf_object__close(obj); +} + +static const uc_function_list_t map_fns[] = { + { "pin", uc_bpf_map_pin }, + { "get", uc_bpf_map_get }, + { "set", uc_bpf_map_set }, + { "delete", uc_bpf_map_delete }, + { "delete_all", uc_bpf_map_delete_all }, + { "foreach", uc_bpf_map_foreach }, + { "iterator", uc_bpf_map_iterator }, +}; + +static void uc_bpf_fd_free(void *ptr) +{ + struct uc_bpf_fd *f = ptr; + + if (f->close) + close(f->fd); + free(f); +} + +static const uc_function_list_t map_iter_fns[] = { + { "next", uc_bpf_map_iter_next }, + { "next_int", uc_bpf_map_iter_next_int }, +}; + +static const uc_function_list_t prog_fns[] = { + { "pin", uc_bpf_program_pin }, + { "tc_attach", uc_bpf_program_tc_attach }, +}; + +static const uc_function_list_t global_fns[] = { + { "error", uc_bpf_error }, + { "set_debug_handler", uc_bpf_set_debug_handler }, + { "open_module", uc_bpf_open_module }, + { "open_map", uc_bpf_open_map }, + { "open_program", uc_bpf_open_program }, + { "tc_detach", uc_bpf_tc_detach }, +}; + +void uc_module_init(uc_vm_t *vm, uc_value_t *scope) +{ + uc_function_list_register(scope, global_fns); + register_constants(vm, scope); + + registry = ucv_array_new(vm); + uc_vm_registry_set(vm, "bpf.registry", registry); + + module_type = uc_type_declare(vm, "bpf.module", module_fns, module_free); + map_type = uc_type_declare(vm, "bpf.map", map_fns, uc_bpf_fd_free); + map_iter_type = uc_type_declare(vm, "bpf.map_iter", map_iter_fns, free); + program_type = uc_type_declare(vm, "bpf.program", prog_fns, uc_bpf_fd_free); +} diff --git a/package/utils/ucode/Makefile b/package/utils/ucode/Makefile index 7c8907a7165..51a378198ce 100644 --- a/package/utils/ucode/Makefile +++ b/package/utils/ucode/Makefile @@ -12,24 +12,55 @@ PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=https://github.com/jow-/ucode.git -PKG_SOURCE_DATE:=2021-03-31 -PKG_SOURCE_VERSION:=973cc6c865dcf6075c493125313058b650b08234 -PKG_MIRROR_HASH:=fb4d3e231c79a9122743f0ced7fd4fdcf81903de5c721d3c18d5779e44d50bdf +PKG_SOURCE_DATE:=2024-02-13 +PKG_SOURCE_VERSION:=3f9811d2f7b730f1f1d030872ae1def7e8349be6 +PKG_MIRROR_HASH:=b05cdaa6ecaf8c4b79e67551085c5580d09c5940304b5837a859324abbb26e94 PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io> PKG_LICENSE:=ISC +PKG_ABI_VERSION:=20230711 +HOST_BUILD_DEPENDS:=libjson-c/host + include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/host-build.mk include $(INCLUDE_DIR)/cmake.mk +CMAKE_OPTIONS += -DSOVERSION=$(PKG_ABI_VERSION) + +ifeq ($(HOST_OS),Darwin) + CMAKE_HOST_OPTIONS += \ + -DCMAKE_SKIP_RPATH=FALSE \ + -DCMAKE_MACOSX_RPATH=1 \ + -DCMAKE_INSTALL_RPATH="${STAGING_DIR_HOSTPKG}/lib" +else + CMAKE_HOST_OPTIONS += \ + -DSOVERSION=$(PKG_ABI_VERSION) +endif + +CMAKE_HOST_OPTIONS += \ + -DFS_SUPPORT=ON \ + -DMATH_SUPPORT=ON \ + -DNL80211_SUPPORT=OFF \ + -DRESOLV_SUPPORT=OFF \ + -DRTNL_SUPPORT=OFF \ + -DSTRUCT_SUPPORT=ON \ + -DUBUS_SUPPORT=OFF \ + -DUCI_SUPPORT=OFF \ + -DULOOP_SUPPORT=OFF \ + -DDEBUG_SUPPORT=ON \ + -DLOG_SUPPORT=OFF + + define Package/ucode/default - SECTION:=utils - CATEGORY:=Utilities - TITLE:=ucode - Tiny scripting and templating language + SUBMENU:=ucode + SECTION:=lang + CATEGORY:=Languages + TITLE:=Tiny scripting and templating language endef define Package/ucode $(Package/ucode/default) - DEPENDS:=+libjson-c + DEPENDS:=+libucode endef define Package/ucode/description @@ -38,79 +69,112 @@ define Package/ucode/description endef -define Package/ucode-mod-fs +define Package/libucode $(Package/ucode/default) - TITLE+= (filesystem module) - DEPENDS:=ucode + SUBMENU:= + SECTION:=libs + CATEGORY:=Libraries + TITLE+= (library) + ABI_VERSION:=$(PKG_ABI_VERSION) + DEPENDS:=+libjson-c endef -define Package/ucode-mod-fs/description - The filesystem plugin module allows interaction with the local file system. +define Package/libucode/description + The libucode package provides the shared runtime library for the ucode interpreter. endef +# 1: name +# 2: cmake symbol +# 3: depends +# 4: description +define UcodeModule + UCODE_MODULES += ucode-mod-$(strip $(1)) + CMAKE_OPTIONS += -D$(strip $(2))=$(if $(CONFIG_PACKAGE_ucode-mod-$(strip $(1))),ON,OFF) + PKG_CONFIG_DEPENDS += CONFIG_PACKAGE_ucode-mod-$(strip $(1)) -define Package/ucode-mod-math + define Package/ucode-mod-$(strip $(1)) $(Package/ucode/default) - TITLE+= (math module) - DEPENDS:=ucode + TITLE+= ($(strip $(1)) module) + DEPENDS:=+ucode $(3) + endef + + define Package/ucode-mod-$(strip $(1))/description + $(strip $(4)) + endef + + define Package/ucode-mod-$(strip $(1))/install + $(INSTALL_DIR) $$(1)/usr/lib/ucode + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/ucode/$(strip $(1)).so $$(1)/usr/lib/ucode/ + endef endef -define Package/ucode-mod-math/description - The math plugin provides access to various <math.h> procedures. + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/lib $(1)/usr/include/ucode + $(CP) $(PKG_INSTALL_DIR)/usr/include/ucode/*.h $(1)/usr/include/ucode/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libucode.so* $(1)/usr/lib/ endef -define Package/ucode-mod-ubus - $(Package/ucode/default) - TITLE+= (ubus module) - DEPENDS:=ucode +libubus +libblobmsg-json +define Package/ucode/install + $(INSTALL_DIR) $(1)/usr/bin + $(CP) $(PKG_INSTALL_DIR)/usr/bin/u* $(1)/usr/bin/ endef -define Package/ucode-mod-ubus/description - The ubus module allows ucode template scripts to enumerate and invoke ubus - procedures. +define Package/libucode/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libucode.so.* $(1)/usr/lib/ endef -define Package/ucode-mod-uci - $(Package/ucode/default) - TITLE+= (uci module) - DEPENDS:=ucode +libuci -endef +$(eval $(call UcodeModule, \ + debug, DEBUG_SUPPORT, +libubox +libucode, \ + The debug plugin module provides runtime debugging and introspection facilities.)) -define Package/ucode-mod-uci/description - The uci module allows templates to read and modify uci configuration. -endef +$(eval $(call UcodeModule, \ + fs, FS_SUPPORT, , \ + The filesystem plugin module allows interaction with the local file system.)) +$(eval $(call UcodeModule, \ + log, LOG_SUPPORT, +libubox, \ + The log plugin module provides access to the syslog and libubox ulog APIs.)) -define Package/ucode/install - $(INSTALL_DIR) $(1)/usr/bin - $(INSTALL_BIN) $(PKG_BUILD_DIR)/ucode $(1)/usr/bin/ucode -endef +$(eval $(call UcodeModule, \ + math, MATH_SUPPORT, , \ + The math plugin provides access to various <math.h> procedures.)) -define Package/ucode-mod-fs/install - $(INSTALL_DIR) $(1)/usr/lib/ucode - $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/fs.so $(1)/usr/lib/ucode/ -endef +$(eval $(call UcodeModule, \ + nl80211, NL80211_SUPPORT, +libnl-tiny +libubox, \ + The nl80211 plugin provides access to the Linux wireless 802.11 netlink API.)) -define Package/ucode-mod-math/install - $(INSTALL_DIR) $(1)/usr/lib/ucode - $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/math.so $(1)/usr/lib/ucode/ -endef +$(eval $(call UcodeModule, \ + resolv, RESOLV_SUPPORT, , \ + The resolv plugin implements simple DNS resolving.)) -define Package/ucode-mod-ubus/install - $(INSTALL_DIR) $(1)/usr/lib/ucode - $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/ubus.so $(1)/usr/lib/ucode/ -endef +$(eval $(call UcodeModule, \ + rtnl, RTNL_SUPPORT, +libnl-tiny +libubox, \ + The rtnl plugin provides access to the Linux routing netlink API.)) -define Package/ucode-mod-uci/install - $(INSTALL_DIR) $(1)/usr/lib/ucode - $(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/uci.so $(1)/usr/lib/ucode/ -endef +$(eval $(call UcodeModule, \ + struct, STRUCT_SUPPORT, , \ + The struct plugin implements Python 3 compatible struct.pack/unpack functionality.)) + +$(eval $(call UcodeModule, \ + ubus, UBUS_SUPPORT, +libubus +libblobmsg-json, \ + The ubus module allows ucode template scripts to enumerate and invoke ubus procedures.)) +$(eval $(call UcodeModule, \ + uci, UCI_SUPPORT, +libuci, \ + The uci module allows templates to read and modify uci configuration.)) +$(eval $(call UcodeModule, \ + uloop, ULOOP_SUPPORT, +libubox, \ + The uloop module allows ucode scripts to interact with OpenWrt uloop event loop implementation.)) + +$(eval $(call BuildPackage,libucode)) $(eval $(call BuildPackage,ucode)) -$(eval $(call BuildPackage,ucode-mod-fs)) -$(eval $(call BuildPackage,ucode-mod-math)) -$(eval $(call BuildPackage,ucode-mod-ubus)) -$(eval $(call BuildPackage,ucode-mod-uci)) + +$(foreach mod,$(UCODE_MODULES), \ + $(eval $(call BuildPackage,$(mod)))) + +$(eval $(call HostBuild)) diff --git a/package/utils/uencrypt/Makefile b/package/utils/uencrypt/Makefile new file mode 100644 index 00000000000..70ca655b6e8 --- /dev/null +++ b/package/utils/uencrypt/Makefile @@ -0,0 +1,85 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2022 Eneas Ulir de Queiroz + +include $(TOPDIR)/rules.mk + +PKG_NAME:=uencrypt +PKG_RELEASE:=5 + +PKG_LICENSE:=GPL-2.0-or-later +PKG_MAINTAINER:=Eneas U de Queiroz <cotequeiroz@gmail.com> + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +CMAKE_INSTALL:=1 +ifeq ($(BUILD_VARIANT),mbedtls) + CMAKE_OPTIONS+=-DUSE_MBEDTLS=1 +else ifeq ($(BUILD_VARIANT),wolfssl) + CMAKE_OPTIONS+=-DUSE_WOLFSSL=1 +endif + +TARGET_CFLAGS+=-Wall + +define Package/uencrypt/default + SECTION:=utils + CATEGORY:=Base system + TITLE:=Small Decryption utility +endef + +define Package/uencrypt/default/description + This is a small encrypton/decryption program. It defaults + to AES-128-CBC, but supports any encryption provided by + the crypto library. Even though it can be used for + non-critical* regular encryption and decryption operations, + it is included here to unencrypt the configuration from mtd + on some devices. + + * Key and IV are exposed on cmdline + + This variant uses $(1) as crypto provider +endef + +define Package/uencrypt-mbedtls + $(Package/uencrypt/default) + VARIANT:=mbedtls + TITLE+= using mbedTLS + DEPENDS:=+libmbedtls + CONFLICTS:=uencrypt-openssl uencrypt-wolfssl +endef + +Package/uencrypt-mbedtls/description= \ + $(call Package/uencrypt/default/description,mbedTLS) + +define Package/uencrypt-openssl + $(Package/uencrypt/default) + VARIANT:=openssl + TITLE+= using OpenSSL + DEPENDS:=+libopenssl + CONFLICTS:=uencrypt-wolfssl +endef + +Package/uencrypt-openssl/description= \ + $(call Package/uencrypt/default/description,OpenSSL) + +define Package/uencrypt-wolfssl + $(Package/uencrypt/default) + VARIANT:=wolfssl + TITLE+= using wolfSSL + DEPENDS:=+libwolfssl +endef + +Package/uencrypt-wolfssl/description= \ + $(call Package/uencrypt/default/description,wolfSSL) + +define Package/uencrypt/default/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/uencrypt $(1)/usr/bin +endef +Package/uencrypt-openssl/install = $(Package/uencrypt/default/install) +Package/uencrypt-wolfssl/install = $(Package/uencrypt/default/install) +Package/uencrypt-mbedtls/install = $(Package/uencrypt/default/install) + +$(eval $(call BuildPackage,uencrypt-mbedtls)) +$(eval $(call BuildPackage,uencrypt-openssl)) +$(eval $(call BuildPackage,uencrypt-wolfssl)) diff --git a/package/utils/uencrypt/src/CMakeLists.txt b/package/utils/uencrypt/src/CMakeLists.txt new file mode 100644 index 00000000000..5e09954f0a2 --- /dev/null +++ b/package/utils/uencrypt/src/CMakeLists.txt @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2022 Eneas Ulir de Queiroz + +cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) +project(uencrypt LANGUAGES C) + +option(USE_WOLFSSL "Use WolfSSL as crypto provider" OFF) +option(USE_MBEDTLS "Use mbedTLS as crypto provider" OFF) +if (USE_MBEDTLS) + if (USE_WOLFSSL) + message(WARNING "USE_MBEDTLS and USE_WOLFSSL are both set. Building with USE_MBEDTLS.") + endif() + add_definitions(-DUSE_MBEDTLS) + find_library(MBEDCRYPTO_LIBRARY mbedcrypto REQUIRED) + set(CRYPTO_LIBRARIES ${MBEDCRYPTO_LIBRARY}) + set(CRYPTO_SOURCES ${PROJECT_NAME}-mbedtls.c) +else() + set(CRYPTO_SOURCES ${PROJECT_NAME}-openssl.c) + if (USE_WOLFSSL) + add_definitions(-DUSE_WOLFSSL) + find_library(WOLFSSL_LIBRARY wolfssl REQUIRED) + set(CRYPTO_LIBRARIES ${WOLFSSL_LIBRARY}) + else() + find_package(OpenSSL REQUIRED) + set(CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY}) + endif() +endif() +add_executable(${PROJECT_NAME} ${PROJECT_NAME}.c ${PROJECT_NAME}.h ${CRYPTO_SOURCES}) + +target_link_libraries(${PROJECT_NAME} ${CRYPTO_LIBRARIES}) + +install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) diff --git a/package/utils/uencrypt/src/uencrypt-mbedtls.c b/package/utils/uencrypt/src/uencrypt-mbedtls.c new file mode 100644 index 00000000000..34851261b79 --- /dev/null +++ b/package/utils/uencrypt/src/uencrypt-mbedtls.c @@ -0,0 +1,186 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright (C) 2023 Eneas Ulir de Queiroz + */ + +#include <ctype.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include "uencrypt.h" + +unsigned char *hexstr2buf(const char *str, long *len) +{ + unsigned char *buf; + long inlen = strlen(str); + + *len = 0; + if (inlen % 2) + return NULL; + + *len = inlen >> 1; + buf = malloc(*len); + for (long x = 0; x < *len; x++) + sscanf(str + x * 2, "%2hhx", buf + x); + return buf; +} + +const cipher_t *get_default_cipher(void) +{ + return mbedtls_cipher_info_from_type (MBEDTLS_CIPHER_AES_128_CBC); +} + +static char* upperstr(char *str) { + for (char *s = str; *s; s++) + *s = toupper((unsigned char) *s); + return str; +} + +const cipher_t *get_cipher_or_print_error(char *name) +{ + const mbedtls_cipher_info_t *cipher; + + cipher = mbedtls_cipher_info_from_string(upperstr(name)); + if (cipher) + return cipher; + + fprintf(stderr, "Error: invalid cipher: %s.\n", name); + fprintf(stderr, "Supported ciphers: \n"); + for (const int *list = mbedtls_cipher_list(); *list; list++) { + cipher = mbedtls_cipher_info_from_type(*list); + if (!cipher) + continue; + fprintf(stderr, "\t%s\n", cipher->name); + } + return NULL; +} + +int get_cipher_ivsize(const cipher_t *cipher) +{ + const mbedtls_cipher_info_t *c = cipher; + + return c->iv_size; +} + +int get_cipher_keysize(const cipher_t *cipher) +{ + const mbedtls_cipher_info_t *c = cipher; + + return c->key_bitlen >> 3; +} + +ctx_t *create_ctx(const cipher_t *cipher, const unsigned char *key, + const unsigned char *iv, int enc, int padding) +{ + mbedtls_cipher_context_t *ctx; + const mbedtls_cipher_info_t *cipher_info=cipher; + int ret; + + ctx = malloc(sizeof (mbedtls_cipher_context_t)); + if (!ctx) { + fprintf (stderr, "Error: create_ctx: out of memory.\n"); + return NULL; + } + + mbedtls_cipher_init(ctx); + ret = mbedtls_cipher_setup(ctx, cipher_info); + if (ret) { + fprintf(stderr, "Error: mbedtls_cipher_setup: %d\n", ret); + goto abort; + } + ret = mbedtls_cipher_setkey(ctx, key, + (int) mbedtls_cipher_get_key_bitlen(ctx), + enc ? MBEDTLS_ENCRYPT : MBEDTLS_DECRYPT); + if (ret) { + fprintf(stderr, "Error: mbedtls_cipher_setkey: %d\n", ret); + goto abort; + } + if (iv) { + ret = mbedtls_cipher_set_iv(ctx, iv, mbedtls_cipher_get_iv_size(ctx)); + if (ret) { + fprintf(stderr, "Error: mbedtls_cipher_set_iv: %d\n", ret); + goto abort; + } + } + + if (cipher_info->mode == MBEDTLS_MODE_CBC) { + ret = mbedtls_cipher_set_padding_mode(ctx, padding ? + MBEDTLS_PADDING_PKCS7 : + MBEDTLS_PADDING_NONE); + if (ret) { + fprintf(stderr, "Error: mbedtls_cipher_set_padding_mode: %d\n", + ret); + goto abort; + } + } else { + if (cipher_info->block_size > 1 && padding) { + fprintf(stderr, + "Error: mbedTLS only allows padding with CBC ciphers.\n"); + goto abort; + } + } + + ret = mbedtls_cipher_reset(ctx); + if (ret) { + fprintf(stderr, "Error: mbedtls_cipher_reset: %d\n", ret); + goto abort; + } + return ctx; + +abort: + free_ctx(ctx); + return NULL; +} + +int do_crypt(FILE *infile, FILE *outfile, ctx_t *ctx) +{ + unsigned char inbuf[CRYPT_BUF_SIZE]; + unsigned char outbuf[CRYPT_BUF_SIZE + MBEDTLS_MAX_BLOCK_LENGTH]; + size_t inlen, outlen, step; + int ret; + + if (mbedtls_cipher_get_cipher_mode(ctx) == MBEDTLS_MODE_ECB) { + step = mbedtls_cipher_get_block_size(ctx); + if (step > CRYPT_BUF_SIZE) { + step = CRYPT_BUF_SIZE; + } + } else { + step = CRYPT_BUF_SIZE; + } + + for (;;) { + inlen = fread(inbuf, 1, step, infile); + if (inlen <= 0) + break; + ret = mbedtls_cipher_update(ctx, inbuf, inlen, outbuf, &outlen); + if (ret) { + fprintf(stderr, "Error: mbedtls_cipher_update: %d\n", ret); + return ret; + } + ret = fwrite(outbuf, 1, outlen, outfile); + if (ret != outlen) { + fprintf(stderr, "Error: cipher_update short write.\n"); + return ret - outlen; + } + } + ret = mbedtls_cipher_finish(ctx, outbuf, &outlen); + if (ret) { + fprintf(stderr, "Error: mbedtls_cipher_finish: %d\n", ret); + return ret; + } + ret = fwrite(outbuf, 1, outlen, outfile); + if (ret != outlen) { + fprintf(stderr, "Error: cipher_finish short write.\n"); + return ret - outlen; + } + + return 0; +} + +void free_ctx(ctx_t *ctx) +{ + if (ctx) { + mbedtls_cipher_free(ctx); + free(ctx); + } +} diff --git a/package/utils/uencrypt/src/uencrypt-openssl.c b/package/utils/uencrypt/src/uencrypt-openssl.c new file mode 100644 index 00000000000..d9182be2bae --- /dev/null +++ b/package/utils/uencrypt/src/uencrypt-openssl.c @@ -0,0 +1,116 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright (C) 2022-2023 Eneas Ulir de Queiroz + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include "uencrypt.h" + +const cipher_t *get_default_cipher(void) +{ + return EVP_aes_128_cbc(); +} + +#ifndef USE_WOLFSSL +static void print_ciphers(const OBJ_NAME *name,void *arg) { + fprintf(arg, "\t%s\n", name->name); +} +#endif + +const cipher_t *get_cipher_or_print_error(char *name) +{ + const EVP_CIPHER *cipher; + + if ((cipher = EVP_get_cipherbyname(name))) + return cipher; + + fprintf(stderr, "Error: invalid cipher: %s.\n", name); +#ifndef USE_WOLFSSL + fprintf(stderr, "Supported ciphers: \n"); + OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_CIPHER_METH, print_ciphers, stderr); +#endif + return NULL; +} + +int get_cipher_ivsize(const cipher_t *cipher) +{ + return EVP_CIPHER_iv_length(cipher); +} + +int get_cipher_keysize(const cipher_t *cipher) +{ + return EVP_CIPHER_key_length(cipher); +} + +ctx_t *create_ctx(const cipher_t *cipher, const unsigned char *key, + const unsigned char *iv, int enc, int padding) +{ + EVP_CIPHER_CTX *ctx; + int ret; + + ctx = EVP_CIPHER_CTX_new(); + if (!ctx) { + fprintf (stderr, "Error: create_ctx: out of memory.\n"); + return NULL; + } + ret = EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, enc); + if (!ret) { + fprintf(stderr, "Error:EVP_CipherInit_ex: %d\n", ret); + goto abort; + } + ret = EVP_CIPHER_CTX_set_padding(ctx, padding); + if (!ret) { + fprintf(stderr, "Error:EVP_CIPHER_CTX_set_padding: %d\n", ret); + goto abort; + } + + return ctx; + +abort: + free_ctx(ctx); + return NULL; +} + + +int do_crypt(FILE *infile, FILE *outfile, ctx_t *ctx) +{ + unsigned char inbuf[CRYPT_BUF_SIZE]; + unsigned char outbuf[CRYPT_BUF_SIZE + EVP_MAX_BLOCK_LENGTH]; + int inlen, outlen; + int ret; + + for (;;) { + inlen = fread(inbuf, 1, CRYPT_BUF_SIZE, infile); + if (inlen <= 0) + break; + ret = EVP_CipherUpdate(ctx, outbuf, &outlen, inbuf, inlen); + if (!ret) { + fprintf(stderr, "Error: EVP_CipherUpdate: %d\n", ret); + return ret; + } + ret = fwrite(outbuf, 1, outlen, outfile); + if (ret != outlen) { + fprintf(stderr, "Error: CipherUpdate short write.\n"); + return ret - outlen; + } + } + ret = EVP_CipherFinal_ex(ctx, outbuf, &outlen); + if (!ret) { + fprintf(stderr, "Error: EVP_CipherFinal: %d\n", ret); + return ret; + } + ret = fwrite(outbuf, 1, outlen, outfile); + if (ret != outlen) { + fprintf(stderr, "Error: CipherFinal short write.\n"); + return ret - outlen; + } + + return 0; +} + +void free_ctx(ctx_t *ctx) +{ + EVP_CIPHER_CTX_free(ctx); +} diff --git a/package/utils/uencrypt/src/uencrypt.c b/package/utils/uencrypt/src/uencrypt.c new file mode 100644 index 00000000000..36e17e220bb --- /dev/null +++ b/package/utils/uencrypt/src/uencrypt.c @@ -0,0 +1,105 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright (C) 2023 Eneas Ulir de Queiroz + */ + +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#include "uencrypt.h" + +static void check_enc_dec(const int enc) +{ + if (enc == -1) + return; + fprintf(stderr, "Error: both -d and -e were specified.\n"); + exit(EXIT_FAILURE); +} + +static void show_usage(const char* name) +{ + fprintf(stderr, "Usage: %s: [-d | -e] [-n] -k key [-i iv] [-c cipher]\n" + "-d = decrypt; -e = encrypt; -n = no padding\n", name); +} + +static void uencrypt_clear_free(void *ptr, size_t len) +{ + if (ptr) { + memset(ptr, 0, len); + free(ptr); + } +} + +int main(int argc, char *argv[]) +{ + int enc = -1; + unsigned char *iv = NULL; + unsigned char *key = NULL; + long keylen = 0, ivlen = 0; + int opt; + int padding = 1; + const cipher_t *cipher = get_default_cipher(); + ctx_t* ctx; + int ret = EXIT_FAILURE; + + while ((opt = getopt(argc, argv, "c:dei:k:n")) != -1) { + switch (opt) { + case 'c': + if (!(cipher = get_cipher_or_print_error(optarg))) + exit(EXIT_FAILURE); + break; + case 'd': + check_enc_dec(enc); + enc = 0; + break; + case 'e': + check_enc_dec(enc); + enc = 1; + break; + case 'i': + iv = hexstr2buf(optarg, &ivlen); + if (iv == NULL) { + fprintf(stderr, "Error setting IV to %s. The IV should be encoded in hex.\n", + optarg); + exit(EINVAL); + } + memset(optarg, '*', strlen(optarg)); + break; + case 'k': + key = hexstr2buf(optarg, &keylen); + if (key == NULL) { + fprintf(stderr, "Error setting key to %s. The key should be encoded in hex.\n", + optarg); + exit(EINVAL); + } + memset(optarg, '*', strlen(optarg)); + break; + case 'n': + padding = 0; + break; + default: + show_usage(argv[0]); + exit(EINVAL); + } + } + if (ivlen != get_cipher_ivsize(cipher)) { + fprintf(stderr, "Error: IV must be %d bytes; given IV is %zd bytes.\n", + get_cipher_ivsize(cipher), ivlen); + exit(EXIT_FAILURE); + } + if (keylen != get_cipher_keysize(cipher)) { + fprintf(stderr, "Error: key must be %d bytes; given key is %zd bytes.\n", + get_cipher_keysize(cipher), keylen); + exit(EXIT_FAILURE); + } + ctx = create_ctx(cipher, key, iv, !!enc, padding); + if (ctx) { + ret = do_crypt(stdin, stdout, ctx); + free_ctx(ctx); + } + uencrypt_clear_free(iv, ivlen); + uencrypt_clear_free(key, keylen); + return ret; +} diff --git a/package/utils/uencrypt/src/uencrypt.h b/package/utils/uencrypt/src/uencrypt.h new file mode 100644 index 00000000000..a4fe1f33762 --- /dev/null +++ b/package/utils/uencrypt/src/uencrypt.h @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright (C) 2022-2023 Eneas Ulir de Queiroz + */ + +#include <stdio.h> + +#define CRYPT_BUF_SIZE 1024 + +#ifdef USE_MBEDTLS +# include <mbedtls/cipher.h> + +# if defined(MBEDTLS_MAX_BLOCK_LENGTH) \ + && MBEDTLS_MAX_BLOCK_LENGTH > CRYPT_BUF_SIZE +# undef CRYPT_BUF_SIZE +# define CRYPT_BUF_SIZE MAX_BLOCK_LENGTH +# endif + +unsigned char *hexstr2buf(const char* str, long *len); + +#else /* USE_MBEDTLS */ +# ifdef USE_WOLFSSL +# include <wolfssl/options.h> +# include <wolfssl/openssl/evp.h> +# else +# include <openssl/evp.h> +# endif + +# if defined(EVP_MAX_BLOCK_LENGTH) \ + && EVP_MAX_BLOCK_LENGTH > CRYPT_BUF_SIZE +# undef CRYPT_BUF_SIZE +# define CRYPT_BUF_SIZE EVP_MAX_BLOCK_LENGTH +# endif + +# define hexstr2buf OPENSSL_hexstr2buf + +#endif /* USE_MBEDTLS */ + +typedef void cipher_t; +typedef void ctx_t; + +const cipher_t *get_default_cipher(void); +const cipher_t *get_cipher_or_print_error(char *name); +int get_cipher_ivsize(const cipher_t *cipher); +int get_cipher_keysize(const cipher_t *cipher); + +ctx_t *create_ctx(const cipher_t *cipher, const unsigned char *key, + const unsigned char *iv, int enc, int padding); +int do_crypt(FILE *infile, FILE *outfile, ctx_t *ctx); +void free_ctx(ctx_t *ctx); diff --git a/package/utils/ugps/Makefile b/package/utils/ugps/Makefile index c70a7b7ea64..66d42dca89d 100644 --- a/package/utils/ugps/Makefile +++ b/package/utils/ugps/Makefile @@ -8,13 +8,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ugps -PKG_RELEASE:=$(AUTORELEASE) +PKG_RELEASE:=1 PKG_SOURCE_URL=$(PROJECT_GIT)/project/ugps.git PKG_SOURCE_PROTO:=git -PKG_SOURCE_DATE:=2021-06-08 -PKG_SOURCE_VERSION:=5e88403fc0d39ae8a270d2c6c6e9c8a4d5232cf3 -PKG_MIRROR_HASH:=a3dfc2cc6def3b634d8b7cda9139926be3d876cf2faa5251c4821987954442a5 +PKG_SOURCE_DATE:=2024-02-14 +PKG_SOURCE_VERSION:=69561a074d6f50f63b82608b19041e5eb2c605a9 +PKG_MIRROR_HASH:=6a9ea235665babc22393df53e6945030a2e2264d92afccf2e9cd61fa01aa3b11 PKG_MAINTAINER:=John Crispin <john@phrozen.org> PKG_LICENSE:=GPL-2.0+ diff --git a/package/utils/ugps/files/ugps.init b/package/utils/ugps/files/ugps.init index 77c36030667..e702b4ca44e 100644 --- a/package/utils/ugps/files/ugps.init +++ b/package/utils/ugps/files/ugps.init @@ -12,6 +12,7 @@ service_triggers() { start_service() { local tty="$(uci get gps.@gps[-1].tty)" + local baudrate="$(uci get gps.@gps[-1].baudrate || echo 0)" local atime="$(uci get gps.@gps[-1].adjust_time)" local disabled="$(uci get gps.@gps[-1].disabled || echo 0)" @@ -29,6 +30,7 @@ start_service() { procd_open_instance procd_set_param command "$PROG" + [ "$baudrate" -eq 0 ] || procd_append_param command "-b ${baudrate}" [ "$atime" -eq 0 ] || procd_append_param command "-a" procd_append_param command "$tty" procd_set_param respawn diff --git a/package/utils/usbgadget/Makefile b/package/utils/usbgadget/Makefile new file mode 100644 index 00000000000..d3a68ea9dfa --- /dev/null +++ b/package/utils/usbgadget/Makefile @@ -0,0 +1,54 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=usbgadget +PKG_RELEASE:=1 + +PKG_LICENSE:=BSD-2-Clause + +PKG_MAINTAINER:=Chuanhong Guo <gch981213@gmail.com> + +include $(INCLUDE_DIR)/package.mk + +define Package/$(PKG_NAME) + SECTION:=utils + CATEGORY:=Utilities + DEPENDS:=@USB_GADGET_SUPPORT +kmod-usb-gadget +kmod-usb-lib-composite + TITLE:=init script to create USB gadgets +endef + +define Build/Compile +endef + +define Package/$(PKG_NAME)/install + $(INSTALL_DIR) $(1)/etc/config $(1)/etc/init.d + $(INSTALL_CONF) ./files/usbgadget.conf $(1)/etc/config/usbgadget + $(INSTALL_BIN) ./files/usbgadget.init $(1)/etc/init.d/usbgadget +endef + +$(eval $(call BuildPackage,$(PKG_NAME))) + +# 1: short name +# 2: description +# 3: dependencies on other packages +define GadgetPreset + define Package/$(PKG_NAME)-$(1) + SECTION:=utils + CATEGORY:=Utilities + TITLE+= $(2) gadget preset + DEPENDS+= $(3) + endef + + define Package/$(PKG_NAME)-$(1)/description + This package contains the USB gadget preset for $(3). + endef + + define Package/$(PKG_NAME)-$(1)/install + $(INSTALL_DIR) $$(1)/usr/share/usbgadget + $(INSTALL_CONF) ./files/presets/$(1) $$(1)/usr/share/usbgadget + endef + + $$(eval $$(call BuildPackage,$(PKG_NAME)-$(1))) +endef + +$(eval $(call GadgetPreset,ncm,CDC-NCM,+kmod-usb-gadget-ncm)) +$(eval $(call GadgetPreset,acm,CDC-ACM,+kmod-usb-gadget-serial))
\ No newline at end of file diff --git a/package/utils/usbgadget/files/presets/acm b/package/utils/usbgadget/files/presets/acm new file mode 100644 index 00000000000..f8ce9c4a4aa --- /dev/null +++ b/package/utils/usbgadget/files/presets/acm @@ -0,0 +1,13 @@ +config gadget 'g1' + option idVendor '0x0525' + option idProduct '0xa4a7' + option bDeviceClass '2' + option product 'Gadget Serial v2.4' + +config configuration 'cfg1' + option configuration 'ACM' + option gadget 'g1' + +config function 'acm1' + option function 'acm' + option configuration 'cfg1' diff --git a/package/utils/usbgadget/files/presets/ncm b/package/utils/usbgadget/files/presets/ncm new file mode 100644 index 00000000000..cb3a19329e7 --- /dev/null +++ b/package/utils/usbgadget/files/presets/ncm @@ -0,0 +1,13 @@ +config gadget 'g1' + option idVendor '0x0525' + option idProduct '0xa4a1' + option bDeviceClass '2' + option product 'NCM Gadget' + +config configuration 'cfg1' + option configuration 'NCM' + option gadget 'g1' + +config function 'ncm1' + option function 'ncm' + option configuration 'cfg1' diff --git a/package/utils/usbgadget/files/usbgadget.conf b/package/utils/usbgadget/files/usbgadget.conf new file mode 100644 index 00000000000..0d80fc97dff --- /dev/null +++ b/package/utils/usbgadget/files/usbgadget.conf @@ -0,0 +1,12 @@ +# apply a preset under /usr/share/usbgadget +config preset + option name 'ncm' + # specify a UDC to enable this gadget: + # option UDC 'musb-hdrc.2.auto' + +# or create a custom gadget here following the content of presets: +#config gadget 'g1' +# option idVendor ... +# ... +# and add an UDC under the gadget section to enable it: +# option UDC 'musb-hdrc.2.auto' diff --git a/package/utils/usbgadget/files/usbgadget.init b/package/utils/usbgadget/files/usbgadget.init new file mode 100644 index 00000000000..f2e105caaef --- /dev/null +++ b/package/utils/usbgadget/files/usbgadget.init @@ -0,0 +1,144 @@ +#!/bin/sh /etc/rc.common + +START=19 + +GADGET_FS=/sys/kernel/config/usb_gadget +GADGET_PRESETS_DIR=/usr/share/usbgadget +GADGET_PREFIX=owrt_ + +log() { + logger -t usbgadget "$@" +} + +apply_configs() { + local fs_path="$1" + local cfg="$2" + for param in $(find "$fs_path" -maxdepth 1 -type f -exec basename '{}' ';'); do + [ "$param" = "UDC" ] && continue + + config_get val "$cfg" "$param" + [ -n "$val" ] && echo "$val" > "${fs_path}/${param}" + done +} + +setup_gadget() { + local cfg="$1" + local gadget_path="${GADGET_FS}/${GADGET_PREFIX}${cfg}" + local param udc + + config_get udc "$cfg" UDC + [ -z "$udc" ] && return + + mkdir "$gadget_path" || return + apply_configs "$gadget_path" "$cfg" + + local strings_path="${gadget_path}/strings/0x409" + mkdir "$strings_path" + apply_configs "$strings_path" "$cfg" +} + +setup_configuration() { + local cfg="$1" + local gadget + config_get gadget "$cfg" gadget + local cfgs_path="${GADGET_FS}/${GADGET_PREFIX}${gadget}/configs" + [ -d "${cfgs_path}" ] || return + local cfg_path="${cfgs_path}/${cfg}.1" + mkdir "$cfg_path" || { + log "failed to create configuration ${cfg}" + return + } + + apply_configs "$cfg_path" "$cfg" + + local strings_path="${cfg_path}/strings/0x409" + mkdir "$strings_path" + apply_configs "$strings_path" "$cfg" +} + +setup_function() { + local cfg="$1" + local usbcfg gadget usbfun + + config_get usbcfg "$cfg" configuration + [ -z "$usbcfg" ] && return + config_get usbfun "$cfg" function + [ -z "$usbfun" ] && return + + config_get gadget "$usbcfg" gadget + local gadget_path="${GADGET_FS}/${GADGET_PREFIX}${gadget}" + local cfg_path="${gadget_path}/configs/${usbcfg}.1" + [ -d "${cfg_path}" ] || return + + local fun_path="${gadget_path}/functions/${usbfun}.${cfg}" + mkdir "$fun_path" || { + log "failed to create function ${usbfun}.${cfg}" + return + } + + apply_configs "$fun_path" "$cfg" + + ln -s "$fun_path" "$cfg_path" +} + +attach_gadget() { + local cfg="$1" + local gadget_path="${GADGET_FS}/${GADGET_PREFIX}${cfg}" + local param udc + + config_get udc "$cfg" UDC + [ -z "$udc" ] && return + + echo "$udc" > "$gadget_path/UDC" +} + +load_gadget() { + config_foreach setup_gadget gadget + config_foreach setup_configuration configuration + config_foreach setup_function function + config_foreach attach_gadget gadget +} + +# use subshell for isolated env +apply_preset() ( + local preset="$1" + local gadget="$2" + UCI_CONFIG_DIR=$GADGET_PRESETS_DIR config_load "$1" + config_set g1 UDC "$2" + load_gadget +) + +load_preset() { + local cfg="$1" + config_get name "$cfg" name + config_get udc "$cfg" UDC + [ -z "$udc" ] && return + apply_preset $name $udc +} + +start() { + grep -q /sys/kernel/config /proc/mounts || \ + mount -t configfs configfs /sys/kernel/config + + [ -d /sys/kernel/config/usb_gadget ] || { + log "usb_gadget support not found." + return 1 + } + + config_load usbgadget + config_foreach load_preset preset + load_gadget +} + +stop() { + for gadget_path in ${GADGET_FS}/${GADGET_PREFIX}* ; do + [ -d "$gadget_path" ] || continue + echo "" > ${gadget_path}/UDC + find ${gadget_path}/configs -maxdepth 2 -type l -exec rm '{}' ';' + rmdir ${gadget_path}/configs/*/strings/* + rmdir ${gadget_path}/configs/* + rmdir ${gadget_path}/functions/* + rmdir ${gadget_path}/strings/* + rmdir $gadget_path + done +} diff --git a/package/utils/usbmode/Makefile b/package/utils/usbmode/Makefile index e3b457efd6d..1aa1980ce27 100644 --- a/package/utils/usbmode/Makefile +++ b/package/utils/usbmode/Makefile @@ -1,13 +1,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=usbmode -PKG_RELEASE:=2 +PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/usbmode.git -PKG_SOURCE_DATE:=2017-12-19 -PKG_SOURCE_VERSION:=f40f84c27534159066c94dadc0c08e0b255c3e26 -PKG_MIRROR_HASH:=840c7ee2843102b09d8943a20820025251cc259385e2b0bde6b7c8cce8190f83 +PKG_SOURCE_DATE:=2022-02-24 +PKG_SOURCE_VERSION:=3c8595a4e75510f58fa231b145d5506768dcafc9 +PKG_MIRROR_HASH:=5f0234945f61639080f039522172151452180dd4aec33bafc8a61b60131c3bed CMAKE_INSTALL:=1 PKG_LICENSE:=GPL-2.0 diff --git a/package/utils/util-linux/Makefile b/package/utils/util-linux/Makefile index b385030e39c..ec6925f0ea9 100644 --- a/package/utils/util-linux/Makefile +++ b/package/utils/util-linux/Makefile @@ -8,15 +8,15 @@ include $(TOPDIR)/rules.mk PKG_NAME:=util-linux -PKG_VERSION:=2.36.1 -PKG_RELEASE:=2 +PKG_VERSION:=2.39.3 +PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz -PKG_SOURCE_URL:=@KERNEL/linux/utils/$(PKG_NAME)/v2.36 -PKG_HASH:=09fac242172cd8ec27f0739d8d192402c69417617091d8c6e974841568f37eed +PKG_SOURCE_URL:=@KERNEL/linux/utils/$(PKG_NAME)/v2.39 +PKG_HASH:=7b6605e48d1a49f43cc4b4cfc59f313d0dd5402fa40b96810bd572e167dfed0f PKG_CPE_ID:=cpe:/a:kernel:util-linux -PKG_LICENSE:=GPL-2.0 +PKG_LICENSE:=GPL-2.0-only PKG_LICENSE_FILES:= COPYING \ libblkid/COPYING \ libmount/COPYING \ @@ -25,14 +25,10 @@ PKG_LICENSE_FILES:= COPYING \ libuuid/COPYING \ Documentation/licenses/COPYING.BSD-3 -PKG_BUILD_PARALLEL:=1 - -PKG_FIXUP:=autoreconf PKG_INSTALL:=1 -DISABLE_NLS:=--disable-nls - include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/meson.mk define Package/util-linux/Default SECTION:=utils @@ -178,6 +174,17 @@ define Package/cfdisk/description cfdisk is a curses-based program for partitioning any hard disk drive endef +define Package/colrm +$(call Package/util-linux/Default) + TITLE:=colrm removes selected columns from a file + DEPENDS:= +endef + +define Package/colrm/description + colrm removes selected columns from a file. Input is taken from + standard input. Output is sent to standard output. +endef + define Package/dmesg $(call Package/util-linux/Default) TITLE:=print or control the kernel ring buffer @@ -265,6 +272,18 @@ define Package/hwclock/description hwclock is a tool for accessing the Hardware Clock endef +define Package/ipcs +$(call Package/util-linux/Default) + TITLE:=show information on IPC facilities +endef + +define Package/ipcs/description + ipcs shows information on the inter-process communication facilities for + which the calling process has read access. By default it shows information + about all three resources: shared memory segments, message queues, and + semaphore arrays. +endef + define Package/logger $(call Package/util-linux/Default) TITLE:=a shell command interface to the syslog system log module @@ -317,6 +336,26 @@ define Package/lscpu/description lscpu displays information about the CPU architecture endef +define Package/lslocks +$(call Package/util-linux/Default) + TITLE:=list local system locks + DEPENDS:= +libmount +libsmartcols +endef + +define Package/lslocks/description + lslocks lists information about all the currently held file locks in a Linux system +endef + +define Package/lsns +$(call Package/util-linux/Default) + TITLE:=list system namespaces + DEPENDS:= +libblkid +libmount +libsmartcols +endef + +define Package/lsns/description + lsns lists information about all namespaces and their processes +endef + define Package/more $(call Package/util-linux/Default) TITLE:=filter for paging through text one screenful at a time @@ -387,6 +426,17 @@ define Package/rename/description expression in their name by replacement endef +define Package/rev +$(call Package/util-linux/Default) + TITLE:=Reverse lines characterwise +endef + +define Package/rev/description + rev utility copies the specified files to the standard output, reversing the + order of characters in every line. If no files are specified, the standard + input is read. +endef + define Package/partx-utils $(call Package/util-linux/Default) TITLE:=inform kernel about the presence and numbering of on-disk partitions @@ -443,6 +493,16 @@ define Package/swap-utils/description contains: mkswap, swaplabel endef +define Package/taskset +$(call Package/util-linux/Default) + TITLE:=set or retrieve a process's CPU affinity + ALTERNATIVES:=200:/usr/bin/taskset:/usr/bin/util-linux-taskset +endef + +define Package/taskset/description + contains: taskset +endef + define Package/unshare $(call Package/util-linux/Default) TITLE:=unshare userspace tool @@ -511,43 +571,69 @@ define Package/wipefs/description libblkid. endef -CONFIGURE_ARGS += \ - --disable-use-tty-group \ - --disable-rpath \ - --disable-tls \ - --disable-su \ - --disable-sulogin \ - --disable-makeinstall-chown \ - --disable-login \ - --disable-nologin \ - --disable-lslogins \ - --disable-runuser \ - --disable-chfn-chsh \ - --without-python \ - --without-udev \ - --without-readline \ - --without-libmagic \ - --with-ncursesw - -TARGET_CFLAGS += $(FPIC) -std=gnu99 +MESON_ARGS += \ + -Dsystemd=disabled \ + -Dtinfo=disabled \ + -Dcryptsetup=disabled \ + -Dlibutil=disabled \ + -Dlibutempter=disabled \ + -Dlibpcre2-posix=disabled \ + -Dlibuser=disabled \ + -Duse-tty-group=false \ + -Duse-tls=false \ + -Dbuild-python=disabled \ + -Dbuild-zramctl=disabled \ + -Dbuild-fsck=disabled \ + -Dbuild-wipefs=disabled \ + -Dbuild-fallocate=disabled \ + -Dbuild-setpriv=disabled \ + -Dbuild-hardlink=disabled \ + -Dbuild-cramfs=disabled \ + -Dbuild-bfs=disabled \ + -Dbuild-minix=disabled \ + -Dbuild-fdformat=disabled \ + -Dbuild-lslogins=disabled \ + -Dbuild-wdctl=disabled \ + -Dbuild-cal=disabled \ + -Dbuild-switch_root=disabled \ + -Dbuild-pivot_root=disabled \ + -Dbuild-lsmem=disabled \ + -Dbuild-lsirq=disabled \ + -Dbuild-irqtop=disabled \ + -Dbuild-chmem=disabled \ + -Dbuild-ipcrm=disabled \ + -Dbuild-rfkill=disabled \ + -Dbuild-tunelp=disabled \ + -Dbuild-kill=disabled \ + -Dbuild-last=disabled \ + -Dbuild-utmpdump=disabled \ + -Dbuild-line=disabled \ + -Dbuild-mesg=disabled \ + -Dbuild-raw=disabled \ + -Dbuild-vipw=disabled \ + -Dbuild-newgrp=disabled \ + -Dbuild-chfn-chsh=disabled \ + -Dbuild-login=disabled \ + -Dbuild-nologin=disabled \ + -Dbuild-sulogin=disabled \ + -Dbuild-su=disabled \ + -Dbuild-runuser=disabled \ + -Dbuild-ul=disabled \ + -Dbuild-pg=disabled \ + -Dbuild-write=disabled \ + -Dbuild-bash-completion=disabled \ + -Dbuild-pylibmount=disabled \ + -Dreadline=disabled \ + -Dmagic=disabled \ + -Dncursesw=enabled define Build/InstallDev $(INSTALL_DIR) $(1)/usr/lib/pkgconfig $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/blkid.pc $(1)/usr/lib/pkgconfig - $(SED) 's,/usr/include,$$$${prefix}/include,g' $(1)/usr/lib/pkgconfig/blkid.pc - $(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' $(1)/usr/lib/pkgconfig/blkid.pc $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/fdisk.pc $(1)/usr/lib/pkgconfig - $(SED) 's,/usr/include,$$$${prefix}/include,g' $(1)/usr/lib/pkgconfig/fdisk.pc - $(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' $(1)/usr/lib/pkgconfig/fdisk.pc $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/mount.pc $(1)/usr/lib/pkgconfig - $(SED) 's,/usr/include,$$$${prefix}/include,g' $(1)/usr/lib/pkgconfig/mount.pc - $(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' $(1)/usr/lib/pkgconfig/mount.pc $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/smartcols.pc $(1)/usr/lib/pkgconfig - $(SED) 's,/usr/include,$$$${prefix}/include,g' $(1)/usr/lib/pkgconfig/smartcols.pc - $(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' $(1)/usr/lib/pkgconfig/smartcols.pc $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/uuid.pc $(1)/usr/lib/pkgconfig - $(SED) 's,/usr/include,$$$${prefix}/include,g' $(1)/usr/lib/pkgconfig/uuid.pc - $(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' $(1)/usr/lib/pkgconfig/uuid.pc $(INSTALL_DIR) $(1)/usr/include/blkid $(CP) $(PKG_INSTALL_DIR)/usr/include/blkid/blkid.h $(1)/usr/include/blkid @@ -561,43 +647,37 @@ define Build/InstallDev $(CP) $(PKG_INSTALL_DIR)/usr/include/libsmartcols/libsmartcols.h $(1)/usr/include/libsmartcols $(INSTALL_DIR) $(1)/usr/lib - $(CP) $(PKG_INSTALL_DIR)/lib/libblkid.so* $(1)/usr/lib - $(CP) $(PKG_INSTALL_DIR)/lib/libfdisk.so* $(1)/usr/lib - $(CP) $(PKG_INSTALL_DIR)/lib/libmount.so* $(1)/usr/lib - $(CP) $(PKG_INSTALL_DIR)/lib/libuuid.so* $(1)/usr/lib - $(CP) $(PKG_INSTALL_DIR)/lib/libsmartcols.so* $(1)/usr/lib - - $(LN) libblkid.so.1 $(1)/usr/lib/libblkid.so - $(LN) libfdisk.so.1 $(1)/usr/lib/libfdisk.so - $(LN) libmount.so.1 $(1)/usr/lib/libmount.so - $(LN) libuuid.so.1 $(1)/usr/lib/libuuid.so - $(LN) libsmartcols.so.1 $(1)/usr/lib/libsmartcols.so + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libblkid.so* $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libfdisk.so* $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libmount.so* $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libuuid.so* $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libsmartcols.so* $(1)/usr/lib endef define Package/libfdisk/install $(INSTALL_DIR) $(1)/usr/lib - $(CP) $(PKG_INSTALL_DIR)/lib/libfdisk.so.* $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libfdisk.so.* $(1)/usr/lib/ endef define Package/libblkid/install $(INSTALL_DIR) $(1)/usr/lib - $(CP) $(PKG_INSTALL_DIR)/lib/libblkid.so.* $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libblkid.so.* $(1)/usr/lib/ endef define Package/libmount/install $(INSTALL_DIR) $(1)/usr/lib - $(CP) $(PKG_INSTALL_DIR)/lib/libmount.so.* $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libmount.so.* $(1)/usr/lib/ endef define Package/libsmartcols/install $(INSTALL_DIR) $(1)/usr/lib - $(CP) $(PKG_INSTALL_DIR)/lib/libsmartcols.so.* $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libsmartcols.so.* $(1)/usr/lib/ endef define Package/libuuid/install $(INSTALL_DIR) $(1)/usr/lib - $(CP) $(PKG_INSTALL_DIR)/lib/libuuid.so.* $(1)/usr/lib/ + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libuuid.so.* $(1)/usr/lib/ endef define Package/agetty/install @@ -630,6 +710,11 @@ define Package/cfdisk/install $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/cfdisk $(1)/usr/sbin/ endef +define Package/colrm/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/colrm $(1)/usr/bin/ +endef + define Package/dmesg/install $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/dmesg $(1)/usr/bin/ @@ -670,6 +755,11 @@ define Package/hwclock/install $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/hwclock $(1)/usr/sbin/ endef +define Package/ipcs/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/ipcs $(1)/usr/bin/ +endef + define Package/logger/install $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/logger $(1)/usr/bin/util-linux-logger @@ -695,6 +785,16 @@ define Package/lscpu/install $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/lscpu $(1)/usr/bin/ endef +define Package/lslocks/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/lslocks $(1)/usr/bin/ +endef + +define Package/lsns/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/lsns $(1)/usr/bin/ +endef + define Package/more/install $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/more $(1)/usr/bin/ @@ -732,6 +832,11 @@ define Package/rename/install $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/rename $(1)/usr/bin/ endef +define Package/rev/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/rev $(1)/usr/bin/ +endef + define Package/partx-utils/install $(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/partx $(1)/usr/sbin/ @@ -761,6 +866,11 @@ define Package/swap-utils/install $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/swaplabel $(1)/usr/sbin/ endef +define Package/taskset/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/taskset $(1)/usr/bin/util-linux-taskset +endef + define Package/unshare/install $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/unshare $(1)/usr/bin/ @@ -804,6 +914,7 @@ $(eval $(call BuildPackage,blkid)) $(eval $(call BuildPackage,blockdev)) $(eval $(call BuildPackage,cal)) $(eval $(call BuildPackage,cfdisk)) +$(eval $(call BuildPackage,colrm)) $(eval $(call BuildPackage,dmesg)) $(eval $(call BuildPackage,eject)) $(eval $(call BuildPackage,fdisk)) @@ -812,11 +923,14 @@ $(eval $(call BuildPackage,flock)) $(eval $(call BuildPackage,fstrim)) $(eval $(call BuildPackage,getopt)) $(eval $(call BuildPackage,hwclock)) +$(eval $(call BuildPackage,ipcs)) $(eval $(call BuildPackage,logger)) $(eval $(call BuildPackage,look)) $(eval $(call BuildPackage,losetup)) $(eval $(call BuildPackage,lsblk)) $(eval $(call BuildPackage,lscpu)) +$(eval $(call BuildPackage,lslocks)) +$(eval $(call BuildPackage,lsns)) $(eval $(call BuildPackage,more)) $(eval $(call BuildPackage,mcookie)) $(eval $(call BuildPackage,mount-utils)) @@ -824,11 +938,13 @@ $(eval $(call BuildPackage,namei)) $(eval $(call BuildPackage,nsenter)) $(eval $(call BuildPackage,prlimit)) $(eval $(call BuildPackage,rename)) +$(eval $(call BuildPackage,rev)) $(eval $(call BuildPackage,partx-utils)) $(eval $(call BuildPackage,script-utils)) $(eval $(call BuildPackage,setterm)) $(eval $(call BuildPackage,sfdisk)) $(eval $(call BuildPackage,swap-utils)) +$(eval $(call BuildPackage,taskset)) $(eval $(call BuildPackage,unshare)) $(eval $(call BuildPackage,uuidd)) $(eval $(call BuildPackage,uuidgen)) diff --git a/package/utils/util-linux/patches/001-meson-properly-handle-gettext-non-existence.patch b/package/utils/util-linux/patches/001-meson-properly-handle-gettext-non-existence.patch new file mode 100644 index 00000000000..f3d49d8d2de --- /dev/null +++ b/package/utils/util-linux/patches/001-meson-properly-handle-gettext-non-existence.patch @@ -0,0 +1,28 @@ +From b8bed37a1493b913bf5bda938487ae0c06c11ce7 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= <thomas@t-8ch.de> +Date: Sat, 5 Aug 2023 08:57:28 +0200 +Subject: [PATCH] meson: properly handle gettext non-existence +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Commit e91a49c9747f ("meson: don't build po if no gettext") +tried to add the possibility to build util-linux without gettext. + +Unfortunately by default the call to find_program() would abort the +build if the program is not found. +Avoid aborting the build. + +Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de> +--- + po/meson.build | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/po/meson.build ++++ b/po/meson.build +@@ -1,4 +1,4 @@ +-if not find_program('gettext').found() ++if not find_program('gettext', required : false).found() + subdir_done() + endif + diff --git a/package/utils/util-linux/patches/100-use_urandom.patch b/package/utils/util-linux/patches/100-use_urandom.patch deleted file mode 100644 index 5817209885f..00000000000 --- a/package/utils/util-linux/patches/100-use_urandom.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/lib/randutils.c -+++ b/lib/randutils.c -@@ -26,6 +26,11 @@ - #define THREAD_LOCAL static - #endif - -+/* force /dev/urandom to avoid hanging on early boot */ -+#undef HAVE_GETRANDOM -+#undef SYS_getrandom -+#undef __NR_getrandom -+ - #ifdef HAVE_GETRANDOM - # include <sys/random.h> - #elif defined (__linux__) diff --git a/package/utils/yafut/Makefile b/package/utils/yafut/Makefile new file mode 100644 index 00000000000..ef16404c336 --- /dev/null +++ b/package/utils/yafut/Makefile @@ -0,0 +1,36 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=yafut +PKG_RELEASE:=1 + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL=https://github.com/kempniu/yafut.git +PKG_MIRROR_HASH:=6eece622d1df99ffee1a18d162d36292f32bf2d5e514663a6b61fd82c2ecbcba +PKG_SOURCE_DATE:=2023-03-31 +PKG_SOURCE_VERSION:=16435e89d449f953712983315e1a89cdb678620d + +PKG_LICENSE:=GPL-2.0 +PKG_LICENSE_FILES:=LICENSE + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +CMAKE_INSTALL:=1 + +define Package/yafut + SECTION:=utils + CATEGORY:=Utilities + TITLE:=Yet Another File UTility + DEPENDS:=@NAND_SUPPORT +endef + +define Package/yafut/description + A program for copying files from/to Yaffs file systems from userspace. +endef + +define Package/yafut/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/yafut $(1)/usr/bin +endef + +$(eval $(call BuildPackage,yafut)) diff --git a/package/utils/zyxel-bootconfig/Makefile b/package/utils/zyxel-bootconfig/Makefile new file mode 100644 index 00000000000..eb2dd79b82b --- /dev/null +++ b/package/utils/zyxel-bootconfig/Makefile @@ -0,0 +1,38 @@ +# +# Copyright (C) 2022 David Bauer <mail@david-bauer.net> +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=zyxel-bootconfig +PKG_RELEASE:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/zyxel-bootconfig + SECTION:=utils + CATEGORY:=Base system + TITLE:=Utility for handling ZyXEL Bootconfig settings + MAINTAINER:=David Bauer <mail@david-bauer.net> +endef + +define Package/zyxel-bootconfig/description + This package contains an utility that allows handling ZyXEL Bootconfig settings. +endef + +define Build/Compile + $(MAKE) -C $(PKG_BUILD_DIR) \ + CC="$(TARGET_CC)" \ + CFLAGS="$(TARGET_CFLAGS) -Wall" +endef + +define Package/zyxel-bootconfig/install + $(INSTALL_DIR) $(1)/usr/bin $(1)/lib/preinit + $(INSTALL_BIN) $(PKG_BUILD_DIR)/zyxel-bootconfig $(1)/usr/bin/ + $(CP) ./files/95_apply_bootconfig $(1)/lib/preinit/95_apply_bootconfig +endef + +$(eval $(call BuildPackage,zyxel-bootconfig)) diff --git a/package/utils/zyxel-bootconfig/files/95_apply_bootconfig b/package/utils/zyxel-bootconfig/files/95_apply_bootconfig new file mode 100644 index 00000000000..c98bc8fbe24 --- /dev/null +++ b/package/utils/zyxel-bootconfig/files/95_apply_bootconfig @@ -0,0 +1,15 @@ +apply_bootconfig() { + . /lib/functions.sh + + case $(board_name) in + zyxel,nwa50ax|\ + zyxel,nwa50ax-pro|\ + zyxel,nwa55axe) + mtd_idx=$(find_mtd_index "bootconfig") + zyxel-bootconfig "/dev/mtd$mtd_idx" set-image-status 0 valid + zyxel-bootconfig "/dev/mtd$mtd_idx" set-active-image 0 + ;; + esac +} + +[ "$INITRAMFS" = "1" ] || boot_hook_add preinit_main apply_bootconfig diff --git a/package/utils/zyxel-bootconfig/src/Makefile b/package/utils/zyxel-bootconfig/src/Makefile new file mode 100644 index 00000000000..66741c8acf0 --- /dev/null +++ b/package/utils/zyxel-bootconfig/src/Makefile @@ -0,0 +1,7 @@ +all: zyxel-bootconfig + +zyxel-bootconfig: + $(CC) $(CFLAGS) -Wall zyxel-bootconfig.c -o zyxel-bootconfig + +clean: + rm -f zyxel-bootconfig diff --git a/package/utils/zyxel-bootconfig/src/zyxel-bootconfig.c b/package/utils/zyxel-bootconfig/src/zyxel-bootconfig.c new file mode 100644 index 00000000000..6dd2f8969f8 --- /dev/null +++ b/package/utils/zyxel-bootconfig/src/zyxel-bootconfig.c @@ -0,0 +1,331 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* Copyright (C) 2022 David Bauer <mail@david-bauer.net> */ + +/* + * First byte: Image status + * + * Possible status-codes: + * 0x0: none + * 0x1: new + * 0x2: valid + * 0x3: invalid + * + * Example: Image 0 valid; Image 1 invalid + * 11001000 + * || || + * img1|| + * img0 + * + * Second byte: Active Image + * Possible values: + * 0x0: Image0 active + * 0x1: Image1 active + */ + +#include <stdio.h> +#include <stdbool.h> +#include <stdlib.h> +#include <stddef.h> + +#include <fcntl.h> +#include <string.h> +#include <unistd.h> + +#include <sys/ioctl.h> +#include <mtd/mtd-user.h> + +#define BOOTCONFIG_SIZE 0x20 +#define BOOTCONFIG_IMAGE_STATUS 0x0 +#define BOOTCONFIG_ACTIVE_IMAGE 0x1 + +#define IMAGE_0_SHIFT 2 +#define IMAGE_0_MASK 0x0c +#define IMAGE_1_SHIFT 6 +#define IMAGE_1_MASK 0xc0 + +#define IMAGE_STATUS(img0, img1) (((img0 << IMAGE_0_SHIFT) & IMAGE_0_MASK) | ((img1 << IMAGE_1_SHIFT) & IMAGE_1_MASK)) + +#define ACTIVE_IMAGE_MASK 0x1 +#define ACTIVE_IMAGE(img) (img & ACTIVE_IMAGE_MASK) + +enum zyxel_bootconfig_image_status { + IMAGE_STATUS_NONE = 0x0, + IMAGE_STATUS_NEW = 0x1, + IMAGE_STATUS_VALID = 0x2, + IMAGE_STATUS_INVALID = 0x3, + __IMAGE_STATUS_EINVAL, +}; + +struct zyxel_bootconfig { + enum zyxel_bootconfig_image_status image0_status; + enum zyxel_bootconfig_image_status image1_status; + unsigned int active_image; +}; + +struct zyxel_bootconfig_mtd { + struct mtd_info_user mtd_info; + int fd; +}; + +struct zyxel_image_status { + enum zyxel_bootconfig_image_status code; + const char *name; +}; + +struct zyxel_image_status image_status_codes[] = { + { .code = IMAGE_STATUS_NONE, .name = "none" }, + { .code = IMAGE_STATUS_NEW, .name = "new" }, + { .code = IMAGE_STATUS_VALID, .name = "valid" }, + { .code = IMAGE_STATUS_INVALID, .name = "invalid" }, + {}, +}; + + +static enum zyxel_bootconfig_image_status zyxel_bootconfig_image_status_parse(const char *status) { + struct zyxel_image_status* s; + + for (s = image_status_codes; s->name; s++) { + if (!strcmp(status, s->name)) { + return s->code; + } + } + + return __IMAGE_STATUS_EINVAL; +} + +const char *zyxel_bootconfig_image_status_name(const enum zyxel_bootconfig_image_status bootconfig) { + struct zyxel_image_status* s; + + for (s = image_status_codes; s->name; s++) { + if (bootconfig == s->code) { + return s->name; + } + } + + return "N/A"; +} + +static void zyxel_bootconfig_mtd_close(struct zyxel_bootconfig_mtd *mtd) { + close(mtd->fd); +} + + +static int zyxel_bootconfig_mtd_open(struct zyxel_bootconfig_mtd *mtd, const char *mtd_name) { + int ret = 0; + + mtd->fd = open(mtd_name, O_RDWR | O_SYNC); + if (mtd->fd < 0) { + fprintf(stderr, "Could not open mtd device: %s\n", mtd_name); + ret = -1; + goto out; + } + + if (ioctl(mtd->fd, MEMGETINFO, &mtd->mtd_info)) { + fprintf(stderr, "Could not get MTD device info from %s\n", mtd_name); + ret = -1; + zyxel_bootconfig_mtd_close(mtd); + goto out; + } + +out: + return ret; +} + + +static int zyxel_bootconfig_read(struct zyxel_bootconfig *config, struct zyxel_bootconfig_mtd *mtd) { + char *args = NULL; + int ret = 0; + + /* Allocate memory for reading boot-config partition */ + args = calloc(1, mtd->mtd_info.erasesize); + if (!args) { + fprintf(stderr, "Could not allocate memory!\n"); + ret = -1; + goto out; + } + + /* Read bootconfig partition */ + pread(mtd->fd, args, mtd->mtd_info.erasesize, 0); + + /* Parse config */ + memset(config, 0, sizeof(*config)); + + config->image0_status = (args[BOOTCONFIG_IMAGE_STATUS] & IMAGE_0_MASK) >> IMAGE_0_SHIFT; + config->image1_status = (args[BOOTCONFIG_IMAGE_STATUS] & IMAGE_1_MASK) >> IMAGE_1_SHIFT; + config->active_image = (args[BOOTCONFIG_ACTIVE_IMAGE] & ACTIVE_IMAGE_MASK); + +out: + if (args) + free(args); + return ret; +} + + +static int zyxel_bootconfig_write(struct zyxel_bootconfig *config, struct zyxel_bootconfig_mtd *mtd) +{ + struct erase_info_user erase_info; + char img_status, img_active; + char *args = NULL; + int ret = 0; + + /* Allocate memory for reading boot-config partition */ + args = calloc(1, mtd->mtd_info.erasesize); + if (!args) { + fprintf(stderr, "Could not allocate memory!\n"); + ret = -1; + goto out; + } + + /* Read bootconfig partition */ + pread(mtd->fd, args, mtd->mtd_info.erasesize, 0); + + img_status = IMAGE_STATUS(config->image0_status, config->image1_status); + img_active = ACTIVE_IMAGE(config->active_image); + + /* Check if bootconfig has to be written */ + if (args[BOOTCONFIG_IMAGE_STATUS] == img_status && args[BOOTCONFIG_ACTIVE_IMAGE] == img_active) { + ret = 0; + goto out; + } + + /* Erase first block (containing the magic) */ + erase_info.start = 0; + erase_info.length = mtd->mtd_info.erasesize; + ret = ioctl(mtd->fd, MEMERASE, &erase_info); + if (ret < 0) { + fprintf(stderr, "Failed to erase block: %i\n", ret); + goto out; + } + + + /* Write bootconfig */ + args[BOOTCONFIG_IMAGE_STATUS] = img_status; + args[BOOTCONFIG_ACTIVE_IMAGE] = img_active; + + if (pwrite(mtd->fd, args, mtd->mtd_info.erasesize, 0) != mtd->mtd_info.erasesize) { + fprintf(stderr, "Error writing bootconfig!\n"); + ret = -1; + goto out; + } + +out: + if (args) + free(args); + return ret; +} + + +static void zyxel_bootconfig_print_usage(char *programm) +{ + struct zyxel_image_status* s = image_status_codes; + + printf("Usage: %s <mtd-device> <command> [args]\n", programm); + printf("Available commands:\n"); + printf(" get-status\n"); + printf(" set-image-status [0/1] ["); + + while (s->name) { + printf("%s", s->name); + s++; + + if (s->name) + printf(","); + } + + printf("]\n"); + printf(" set-active-image [0/1]\n"); +} + +int main(int argc, char *argv[]) +{ + enum zyxel_bootconfig_image_status image_status; + struct zyxel_bootconfig_mtd mtd; + struct zyxel_bootconfig config; + const char *mtd_name, *command; + bool writeback = false; + int image_idx; + + if (argc < 3) { + zyxel_bootconfig_print_usage(argv[0]); + return 1; + } + + mtd_name = argv[1]; + command = argv[2]; + + if (zyxel_bootconfig_mtd_open(&mtd, mtd_name)) { + fprintf(stderr, "Error opening %s!\n", mtd_name); + return 1; + } + + if (zyxel_bootconfig_read(&config, &mtd)) { + fprintf(stderr, "Error reading bootconfig!\n"); + zyxel_bootconfig_mtd_close(&mtd); + return 1; + } + + if (!strcmp(command, "set-image-status")) { + if (argc < 5) { + zyxel_bootconfig_print_usage(argv[0]); + zyxel_bootconfig_mtd_close(&mtd); + return 1; + } + + image_idx = atoi(argv[3]); + if (image_idx > 1 || image_idx < 0) { + fprintf(stderr, "Invalid image-slot set!\n"); + zyxel_bootconfig_mtd_close(&mtd); + return 1; + } + + image_status = zyxel_bootconfig_image_status_parse(argv[4]); + if (image_status == __IMAGE_STATUS_EINVAL) { + fprintf(stderr, "Invalid image-status!\n"); + zyxel_bootconfig_mtd_close(&mtd); + return 1; + } + + if (image_idx == 0) { + config.image0_status = image_status; + } else { + config.image1_status = image_status; + } + + writeback = true; + } else if (!strcmp(command, "set-active-image")) { + if (argc < 4) { + zyxel_bootconfig_print_usage(argv[0]); + zyxel_bootconfig_mtd_close(&mtd); + return 1; + } + + image_idx = atoi(argv[3]); + if (image_idx > 1 || image_idx < 0) { + fprintf(stderr, "Invalid image-slot set!\n"); + zyxel_bootconfig_mtd_close(&mtd); + return 1; + } + + config.active_image = image_idx; + + writeback = true; + } else if (!strcmp(command, "get-status")) { + printf("Active Image: %d\n", config.active_image); + printf("Image 0 Status: %s\n", zyxel_bootconfig_image_status_name(config.image0_status)); + printf("Image 1 Status: %s\n", zyxel_bootconfig_image_status_name(config.image1_status)); + + writeback = false; + } + + if (writeback) { + if (zyxel_bootconfig_write(&config, &mtd)) { + fprintf(stderr, "Error writing bootconfig!\n"); + zyxel_bootconfig_mtd_close(&mtd); + return 1; + } + + zyxel_bootconfig_mtd_close(&mtd); + } + + return 0; +} |
