Compare commits
341
Commits
1_5_stable
...
1_6_2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a0ec7918f3 | ||
|
|
52c886144f | ||
|
|
32a66a8e93 | ||
|
|
4bbeebd666 | ||
|
|
d08b43f8a5 | ||
|
|
37e977b80e | ||
|
|
dbb06975a8 | ||
|
|
c3eb33731d | ||
|
|
8a37a2a352 | ||
|
|
9cb801884a | ||
|
|
3f22b7f718 | ||
|
|
a0d7508748 | ||
|
|
fdcfa2aba7 | ||
|
|
342b0ab945 | ||
|
|
9a7d38fe24 | ||
|
|
fad2b86c9e | ||
|
|
c2f011aa03 | ||
|
|
22a9a3c6f8 | ||
|
|
a1d24a0b6e | ||
|
|
199c0d542b | ||
|
|
0b3b41b62a | ||
|
|
27f79ff03d | ||
|
|
4b924f3a5c | ||
|
|
4ef7d3a2de | ||
|
|
fe3e1776ad | ||
|
|
1c9ad62d26 | ||
|
|
b6adbf1be2 | ||
|
|
5a6aeddfa7 | ||
|
|
6239b1f50a | ||
|
|
ba7cf260fd | ||
|
|
0a83fc3984 | ||
|
|
201c72a8d6 | ||
|
|
28c0f0f4fe | ||
|
|
d76c049cc4 | ||
|
|
163a855731 | ||
|
|
5a1437d835 | ||
|
|
cd7f4d27a2 | ||
|
|
2b6bbad4db | ||
|
|
0fe67b16ce | ||
|
|
b055001b6a | ||
|
|
90e485ce79 | ||
|
|
1744cb1861 | ||
|
|
170435c575 | ||
|
|
1a7358612f | ||
|
|
94dace3016 | ||
|
|
6963eb53a1 | ||
|
|
0681033918 | ||
|
|
8805eeb44a | ||
|
|
219e88d050 | ||
|
|
004baba2d6 | ||
|
|
262d765351 | ||
|
|
14b5dd9943 | ||
|
|
fe52a74ecf | ||
|
|
46846e25a4 | ||
|
|
38ec147a18 | ||
|
|
6d709972cd | ||
|
|
4500c58a07 | ||
|
|
d9b5ab868c | ||
|
|
78e48b2c2c | ||
|
|
ffba941d29 | ||
|
|
5b34083004 | ||
|
|
cd5c7866e3 | ||
|
|
c8be5ee325 | ||
|
|
b6a741ffa7 | ||
|
|
96f67dc69d | ||
|
|
d46e6d1a55 | ||
|
|
a35958d4ad | ||
|
|
c666f71e3b | ||
|
|
831dcc439c | ||
|
|
c29903221d | ||
|
|
3e7b0e6120 | ||
|
|
1f4cf517f5 | ||
|
|
8f6bdb42df | ||
|
|
418a7fb29b | ||
|
|
c2b3e370d6 | ||
|
|
64332bf857 | ||
|
|
d6050949b8 | ||
|
|
764d59d488 | ||
|
|
03eb8bf6ce | ||
|
|
602d13cba5 | ||
|
|
119b995437 | ||
|
|
3e9aaae5dc | ||
|
|
e0a336747c | ||
|
|
53079d494e | ||
|
|
2b54aaa9bf | ||
|
|
389f9d52d5 | ||
|
|
57bf668d11 | ||
|
|
68de720723 | ||
|
|
8465a99ce7 | ||
|
|
bf678d5423 | ||
|
|
a035e9f1a9 | ||
|
|
a04561f5f7 | ||
|
|
7e84e539de | ||
|
|
92c0b8222e | ||
|
|
0cacc80952 | ||
|
|
02f47e9f81 | ||
|
|
21f0d4c55e | ||
|
|
b952835efe | ||
|
|
dd4cb2b31e | ||
|
|
a6c467f6d1 | ||
|
|
734e5ebc93 | ||
|
|
ac0e5ab96a | ||
|
|
3349fc4da9 | ||
|
|
400c5b6fc6 | ||
|
|
6e6d331d97 | ||
|
|
f71d916b60 | ||
|
|
e725bfe6e0 | ||
|
|
f2fffd0014 | ||
|
|
3bc18253b0 | ||
|
|
f92df58d3d | ||
|
|
3c82e48923 | ||
|
|
eda43d7f45 | ||
|
|
d01ff13454 | ||
|
|
dd999a2241 | ||
|
|
bd100b7478 | ||
|
|
4ac530c0ef | ||
|
|
ef36ead370 | ||
|
|
dcf4de20a1 | ||
|
|
f20de5bb42 | ||
|
|
d4728145e3 | ||
|
|
08c8c1d3b3 | ||
|
|
e3f2f89891 | ||
|
|
b81b3df1fa | ||
|
|
0937be5fa6 | ||
|
|
b5eaabb322 | ||
|
|
3ac0e00553 | ||
|
|
18e19f2b0d | ||
|
|
a6a1785a30 | ||
|
|
706fdc98c3 | ||
|
|
1359da6ac7 | ||
|
|
762d35c75f | ||
|
|
52881e9f23 | ||
|
|
2f1bb36a55 | ||
|
|
87cb2db703 | ||
|
|
54e7ffb3a4 | ||
|
|
5f786c24e4 | ||
|
|
f6250a3bee | ||
|
|
d1801a4430 | ||
|
|
9ace613406 | ||
|
|
05a6d9cbb2 | ||
|
|
8581863a1b | ||
|
|
516a0ca2dc | ||
|
|
c34d35557b | ||
|
|
3ace9fa6d8 | ||
|
|
088b959d00 | ||
|
|
2ace1e3f07 | ||
|
|
55b2de71d7 | ||
|
|
517d1aac7f | ||
|
|
198714c0dd | ||
|
|
7d4c44e1b1 | ||
|
|
ac678ec2f1 | ||
|
|
17e3c34aa7 | ||
|
|
bc9d7d788b | ||
|
|
ab51bf4e28 | ||
|
|
e468ef27b7 | ||
|
|
0922192740 | ||
|
|
84f75b0b94 | ||
|
|
8acf521432 | ||
|
|
be1a9d4237 | ||
|
|
91de7c0328 | ||
|
|
58394b1e29 | ||
|
|
e471275813 | ||
|
|
5f9468e996 | ||
|
|
8a28e620ce | ||
|
|
bf3561fd15 | ||
|
|
f5294e1f4c | ||
|
|
16abcd90ae | ||
|
|
334fa9bcb5 | ||
|
|
87468857f6 | ||
|
|
f7fcca4af7 | ||
|
|
1d6a4aec2c | ||
|
|
fbf6dea5a2 | ||
|
|
f03dbeda90 | ||
|
|
b636d8c18c | ||
|
|
beaca811e4 | ||
|
|
62f0479cf1 | ||
|
|
945bd3dee8 | ||
|
|
3211adc184 | ||
|
|
3a62a737f7 | ||
|
|
b69f35effe | ||
|
|
7cced6e574 | ||
|
|
0de3c55b42 | ||
|
|
831a20f512 | ||
|
|
c98c31783c | ||
|
|
b290889f02 | ||
|
|
51742f4bb0 | ||
|
|
50f7f446ec | ||
|
|
d7c8196c1b | ||
|
|
8fd371276f | ||
|
|
6398cf477d | ||
|
|
e4f2d064b0 | ||
|
|
12c96a64a4 | ||
|
|
0d058361e7 | ||
|
|
03fc408de6 | ||
|
|
d571c08c25 | ||
|
|
473dae080a | ||
|
|
f1a7141cfc | ||
|
|
80d14beae9 | ||
|
|
8905496444 | ||
|
|
c6758a07c6 | ||
|
|
335b63d8d1 | ||
|
|
07c394e69b | ||
|
|
99003b8a87 | ||
|
|
f73cac8d3d | ||
|
|
e87d7955f8 | ||
|
|
51f7ab6162 | ||
|
|
246b5c3916 | ||
|
|
b38cf3ff8a | ||
|
|
a9d7d24e1f | ||
|
|
99912ca733 | ||
|
|
ff131b980d | ||
|
|
163516da3a | ||
|
|
de17ece1db | ||
|
|
8b1fab2879 | ||
|
|
7e8a53a335 | ||
|
|
3f3aa2a57d | ||
|
|
cd7001f705 | ||
|
|
1b4b2cb20e | ||
|
|
53d445aa75 | ||
|
|
7e754f12d3 | ||
|
|
2dfdd44d9d | ||
|
|
c44ab01b75 | ||
|
|
95cb3263ae | ||
|
|
32b633aa3f | ||
|
|
786834bcee | ||
|
|
240a1cfbbe | ||
|
|
5694d5f8d2 | ||
|
|
8d9f495d68 | ||
|
|
b04b4357ff | ||
|
|
bbd695d801 | ||
|
|
ca3484103e | ||
|
|
1ae63fc1bc | ||
|
|
9c146a91d3 | ||
|
|
fdf63a30fe | ||
|
|
540a2a1f3b | ||
|
|
fbd2918f5c | ||
|
|
bb5b01c7c7 | ||
|
|
04c99ebb4f | ||
|
|
19507f0869 | ||
|
|
5a30d59c3d | ||
|
|
bf295dd5b6 | ||
|
|
df5bbb938a | ||
|
|
1bb552b1d9 | ||
|
|
9020d850bf | ||
|
|
c7b10dc037 | ||
|
|
2f7b923f5c | ||
|
|
5f42d26865 | ||
|
|
29fe7265b8 | ||
|
|
00c2c4868a | ||
|
|
45aebfd32d | ||
|
|
2e75dcc80d | ||
|
|
6d79dd66cb | ||
|
|
bdd253e450 | ||
|
|
7d6c9296e7 | ||
|
|
56fce00fc7 | ||
|
|
febe3c4211 | ||
|
|
d9c2d5fe4f | ||
|
|
10aed96f14 | ||
|
|
24efe4f15f | ||
|
|
1ca332b367 | ||
|
|
2a47dea263 | ||
|
|
3a60244ae9 | ||
|
|
0e6ab01c5a | ||
|
|
794687947f | ||
|
|
64a15124e7 | ||
|
|
02fd66885c | ||
|
|
b933ac1e25 | ||
|
|
992e05b6f0 | ||
|
|
cea0a8bccb | ||
|
|
8025afad8a | ||
|
|
3c5929a53b | ||
|
|
adb01b1583 | ||
|
|
729bd9e0b0 | ||
|
|
b05a939bcc | ||
|
|
60fadaca28 | ||
|
|
57a426b15b | ||
|
|
ba2fb719b9 | ||
|
|
2856dab477 | ||
|
|
f443bffd3c | ||
|
|
6fa8b8e17f | ||
|
|
9eb51ad6b9 | ||
|
|
ae47cd1da7 | ||
|
|
4caa09a782 | ||
|
|
666c40c9fc | ||
|
|
7b881c7168 | ||
|
|
cc890264d9 | ||
|
|
eceecea568 | ||
|
|
52a9db6bb8 | ||
|
|
2e723237c9 | ||
|
|
53f83d68fb | ||
|
|
5e43d8591b | ||
|
|
a87ed2c716 | ||
|
|
307d27df4f | ||
|
|
557b458767 | ||
|
|
32773aca55 | ||
|
|
3e816c1252 | ||
|
|
3d43edb28c | ||
|
|
c7d4b98cbd | ||
|
|
45cd089df1 | ||
|
|
450196c119 | ||
|
|
b7cffd4bed | ||
|
|
0a537a0c57 | ||
|
|
0864f4d14f | ||
|
|
58a275b303 | ||
|
|
0eec4abb13 | ||
|
|
7c282a2078 | ||
|
|
f1ba749509 | ||
|
|
6a5598c2bc | ||
|
|
ebf48bb80c | ||
|
|
10457b90db | ||
|
|
f4d40c87d3 | ||
|
|
3983bd5593 | ||
|
|
17a1526f9e | ||
|
|
91dd275f05 | ||
|
|
576de34d1c | ||
|
|
afa7023b46 | ||
|
|
4e1361a481 | ||
|
|
b813eaff23 | ||
|
|
53091ecd20 | ||
|
|
ec1a4b5a52 | ||
|
|
af1c84360f | ||
|
|
5a142025d3 | ||
|
|
bb7fcb4229 | ||
|
|
f62c6fa1ca | ||
|
|
cd43dfdeec | ||
|
|
cad04ef4f3 | ||
|
|
10f8f5f443 | ||
|
|
55f30b05ac | ||
|
|
c0415a9833 | ||
|
|
8a503be840 | ||
|
|
7695328575 | ||
|
|
219d14d514 | ||
|
|
644849a3aa | ||
|
|
1fc6e56684 | ||
|
|
5b27fbe990 | ||
|
|
b5b45a91f0 | ||
|
|
d3bac03988 | ||
|
|
9067f13be0 | ||
|
|
1b6fa4c57c | ||
|
|
ce074df814 | ||
|
|
7d10823f6a |
No files matched your search
@@ -141,6 +141,13 @@ config FEATURE_CLEAN_UP
|
||||
Don't enable this unless you have a really good reason to clean
|
||||
things up manually.
|
||||
|
||||
config FEATURE_PIDFILE
|
||||
bool "Support writing pidfiles"
|
||||
default n
|
||||
help
|
||||
This option makes some applets (crond, syslogd and inetd) write
|
||||
a pidfile in /var/run. Some applications rely on them
|
||||
|
||||
config FEATURE_SUID
|
||||
bool "Support for SUID/SGID handling"
|
||||
default n
|
||||
@@ -231,13 +238,19 @@ config SELINUX
|
||||
|
||||
Most people will leave this set to 'N'.
|
||||
|
||||
config FEATURE_EXEC_PREFER_APPLETS
|
||||
config FEATURE_PREFER_APPLETS
|
||||
bool "exec prefers applets"
|
||||
default n
|
||||
help
|
||||
This is an experimental option which directs applets about to
|
||||
call 'exec' to try and find an applicable busybox applet before
|
||||
searching the executable path for a binary or symlink to execute.
|
||||
searching the PATH. This is typically done by exec'ing
|
||||
/proc/self/exe.
|
||||
This may affect shell, find -exec, xargs and similar applets.
|
||||
They will use applets even if /bin/<applet> -> busybox link
|
||||
is missing (or is not a link to busybox). However, this causes
|
||||
problems in chroot jails without mounted /proc and with ps/top
|
||||
(command name can be shown as 'exe' for applets started this way).
|
||||
|
||||
config BUSYBOX_EXEC_PATH
|
||||
string "Path to BusyBox executable"
|
||||
@@ -375,7 +388,6 @@ config WERROR
|
||||
choice
|
||||
prompt "Additional debugging library"
|
||||
default NO_DEBUG_LIB
|
||||
depends on DEBUG
|
||||
help
|
||||
Using an additional debugging library will make BusyBox become
|
||||
considerable larger and will cause it to run more slowly. You
|
||||
@@ -455,10 +467,10 @@ config INSTALL_APPLET_HARDLINKS
|
||||
|
||||
config INSTALL_APPLET_DONT
|
||||
bool "not installed"
|
||||
depends on FEATURE_INSTALLER || FEATURE_SH_STANDALONE_SHELL || FEATURE_EXEC_PREFER_APPLETS
|
||||
depends on FEATURE_INSTALLER || FEATURE_SH_STANDALONE || FEATURE_PREFER_APPLETS
|
||||
help
|
||||
Do not install applet links. Useful when using the -install feature
|
||||
or a standalone shell for rescue pruposes.
|
||||
or a standalone shell for rescue purposes.
|
||||
|
||||
endchoice
|
||||
|
||||
@@ -494,3 +506,4 @@ source shell/Config.in
|
||||
source sysklogd/Config.in
|
||||
source runit/Config.in
|
||||
source selinux/Config.in
|
||||
source ipsvd/Config.in
|
||||
@@ -1,6 +1,6 @@
|
||||
VERSION = 1
|
||||
PATCHLEVEL = 5
|
||||
SUBLEVEL = 0
|
||||
PATCHLEVEL = 6
|
||||
SUBLEVEL = 2
|
||||
EXTRAVERSION =
|
||||
NAME = Unnamed
|
||||
|
||||
@@ -302,6 +302,8 @@ AFLAGS_KERNEL =
|
||||
CFLAGS := $(CFLAGS)
|
||||
CPPFLAGS := $(CPPFLAGS)
|
||||
AFLAGS := $(AFLAGS)
|
||||
LDFLAGS := $(LDFLAGS)
|
||||
LDLIBS :=
|
||||
|
||||
# Read KERNELRELEASE from .kernelrelease (if it exists)
|
||||
KERNELRELEASE = $(shell cat .kernelrelease 2> /dev/null)
|
||||
@@ -315,6 +317,7 @@ export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION \
|
||||
export CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
|
||||
export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
|
||||
export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
|
||||
export FLTFLAGS
|
||||
|
||||
# When compiling out-of-tree modules, put MODVERDIR in the module
|
||||
# tree rather than in the kernel tree. The kernel tree might
|
||||
@@ -432,6 +435,7 @@ libs-y := \
|
||||
editors/ \
|
||||
findutils/ \
|
||||
init/ \
|
||||
ipsvd/ \
|
||||
libbb/ \
|
||||
libpwdgrp/ \
|
||||
loginutils/ \
|
||||
@@ -565,7 +569,8 @@ quiet_cmd_busybox__ ?= LINK $@
|
||||
cmd_busybox__ ?= $(srctree)/scripts/trylink $(CC) $(LDFLAGS) \
|
||||
-o $@ -Wl,-M \
|
||||
-Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections \
|
||||
-Wl,--start-group $(busybox-all) -Wl,--end-group
|
||||
-Wl,--start-group $(busybox-all) -Wl,--end-group \
|
||||
$(LDLIBS)
|
||||
|
||||
# Generate System.map
|
||||
quiet_cmd_sysmap = SYSMAP
|
||||
|
||||
@@ -143,3 +143,5 @@ SYN_CPPFLAGS := $(subst $(brace_close),\$(brace_close),$(SYN_CPPFLAGS))
|
||||
.PHONY: html
|
||||
html: $(syn)
|
||||
synopsis -f HTML -Wf,title="'BusyBox Documentation'" -o $@ $^
|
||||
|
||||
-include $(srctree)/Makefile.local
|
||||
+13
-1
@@ -56,6 +56,18 @@ LDFLAGS += -static
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SELINUX),y)
|
||||
LDFLAGS += -lselinux -lsepol
|
||||
LDLIBS += -lselinux -lsepol
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EFENCE),y)
|
||||
LDLIBS += -lefence
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_DMALLOC),y)
|
||||
LDLIBS += -ldmalloc
|
||||
endif
|
||||
|
||||
#LDFLAGS += -nostdlib
|
||||
|
||||
# Busybox is a stack-fatty so make sure we increase default size
|
||||
FLTFLAGS += -s 20000
|
||||
@@ -36,12 +36,7 @@ Rob Landley <rob@landley.net>:
|
||||
modutils. The orig depmod is rather pointless to have to add to a firmware image
|
||||
in when we already have a insmod/rmmod and friends.
|
||||
Unify base64 handling.
|
||||
There's base64 encoding and decoding going on in:
|
||||
networking/wget.c:base64enc()
|
||||
coreutils/uudecode.c:read_base64()
|
||||
coreutils/uuencode.c:tbl_base64[]
|
||||
networking/httpd.c:decodeBase64()
|
||||
And probably elsewhere. That needs to be unified into libbb functions.
|
||||
[done]
|
||||
Do a SUSv3 audit
|
||||
Look at the full Single Unix Specification version 3 (available online at
|
||||
"http://www.opengroup.org/onlinepubs/009695399/nfindex.html") and
|
||||
@@ -167,15 +162,20 @@ man
|
||||
---
|
||||
ar
|
||||
Write support?
|
||||
----
|
||||
---
|
||||
stty / catv
|
||||
stty's visible() function and catv's guts are identical. Merge them into
|
||||
an appropriate libbb function.
|
||||
----
|
||||
---
|
||||
struct suffix_mult
|
||||
Several duplicate users of: grep -r "1024\*1024" * -B2 -A1
|
||||
Merge to a single size_suffixes[] in libbb.
|
||||
Users: head tail od_bloaty hexdump and (partially as it wouldn't hurt) svlogd
|
||||
---
|
||||
tail
|
||||
./busybox tail -f foo.c~ TODO
|
||||
should not print fmt=header_fmt for subsequent date >> TODO; i.e. only
|
||||
fmt+ if another (not the current) file did change
|
||||
|
||||
Architectural issues:
|
||||
|
||||
|
||||
@@ -0,0 +1,711 @@
|
||||
# This .config compiles for NOMMU.
|
||||
# TODO:
|
||||
# Pick disabled applet, enable & try to make it compile & work on NOMMU
|
||||
|
||||
#
|
||||
# Automatically generated make config: don't edit
|
||||
# Busybox version: 1.6.0.svn
|
||||
# Wed Apr 11 01:29:04 2007
|
||||
#
|
||||
CONFIG_HAVE_DOT_CONFIG=y
|
||||
|
||||
#
|
||||
# Busybox Settings
|
||||
#
|
||||
|
||||
#
|
||||
# General Configuration
|
||||
#
|
||||
# CONFIG_NITPICK is not set
|
||||
# CONFIG_DESKTOP is not set
|
||||
# CONFIG_FEATURE_BUFFERS_USE_MALLOC is not set
|
||||
# CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set
|
||||
# CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set
|
||||
CONFIG_SHOW_USAGE=y
|
||||
CONFIG_FEATURE_VERBOSE_USAGE=y
|
||||
CONFIG_FEATURE_COMPRESS_USAGE=y
|
||||
CONFIG_FEATURE_INSTALLER=y
|
||||
# CONFIG_LOCALE_SUPPORT is not set
|
||||
CONFIG_GETOPT_LONG=y
|
||||
CONFIG_FEATURE_DEVPTS=y
|
||||
# CONFIG_FEATURE_CLEAN_UP is not set
|
||||
CONFIG_FEATURE_PIDFILE=y
|
||||
CONFIG_FEATURE_SUID=y
|
||||
CONFIG_FEATURE_SYSLOG=y
|
||||
# CONFIG_FEATURE_SUID_CONFIG is not set
|
||||
# CONFIG_FEATURE_SUID_CONFIG_QUIET is not set
|
||||
# CONFIG_FEATURE_HAVE_RPC is not set
|
||||
# CONFIG_SELINUX is not set
|
||||
CONFIG_FEATURE_PREFER_APPLETS=y
|
||||
CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe"
|
||||
|
||||
#
|
||||
# Build Options
|
||||
#
|
||||
# CONFIG_STATIC is not set
|
||||
# CONFIG_BUILD_LIBBUSYBOX is not set
|
||||
# CONFIG_FEATURE_FULL_LIBBUSYBOX is not set
|
||||
# CONFIG_FEATURE_SHARED_BUSYBOX is not set
|
||||
CONFIG_LFS=y
|
||||
# CONFIG_BUILD_AT_ONCE is not set
|
||||
|
||||
#
|
||||
# Debugging Options
|
||||
#
|
||||
# CONFIG_DEBUG is not set
|
||||
CONFIG_WERROR=y
|
||||
CONFIG_NO_DEBUG_LIB=y
|
||||
# CONFIG_DMALLOC is not set
|
||||
# CONFIG_EFENCE is not set
|
||||
CONFIG_INCLUDE_SUSv2=y
|
||||
|
||||
#
|
||||
# Installation Options
|
||||
#
|
||||
# CONFIG_INSTALL_NO_USR is not set
|
||||
CONFIG_INSTALL_APPLET_SYMLINKS=y
|
||||
# CONFIG_INSTALL_APPLET_HARDLINKS is not set
|
||||
# CONFIG_INSTALL_APPLET_DONT is not set
|
||||
CONFIG_PREFIX="./_install"
|
||||
|
||||
#
|
||||
# Busybox Library Tuning
|
||||
#
|
||||
CONFIG_PASSWORD_MINLEN=6
|
||||
CONFIG_MD5_SIZE_VS_SPEED=2
|
||||
CONFIG_FEATURE_EDITING=y
|
||||
# CONFIG_FEATURE_EDITING_FANCY_KEYS is not set
|
||||
# CONFIG_FEATURE_EDITING_VI is not set
|
||||
CONFIG_FEATURE_EDITING_HISTORY=15
|
||||
# CONFIG_FEATURE_EDITING_SAVEHISTORY is not set
|
||||
# CONFIG_FEATURE_TAB_COMPLETION is not set
|
||||
# CONFIG_FEATURE_USERNAME_COMPLETION is not set
|
||||
# CONFIG_FEATURE_EDITING_FANCY_PROMPT is not set
|
||||
|
||||
#
|
||||
# Applets
|
||||
#
|
||||
|
||||
#
|
||||
# Archival Utilities
|
||||
#
|
||||
CONFIG_AR=y
|
||||
CONFIG_FEATURE_AR_LONG_FILENAMES=y
|
||||
CONFIG_BUNZIP2=y
|
||||
CONFIG_CPIO=y
|
||||
# CONFIG_DPKG is not set
|
||||
# CONFIG_DPKG_DEB is not set
|
||||
# CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY is not set
|
||||
CONFIG_GUNZIP=y
|
||||
CONFIG_FEATURE_GUNZIP_UNCOMPRESS=y
|
||||
CONFIG_GZIP=y
|
||||
CONFIG_RPM2CPIO=y
|
||||
# CONFIG_RPM is not set
|
||||
CONFIG_TAR=y
|
||||
CONFIG_FEATURE_TAR_CREATE=y
|
||||
# CONFIG_FEATURE_TAR_BZIP2 is not set
|
||||
# CONFIG_FEATURE_TAR_LZMA is not set
|
||||
CONFIG_FEATURE_TAR_FROM=y
|
||||
# CONFIG_FEATURE_TAR_GZIP is not set
|
||||
# CONFIG_FEATURE_TAR_COMPRESS is not set
|
||||
CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY=y
|
||||
CONFIG_FEATURE_TAR_GNU_EXTENSIONS=y
|
||||
CONFIG_FEATURE_TAR_LONG_OPTIONS=y
|
||||
CONFIG_UNCOMPRESS=y
|
||||
CONFIG_UNLZMA=y
|
||||
CONFIG_FEATURE_LZMA_FAST=y
|
||||
CONFIG_UNZIP=y
|
||||
|
||||
#
|
||||
# Common options for cpio and tar
|
||||
#
|
||||
CONFIG_FEATURE_UNARCHIVE_TAPE=y
|
||||
# CONFIG_FEATURE_DEB_TAR_GZ is not set
|
||||
# CONFIG_FEATURE_DEB_TAR_BZ2 is not set
|
||||
# CONFIG_FEATURE_DEB_TAR_LZMA is not set
|
||||
|
||||
#
|
||||
# Coreutils
|
||||
#
|
||||
CONFIG_BASENAME=y
|
||||
CONFIG_CAL=y
|
||||
CONFIG_CAT=y
|
||||
CONFIG_CATV=y
|
||||
CONFIG_CHGRP=y
|
||||
CONFIG_CHMOD=y
|
||||
CONFIG_CHOWN=y
|
||||
CONFIG_CHROOT=y
|
||||
CONFIG_CKSUM=y
|
||||
CONFIG_CMP=y
|
||||
CONFIG_COMM=y
|
||||
CONFIG_CP=y
|
||||
CONFIG_CUT=y
|
||||
CONFIG_DATE=y
|
||||
CONFIG_FEATURE_DATE_ISOFMT=y
|
||||
CONFIG_DD=y
|
||||
CONFIG_FEATURE_DD_SIGNAL_HANDLING=y
|
||||
CONFIG_FEATURE_DD_IBS_OBS=y
|
||||
CONFIG_DF=y
|
||||
CONFIG_DIFF=y
|
||||
CONFIG_FEATURE_DIFF_BINARY=y
|
||||
CONFIG_FEATURE_DIFF_DIR=y
|
||||
CONFIG_FEATURE_DIFF_MINIMAL=y
|
||||
CONFIG_DIRNAME=y
|
||||
CONFIG_DOS2UNIX=y
|
||||
CONFIG_UNIX2DOS=y
|
||||
CONFIG_DU=y
|
||||
CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K=y
|
||||
CONFIG_ECHO=y
|
||||
CONFIG_FEATURE_FANCY_ECHO=y
|
||||
CONFIG_ENV=y
|
||||
CONFIG_FEATURE_ENV_LONG_OPTIONS=y
|
||||
CONFIG_EXPR=y
|
||||
CONFIG_EXPR_MATH_SUPPORT_64=y
|
||||
CONFIG_FALSE=y
|
||||
CONFIG_FOLD=y
|
||||
CONFIG_HEAD=y
|
||||
CONFIG_FEATURE_FANCY_HEAD=y
|
||||
CONFIG_HOSTID=y
|
||||
CONFIG_ID=y
|
||||
CONFIG_INSTALL=y
|
||||
CONFIG_FEATURE_INSTALL_LONG_OPTIONS=y
|
||||
CONFIG_LENGTH=y
|
||||
CONFIG_LN=y
|
||||
CONFIG_LOGNAME=y
|
||||
CONFIG_LS=y
|
||||
CONFIG_FEATURE_LS_FILETYPES=y
|
||||
CONFIG_FEATURE_LS_FOLLOWLINKS=y
|
||||
CONFIG_FEATURE_LS_RECURSIVE=y
|
||||
CONFIG_FEATURE_LS_SORTFILES=y
|
||||
CONFIG_FEATURE_LS_TIMESTAMPS=y
|
||||
CONFIG_FEATURE_LS_USERNAME=y
|
||||
CONFIG_FEATURE_LS_COLOR=y
|
||||
CONFIG_FEATURE_LS_COLOR_IS_DEFAULT=y
|
||||
CONFIG_MD5SUM=y
|
||||
CONFIG_MKDIR=y
|
||||
CONFIG_FEATURE_MKDIR_LONG_OPTIONS=y
|
||||
CONFIG_MKFIFO=y
|
||||
CONFIG_MKNOD=y
|
||||
CONFIG_MV=y
|
||||
CONFIG_FEATURE_MV_LONG_OPTIONS=y
|
||||
CONFIG_NICE=y
|
||||
CONFIG_NOHUP=y
|
||||
CONFIG_OD=y
|
||||
CONFIG_PRINTENV=y
|
||||
CONFIG_PRINTF=y
|
||||
CONFIG_PWD=y
|
||||
CONFIG_REALPATH=y
|
||||
CONFIG_RM=y
|
||||
CONFIG_RMDIR=y
|
||||
CONFIG_SEQ=y
|
||||
CONFIG_SHA1SUM=y
|
||||
CONFIG_SLEEP=y
|
||||
CONFIG_FEATURE_FANCY_SLEEP=y
|
||||
CONFIG_SORT=y
|
||||
CONFIG_FEATURE_SORT_BIG=y
|
||||
CONFIG_SPLIT=y
|
||||
CONFIG_FEATURE_SPLIT_FANCY=y
|
||||
CONFIG_STAT=y
|
||||
CONFIG_FEATURE_STAT_FORMAT=y
|
||||
CONFIG_STTY=y
|
||||
CONFIG_SUM=y
|
||||
CONFIG_SYNC=y
|
||||
CONFIG_TAIL=y
|
||||
CONFIG_FEATURE_FANCY_TAIL=y
|
||||
CONFIG_TEE=y
|
||||
CONFIG_FEATURE_TEE_USE_BLOCK_IO=y
|
||||
CONFIG_TEST=y
|
||||
CONFIG_FEATURE_TEST_64=y
|
||||
CONFIG_TOUCH=y
|
||||
CONFIG_TR=y
|
||||
CONFIG_FEATURE_TR_CLASSES=y
|
||||
CONFIG_FEATURE_TR_EQUIV=y
|
||||
CONFIG_TRUE=y
|
||||
CONFIG_TTY=y
|
||||
CONFIG_UNAME=y
|
||||
CONFIG_UNIQ=y
|
||||
CONFIG_USLEEP=y
|
||||
CONFIG_UUDECODE=y
|
||||
CONFIG_UUENCODE=y
|
||||
CONFIG_WATCH=y
|
||||
CONFIG_WC=y
|
||||
CONFIG_FEATURE_WC_LARGE=y
|
||||
CONFIG_WHO=y
|
||||
CONFIG_WHOAMI=y
|
||||
CONFIG_YES=y
|
||||
|
||||
#
|
||||
# Common options for cp and mv
|
||||
#
|
||||
CONFIG_FEATURE_PRESERVE_HARDLINKS=y
|
||||
|
||||
#
|
||||
# Common options for ls, more and telnet
|
||||
#
|
||||
CONFIG_FEATURE_AUTOWIDTH=y
|
||||
|
||||
#
|
||||
# Common options for df, du, ls
|
||||
#
|
||||
CONFIG_FEATURE_HUMAN_READABLE=y
|
||||
|
||||
#
|
||||
# Common options for md5sum, sha1sum
|
||||
#
|
||||
CONFIG_FEATURE_MD5_SHA1_SUM_CHECK=y
|
||||
|
||||
#
|
||||
# Console Utilities
|
||||
#
|
||||
CONFIG_CHVT=y
|
||||
CONFIG_CLEAR=y
|
||||
CONFIG_DEALLOCVT=y
|
||||
CONFIG_DUMPKMAP=y
|
||||
CONFIG_LOADFONT=y
|
||||
CONFIG_LOADKMAP=y
|
||||
CONFIG_OPENVT=y
|
||||
CONFIG_RESET=y
|
||||
CONFIG_RESIZE=y
|
||||
CONFIG_FEATURE_RESIZE_PRINT=y
|
||||
CONFIG_SETCONSOLE=y
|
||||
CONFIG_FEATURE_SETCONSOLE_LONG_OPTIONS=y
|
||||
CONFIG_SETKEYCODES=y
|
||||
CONFIG_SETLOGCONS=y
|
||||
|
||||
#
|
||||
# Debian Utilities
|
||||
#
|
||||
CONFIG_MKTEMP=y
|
||||
CONFIG_PIPE_PROGRESS=y
|
||||
CONFIG_READLINK=y
|
||||
CONFIG_FEATURE_READLINK_FOLLOW=y
|
||||
CONFIG_RUN_PARTS=y
|
||||
CONFIG_FEATURE_RUN_PARTS_LONG_OPTIONS=y
|
||||
CONFIG_FEATURE_RUN_PARTS_FANCY=y
|
||||
# CONFIG_START_STOP_DAEMON is not set
|
||||
# CONFIG_FEATURE_START_STOP_DAEMON_FANCY is not set
|
||||
# CONFIG_FEATURE_START_STOP_DAEMON_LONG_OPTIONS is not set
|
||||
CONFIG_WHICH=y
|
||||
|
||||
#
|
||||
# Editors
|
||||
#
|
||||
CONFIG_AWK=y
|
||||
CONFIG_FEATURE_AWK_MATH=y
|
||||
CONFIG_ED=y
|
||||
CONFIG_PATCH=y
|
||||
CONFIG_SED=y
|
||||
CONFIG_VI=y
|
||||
CONFIG_FEATURE_VI_COLON=y
|
||||
CONFIG_FEATURE_VI_YANKMARK=y
|
||||
CONFIG_FEATURE_VI_SEARCH=y
|
||||
CONFIG_FEATURE_VI_USE_SIGNALS=y
|
||||
CONFIG_FEATURE_VI_DOT_CMD=y
|
||||
CONFIG_FEATURE_VI_READONLY=y
|
||||
CONFIG_FEATURE_VI_SETOPTS=y
|
||||
CONFIG_FEATURE_VI_SET=y
|
||||
CONFIG_FEATURE_VI_WIN_RESIZE=y
|
||||
CONFIG_FEATURE_VI_OPTIMIZE_CURSOR=y
|
||||
CONFIG_FEATURE_ALLOW_EXEC=y
|
||||
|
||||
#
|
||||
# Finding Utilities
|
||||
#
|
||||
CONFIG_FIND=y
|
||||
CONFIG_FEATURE_FIND_PRINT0=y
|
||||
CONFIG_FEATURE_FIND_MTIME=y
|
||||
CONFIG_FEATURE_FIND_MMIN=y
|
||||
CONFIG_FEATURE_FIND_PERM=y
|
||||
CONFIG_FEATURE_FIND_TYPE=y
|
||||
CONFIG_FEATURE_FIND_XDEV=y
|
||||
CONFIG_FEATURE_FIND_NEWER=y
|
||||
CONFIG_FEATURE_FIND_INUM=y
|
||||
CONFIG_FEATURE_FIND_EXEC=y
|
||||
CONFIG_FEATURE_FIND_USER=y
|
||||
CONFIG_FEATURE_FIND_GROUP=y
|
||||
CONFIG_FEATURE_FIND_NOT=y
|
||||
CONFIG_FEATURE_FIND_DEPTH=y
|
||||
CONFIG_FEATURE_FIND_PAREN=y
|
||||
CONFIG_FEATURE_FIND_SIZE=y
|
||||
CONFIG_FEATURE_FIND_PRUNE=y
|
||||
CONFIG_GREP=y
|
||||
CONFIG_FEATURE_GREP_EGREP_ALIAS=y
|
||||
CONFIG_FEATURE_GREP_FGREP_ALIAS=y
|
||||
CONFIG_FEATURE_GREP_CONTEXT=y
|
||||
CONFIG_XARGS=y
|
||||
CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION=y
|
||||
CONFIG_FEATURE_XARGS_SUPPORT_QUOTES=y
|
||||
CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT=y
|
||||
CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM=y
|
||||
|
||||
#
|
||||
# Init Utilities
|
||||
#
|
||||
# CONFIG_INIT is not set
|
||||
# CONFIG_DEBUG_INIT is not set
|
||||
# CONFIG_FEATURE_USE_INITTAB is not set
|
||||
# CONFIG_FEATURE_INIT_SCTTY is not set
|
||||
# CONFIG_FEATURE_INIT_SYSLOG is not set
|
||||
# CONFIG_FEATURE_EXTRA_QUIET is not set
|
||||
# CONFIG_FEATURE_INIT_COREDUMPS is not set
|
||||
# CONFIG_FEATURE_INITRD is not set
|
||||
CONFIG_HALT=y
|
||||
CONFIG_MESG=y
|
||||
|
||||
#
|
||||
# Login/Password Management Utilities
|
||||
#
|
||||
CONFIG_FEATURE_SHADOWPASSWDS=y
|
||||
CONFIG_USE_BB_SHADOW=y
|
||||
CONFIG_USE_BB_PWD_GRP=y
|
||||
CONFIG_ADDGROUP=y
|
||||
CONFIG_FEATURE_ADDUSER_TO_GROUP=y
|
||||
CONFIG_DELGROUP=y
|
||||
CONFIG_ADDUSER=y
|
||||
CONFIG_DELUSER=y
|
||||
CONFIG_GETTY=y
|
||||
CONFIG_FEATURE_UTMP=y
|
||||
CONFIG_FEATURE_WTMP=y
|
||||
CONFIG_LOGIN=y
|
||||
CONFIG_LOGIN_SCRIPTS=y
|
||||
CONFIG_FEATURE_SECURETTY=y
|
||||
CONFIG_PASSWD=y
|
||||
CONFIG_FEATURE_PASSWD_WEAK_CHECK=y
|
||||
CONFIG_SU=y
|
||||
CONFIG_FEATURE_SU_SYSLOG=y
|
||||
CONFIG_FEATURE_SU_CHECKS_SHELLS=y
|
||||
CONFIG_SULOGIN=y
|
||||
CONFIG_VLOCK=y
|
||||
|
||||
#
|
||||
# Linux Ext2 FS Progs
|
||||
#
|
||||
CONFIG_CHATTR=y
|
||||
CONFIG_FSCK=y
|
||||
CONFIG_LSATTR=y
|
||||
|
||||
#
|
||||
# Linux Module Utilities
|
||||
#
|
||||
CONFIG_INSMOD=y
|
||||
CONFIG_FEATURE_INSMOD_VERSION_CHECKING=y
|
||||
CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS=y
|
||||
CONFIG_FEATURE_INSMOD_LOADINKMEM=y
|
||||
CONFIG_FEATURE_INSMOD_LOAD_MAP=y
|
||||
CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL=y
|
||||
CONFIG_RMMOD=y
|
||||
CONFIG_LSMOD=y
|
||||
CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT=y
|
||||
CONFIG_MODPROBE=y
|
||||
CONFIG_FEATURE_MODPROBE_MULTIPLE_OPTIONS=y
|
||||
CONFIG_FEATURE_MODPROBE_FANCY_ALIAS=y
|
||||
|
||||
#
|
||||
# Options common to multiple modutils
|
||||
#
|
||||
CONFIG_FEATURE_CHECK_TAINTED_MODULE=y
|
||||
CONFIG_FEATURE_2_4_MODULES=y
|
||||
CONFIG_FEATURE_2_6_MODULES=y
|
||||
# CONFIG_FEATURE_QUERY_MODULE_INTERFACE is not set
|
||||
|
||||
#
|
||||
# Linux System Utilities
|
||||
#
|
||||
CONFIG_DMESG=y
|
||||
CONFIG_FEATURE_DMESG_PRETTY=y
|
||||
CONFIG_FBSET=y
|
||||
CONFIG_FEATURE_FBSET_FANCY=y
|
||||
CONFIG_FEATURE_FBSET_READMODE=y
|
||||
CONFIG_FDFLUSH=y
|
||||
CONFIG_FDFORMAT=y
|
||||
CONFIG_FDISK=y
|
||||
CONFIG_FDISK_SUPPORT_LARGE_DISKS=y
|
||||
CONFIG_FEATURE_FDISK_WRITABLE=y
|
||||
CONFIG_FEATURE_AIX_LABEL=y
|
||||
CONFIG_FEATURE_SGI_LABEL=y
|
||||
CONFIG_FEATURE_SUN_LABEL=y
|
||||
CONFIG_FEATURE_OSF_LABEL=y
|
||||
CONFIG_FEATURE_FDISK_ADVANCED=y
|
||||
CONFIG_FREERAMDISK=y
|
||||
CONFIG_FSCK_MINIX=y
|
||||
CONFIG_MKFS_MINIX=y
|
||||
|
||||
#
|
||||
# Minix filesystem support
|
||||
#
|
||||
CONFIG_FEATURE_MINIX2=y
|
||||
CONFIG_GETOPT=y
|
||||
CONFIG_HEXDUMP=y
|
||||
CONFIG_HWCLOCK=y
|
||||
CONFIG_FEATURE_HWCLOCK_LONG_OPTIONS=y
|
||||
CONFIG_FEATURE_HWCLOCK_ADJTIME_FHS=y
|
||||
CONFIG_IPCRM=y
|
||||
CONFIG_IPCS=y
|
||||
CONFIG_LOSETUP=y
|
||||
CONFIG_MDEV=y
|
||||
CONFIG_FEATURE_MDEV_CONF=y
|
||||
CONFIG_FEATURE_MDEV_EXEC=y
|
||||
CONFIG_MKSWAP=y
|
||||
CONFIG_FEATURE_MKSWAP_V0=y
|
||||
CONFIG_MORE=y
|
||||
CONFIG_FEATURE_USE_TERMIOS=y
|
||||
CONFIG_MOUNT=y
|
||||
# CONFIG_FEATURE_MOUNT_NFS is not set
|
||||
CONFIG_FEATURE_MOUNT_CIFS=y
|
||||
CONFIG_FEATURE_MOUNT_FLAGS=y
|
||||
CONFIG_FEATURE_MOUNT_FSTAB=y
|
||||
CONFIG_PIVOT_ROOT=y
|
||||
CONFIG_RDATE=y
|
||||
CONFIG_READPROFILE=y
|
||||
CONFIG_SETARCH=y
|
||||
CONFIG_SWAPONOFF=y
|
||||
CONFIG_SWITCH_ROOT=y
|
||||
CONFIG_UMOUNT=y
|
||||
CONFIG_FEATURE_UMOUNT_ALL=y
|
||||
|
||||
#
|
||||
# Common options for mount/umount
|
||||
#
|
||||
CONFIG_FEATURE_MOUNT_LOOP=y
|
||||
# CONFIG_FEATURE_MTAB_SUPPORT is not set
|
||||
|
||||
#
|
||||
# Miscellaneous Utilities
|
||||
#
|
||||
CONFIG_ADJTIMEX=y
|
||||
# CONFIG_BBCONFIG is not set
|
||||
CONFIG_CHRT=y
|
||||
# CONFIG_CROND is not set
|
||||
# CONFIG_DEBUG_CROND_OPTION is not set
|
||||
# CONFIG_FEATURE_CROND_CALL_SENDMAIL is not set
|
||||
# CONFIG_CRONTAB is not set
|
||||
CONFIG_DC=y
|
||||
# CONFIG_DEVFSD is not set
|
||||
# CONFIG_DEVFSD_MODLOAD is not set
|
||||
# CONFIG_DEVFSD_FG_NP is not set
|
||||
# CONFIG_DEVFSD_VERBOSE is not set
|
||||
# CONFIG_FEATURE_DEVFS is not set
|
||||
CONFIG_EJECT=y
|
||||
CONFIG_LAST=y
|
||||
CONFIG_LESS=y
|
||||
CONFIG_FEATURE_LESS_MAXLINES=9999999
|
||||
CONFIG_FEATURE_LESS_BRACKETS=y
|
||||
CONFIG_FEATURE_LESS_FLAGS=y
|
||||
CONFIG_FEATURE_LESS_FLAGCS=y
|
||||
CONFIG_FEATURE_LESS_MARKS=y
|
||||
CONFIG_FEATURE_LESS_REGEXP=y
|
||||
CONFIG_HDPARM=y
|
||||
CONFIG_FEATURE_HDPARM_GET_IDENTITY=y
|
||||
CONFIG_FEATURE_HDPARM_HDIO_SCAN_HWIF=y
|
||||
CONFIG_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF=y
|
||||
CONFIG_FEATURE_HDPARM_HDIO_DRIVE_RESET=y
|
||||
CONFIG_FEATURE_HDPARM_HDIO_TRISTATE_HWIF=y
|
||||
CONFIG_FEATURE_HDPARM_HDIO_GETSET_DMA=y
|
||||
CONFIG_MAKEDEVS=y
|
||||
# CONFIG_FEATURE_MAKEDEVS_LEAF is not set
|
||||
CONFIG_FEATURE_MAKEDEVS_TABLE=y
|
||||
CONFIG_MOUNTPOINT=y
|
||||
CONFIG_MT=y
|
||||
CONFIG_NMETER=y
|
||||
CONFIG_RAIDAUTORUN=y
|
||||
CONFIG_READAHEAD=y
|
||||
CONFIG_RUNLEVEL=y
|
||||
CONFIG_RX=y
|
||||
CONFIG_STRINGS=y
|
||||
CONFIG_SETSID=y
|
||||
# CONFIG_TASKSET is not set
|
||||
# CONFIG_FEATURE_TASKSET_FANCY is not set
|
||||
CONFIG_TIME=y
|
||||
CONFIG_WATCHDOG=y
|
||||
|
||||
#
|
||||
# Networking Utilities
|
||||
#
|
||||
CONFIG_FEATURE_IPV6=y
|
||||
# CONFIG_VERBOSE_RESOLUTION_ERRORS is not set
|
||||
CONFIG_ARP=y
|
||||
CONFIG_ARPING=y
|
||||
CONFIG_DNSD=y
|
||||
CONFIG_ETHER_WAKE=y
|
||||
CONFIG_FAKEIDENTD=y
|
||||
CONFIG_FTPGET=y
|
||||
CONFIG_FTPPUT=y
|
||||
CONFIG_FEATURE_FTPGETPUT_LONG_OPTIONS=y
|
||||
CONFIG_HOSTNAME=y
|
||||
# CONFIG_HTTPD is not set
|
||||
# CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP is not set
|
||||
# CONFIG_FEATURE_HTTPD_SETUID is not set
|
||||
# CONFIG_FEATURE_HTTPD_BASIC_AUTH is not set
|
||||
# CONFIG_FEATURE_HTTPD_AUTH_MD5 is not set
|
||||
# CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES is not set
|
||||
# CONFIG_FEATURE_HTTPD_CGI is not set
|
||||
# CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR is not set
|
||||
# CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV is not set
|
||||
# CONFIG_FEATURE_HTTPD_ENCODE_URL_STR is not set
|
||||
CONFIG_IFCONFIG=y
|
||||
CONFIG_FEATURE_IFCONFIG_STATUS=y
|
||||
CONFIG_FEATURE_IFCONFIG_SLIP=y
|
||||
CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ=y
|
||||
CONFIG_FEATURE_IFCONFIG_HW=y
|
||||
CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS=y
|
||||
# CONFIG_IFUPDOWN is not set
|
||||
# CONFIG_FEATURE_IFUPDOWN_IP is not set
|
||||
# CONFIG_FEATURE_IFUPDOWN_IP_BUILTIN is not set
|
||||
# CONFIG_FEATURE_IFUPDOWN_IFCONFIG_BUILTIN is not set
|
||||
# CONFIG_FEATURE_IFUPDOWN_IPV4 is not set
|
||||
# CONFIG_FEATURE_IFUPDOWN_IPV6 is not set
|
||||
# CONFIG_FEATURE_IFUPDOWN_IPX is not set
|
||||
# CONFIG_FEATURE_IFUPDOWN_MAPPING is not set
|
||||
# CONFIG_INETD is not set
|
||||
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO is not set
|
||||
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD is not set
|
||||
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME is not set
|
||||
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME is not set
|
||||
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN is not set
|
||||
# CONFIG_FEATURE_INETD_RPC is not set
|
||||
CONFIG_IP=y
|
||||
CONFIG_FEATURE_IP_ADDRESS=y
|
||||
CONFIG_FEATURE_IP_LINK=y
|
||||
CONFIG_FEATURE_IP_ROUTE=y
|
||||
CONFIG_FEATURE_IP_TUNNEL=y
|
||||
CONFIG_FEATURE_IP_RULE=y
|
||||
CONFIG_FEATURE_IP_SHORT_FORMS=y
|
||||
CONFIG_IPADDR=y
|
||||
CONFIG_IPLINK=y
|
||||
CONFIG_IPROUTE=y
|
||||
CONFIG_IPTUNNEL=y
|
||||
CONFIG_IPRULE=y
|
||||
CONFIG_IPCALC=y
|
||||
CONFIG_FEATURE_IPCALC_FANCY=y
|
||||
CONFIG_FEATURE_IPCALC_LONG_OPTIONS=y
|
||||
CONFIG_NAMEIF=y
|
||||
CONFIG_NC=y
|
||||
CONFIG_NC_SERVER=y
|
||||
CONFIG_NC_EXTRA=y
|
||||
CONFIG_NETSTAT=y
|
||||
CONFIG_NSLOOKUP=y
|
||||
CONFIG_PING=y
|
||||
CONFIG_PING6=y
|
||||
CONFIG_FEATURE_FANCY_PING=y
|
||||
CONFIG_ROUTE=y
|
||||
CONFIG_TELNET=y
|
||||
CONFIG_FEATURE_TELNET_TTYPE=y
|
||||
CONFIG_FEATURE_TELNET_AUTOLOGIN=y
|
||||
# CONFIG_TELNETD is not set
|
||||
# CONFIG_FEATURE_TELNETD_STANDALONE is not set
|
||||
CONFIG_TFTP=y
|
||||
CONFIG_FEATURE_TFTP_GET=y
|
||||
CONFIG_FEATURE_TFTP_PUT=y
|
||||
CONFIG_FEATURE_TFTP_BLOCKSIZE=y
|
||||
# CONFIG_DEBUG_TFTP is not set
|
||||
CONFIG_TRACEROUTE=y
|
||||
# CONFIG_FEATURE_TRACEROUTE_VERBOSE is not set
|
||||
# CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE is not set
|
||||
# CONFIG_FEATURE_TRACEROUTE_USE_ICMP is not set
|
||||
CONFIG_APP_UDHCPD=y
|
||||
CONFIG_APP_DHCPRELAY=y
|
||||
CONFIG_APP_DUMPLEASES=y
|
||||
# CONFIG_APP_UDHCPC is not set
|
||||
CONFIG_FEATURE_UDHCP_SYSLOG=y
|
||||
# CONFIG_FEATURE_UDHCP_DEBUG is not set
|
||||
CONFIG_FEATURE_RFC3397=y
|
||||
CONFIG_VCONFIG=y
|
||||
CONFIG_WGET=y
|
||||
CONFIG_FEATURE_WGET_STATUSBAR=y
|
||||
CONFIG_FEATURE_WGET_AUTHENTICATION=y
|
||||
CONFIG_FEATURE_WGET_LONG_OPTIONS=y
|
||||
CONFIG_ZCIP=y
|
||||
|
||||
#
|
||||
# Process Utilities
|
||||
#
|
||||
CONFIG_FREE=y
|
||||
CONFIG_FUSER=y
|
||||
CONFIG_KILL=y
|
||||
CONFIG_KILLALL=y
|
||||
CONFIG_KILLALL5=y
|
||||
CONFIG_PIDOF=y
|
||||
CONFIG_FEATURE_PIDOF_SINGLE=y
|
||||
CONFIG_FEATURE_PIDOF_OMIT=y
|
||||
CONFIG_PS=y
|
||||
CONFIG_FEATURE_PS_WIDE=y
|
||||
CONFIG_RENICE=y
|
||||
CONFIG_BB_SYSCTL=y
|
||||
CONFIG_TOP=y
|
||||
CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE=y
|
||||
CONFIG_UPTIME=y
|
||||
|
||||
#
|
||||
# Shells
|
||||
#
|
||||
# CONFIG_FEATURE_SH_IS_ASH is not set
|
||||
# CONFIG_FEATURE_SH_IS_HUSH is not set
|
||||
# CONFIG_FEATURE_SH_IS_LASH is not set
|
||||
# CONFIG_FEATURE_SH_IS_MSH is not set
|
||||
CONFIG_FEATURE_SH_IS_NONE=y
|
||||
# CONFIG_ASH is not set
|
||||
# CONFIG_ASH_JOB_CONTROL is not set
|
||||
# CONFIG_ASH_READ_NCHARS is not set
|
||||
# CONFIG_ASH_READ_TIMEOUT is not set
|
||||
# CONFIG_ASH_ALIAS is not set
|
||||
# CONFIG_ASH_MATH_SUPPORT is not set
|
||||
# CONFIG_ASH_MATH_SUPPORT_64 is not set
|
||||
# CONFIG_ASH_GETOPTS is not set
|
||||
# CONFIG_ASH_BUILTIN_ECHO is not set
|
||||
# CONFIG_ASH_BUILTIN_TEST is not set
|
||||
# CONFIG_ASH_CMDCMD is not set
|
||||
# CONFIG_ASH_MAIL is not set
|
||||
# CONFIG_ASH_OPTIMIZE_FOR_SIZE is not set
|
||||
# CONFIG_ASH_RANDOM_SUPPORT is not set
|
||||
# CONFIG_ASH_EXPAND_PRMT is not set
|
||||
# CONFIG_HUSH is not set
|
||||
# CONFIG_LASH is not set
|
||||
CONFIG_MSH=y
|
||||
|
||||
#
|
||||
# Bourne Shell Options
|
||||
#
|
||||
CONFIG_FEATURE_SH_EXTRA_QUIET=y
|
||||
CONFIG_FEATURE_SH_STANDALONE=y
|
||||
|
||||
#
|
||||
# System Logging Utilities
|
||||
#
|
||||
CONFIG_SYSLOGD=y
|
||||
CONFIG_FEATURE_ROTATE_LOGFILE=y
|
||||
CONFIG_FEATURE_REMOTE_LOG=y
|
||||
CONFIG_FEATURE_IPC_SYSLOG=y
|
||||
CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE=16
|
||||
CONFIG_LOGREAD=y
|
||||
CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING=y
|
||||
CONFIG_KLOGD=y
|
||||
CONFIG_LOGGER=y
|
||||
|
||||
#
|
||||
# Runit Utilities
|
||||
#
|
||||
# CONFIG_RUNSV is not set
|
||||
# CONFIG_RUNSVDIR is not set
|
||||
CONFIG_SV=y
|
||||
# CONFIG_SVLOGD is not set
|
||||
CONFIG_CHPST=y
|
||||
CONFIG_SETUIDGID=y
|
||||
CONFIG_ENVUIDGID=y
|
||||
CONFIG_ENVDIR=y
|
||||
CONFIG_SOFTLIMIT=y
|
||||
# CONFIG_CHCON is not set
|
||||
# CONFIG_FEATURE_CHCON_LONG_OPTIONS is not set
|
||||
# CONFIG_GETENFORCE is not set
|
||||
# CONFIG_GETSEBOOL is not set
|
||||
# CONFIG_LOAD_POLICY is not set
|
||||
# CONFIG_MATCHPATHCON is not set
|
||||
# CONFIG_RUNCON is not set
|
||||
# CONFIG_FEATURE_RUNCON_LONG_OPTIONS is not set
|
||||
# CONFIG_SELINUXENABLED is not set
|
||||
# CONFIG_SETENFORCE is not set
|
||||
|
||||
#
|
||||
# ipsvd utilities
|
||||
#
|
||||
# CONFIG_TCPSVD is not set
|
||||
# CONFIG_UDPSVD is not set
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
obj-y:=
|
||||
obj-y += applets.o
|
||||
obj-y += busybox.o
|
||||
|
||||
# Generated file needs additional love
|
||||
|
||||
|
||||
+365
-181
@@ -15,11 +15,6 @@
|
||||
#include <assert.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#define PROTOTYPES
|
||||
#include "applets.h"
|
||||
#undef PROTOTYPES
|
||||
|
||||
|
||||
/* Apparently uclibc defines __GLIBC__ (compat trick?). Oh well. */
|
||||
#if ENABLE_STATIC && defined(__GLIBC__) && !defined(__UCLIBC__)
|
||||
#warning Static linking against glibc produces buggy executables
|
||||
@@ -28,10 +23,18 @@
|
||||
#warning Note that glibc is unsuitable for static linking anyway.
|
||||
#warning If you still want to do it, remove -Wl,--gc-sections
|
||||
#warning from top-level Makefile and remove this warning.
|
||||
#error Aborting compilation.
|
||||
#endif
|
||||
|
||||
|
||||
/* Declare <applet>_main() */
|
||||
#define PROTOTYPES
|
||||
#include "applets.h"
|
||||
#undef PROTOTYPES
|
||||
|
||||
#if ENABLE_SHOW_USAGE && !ENABLE_FEATURE_COMPRESS_USAGE
|
||||
static const char usage_messages[] =
|
||||
/* Define usage_messages[] */
|
||||
static const char usage_messages[] = ""
|
||||
#define MAKE_USAGE
|
||||
#include "usage.h"
|
||||
#include "applets.h"
|
||||
@@ -39,38 +42,33 @@ static const char usage_messages[] =
|
||||
#undef MAKE_USAGE
|
||||
#else
|
||||
#define usage_messages 0
|
||||
#endif /* ENABLE_SHOW_USAGE */
|
||||
#endif /* SHOW_USAGE */
|
||||
|
||||
#undef APPLET
|
||||
#undef APPLET_NOUSAGE
|
||||
#undef PROTOTYPES
|
||||
/* Define struct bb_applet applets[] */
|
||||
#include "applets.h"
|
||||
/* The -1 arises because of the {0,NULL,0,-1} entry. */
|
||||
const unsigned short NUM_APPLETS = sizeof(applets) / sizeof(applets[0]) - 1;
|
||||
|
||||
static struct BB_applet *applet_using;
|
||||
const struct bb_applet *current_applet;
|
||||
const char *applet_name ATTRIBUTE_EXTERNALLY_VISIBLE;
|
||||
#if !BB_MMU
|
||||
bool re_execed;
|
||||
#endif
|
||||
|
||||
/* The -1 arises because of the {0,NULL,0,-1} entry above. */
|
||||
const unsigned short NUM_APPLETS = (sizeof (applets) / sizeof (struct BB_applet) - 1);
|
||||
USE_FEATURE_SUID(static uid_t ruid;) /* real uid */
|
||||
|
||||
#if ENABLE_FEATURE_SUID_CONFIG
|
||||
|
||||
#ifdef CONFIG_FEATURE_SUID_CONFIG
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#define CONFIG_FILE "/etc/busybox.conf"
|
||||
|
||||
/* applets [] is const, so we have to define this "override" structure */
|
||||
static struct BB_suid_config
|
||||
{
|
||||
struct BB_applet *m_applet;
|
||||
|
||||
/* applets[] is const, so we have to define this "override" structure */
|
||||
static struct BB_suid_config {
|
||||
const struct bb_applet *m_applet;
|
||||
uid_t m_uid;
|
||||
gid_t m_gid;
|
||||
mode_t m_mode;
|
||||
|
||||
struct BB_suid_config *m_next;
|
||||
} *suid_config;
|
||||
|
||||
static int suid_cfg_readable;
|
||||
static bool suid_cfg_readable;
|
||||
|
||||
/* check if u is member of group g */
|
||||
static int ingroup(uid_t u, gid_t g)
|
||||
@@ -103,53 +101,55 @@ static char *get_trimmed_slice(char *s, char *e)
|
||||
break;
|
||||
}
|
||||
}
|
||||
e[1] = 0;
|
||||
e[1] = '\0';
|
||||
|
||||
/* Next, advance past all leading space and return a ptr to the
|
||||
* first non-space char; possibly the terminating nul. */
|
||||
return skip_whitespace(s);
|
||||
}
|
||||
|
||||
|
||||
#define parse_error(x) do { errmsg = x; goto pe_label; } while(0)
|
||||
|
||||
/* Don't depend on the tools to combine strings. */
|
||||
static const char config_file[] = CONFIG_FILE;
|
||||
|
||||
/* There are 4 chars + 1 nul for each of user/group/other. */
|
||||
static const char mode_chars[] = "Ssx-\0Ssx-\0Ttx-";
|
||||
static const char config_file[] = "/etc/busybox.conf";
|
||||
|
||||
/* We don't supply a value for the nul, so an index adjustment is
|
||||
* necessary below. Also, we use unsigned short here to save some
|
||||
* space even though these are really mode_t values. */
|
||||
static const unsigned short mode_mask[] = {
|
||||
/* SST sst xxx --- */
|
||||
/* SST sst xxx --- */
|
||||
S_ISUID, S_ISUID|S_IXUSR, S_IXUSR, 0, /* user */
|
||||
S_ISGID, S_ISGID|S_IXGRP, S_IXGRP, 0, /* group */
|
||||
0, S_IXOTH, S_IXOTH, 0 /* other */
|
||||
};
|
||||
|
||||
#define parse_error(x) do { errmsg = x; goto pe_label; } while (0)
|
||||
|
||||
static void parse_config_file(void)
|
||||
{
|
||||
struct BB_suid_config *sct_head;
|
||||
struct BB_suid_config *sct;
|
||||
struct BB_applet *applet;
|
||||
const struct bb_applet *applet;
|
||||
FILE *f;
|
||||
const char *errmsg;
|
||||
char *s;
|
||||
char *e;
|
||||
int i, lc, section;
|
||||
int i;
|
||||
unsigned lc;
|
||||
smallint section;
|
||||
char buffer[256];
|
||||
struct stat st;
|
||||
|
||||
assert(!suid_config); /* Should be set to NULL by bss init. */
|
||||
assert(!suid_config); /* Should be set to NULL by bss init. */
|
||||
|
||||
if ((stat(config_file, &st) != 0) /* No config file? */
|
||||
|| !S_ISREG(st.st_mode) /* Not a regular file? */
|
||||
|| (st.st_uid != 0) /* Not owned by root? */
|
||||
|| (st.st_mode & (S_IWGRP | S_IWOTH)) /* Writable by non-root? */
|
||||
|| !(f = fopen(config_file, "r")) /* Cannot open? */
|
||||
) {
|
||||
ruid = getuid();
|
||||
if (ruid == 0) /* run by root - don't need to even read config file */
|
||||
return;
|
||||
|
||||
if ((stat(config_file, &st) != 0) /* No config file? */
|
||||
|| !S_ISREG(st.st_mode) /* Not a regular file? */
|
||||
|| (st.st_uid != 0) /* Not owned by root? */
|
||||
|| (st.st_mode & (S_IWGRP | S_IWOTH)) /* Writable by non-root? */
|
||||
|| !(f = fopen(config_file, "r")) /* Cannot open? */
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ static void parse_config_file(void)
|
||||
sct_head = NULL;
|
||||
section = lc = 0;
|
||||
|
||||
do {
|
||||
while (1) {
|
||||
s = buffer;
|
||||
|
||||
if (!fgets(s, sizeof(buffer), f)) { /* Are we done? */
|
||||
@@ -185,7 +185,8 @@ static void parse_config_file(void)
|
||||
|
||||
/* Trim leading and trailing whitespace, ignoring comments, and
|
||||
* check if the resulting string is empty. */
|
||||
if (!*(s = get_trimmed_slice(s, strchrnul(s, '#')))) {
|
||||
s = get_trimmed_slice(s, strchrnul(s, '#'));
|
||||
if (!*s) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -195,10 +196,11 @@ static void parse_config_file(void)
|
||||
/* Unlike the old code, we ignore leading and trailing
|
||||
* whitespace for the section name. We also require that
|
||||
* there are no stray characters after the closing bracket. */
|
||||
if (!(e = strchr(s, ']')) /* Missing right bracket? */
|
||||
|| e[1] /* Trailing characters? */
|
||||
|| !*(s = get_trimmed_slice(s+1, e)) /* Missing name? */
|
||||
) {
|
||||
e = strchr(s, ']');
|
||||
if (!e /* Missing right bracket? */
|
||||
|| e[1] /* Trailing characters? */
|
||||
|| !*(s = get_trimmed_slice(s+1, e)) /* Missing name? */
|
||||
) {
|
||||
parse_error("section header");
|
||||
}
|
||||
/* Right now we only have one section so just check it.
|
||||
@@ -224,7 +226,8 @@ static void parse_config_file(void)
|
||||
* where both key and value could contain inner whitespace. */
|
||||
|
||||
/* First get the key (an applet name in our case). */
|
||||
if (!!(e = strchr(s, '='))) {
|
||||
e = strchr(s, '=');
|
||||
if (e) {
|
||||
s = get_trimmed_slice(s, e);
|
||||
}
|
||||
if (!e || !*s) { /* Missing '=' or empty key. */
|
||||
@@ -233,9 +236,10 @@ static void parse_config_file(void)
|
||||
|
||||
/* Ok, we have an applet name. Process the rhs if this
|
||||
* applet is currently built in and ignore it otherwise.
|
||||
* Note: This can hide config file bugs which only pop
|
||||
* Note: this can hide config file bugs which only pop
|
||||
* up when the busybox configuration is changed. */
|
||||
if ((applet = find_applet_by_name(s))) {
|
||||
applet = find_applet_by_name(s);
|
||||
if (applet) {
|
||||
/* Note: We currently don't check for duplicates!
|
||||
* The last config line for each applet will be the
|
||||
* one used since we insert at the head of the list.
|
||||
@@ -250,9 +254,13 @@ static void parse_config_file(void)
|
||||
|
||||
e = skip_whitespace(e+1);
|
||||
|
||||
for (i=0 ; i < 3 ; i++) {
|
||||
for (i = 0; i < 3; i++) {
|
||||
/* There are 4 chars + 1 nul for each of user/group/other. */
|
||||
static const char mode_chars[] = "Ssx-\0" "Ssx-\0" "Ttx-";
|
||||
|
||||
const char *q;
|
||||
if (!*(q = strchrnul(mode_chars + 5*i, *e++))) {
|
||||
q = strchrnul(mode_chars + 5*i, *e++);
|
||||
if (!*q) {
|
||||
parse_error("mode");
|
||||
}
|
||||
/* Adjust by -i to account for nul. */
|
||||
@@ -263,35 +271,32 @@ static void parse_config_file(void)
|
||||
|
||||
s = skip_whitespace(e);
|
||||
|
||||
/* Note: We require whitespace between the mode and the
|
||||
/* Note: we require whitespace between the mode and the
|
||||
* user/group info. */
|
||||
if ((s == e) || !(e = strchr(s, '.'))) {
|
||||
parse_error("<uid>.<gid>");
|
||||
}
|
||||
*e++ = 0;
|
||||
*e++ = '\0';
|
||||
|
||||
/* We can't use get_ug_id here since it would exit()
|
||||
* if a uid or gid was not found. Oh well... */
|
||||
{
|
||||
char *e2;
|
||||
|
||||
sct->m_uid = strtoul(s, &e2, 10);
|
||||
if (*e2 || (s == e2)) {
|
||||
struct passwd *pwd = getpwnam(s);
|
||||
if (!pwd) {
|
||||
parse_error("user");
|
||||
}
|
||||
sct->m_uid = pwd->pw_uid;
|
||||
sct->m_uid = bb_strtoul(s, NULL, 10);
|
||||
if (errno) {
|
||||
struct passwd *pwd = getpwnam(s);
|
||||
if (!pwd) {
|
||||
parse_error("user");
|
||||
}
|
||||
sct->m_uid = pwd->pw_uid;
|
||||
}
|
||||
|
||||
sct->m_gid = strtoul(e, &e2, 10);
|
||||
if (*e2 || (e == e2)) {
|
||||
struct group *grp;
|
||||
if (!(grp = getgrnam(e))) {
|
||||
parse_error("group");
|
||||
}
|
||||
sct->m_gid = grp->gr_gid;
|
||||
sct->m_gid = bb_strtoul(e, NULL, 10);
|
||||
if (errno) {
|
||||
struct group *grp;
|
||||
grp = getgrnam(e);
|
||||
if (!grp) {
|
||||
parse_error("group");
|
||||
}
|
||||
sct->m_gid = grp->gr_gid;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
@@ -308,7 +313,7 @@ static void parse_config_file(void)
|
||||
parse_error("keyword outside section");
|
||||
}
|
||||
|
||||
} while (1);
|
||||
} /* while (1) */
|
||||
|
||||
pe_label:
|
||||
fprintf(stderr, "Parse error in %s, line %d: %s\n",
|
||||
@@ -322,174 +327,353 @@ static void parse_config_file(void)
|
||||
sct_head = sct;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
#define parse_config_file() ((void)0)
|
||||
#endif /* CONFIG_FEATURE_SUID_CONFIG */
|
||||
|
||||
#ifdef CONFIG_FEATURE_SUID
|
||||
static void check_suid(struct BB_applet *applet)
|
||||
static inline void parse_config_file(void)
|
||||
{
|
||||
uid_t ruid = getuid(); /* real [ug]id */
|
||||
uid_t rgid = getgid();
|
||||
USE_FEATURE_SUID(ruid = getuid();)
|
||||
}
|
||||
#endif /* FEATURE_SUID_CONFIG */
|
||||
|
||||
#ifdef CONFIG_FEATURE_SUID_CONFIG
|
||||
|
||||
#if ENABLE_FEATURE_SUID
|
||||
static void check_suid(const struct bb_applet *applet)
|
||||
{
|
||||
gid_t rgid; /* real gid */
|
||||
|
||||
if (ruid == 0) /* set by parse_config_file() */
|
||||
return; /* run by root - no need to check more */
|
||||
rgid = getgid();
|
||||
|
||||
#if ENABLE_FEATURE_SUID_CONFIG
|
||||
if (suid_cfg_readable) {
|
||||
uid_t uid;
|
||||
struct BB_suid_config *sct;
|
||||
mode_t m;
|
||||
|
||||
for (sct = suid_config; sct; sct = sct->m_next) {
|
||||
if (sct->m_applet == applet)
|
||||
break;
|
||||
}
|
||||
if (sct) {
|
||||
mode_t m = sct->m_mode;
|
||||
|
||||
if (sct->m_uid == ruid)
|
||||
/* same uid */
|
||||
m >>= 6;
|
||||
else if ((sct->m_gid == rgid) || ingroup(ruid, sct->m_gid))
|
||||
/* same group / in group */
|
||||
m >>= 3;
|
||||
|
||||
if (!(m & S_IXOTH)) /* is x bit not set ? */
|
||||
bb_error_msg_and_die("you have no permission to run this applet!");
|
||||
|
||||
if (sct->m_gid != 0) {
|
||||
/* _both_ have to be set for sgid */
|
||||
if ((sct->m_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) {
|
||||
xsetgid(sct->m_gid);
|
||||
} else xsetgid(rgid); /* no sgid -> drop */
|
||||
}
|
||||
if (sct->m_uid != 0) {
|
||||
if (sct->m_mode & S_ISUID) xsetuid(sct->m_uid);
|
||||
else xsetuid(ruid); /* no suid -> drop */
|
||||
}
|
||||
} else {
|
||||
/* default: drop all privileges */
|
||||
xsetgid(rgid);
|
||||
xsetuid(ruid);
|
||||
goto found;
|
||||
}
|
||||
/* default: drop all privileges */
|
||||
xsetgid(rgid);
|
||||
xsetuid(ruid);
|
||||
return;
|
||||
} else {
|
||||
#ifndef CONFIG_FEATURE_SUID_CONFIG_QUIET
|
||||
static int onetime = 0;
|
||||
found:
|
||||
m = sct->m_mode;
|
||||
if (sct->m_uid == ruid)
|
||||
/* same uid */
|
||||
m >>= 6;
|
||||
else if ((sct->m_gid == rgid) || ingroup(ruid, sct->m_gid))
|
||||
/* same group / in group */
|
||||
m >>= 3;
|
||||
|
||||
if (!(m & S_IXOTH)) /* is x bit not set ? */
|
||||
bb_error_msg_and_die("you have no permission to run this applet!");
|
||||
|
||||
/* _both_ sgid and group_exec have to be set for setegid */
|
||||
if ((sct->m_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
|
||||
rgid = sct->m_gid;
|
||||
/* else (no setegid) we will set egid = rgid */
|
||||
|
||||
/* We set effective AND saved ids. If saved-id is not set
|
||||
* like we do below, seteiud(0) can still later succeed! */
|
||||
if (setresgid(-1, rgid, rgid))
|
||||
bb_perror_msg_and_die("setresgid");
|
||||
|
||||
/* do we have to set effective uid? */
|
||||
uid = ruid;
|
||||
if (sct->m_mode & S_ISUID)
|
||||
uid = sct->m_uid;
|
||||
/* else (no seteuid) we will set euid = ruid */
|
||||
|
||||
if (setresuid(-1, uid, uid))
|
||||
bb_perror_msg_and_die("setresuid");
|
||||
return;
|
||||
}
|
||||
#if !ENABLE_FEATURE_SUID_CONFIG_QUIET
|
||||
{
|
||||
static bool onetime = 0;
|
||||
|
||||
if (!onetime) {
|
||||
onetime = 1;
|
||||
fprintf(stderr, "Using fallback suid method\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (applet->need_suid == _BB_SUID_ALWAYS) {
|
||||
if (geteuid()) bb_error_msg_and_die("applet requires root privileges!");
|
||||
/* Real uid is not 0. If euid isn't 0 too, suid bit
|
||||
* is most probably not set on our executable */
|
||||
if (geteuid())
|
||||
bb_error_msg_and_die("applet requires root privileges!");
|
||||
} else if (applet->need_suid == _BB_SUID_NEVER) {
|
||||
xsetgid(rgid); /* drop all privileges */
|
||||
xsetgid(rgid); /* drop all privileges */
|
||||
xsetuid(ruid);
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define check_suid(x)
|
||||
#endif /* CONFIG_FEATURE_SUID */
|
||||
#define check_suid(x) ((void)0)
|
||||
#endif /* FEATURE_SUID */
|
||||
|
||||
|
||||
|
||||
#ifdef CONFIG_FEATURE_COMPRESS_USAGE
|
||||
#if ENABLE_FEATURE_COMPRESS_USAGE
|
||||
|
||||
#include "usage_compressed.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
static const char *unpack_usage_messages(void)
|
||||
{
|
||||
int input[2], output[2], pid;
|
||||
char *buf;
|
||||
char *outbuf = NULL;
|
||||
bunzip_data *bd;
|
||||
int i;
|
||||
|
||||
if(pipe(input) < 0 || pipe(output) < 0)
|
||||
exit(1);
|
||||
|
||||
pid = fork();
|
||||
switch (pid) {
|
||||
case -1: /* error */
|
||||
exit(1);
|
||||
case 0: /* child */
|
||||
close(input[1]);
|
||||
close(output[0]);
|
||||
uncompressStream(input[0], output[1]);
|
||||
exit(0);
|
||||
i = start_bunzip(&bd,
|
||||
/* src_fd: */ -1,
|
||||
/* inbuf: */ packed_usage,
|
||||
/* len: */ sizeof(packed_usage));
|
||||
/* read_bunzip can longjmp to start_bunzip, and ultimately
|
||||
* end up here with i != 0 on read data errors! Not trivial */
|
||||
if (!i) {
|
||||
/* Cannot use xmalloc: will leak bd in NOFORK case! */
|
||||
outbuf = malloc_or_warn(SIZEOF_usage_messages);
|
||||
if (outbuf)
|
||||
read_bunzip(bd, outbuf, SIZEOF_usage_messages);
|
||||
}
|
||||
/* parent */
|
||||
|
||||
close(input[0]);
|
||||
close(output[1]);
|
||||
pid = fork();
|
||||
switch (pid) {
|
||||
case -1: /* error */
|
||||
exit(1);
|
||||
case 0: /* child */
|
||||
full_write(input[1], packed_usage, sizeof(packed_usage));
|
||||
exit(0);
|
||||
}
|
||||
/* parent */
|
||||
close(input[1]);
|
||||
|
||||
buf = xmalloc(SIZEOF_usage_messages);
|
||||
full_read(output[0], buf, SIZEOF_usage_messages);
|
||||
return buf;
|
||||
dealloc_bunzip(bd);
|
||||
return outbuf;
|
||||
}
|
||||
#define dealloc_usage_messages(s) free(s)
|
||||
|
||||
#else
|
||||
|
||||
#define unpack_usage_messages() usage_messages
|
||||
#endif /* ENABLE_FEATURE_COMPRESS_USAGE */
|
||||
#define dealloc_usage_messages(s) ((void)(s))
|
||||
|
||||
#endif /* FEATURE_COMPRESS_USAGE */
|
||||
|
||||
|
||||
void bb_show_usage(void)
|
||||
{
|
||||
if (ENABLE_SHOW_USAGE) {
|
||||
const char *format_string;
|
||||
const char *usage_string = unpack_usage_messages();
|
||||
const char *p;
|
||||
const char *usage_string = p = unpack_usage_messages();
|
||||
int i;
|
||||
|
||||
for (i = applet_using - applets; i > 0;)
|
||||
if (!*usage_string++) --i;
|
||||
i = current_applet - applets;
|
||||
while (i) {
|
||||
while (*p++) continue;
|
||||
i--;
|
||||
}
|
||||
|
||||
format_string = "%s\n\nUsage: %s %s\n\n";
|
||||
if (*usage_string == '\b')
|
||||
if (*p == '\b')
|
||||
format_string = "%s\n\nNo help available.\n\n";
|
||||
fprintf(stderr, format_string, bb_msg_full_version,
|
||||
applet_using->name, usage_string);
|
||||
applet_name, p);
|
||||
dealloc_usage_messages((char*)usage_string);
|
||||
}
|
||||
|
||||
exit(xfunc_error_retval);
|
||||
xfunc_die();
|
||||
}
|
||||
|
||||
|
||||
static int applet_name_compare(const void *name, const void *vapplet)
|
||||
{
|
||||
const struct BB_applet *applet = vapplet;
|
||||
const struct bb_applet *applet = vapplet;
|
||||
|
||||
return strcmp(name, applet->name);
|
||||
}
|
||||
|
||||
struct BB_applet *find_applet_by_name(const char *name)
|
||||
const struct bb_applet *find_applet_by_name(const char *name)
|
||||
{
|
||||
return bsearch(name, applets, NUM_APPLETS, sizeof(struct BB_applet),
|
||||
/* Do a binary search to find the applet entry given the name. */
|
||||
return bsearch(name, applets, NUM_APPLETS, sizeof(applets[0]),
|
||||
applet_name_compare);
|
||||
}
|
||||
|
||||
void run_applet_by_name(const char *name, int argc, char **argv)
|
||||
{
|
||||
if (ENABLE_FEATURE_SUID_CONFIG)
|
||||
parse_config_file();
|
||||
|
||||
if (!strncmp(name, "busybox", 7))
|
||||
exit(busybox_main(argc, argv));
|
||||
/* Do a binary search to find the applet entry given the name. */
|
||||
applet_using = find_applet_by_name(name);
|
||||
if (applet_using) {
|
||||
applet_name = applet_using->name;
|
||||
if (argc == 2 && !strcmp(argv[1], "--help"))
|
||||
bb_show_usage();
|
||||
if (ENABLE_FEATURE_SUID)
|
||||
check_suid(applet_using);
|
||||
exit(applet_using->main(argc, argv));
|
||||
#if ENABLE_FEATURE_INSTALLER
|
||||
/* create (sym)links for each applet */
|
||||
static void install_links(const char *busybox, int use_symbolic_links)
|
||||
{
|
||||
/* directory table
|
||||
* this should be consistent w/ the enum,
|
||||
* busybox.h::bb_install_loc_t, or else... */
|
||||
static const char usr_bin [] = "/usr/bin";
|
||||
static const char usr_sbin[] = "/usr/sbin";
|
||||
static const char *const install_dir[] = {
|
||||
&usr_bin [8], /* "", equivalent to "/" for concat_path_file() */
|
||||
&usr_bin [4], /* "/bin" */
|
||||
&usr_sbin[4], /* "/sbin" */
|
||||
usr_bin,
|
||||
usr_sbin
|
||||
};
|
||||
|
||||
int (*lf)(const char *, const char *) = link;
|
||||
char *fpc;
|
||||
int i;
|
||||
int rc;
|
||||
|
||||
if (use_symbolic_links)
|
||||
lf = symlink;
|
||||
|
||||
for (i = 0; applets[i].name != NULL; i++) {
|
||||
fpc = concat_path_file(
|
||||
install_dir[applets[i].install_loc],
|
||||
applets[i].name);
|
||||
rc = lf(busybox, fpc);
|
||||
if (rc != 0 && errno != EEXIST) {
|
||||
bb_perror_msg("%s", fpc);
|
||||
}
|
||||
free(fpc);
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define install_links(x,y) ((void)0)
|
||||
#endif /* FEATURE_INSTALLER */
|
||||
|
||||
|
||||
/* If we were called as "busybox..." */
|
||||
static int busybox_main(char **argv)
|
||||
{
|
||||
if (!argv[1]) {
|
||||
/* Called without arguments */
|
||||
const struct bb_applet *a;
|
||||
int col, output_width;
|
||||
help:
|
||||
output_width = 80;
|
||||
if (ENABLE_FEATURE_AUTOWIDTH) {
|
||||
/* Obtain the terminal width. */
|
||||
get_terminal_width_height(0, &output_width, NULL);
|
||||
}
|
||||
/* leading tab and room to wrap */
|
||||
output_width -= sizeof("start-stop-daemon, ") + 8;
|
||||
|
||||
printf("%s\n"
|
||||
"Copyright (C) 1998-2006 Erik Andersen, Rob Landley, and others.\n"
|
||||
"Licensed under GPLv2. See source distribution for full notice.\n"
|
||||
"\n"
|
||||
"Usage: busybox [function] [arguments]...\n"
|
||||
" or: [function] [arguments]...\n"
|
||||
"\n"
|
||||
"\tBusyBox is a multi-call binary that combines many common Unix\n"
|
||||
"\tutilities into a single executable. Most people will create a\n"
|
||||
"\tlink to busybox for each function they wish to use and BusyBox\n"
|
||||
"\twill act like whatever it was invoked as!\n"
|
||||
"\nCurrently defined functions:\n", bb_msg_full_version);
|
||||
col = 0;
|
||||
a = applets;
|
||||
while (a->name) {
|
||||
if (col > output_width) {
|
||||
puts(",");
|
||||
col = 0;
|
||||
}
|
||||
col += printf("%s%s", (col ? ", " : "\t"), a->name);
|
||||
a++;
|
||||
}
|
||||
puts("\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ENABLE_FEATURE_INSTALLER && strcmp(argv[1], "--install") == 0) {
|
||||
int use_symbolic_links = 0;
|
||||
char *busybox;
|
||||
|
||||
/* to use symlinks, or not to use symlinks... */
|
||||
if (argv[2])
|
||||
if (strcmp(argv[2], "-s") == 0)
|
||||
use_symbolic_links = 1;
|
||||
|
||||
/* link */
|
||||
busybox = xmalloc_readlink_or_warn("/proc/self/exe");
|
||||
if (!busybox)
|
||||
return 1;
|
||||
install_links(busybox, use_symbolic_links);
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
free(busybox);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strcmp(argv[1], "--help") == 0) {
|
||||
/* "busybox --help [<applet>]" */
|
||||
if (!argv[2])
|
||||
goto help;
|
||||
/* convert to "<applet> --help" */
|
||||
argv[0] = argv[2];
|
||||
argv[2] = NULL;
|
||||
} else {
|
||||
/* "busybox <applet> arg1 arg2 ..." */
|
||||
argv++;
|
||||
}
|
||||
/* we want "<argv[0]>: applet not found", not "busybox: ..." */
|
||||
applet_name = argv[0];
|
||||
run_applet_and_exit(argv[0], argv);
|
||||
bb_error_msg_and_die("applet not found");
|
||||
}
|
||||
|
||||
void run_current_applet_and_exit(char **argv)
|
||||
{
|
||||
int argc = 1;
|
||||
|
||||
while (argv[argc])
|
||||
argc++;
|
||||
|
||||
/* Reinit some shared global data */
|
||||
optind = 1;
|
||||
xfunc_error_retval = EXIT_FAILURE;
|
||||
|
||||
applet_name = current_applet->name;
|
||||
if (argc == 2 && !strcmp(argv[1], "--help"))
|
||||
bb_show_usage();
|
||||
if (ENABLE_FEATURE_SUID)
|
||||
check_suid(current_applet);
|
||||
exit(current_applet->main(argc, argv));
|
||||
}
|
||||
|
||||
void run_applet_and_exit(const char *name, char **argv)
|
||||
{
|
||||
current_applet = find_applet_by_name(name);
|
||||
if (current_applet)
|
||||
run_current_applet_and_exit(argv);
|
||||
if (!strncmp(name, "busybox", 7))
|
||||
exit(busybox_main(argv));
|
||||
}
|
||||
|
||||
|
||||
#ifdef __GLIBC__
|
||||
/* Make it reside in R/W memory: */
|
||||
int *const bb_errno __attribute__ ((section (".data")));
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *s;
|
||||
|
||||
#ifdef __GLIBC__
|
||||
(*(int **)&bb_errno) = __errno_location();
|
||||
#endif
|
||||
|
||||
#if !BB_MMU
|
||||
/* NOMMU re-exec trick sets high-order bit in first byte of name */
|
||||
if (argv[0][0] & 0x80) {
|
||||
re_execed = 1;
|
||||
argv[0][0] &= 0x7f;
|
||||
}
|
||||
#endif
|
||||
applet_name = argv[0];
|
||||
if (applet_name[0] == '-')
|
||||
applet_name++;
|
||||
s = strrchr(applet_name, '/');
|
||||
if (s)
|
||||
applet_name = s + 1;
|
||||
|
||||
parse_config_file(); /* ...maybe, if FEATURE_SUID_CONFIG */
|
||||
|
||||
/* Set locale for everybody except 'init' */
|
||||
if (ENABLE_LOCALE_SUPPORT && getpid() != 1)
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
run_applet_and_exit(applet_name, argv);
|
||||
bb_error_msg_and_die("applet not found");
|
||||
}
|
||||
@@ -1,147 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* BusyBox' main applet dispatcher.
|
||||
*
|
||||
* Licensed under GPLv2, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
#include "busybox.h"
|
||||
|
||||
const char *applet_name ATTRIBUTE_EXTERNALLY_VISIBLE;
|
||||
|
||||
#ifdef CONFIG_FEATURE_INSTALLER
|
||||
/*
|
||||
* directory table
|
||||
* this should be consistent w/ the enum, busybox.h::Location,
|
||||
* or else...
|
||||
*/
|
||||
static const char usr_bin [] = "/usr/bin";
|
||||
static const char usr_sbin[] = "/usr/sbin";
|
||||
|
||||
static const char* const install_dir[] = {
|
||||
&usr_bin [8], /* "", equivalent to "/" for concat_path_file() */
|
||||
&usr_bin [4], /* "/bin" */
|
||||
&usr_sbin[4], /* "/sbin" */
|
||||
usr_bin,
|
||||
usr_sbin
|
||||
};
|
||||
|
||||
/* abstract link() */
|
||||
typedef int (*link_func)(const char *, const char *);
|
||||
|
||||
/* create (sym)links for each applet */
|
||||
static void install_links(const char *busybox, int use_symbolic_links)
|
||||
{
|
||||
link_func lf = link;
|
||||
char *fpc;
|
||||
int i;
|
||||
int rc;
|
||||
|
||||
if (use_symbolic_links)
|
||||
lf = symlink;
|
||||
|
||||
for (i = 0; applets[i].name != NULL; i++) {
|
||||
fpc = concat_path_file(
|
||||
install_dir[applets[i].location],
|
||||
applets[i].name);
|
||||
rc = lf(busybox, fpc);
|
||||
if (rc != 0 && errno != EEXIST) {
|
||||
bb_perror_msg("%s", fpc);
|
||||
}
|
||||
free(fpc);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
#define install_links(x,y)
|
||||
#endif /* CONFIG_FEATURE_INSTALLER */
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *s;
|
||||
|
||||
applet_name = argv[0];
|
||||
if (*applet_name == '-')
|
||||
applet_name++;
|
||||
while ((s = strchr(applet_name, '/')))
|
||||
applet_name = s + 1;
|
||||
|
||||
/* Set locale for everybody except 'init' */
|
||||
if (ENABLE_LOCALE_SUPPORT && getpid() != 1)
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
run_applet_by_name(applet_name, argc, argv);
|
||||
bb_error_msg_and_die("applet not found");
|
||||
}
|
||||
|
||||
int busybox_main(int argc, char **argv);
|
||||
int busybox_main(int argc, char **argv)
|
||||
{
|
||||
/*
|
||||
* This style of argument parsing doesn't scale well
|
||||
* in the event that busybox starts wanting more --options.
|
||||
* If someone has a cleaner approach, by all means implement it.
|
||||
*/
|
||||
if (ENABLE_FEATURE_INSTALLER && argc > 1 && !strcmp(argv[1], "--install")) {
|
||||
int use_symbolic_links = 0;
|
||||
char *busybox;
|
||||
|
||||
/* to use symlinks, or not to use symlinks... */
|
||||
if (argc > 2)
|
||||
if (strcmp(argv[2], "-s") == 0)
|
||||
use_symbolic_links = 1;
|
||||
|
||||
/* link */
|
||||
// XXX: FIXME: this is broken. Why not just use argv[0] ?
|
||||
busybox = xmalloc_readlink_or_warn("/proc/self/exe");
|
||||
if (!busybox)
|
||||
return 1;
|
||||
install_links(busybox, use_symbolic_links);
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
free(busybox);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Deal with --help. (Also print help when called with no arguments) */
|
||||
|
||||
if (argc == 1 || !strcmp(argv[1], "--help") ) {
|
||||
if (argc > 2) {
|
||||
applet_name = argv[2];
|
||||
run_applet_by_name(applet_name, 2, argv);
|
||||
} else {
|
||||
const struct BB_applet *a;
|
||||
int col, output_width;
|
||||
|
||||
output_width = 80 - sizeof("start-stop-daemon, ") - 8;
|
||||
if (ENABLE_FEATURE_AUTOWIDTH) {
|
||||
/* Obtain the terminal width. */
|
||||
get_terminal_width_height(0, &output_width, NULL);
|
||||
/* leading tab and room to wrap */
|
||||
output_width -= sizeof("start-stop-daemon, ") + 8;
|
||||
}
|
||||
|
||||
printf("%s\n"
|
||||
"Copyright (C) 1998-2006 Erik Andersen, Rob Landley, and others.\n"
|
||||
"Licensed under GPLv2. See source distribution for full notice.\n\n"
|
||||
"Usage: busybox [function] [arguments]...\n"
|
||||
" or: [function] [arguments]...\n\n"
|
||||
"\tBusyBox is a multi-call binary that combines many common Unix\n"
|
||||
"\tutilities into a single executable. Most people will create a\n"
|
||||
"\tlink to busybox for each function they wish to use and BusyBox\n"
|
||||
"\twill act like whatever it was invoked as!\n"
|
||||
"\nCurrently defined functions:\n", bb_msg_full_version);
|
||||
col = 0;
|
||||
for (a = applets; a->name;) {
|
||||
col += printf("%s%s", (col ? ", " : "\t"), a->name);
|
||||
a++;
|
||||
if (col > output_width && a->name) {
|
||||
puts(",");
|
||||
col = 0;
|
||||
}
|
||||
}
|
||||
puts("\n");
|
||||
return 0;
|
||||
}
|
||||
} else run_applet_by_name(argv[1], argc - 1, argv + 1);
|
||||
|
||||
bb_error_msg_and_die("applet not found");
|
||||
}
|
||||
@@ -9,12 +9,11 @@ const char *applet_name;
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
//Ok to remove? #include "bb_config.h"
|
||||
#include "usage.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
applet_name=argv[0];
|
||||
applet_name = argv[0];
|
||||
|
||||
return APPLET_main(argc,argv);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../include/autoconf.h"
|
||||
#include "../include/busybox.h"
|
||||
|
||||
static const char usage_messages[] = ""
|
||||
#define MAKE_USAGE
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
* http://www.unix-systems.org/single_unix_specification_v2/xcu/ar.html
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
static void header_verbose_list_ar(const file_header_t *file_header)
|
||||
|
||||
+5
-11
@@ -5,7 +5,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
enum {
|
||||
@@ -20,16 +20,11 @@ enum {
|
||||
static
|
||||
int open_to_or_warn(int to_fd, const char *filename, int flags, int mode)
|
||||
{
|
||||
int fd = open(filename, flags, mode);
|
||||
int fd = open3_or_warn(filename, flags, mode);
|
||||
if (fd < 0) {
|
||||
bb_perror_msg("%s", filename);
|
||||
return 1;
|
||||
}
|
||||
if (fd != to_fd) {
|
||||
if (dup2(fd, to_fd) < 0)
|
||||
bb_perror_msg_and_die("cannot dup");
|
||||
close(fd);
|
||||
}
|
||||
xmove_fd(fd, to_fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -105,8 +100,7 @@ int bbunpack(char **argv,
|
||||
if (new_name == filename)
|
||||
filename[strlen(filename)] = '.';
|
||||
}
|
||||
if (unlink(del) < 0)
|
||||
bb_perror_msg_and_die("cannot remove %s", del);
|
||||
xunlink(del);
|
||||
|
||||
#if 0 /* Currently buggy - wrong name: "a.gz: 261% - replaced with a.gz" */
|
||||
/* Extreme bloat for gunzip compat */
|
||||
@@ -223,7 +217,7 @@ char* make_new_name_gunzip(char *filename)
|
||||
#endif
|
||||
) {
|
||||
extension[-1] = '\0';
|
||||
} else if(strcmp(extension, "tgz") == 0) {
|
||||
} else if (strcmp(extension, "tgz") == 0) {
|
||||
filename = xstrdup(filename);
|
||||
extension = strrchr(filename, '.');
|
||||
extension[2] = 'a';
|
||||
|
||||
+8
-12
@@ -11,20 +11,16 @@
|
||||
* Only supports new ASCII and CRC formats
|
||||
*
|
||||
*/
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
#include "busybox.h"
|
||||
|
||||
#define CPIO_OPT_EXTRACT 0x01
|
||||
#define CPIO_OPT_TEST 0x02
|
||||
#define CPIO_OPT_UNCONDITIONAL 0x04
|
||||
#define CPIO_OPT_VERBOSE 0x08
|
||||
#define CPIO_OPT_FILE 0x10
|
||||
#define CPIO_OPT_CREATE_LEADING_DIR 0x20
|
||||
#define CPIO_OPT_PRESERVE_MTIME 0x40
|
||||
#define CPIO_OPT_EXTRACT 0x01
|
||||
#define CPIO_OPT_TEST 0x02
|
||||
#define CPIO_OPT_UNCONDITIONAL 0x04
|
||||
#define CPIO_OPT_VERBOSE 0x08
|
||||
#define CPIO_OPT_FILE 0x10
|
||||
#define CPIO_OPT_CREATE_LEADING_DIR 0x20
|
||||
#define CPIO_OPT_PRESERVE_MTIME 0x40
|
||||
|
||||
int cpio_main(int argc, char **argv);
|
||||
int cpio_main(int argc, char **argv)
|
||||
|
||||
+72
-70
@@ -24,7 +24,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
/* note: if you vary hash_prime sizes be aware,
|
||||
@@ -53,16 +53,16 @@
|
||||
* and available file */
|
||||
#define PACKAGE_HASH_PRIME 10007
|
||||
typedef struct edge_s {
|
||||
unsigned operator:3;
|
||||
unsigned operator:4; /* was:3 */
|
||||
unsigned type:4;
|
||||
unsigned name:14;
|
||||
unsigned version:14;
|
||||
unsigned name:16; /* was:14 */
|
||||
unsigned version:16; /* was:14 */
|
||||
} edge_t;
|
||||
|
||||
typedef struct common_node_s {
|
||||
unsigned name:14;
|
||||
unsigned version:14;
|
||||
unsigned num_of_edges:14;
|
||||
unsigned name:16; /* was:14 */
|
||||
unsigned version:16; /* was:14 */
|
||||
unsigned num_of_edges:16; /* was:14 */
|
||||
edge_t **edge;
|
||||
} common_node_t;
|
||||
|
||||
@@ -71,8 +71,8 @@ typedef struct common_node_s {
|
||||
* likely to be installed at any one time, so there is a bit of leeway here */
|
||||
#define STATUS_HASH_PRIME 8191
|
||||
typedef struct status_node_s {
|
||||
unsigned package:14; /* has to fit PACKAGE_HASH_PRIME */
|
||||
unsigned status:14; /* has to fit STATUS_HASH_PRIME */
|
||||
unsigned package:16; /* was:14 */ /* has to fit PACKAGE_HASH_PRIME */
|
||||
unsigned status:16; /* was:14 */ /* has to fit STATUS_HASH_PRIME */
|
||||
} status_node_t;
|
||||
|
||||
/* Were statically declared here, but such a big bss is nommu-unfriendly */
|
||||
@@ -107,13 +107,13 @@ enum operator_e {
|
||||
typedef struct deb_file_s {
|
||||
char *control_file;
|
||||
char *filename;
|
||||
unsigned package:14;
|
||||
unsigned package:16; /* was:14 */
|
||||
} deb_file_t;
|
||||
|
||||
|
||||
static void make_hash(const char *key, unsigned *start, unsigned *decrement, const int hash_prime)
|
||||
{
|
||||
unsigned long int hash_num = key[0];
|
||||
unsigned long hash_num = key[0];
|
||||
int len = strlen(key);
|
||||
int i;
|
||||
|
||||
@@ -352,7 +352,8 @@ static int search_package_hashtable(const unsigned name, const unsigned version,
|
||||
* FIXME: I don't think this is very efficient, but I thought I'd keep
|
||||
* it simple for now until it proves to be a problem.
|
||||
*/
|
||||
static int search_for_provides(int needle, int start_at) {
|
||||
static int search_for_provides(int needle, int start_at)
|
||||
{
|
||||
int i, j;
|
||||
common_node_t *p;
|
||||
for (i = start_at + 1; i < PACKAGE_HASH_PRIME; i++) {
|
||||
@@ -472,9 +473,13 @@ static void add_split_dependencies(common_node_t *parent_node, const char *whole
|
||||
or_edge->version++;
|
||||
|
||||
add_edge_to_node(parent_node, edge);
|
||||
} while ((field2 = strtok_r(NULL, "|", &line_ptr2)) != NULL);
|
||||
field2 = strtok_r(NULL, "|", &line_ptr2);
|
||||
} while (field2 != NULL);
|
||||
|
||||
free(line2);
|
||||
} while ((field = strtok_r(NULL, ",", &line_ptr1)) != NULL);
|
||||
field = strtok_r(NULL, ",", &line_ptr1);
|
||||
} while (field != NULL);
|
||||
|
||||
free(line);
|
||||
}
|
||||
|
||||
@@ -579,7 +584,7 @@ static unsigned fill_package_struct(char *control_buffer)
|
||||
{
|
||||
static const char *const field_names[] = { "Package", "Version",
|
||||
"Pre-Depends", "Depends","Replaces", "Provides",
|
||||
"Conflicts", "Suggests", "Recommends", "Enhances", 0
|
||||
"Conflicts", "Suggests", "Recommends", "Enhances", NULL
|
||||
};
|
||||
|
||||
common_node_t *new_node = xzalloc(sizeof(common_node_t));
|
||||
@@ -705,7 +710,8 @@ static void set_status(const unsigned status_node_num, const char *new_value, co
|
||||
free(new_status);
|
||||
}
|
||||
|
||||
static const char *describe_status(int status_num) {
|
||||
static const char *describe_status(int status_num)
|
||||
{
|
||||
int status_want, status_state ;
|
||||
if (status_hashtable[status_num] == NULL || status_hashtable[status_num]->status == 0)
|
||||
return "is not installed or flagged to be installed\n";
|
||||
@@ -721,7 +727,7 @@ static const char *describe_status(int status_num) {
|
||||
if (status_want == search_name_hashtable("purge"))
|
||||
return "is marked to be purged";
|
||||
}
|
||||
if (status_want == search_name_hashtable("unknown"))
|
||||
if (status_want == search_name_hashtable("unknown"))
|
||||
return "is in an indeterminate state";
|
||||
if (status_want == search_name_hashtable("install"))
|
||||
return "is marked to be installed";
|
||||
@@ -793,7 +799,8 @@ static void write_status_file(deb_file_t **deb_file)
|
||||
|
||||
/* Update previously known packages */
|
||||
while ((control_buffer = xmalloc_fgets_str(old_status_file, "\n\n")) != NULL) {
|
||||
if ((tmp_string = strstr(control_buffer, "Package:")) == NULL) {
|
||||
tmp_string = strstr(control_buffer, "Package:");
|
||||
if (tmp_string == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -818,8 +825,9 @@ static void write_status_file(deb_file_t **deb_file)
|
||||
if (strcmp(status_from_file, status_from_hashtable) != 0) {
|
||||
/* New status isnt exactly the same as old status */
|
||||
const int state_status = get_status(status_num, 3);
|
||||
if ((strcmp("installed", name_hashtable[state_status]) == 0) ||
|
||||
(strcmp("unpacked", name_hashtable[state_status]) == 0)) {
|
||||
if ((strcmp("installed", name_hashtable[state_status]) == 0)
|
||||
|| (strcmp("unpacked", name_hashtable[state_status]) == 0)
|
||||
) {
|
||||
/* We need to add the control file from the package */
|
||||
i = 0;
|
||||
while (deb_file[i] != NULL) {
|
||||
@@ -884,7 +892,7 @@ static void write_status_file(deb_file_t **deb_file)
|
||||
}
|
||||
}
|
||||
/* If the package from the status file wasnt handle above, do it now*/
|
||||
if (! write_flag) {
|
||||
if (!write_flag) {
|
||||
fprintf(new_status_file, "%s\n\n", control_buffer);
|
||||
}
|
||||
|
||||
@@ -1065,12 +1073,14 @@ static int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
|
||||
const edge_t *package_edge = package_node->edge[j];
|
||||
unsigned package_num;
|
||||
|
||||
if (package_edge->type == EDGE_OR_PRE_DEPENDS ||
|
||||
package_edge->type == EDGE_OR_DEPENDS) { /* start an EDGE_OR_ list */
|
||||
if (package_edge->type == EDGE_OR_PRE_DEPENDS
|
||||
|| package_edge->type == EDGE_OR_DEPENDS
|
||||
) { /* start an EDGE_OR_ list */
|
||||
number_of_alternatives = package_edge->version;
|
||||
root_of_alternatives = package_edge;
|
||||
continue;
|
||||
} else if (number_of_alternatives == 0) { /* not in the middle of an EDGE_OR_ list */
|
||||
}
|
||||
if (number_of_alternatives == 0) { /* not in the middle of an EDGE_OR_ list */
|
||||
number_of_alternatives = 1;
|
||||
root_of_alternatives = NULL;
|
||||
}
|
||||
@@ -1120,14 +1130,14 @@ static int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
|
||||
name_hashtable[package_node->name],
|
||||
package_edge->type == EDGE_PRE_DEPENDS ? "pre-" : "",
|
||||
name_hashtable[root_of_alternatives->name]);
|
||||
else
|
||||
bb_error_msg_and_die(
|
||||
"package %s %sdepends on %s, which %s\n",
|
||||
name_hashtable[package_node->name],
|
||||
package_edge->type == EDGE_PRE_DEPENDS ? "pre-" : "",
|
||||
name_hashtable[package_edge->name],
|
||||
describe_status(status_num));
|
||||
} else if (result == 0 && number_of_alternatives) {
|
||||
bb_error_msg_and_die(
|
||||
"package %s %sdepends on %s, which %s\n",
|
||||
name_hashtable[package_node->name],
|
||||
package_edge->type == EDGE_PRE_DEPENDS ? "pre-" : "",
|
||||
name_hashtable[package_edge->name],
|
||||
describe_status(status_num));
|
||||
}
|
||||
if (result == 0 && number_of_alternatives) {
|
||||
/* we've found a package which
|
||||
* satisfies the dependency,
|
||||
* so skip over the rest of
|
||||
@@ -1165,49 +1175,42 @@ static char **create_list(const char *filename)
|
||||
|
||||
if (count == 0) {
|
||||
return NULL;
|
||||
} else {
|
||||
file_list[count] = NULL;
|
||||
return file_list;
|
||||
}
|
||||
file_list[count] = NULL;
|
||||
return file_list;
|
||||
}
|
||||
|
||||
/* maybe i should try and hook this into remove_file.c somehow */
|
||||
static int remove_file_array(char **remove_names, char **exclude_names)
|
||||
{
|
||||
struct stat path_stat;
|
||||
int match_flag;
|
||||
int remove_flag = FALSE;
|
||||
int i,j;
|
||||
int remove_flag = 1; /* not removed anything yet */
|
||||
int i, j;
|
||||
|
||||
if (remove_names == NULL) {
|
||||
return FALSE;
|
||||
return 0;
|
||||
}
|
||||
for (i = 0; remove_names[i] != NULL; i++) {
|
||||
match_flag = FALSE;
|
||||
if (exclude_names != NULL) {
|
||||
for (j = 0; exclude_names[j] != 0; j++) {
|
||||
for (j = 0; exclude_names[j] != NULL; j++) {
|
||||
if (strcmp(remove_names[i], exclude_names[j]) == 0) {
|
||||
match_flag = TRUE;
|
||||
break;
|
||||
goto skip;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!match_flag) {
|
||||
if (lstat(remove_names[i], &path_stat) < 0) {
|
||||
continue;
|
||||
}
|
||||
if (S_ISDIR(path_stat.st_mode)) {
|
||||
if (rmdir(remove_names[i]) != -1) {
|
||||
remove_flag = TRUE;
|
||||
}
|
||||
} else {
|
||||
if (unlink(remove_names[i]) != -1) {
|
||||
remove_flag = TRUE;
|
||||
}
|
||||
}
|
||||
/* TODO: why we are checking lstat? we can just try rm/rmdir */
|
||||
if (lstat(remove_names[i], &path_stat) < 0) {
|
||||
continue;
|
||||
}
|
||||
if (S_ISDIR(path_stat.st_mode)) {
|
||||
remove_flag &= rmdir(remove_names[i]); /* 0 if no error */
|
||||
} else {
|
||||
remove_flag &= unlink(remove_names[i]); /* 0 if no error */
|
||||
}
|
||||
skip:
|
||||
continue;
|
||||
}
|
||||
return remove_flag;
|
||||
return (remove_flag == 0);
|
||||
}
|
||||
|
||||
static int run_package_script(const char *package_name, const char *script_type)
|
||||
@@ -1224,8 +1227,11 @@ static int run_package_script(const char *package_name, const char *script_type)
|
||||
return result;
|
||||
}
|
||||
|
||||
static const char *all_control_files[] = {"preinst", "postinst", "prerm", "postrm",
|
||||
"list", "md5sums", "shlibs", "conffiles", "config", "templates", NULL };
|
||||
static const char *all_control_files[] = {
|
||||
"preinst", "postinst", "prerm", "postrm",
|
||||
"list", "md5sums", "shlibs", "conffiles",
|
||||
"config", "templates", NULL
|
||||
};
|
||||
|
||||
static char **all_control_list(const char *package_name)
|
||||
{
|
||||
@@ -1244,7 +1250,6 @@ static char **all_control_list(const char *package_name)
|
||||
|
||||
static void free_array(char **array)
|
||||
{
|
||||
|
||||
if (array) {
|
||||
unsigned i = 0;
|
||||
while (array[i]) {
|
||||
@@ -1267,8 +1272,7 @@ static void list_packages(void)
|
||||
puts("+++-==============-==============");
|
||||
|
||||
/* go through status hash, dereference package hash and finally strings */
|
||||
for (i=0; i<STATUS_HASH_PRIME+1; i++) {
|
||||
|
||||
for (i = 0; i < STATUS_HASH_PRIME+1; i++) {
|
||||
if (status_hashtable[i]) {
|
||||
const char *stat_str; /* status string */
|
||||
const char *name_str; /* package name */
|
||||
@@ -1285,7 +1289,7 @@ static void list_packages(void)
|
||||
s1 = stat_str[0] == 'i' ? 'i' : 'r';
|
||||
|
||||
/* get abbreviation for status field 2 */
|
||||
for (j=0, spccnt=0; stat_str[j] && spccnt<2; j++) {
|
||||
for (j = 0, spccnt = 0; stat_str[j] && spccnt < 2; j++) {
|
||||
if (stat_str[j] == ' ') spccnt++;
|
||||
}
|
||||
s2 = stat_str[j];
|
||||
@@ -1293,7 +1297,7 @@ static void list_packages(void)
|
||||
/* print out the line formatted like Debian dpkg */
|
||||
printf("%c%c %-14s %s\n", s1, s2, name_str, vers_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void remove_package(const unsigned package_num, int noisy)
|
||||
@@ -1306,14 +1310,12 @@ static void remove_package(const unsigned package_num, int noisy)
|
||||
char **exclude_files;
|
||||
char list_name[package_name_length + 25];
|
||||
char conffile_name[package_name_length + 30];
|
||||
int return_value;
|
||||
|
||||
if (noisy)
|
||||
printf("Removing %s (%s)...\n", package_name, package_version);
|
||||
|
||||
/* run prerm script */
|
||||
return_value = run_package_script(package_name, "prerm");
|
||||
if (return_value == -1) {
|
||||
if (run_package_script(package_name, "prerm") != 0) {
|
||||
bb_error_msg_and_die("script failed, prerm failure");
|
||||
}
|
||||
|
||||
@@ -1381,8 +1383,8 @@ static void purge_package(const unsigned package_num)
|
||||
free(exclude_files);
|
||||
|
||||
/* run postrm script */
|
||||
if (run_package_script(package_name, "postrm") == -1) {
|
||||
bb_error_msg_and_die("postrm fialure.. set status to what?");
|
||||
if (run_package_script(package_name, "postrm") != 0) {
|
||||
bb_error_msg_and_die("postrm failure.. set status to what?");
|
||||
}
|
||||
|
||||
/* Change package status */
|
||||
@@ -1548,7 +1550,7 @@ static void configure_package(deb_file_t *deb_file)
|
||||
/* Run the postinst script */
|
||||
if (run_package_script(package_name, "postinst") != 0) {
|
||||
/* TODO: handle failure gracefully */
|
||||
bb_error_msg_and_die("postrm failure.. set status to what?");
|
||||
bb_error_msg_and_die("postinst failure.. set status to what?");
|
||||
}
|
||||
/* Change status to reflect success */
|
||||
set_status(status_num, "install", 1);
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#define DPKG_DEB_OPT_CONTENTS 1
|
||||
|
||||
+3
-3
@@ -39,7 +39,7 @@ gzip: bogus: No such file or directory
|
||||
aa: 85.1% -- replaced with aa.gz
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
|
||||
/* ===========================================================================
|
||||
@@ -47,7 +47,7 @@ aa: 85.1% -- replaced with aa.gz
|
||||
//#define DEBUG 1
|
||||
/* Diagnostic functions */
|
||||
#ifdef DEBUG
|
||||
# define Assert(cond,msg) {if(!(cond)) bb_error_msg(msg);}
|
||||
# define Assert(cond,msg) { if (!(cond)) bb_error_msg(msg); }
|
||||
# define Trace(x) fprintf x
|
||||
# define Tracev(x) {if (verbose) fprintf x ;}
|
||||
# define Tracevv(x) {if (verbose > 1) fprintf x ;}
|
||||
@@ -2079,7 +2079,7 @@ int gzip_main(int argc, char **argv)
|
||||
ALLOC(ush, G1.prev, 1L << BITS);
|
||||
|
||||
/* Initialise the CRC32 table */
|
||||
G1.crc_32_tab = crc32_filltable(0);
|
||||
G1.crc_32_tab = crc32_filltable(NULL, 0);
|
||||
|
||||
return bbunpack(argv, make_new_name_gzip, pack_gzip);
|
||||
}
|
||||
@@ -26,7 +26,6 @@ lib-y:= \
|
||||
\
|
||||
data_align.o \
|
||||
find_list_entry.o \
|
||||
open_transformer.o \
|
||||
init_handle.o
|
||||
|
||||
GUNZIP_FILES:= check_header_gzip.o decompress_unzip.o
|
||||
@@ -36,6 +35,16 @@ DPKG_FILES:= \
|
||||
get_header_tar.o \
|
||||
filter_accept_list_reassign.o
|
||||
|
||||
# open_transformer uses fork(). Compile it only if absolutely necessary
|
||||
lib-$(CONFIG_RPM) += open_transformer.o
|
||||
lib-$(CONFIG_FEATURE_TAR_BZIP2) += open_transformer.o
|
||||
lib-$(CONFIG_FEATURE_TAR_LZMA) += open_transformer.o
|
||||
lib-$(CONFIG_FEATURE_TAR_GZIP) += open_transformer.o
|
||||
lib-$(CONFIG_FEATURE_TAR_COMPRESS) += open_transformer.o
|
||||
lib-$(CONFIG_FEATURE_DEB_TAR_GZ) += open_transformer.o
|
||||
lib-$(CONFIG_FEATURE_DEB_TAR_BZ2) += open_transformer.o
|
||||
lib-$(CONFIG_FEATURE_DEB_TAR_LZMA) += open_transformer.o
|
||||
|
||||
lib-$(CONFIG_AR) += get_header_ar.o unpack_ar_archive.o
|
||||
lib-$(CONFIG_BUNZIP2) += decompress_bunzip2.o
|
||||
lib-$(CONFIG_UNLZMA) += decompress_unlzma.o
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
ssize_t archive_xread_all_eof(archive_handle_t *archive_handle,
|
||||
unsigned char *buf, size_t count)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
//#include <sys/types.h>
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
void data_extract_to_stdout(archive_handle_t *archive_handle)
|
||||
|
||||
@@ -3,12 +3,8 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
void data_skip(archive_handle_t *archive_handle)
|
||||
{
|
||||
|
||||
@@ -55,81 +55,80 @@
|
||||
/* This is what we know about each Huffman coding group */
|
||||
struct group_data {
|
||||
/* We have an extra slot at the end of limit[] for a sentinal value. */
|
||||
int limit[MAX_HUFCODE_BITS+1],base[MAX_HUFCODE_BITS],permute[MAX_SYMBOLS];
|
||||
int limit[MAX_HUFCODE_BITS+1], base[MAX_HUFCODE_BITS], permute[MAX_SYMBOLS];
|
||||
int minLen, maxLen;
|
||||
};
|
||||
|
||||
/* Structure holding all the housekeeping data, including IO buffers and
|
||||
memory that persists between calls to bunzip */
|
||||
|
||||
typedef struct {
|
||||
struct bunzip_data {
|
||||
/* State for interrupting output loop */
|
||||
|
||||
int writeCopies,writePos,writeRunCountdown,writeCount,writeCurrent;
|
||||
int writeCopies, writePos, writeRunCountdown, writeCount, writeCurrent;
|
||||
|
||||
/* I/O tracking data (file handles, buffers, positions, etc.) */
|
||||
|
||||
int in_fd,out_fd,inbufCount,inbufPos /*,outbufPos*/;
|
||||
int in_fd, out_fd, inbufCount, inbufPos /*, outbufPos*/;
|
||||
unsigned char *inbuf /*,*outbuf*/;
|
||||
unsigned int inbufBitCount, inbufBits;
|
||||
unsigned inbufBitCount, inbufBits;
|
||||
|
||||
/* The CRC values stored in the block header and calculated from the data */
|
||||
|
||||
uint32_t headerCRC, totalCRC, writeCRC;
|
||||
uint32_t *crc32Table;
|
||||
|
||||
/* Intermediate buffer and its size (in bytes) */
|
||||
|
||||
unsigned int *dbuf, dbufSize;
|
||||
|
||||
/* These things are a bit too big to go on the stack */
|
||||
|
||||
unsigned char selectors[32768]; /* nSelectors=15 bits */
|
||||
struct group_data groups[MAX_GROUPS]; /* Huffman coding tables */
|
||||
unsigned *dbuf, dbufSize;
|
||||
|
||||
/* For I/O error handling */
|
||||
|
||||
jmp_buf jmpbuf;
|
||||
} bunzip_data;
|
||||
|
||||
/* Big things go last (register-relative addressing can be larger for big offsets */
|
||||
uint32_t crc32Table[256];
|
||||
unsigned char selectors[32768]; /* nSelectors=15 bits */
|
||||
struct group_data groups[MAX_GROUPS]; /* Huffman coding tables */
|
||||
};
|
||||
/* typedef struct bunzip_data bunzip_data; -- done in .h file */
|
||||
|
||||
|
||||
/* Return the next nnn bits of input. All reads from the compressed input
|
||||
are done through this function. All reads are big endian */
|
||||
|
||||
static unsigned int get_bits(bunzip_data *bd, char bits_wanted)
|
||||
static unsigned get_bits(bunzip_data *bd, char bits_wanted)
|
||||
{
|
||||
unsigned int bits=0;
|
||||
unsigned bits = 0;
|
||||
|
||||
/* If we need to get more data from the byte buffer, do so. (Loop getting
|
||||
one byte at a time to enforce endianness and avoid unaligned access.) */
|
||||
|
||||
while (bd->inbufBitCount<bits_wanted) {
|
||||
while (bd->inbufBitCount < bits_wanted) {
|
||||
|
||||
/* If we need to read more data from file into byte buffer, do so */
|
||||
|
||||
if(bd->inbufPos==bd->inbufCount) {
|
||||
if((bd->inbufCount = read(bd->in_fd, bd->inbuf, IOBUF_SIZE)) <= 0)
|
||||
longjmp(bd->jmpbuf,RETVAL_UNEXPECTED_INPUT_EOF);
|
||||
bd->inbufPos=0;
|
||||
if (bd->inbufPos == bd->inbufCount) {
|
||||
/* if "no input fd" case: in_fd == -1, read fails, we jump */
|
||||
bd->inbufCount = read(bd->in_fd, bd->inbuf, IOBUF_SIZE);
|
||||
if (bd->inbufCount <= 0)
|
||||
longjmp(bd->jmpbuf, RETVAL_UNEXPECTED_INPUT_EOF);
|
||||
bd->inbufPos = 0;
|
||||
}
|
||||
|
||||
/* Avoid 32-bit overflow (dump bit buffer to top of output) */
|
||||
|
||||
if(bd->inbufBitCount>=24) {
|
||||
bits=bd->inbufBits&((1<<bd->inbufBitCount)-1);
|
||||
bits_wanted-=bd->inbufBitCount;
|
||||
bits<<=bits_wanted;
|
||||
bd->inbufBitCount=0;
|
||||
if (bd->inbufBitCount >= 24) {
|
||||
bits = bd->inbufBits & ((1 << bd->inbufBitCount) - 1);
|
||||
bits_wanted -= bd->inbufBitCount;
|
||||
bits <<= bits_wanted;
|
||||
bd->inbufBitCount = 0;
|
||||
}
|
||||
|
||||
/* Grab next 8 bits of input from buffer. */
|
||||
|
||||
bd->inbufBits=(bd->inbufBits<<8)|bd->inbuf[bd->inbufPos++];
|
||||
bd->inbufBitCount+=8;
|
||||
bd->inbufBits = (bd->inbufBits<<8) | bd->inbuf[bd->inbufPos++];
|
||||
bd->inbufBitCount += 8;
|
||||
}
|
||||
|
||||
/* Calculate result */
|
||||
|
||||
bd->inbufBitCount-=bits_wanted;
|
||||
bits|=(bd->inbufBits>>bd->inbufBitCount)&((1<<bits_wanted)-1);
|
||||
bd->inbufBitCount -= bits_wanted;
|
||||
bits |= (bd->inbufBits >> bd->inbufBitCount) & ((1 << bits_wanted) - 1);
|
||||
|
||||
return bits;
|
||||
}
|
||||
@@ -139,26 +138,26 @@ static unsigned int get_bits(bunzip_data *bd, char bits_wanted)
|
||||
static int get_next_block(bunzip_data *bd)
|
||||
{
|
||||
struct group_data *hufGroup;
|
||||
int dbufCount,nextSym,dbufSize,groupCount,*base,*limit,selector,
|
||||
i,j,k,t,runPos,symCount,symTotal,nSelectors,byteCount[256];
|
||||
int dbufCount, nextSym, dbufSize, groupCount, *base, *limit, selector,
|
||||
i, j, k, t, runPos, symCount, symTotal, nSelectors, byteCount[256];
|
||||
unsigned char uc, symToByte[256], mtfSymbol[256], *selectors;
|
||||
unsigned int *dbuf,origPtr;
|
||||
unsigned *dbuf, origPtr;
|
||||
|
||||
dbuf=bd->dbuf;
|
||||
dbufSize=bd->dbufSize;
|
||||
selectors=bd->selectors;
|
||||
dbuf = bd->dbuf;
|
||||
dbufSize = bd->dbufSize;
|
||||
selectors = bd->selectors;
|
||||
|
||||
/* Reset longjmp I/O error handling */
|
||||
|
||||
i=setjmp(bd->jmpbuf);
|
||||
i = setjmp(bd->jmpbuf);
|
||||
if (i) return i;
|
||||
|
||||
/* Read in header signature and CRC, then validate signature.
|
||||
(last block signature means CRC is for whole file, return now) */
|
||||
|
||||
i = get_bits(bd,24);
|
||||
j = get_bits(bd,24);
|
||||
bd->headerCRC=get_bits(bd,32);
|
||||
i = get_bits(bd, 24);
|
||||
j = get_bits(bd, 24);
|
||||
bd->headerCRC = get_bits(bd, 32);
|
||||
if ((i == 0x177245) && (j == 0x385090)) return RETVAL_LAST_BLOCK;
|
||||
if ((i != 0x314159) || (j != 0x265359)) return RETVAL_NOT_BZIP_DATA;
|
||||
|
||||
@@ -166,8 +165,9 @@ static int get_next_block(bunzip_data *bd)
|
||||
some code for this in busybox 1.0.0-pre3, but nobody ever noticed that
|
||||
it didn't actually work. */
|
||||
|
||||
if (get_bits(bd,1)) return RETVAL_OBSOLETE_INPUT;
|
||||
if ((origPtr=get_bits(bd,24)) > dbufSize) return RETVAL_DATA_ERROR;
|
||||
if (get_bits(bd, 1)) return RETVAL_OBSOLETE_INPUT;
|
||||
origPtr = get_bits(bd, 24);
|
||||
if (origPtr > dbufSize) return RETVAL_DATA_ERROR;
|
||||
|
||||
/* mapping table: if some byte values are never used (encoding things
|
||||
like ascii text), the compression code removes the gaps to have fewer
|
||||
@@ -175,48 +175,52 @@ static int get_next_block(bunzip_data *bd)
|
||||
values were present. We make a translation table to convert the symbols
|
||||
back to the corresponding bytes. */
|
||||
|
||||
t=get_bits(bd, 16);
|
||||
symTotal=0;
|
||||
for (i=0;i<16;i++) {
|
||||
if(t&(1<<(15-i))) {
|
||||
k=get_bits(bd,16);
|
||||
for (j=0;j<16;j++)
|
||||
if(k&(1<<(15-j))) symToByte[symTotal++]=(16*i)+j;
|
||||
t = get_bits(bd, 16);
|
||||
symTotal = 0;
|
||||
for (i = 0; i < 16; i++) {
|
||||
if (t & (1 << (15-i))) {
|
||||
k = get_bits(bd, 16);
|
||||
for (j = 0; j < 16; j++)
|
||||
if (k & (1 << (15-j)))
|
||||
symToByte[symTotal++] = (16*i) + j;
|
||||
}
|
||||
}
|
||||
|
||||
/* How many different Huffman coding groups does this block use? */
|
||||
|
||||
groupCount=get_bits(bd,3);
|
||||
if (groupCount<2 || groupCount>MAX_GROUPS) return RETVAL_DATA_ERROR;
|
||||
groupCount = get_bits(bd, 3);
|
||||
if (groupCount < 2 || groupCount > MAX_GROUPS)
|
||||
return RETVAL_DATA_ERROR;
|
||||
|
||||
/* nSelectors: Every GROUP_SIZE many symbols we select a new Huffman coding
|
||||
group. Read in the group selector list, which is stored as MTF encoded
|
||||
bit runs. (MTF=Move To Front, as each value is used it's moved to the
|
||||
start of the list.) */
|
||||
|
||||
if(!(nSelectors=get_bits(bd, 15))) return RETVAL_DATA_ERROR;
|
||||
for (i=0; i<groupCount; i++) mtfSymbol[i] = i;
|
||||
for (i=0; i<nSelectors; i++) {
|
||||
nSelectors = get_bits(bd, 15);
|
||||
if (!nSelectors) return RETVAL_DATA_ERROR;
|
||||
for (i = 0; i < groupCount; i++) mtfSymbol[i] = i;
|
||||
for (i = 0; i < nSelectors; i++) {
|
||||
|
||||
/* Get next value */
|
||||
|
||||
for (j=0;get_bits(bd,1);j++) if (j>=groupCount) return RETVAL_DATA_ERROR;
|
||||
for (j = 0; get_bits(bd, 1); j++)
|
||||
if (j>=groupCount) return RETVAL_DATA_ERROR;
|
||||
|
||||
/* Decode MTF to get the next selector */
|
||||
|
||||
uc = mtfSymbol[j];
|
||||
for (;j;j--) mtfSymbol[j] = mtfSymbol[j-1];
|
||||
mtfSymbol[0]=selectors[i]=uc;
|
||||
mtfSymbol[0] = selectors[i] = uc;
|
||||
}
|
||||
|
||||
/* Read the Huffman coding tables for each group, which code for symTotal
|
||||
literal symbols, plus two run symbols (RUNA, RUNB) */
|
||||
|
||||
symCount=symTotal+2;
|
||||
for (j=0; j<groupCount; j++) {
|
||||
unsigned char length[MAX_SYMBOLS],temp[MAX_HUFCODE_BITS+1];
|
||||
int minLen, maxLen, pp;
|
||||
symCount = symTotal + 2;
|
||||
for (j = 0; j < groupCount; j++) {
|
||||
unsigned char length[MAX_SYMBOLS], temp[MAX_HUFCODE_BITS+1];
|
||||
int minLen, maxLen, pp;
|
||||
|
||||
/* Read Huffman code lengths for each symbol. They're stored in
|
||||
a way similar to mtf; record a starting value for the first symbol,
|
||||
@@ -225,17 +229,17 @@ static int get_next_block(bunzip_data *bd)
|
||||
an optimization that makes the test inside the loop simpler: symbol
|
||||
length 0 becomes negative, so an unsigned inequality catches it.) */
|
||||
|
||||
t=get_bits(bd, 5)-1;
|
||||
t = get_bits(bd, 5) - 1;
|
||||
for (i = 0; i < symCount; i++) {
|
||||
for (;;) {
|
||||
if (((unsigned)t) > (MAX_HUFCODE_BITS-1))
|
||||
if ((unsigned)t > (MAX_HUFCODE_BITS-1))
|
||||
return RETVAL_DATA_ERROR;
|
||||
|
||||
/* If first bit is 0, stop. Else second bit indicates whether
|
||||
to increment or decrement the value. Optimization: grab 2
|
||||
bits and unget the second if the first was 0. */
|
||||
|
||||
k = get_bits(bd,2);
|
||||
k = get_bits(bd, 2);
|
||||
if (k < 2) {
|
||||
bd->inbufBitCount++;
|
||||
break;
|
||||
@@ -243,20 +247,20 @@ static int get_next_block(bunzip_data *bd)
|
||||
|
||||
/* Add one if second bit 1, else subtract 1. Avoids if/else */
|
||||
|
||||
t+=(((k+1)&2)-1);
|
||||
t += (((k+1) & 2) - 1);
|
||||
}
|
||||
|
||||
/* Correct for the initial -1, to get the final symbol length */
|
||||
|
||||
length[i]=t+1;
|
||||
length[i] = t + 1;
|
||||
}
|
||||
|
||||
/* Find largest and smallest lengths in this group */
|
||||
|
||||
minLen=maxLen=length[0];
|
||||
minLen = maxLen = length[0];
|
||||
for (i = 1; i < symCount; i++) {
|
||||
if(length[i] > maxLen) maxLen = length[i];
|
||||
else if(length[i] < minLen) minLen = length[i];
|
||||
if (length[i] > maxLen) maxLen = length[i];
|
||||
else if (length[i] < minLen) minLen = length[i];
|
||||
}
|
||||
|
||||
/* Calculate permute[], base[], and limit[] tables from length[].
|
||||
@@ -270,7 +274,7 @@ static int get_next_block(bunzip_data *bd)
|
||||
* length: each code with a value>limit[length] needs another bit.
|
||||
*/
|
||||
|
||||
hufGroup=bd->groups+j;
|
||||
hufGroup = bd->groups + j;
|
||||
hufGroup->minLen = minLen;
|
||||
hufGroup->maxLen = maxLen;
|
||||
|
||||
@@ -278,30 +282,31 @@ static int get_next_block(bunzip_data *bd)
|
||||
and limit array pointers so we're not always wasting the first
|
||||
entry. We do this again when using them (during symbol decoding).*/
|
||||
|
||||
base=hufGroup->base-1;
|
||||
limit=hufGroup->limit-1;
|
||||
base = hufGroup->base - 1;
|
||||
limit = hufGroup->limit - 1;
|
||||
|
||||
/* Calculate permute[]. Concurently, initialize temp[] and limit[]. */
|
||||
|
||||
pp=0;
|
||||
for (i=minLen;i<=maxLen;i++) {
|
||||
temp[i]=limit[i]=0;
|
||||
for (t=0;t<symCount;t++)
|
||||
if(length[t]==i) hufGroup->permute[pp++] = t;
|
||||
pp = 0;
|
||||
for (i = minLen; i <= maxLen; i++) {
|
||||
temp[i] = limit[i] = 0;
|
||||
for (t = 0; t < symCount; t++)
|
||||
if (length[t] == i)
|
||||
hufGroup->permute[pp++] = t;
|
||||
}
|
||||
|
||||
/* Count symbols coded for at each bit length */
|
||||
|
||||
for (i=0;i<symCount;i++) temp[length[i]]++;
|
||||
for (i = 0; i < symCount; i++) temp[length[i]]++;
|
||||
|
||||
/* Calculate limit[] (the largest symbol-coding value at each bit
|
||||
* length, which is (previous limit<<1)+symbols at this level), and
|
||||
* base[] (number of symbols to ignore at each bit length, which is
|
||||
* limit minus the cumulative count of symbols coded for already). */
|
||||
|
||||
pp=t=0;
|
||||
for (i=minLen; i<maxLen; i++) {
|
||||
pp+=temp[i];
|
||||
pp = t = 0;
|
||||
for (i = minLen; i < maxLen; i++) {
|
||||
pp += temp[i];
|
||||
|
||||
/* We read the largest possible symbol size and then unget bits
|
||||
after determining how many we need, and those extra bits could
|
||||
@@ -310,13 +315,14 @@ static int get_next_block(bunzip_data *bd)
|
||||
so here we set all the trailing to-be-ignored bits to 1 so they
|
||||
don't affect the value>limit[length] comparison. */
|
||||
|
||||
limit[i]= (pp << (maxLen - i)) - 1;
|
||||
pp<<=1;
|
||||
base[i+1]=pp-(t+=temp[i]);
|
||||
limit[i] = (pp << (maxLen - i)) - 1;
|
||||
pp <<= 1;
|
||||
t += temp[i];
|
||||
base[i+1] = pp - t;
|
||||
}
|
||||
limit[maxLen+1] = INT_MAX; /* Sentinal value for reading next sym. */
|
||||
limit[maxLen]=pp+temp[maxLen]-1;
|
||||
base[minLen]=0;
|
||||
limit[maxLen] = pp + temp[maxLen] - 1;
|
||||
base[minLen] = 0;
|
||||
}
|
||||
|
||||
/* We've finished reading and digesting the block header. Now read this
|
||||
@@ -325,24 +331,24 @@ static int get_next_block(bunzip_data *bd)
|
||||
|
||||
/* Initialize symbol occurrence counters and symbol Move To Front table */
|
||||
|
||||
for (i=0;i<256;i++) {
|
||||
for (i = 0; i < 256; i++) {
|
||||
byteCount[i] = 0;
|
||||
mtfSymbol[i]=(unsigned char)i;
|
||||
mtfSymbol[i] = (unsigned char)i;
|
||||
}
|
||||
|
||||
/* Loop through compressed symbols. */
|
||||
|
||||
runPos=dbufCount=selector=0;
|
||||
runPos = dbufCount = selector = 0;
|
||||
for (;;) {
|
||||
|
||||
/* fetch next Huffman coding group from list. */
|
||||
|
||||
symCount=GROUP_SIZE-1;
|
||||
if(selector>=nSelectors) return RETVAL_DATA_ERROR;
|
||||
hufGroup=bd->groups+selectors[selector++];
|
||||
base=hufGroup->base-1;
|
||||
limit=hufGroup->limit-1;
|
||||
continue_this_group:
|
||||
symCount = GROUP_SIZE - 1;
|
||||
if (selector >= nSelectors) return RETVAL_DATA_ERROR;
|
||||
hufGroup = bd->groups + selectors[selector++];
|
||||
base = hufGroup->base - 1;
|
||||
limit = hufGroup->limit - 1;
|
||||
continue_this_group:
|
||||
|
||||
/* Read next Huffman-coded symbol. */
|
||||
|
||||
@@ -353,33 +359,34 @@ continue_this_group:
|
||||
valid compressed file. As a further optimization, we do the read
|
||||
inline (falling back to a call to get_bits if the buffer runs
|
||||
dry). The following (up to got_huff_bits:) is equivalent to
|
||||
j=get_bits(bd,hufGroup->maxLen);
|
||||
j = get_bits(bd, hufGroup->maxLen);
|
||||
*/
|
||||
|
||||
while (bd->inbufBitCount<hufGroup->maxLen) {
|
||||
if(bd->inbufPos==bd->inbufCount) {
|
||||
j = get_bits(bd,hufGroup->maxLen);
|
||||
while (bd->inbufBitCount < hufGroup->maxLen) {
|
||||
if (bd->inbufPos == bd->inbufCount) {
|
||||
j = get_bits(bd, hufGroup->maxLen);
|
||||
goto got_huff_bits;
|
||||
}
|
||||
bd->inbufBits=(bd->inbufBits<<8)|bd->inbuf[bd->inbufPos++];
|
||||
bd->inbufBitCount+=8;
|
||||
bd->inbufBits = (bd->inbufBits << 8) | bd->inbuf[bd->inbufPos++];
|
||||
bd->inbufBitCount += 8;
|
||||
};
|
||||
bd->inbufBitCount-=hufGroup->maxLen;
|
||||
j = (bd->inbufBits>>bd->inbufBitCount)&((1<<hufGroup->maxLen)-1);
|
||||
bd->inbufBitCount -= hufGroup->maxLen;
|
||||
j = (bd->inbufBits >> bd->inbufBitCount) & ((1 << hufGroup->maxLen) - 1);
|
||||
|
||||
got_huff_bits:
|
||||
got_huff_bits:
|
||||
|
||||
/* Figure how how many bits are in next symbol and unget extras */
|
||||
|
||||
i=hufGroup->minLen;
|
||||
while (j>limit[i]) ++i;
|
||||
i = hufGroup->minLen;
|
||||
while (j > limit[i]) ++i;
|
||||
bd->inbufBitCount += (hufGroup->maxLen - i);
|
||||
|
||||
/* Huffman decode value to get nextSym (with bounds checking) */
|
||||
|
||||
if ((i > hufGroup->maxLen)
|
||||
|| (((unsigned)(j=(j>>(hufGroup->maxLen-i))-base[i]))
|
||||
>= MAX_SYMBOLS))
|
||||
if (i > hufGroup->maxLen)
|
||||
return RETVAL_DATA_ERROR;
|
||||
j = (j >> (hufGroup->maxLen - i)) - base[i];
|
||||
if ((unsigned)j >= MAX_SYMBOLS)
|
||||
return RETVAL_DATA_ERROR;
|
||||
nextSym = hufGroup->permute[j];
|
||||
|
||||
@@ -388,11 +395,11 @@ got_huff_bits:
|
||||
check if nextSym indicates a repeated run, and if so loop collecting
|
||||
how many times to repeat the last literal. */
|
||||
|
||||
if (((unsigned)nextSym) <= SYMBOL_RUNB) { /* RUNA or RUNB */
|
||||
if ((unsigned)nextSym <= SYMBOL_RUNB) { /* RUNA or RUNB */
|
||||
|
||||
/* If this is the start of a new run, zero out counter */
|
||||
|
||||
if(!runPos) {
|
||||
if (!runPos) {
|
||||
runPos = 1;
|
||||
t = 0;
|
||||
}
|
||||
@@ -406,7 +413,7 @@ got_huff_bits:
|
||||
context). Thus space is saved. */
|
||||
|
||||
t += (runPos << nextSym); /* +runPos if RUNA; +2*runPos if RUNB */
|
||||
if(runPos < dbufSize) runPos <<= 1;
|
||||
if (runPos < dbufSize) runPos <<= 1;
|
||||
goto end_of_huffman_loop;
|
||||
}
|
||||
|
||||
@@ -415,18 +422,18 @@ got_huff_bits:
|
||||
copies to our buffer of decoded symbols (dbuf) now. (The last
|
||||
literal used is the one at the head of the mtfSymbol array.) */
|
||||
|
||||
if(runPos) {
|
||||
runPos=0;
|
||||
if(dbufCount+t>=dbufSize) return RETVAL_DATA_ERROR;
|
||||
if (runPos) {
|
||||
runPos = 0;
|
||||
if (dbufCount + t >= dbufSize) return RETVAL_DATA_ERROR;
|
||||
|
||||
uc = symToByte[mtfSymbol[0]];
|
||||
byteCount[uc] += t;
|
||||
while (t--) dbuf[dbufCount++]=uc;
|
||||
while (t--) dbuf[dbufCount++] = uc;
|
||||
}
|
||||
|
||||
/* Is this the terminating symbol? */
|
||||
|
||||
if(nextSym>symTotal) break;
|
||||
if (nextSym > symTotal) break;
|
||||
|
||||
/* At this point, nextSym indicates a new literal character. Subtract
|
||||
one to get the position in the MTF array at which this literal is
|
||||
@@ -436,7 +443,7 @@ got_huff_bits:
|
||||
as part of a run above. Therefore 1 unused mtf position minus
|
||||
2 non-literal nextSym values equals -1.) */
|
||||
|
||||
if(dbufCount>=dbufSize) return RETVAL_DATA_ERROR;
|
||||
if (dbufCount >= dbufSize) return RETVAL_DATA_ERROR;
|
||||
i = nextSym - 1;
|
||||
uc = mtfSymbol[i];
|
||||
|
||||
@@ -449,22 +456,22 @@ got_huff_bits:
|
||||
mtfSymbol[i] = mtfSymbol[i-1];
|
||||
} while (--i);
|
||||
mtfSymbol[0] = uc;
|
||||
uc=symToByte[uc];
|
||||
uc = symToByte[uc];
|
||||
|
||||
/* We have our literal byte. Save it into dbuf. */
|
||||
|
||||
byteCount[uc]++;
|
||||
dbuf[dbufCount++] = (unsigned int)uc;
|
||||
dbuf[dbufCount++] = (unsigned)uc;
|
||||
|
||||
/* Skip group initialization if we're not done with this group. Done
|
||||
* this way to avoid compiler warning. */
|
||||
|
||||
end_of_huffman_loop:
|
||||
if(symCount--) goto continue_this_group;
|
||||
end_of_huffman_loop:
|
||||
if (symCount--) goto continue_this_group;
|
||||
}
|
||||
|
||||
/* At this point, we've read all the Huffman-coded symbols (and repeated
|
||||
runs) for this block from the input stream, and decoded them into the
|
||||
runs) for this block from the input stream, and decoded them into the
|
||||
intermediate buffer. There are dbufCount many decoded bytes in dbuf[].
|
||||
Now undo the Burrows-Wheeler transform on dbuf.
|
||||
See http://dogma.net/markn/articles/bwt/bwt.htm
|
||||
@@ -472,17 +479,17 @@ end_of_huffman_loop:
|
||||
|
||||
/* Turn byteCount into cumulative occurrence counts of 0 to n-1. */
|
||||
|
||||
j=0;
|
||||
for (i=0;i<256;i++) {
|
||||
k=j+byteCount[i];
|
||||
j = 0;
|
||||
for (i = 0; i < 256; i++) {
|
||||
k = j + byteCount[i];
|
||||
byteCount[i] = j;
|
||||
j=k;
|
||||
j = k;
|
||||
}
|
||||
|
||||
/* Figure out what order dbuf would be in if we sorted it. */
|
||||
|
||||
for (i=0;i<dbufCount;i++) {
|
||||
uc=(unsigned char)(dbuf[i] & 0xff);
|
||||
for (i = 0; i < dbufCount; i++) {
|
||||
uc = (unsigned char)(dbuf[i] & 0xff);
|
||||
dbuf[byteCount[uc]] |= (i << 8);
|
||||
byteCount[uc]++;
|
||||
}
|
||||
@@ -491,14 +498,14 @@ end_of_huffman_loop:
|
||||
doesn't get output, and if the first three characters are identical
|
||||
it doesn't qualify as a run (hence writeRunCountdown=5). */
|
||||
|
||||
if(dbufCount) {
|
||||
if(origPtr>=dbufCount) return RETVAL_DATA_ERROR;
|
||||
bd->writePos=dbuf[origPtr];
|
||||
bd->writeCurrent=(unsigned char)(bd->writePos&0xff);
|
||||
bd->writePos>>=8;
|
||||
bd->writeRunCountdown=5;
|
||||
if (dbufCount) {
|
||||
if (origPtr >= dbufCount) return RETVAL_DATA_ERROR;
|
||||
bd->writePos = dbuf[origPtr];
|
||||
bd->writeCurrent = (unsigned char)(bd->writePos & 0xff);
|
||||
bd->writePos >>= 8;
|
||||
bd->writeRunCountdown = 5;
|
||||
}
|
||||
bd->writeCount=dbufCount;
|
||||
bd->writeCount = dbufCount;
|
||||
|
||||
return RETVAL_OK;
|
||||
}
|
||||
@@ -510,18 +517,18 @@ end_of_huffman_loop:
|
||||
are ignored, data is written to out_fd and return is RETVAL_OK or error.
|
||||
*/
|
||||
|
||||
static int read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
int read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
{
|
||||
const unsigned int *dbuf;
|
||||
int pos,current,previous,gotcount;
|
||||
const unsigned *dbuf;
|
||||
int pos, current, previous, gotcount;
|
||||
|
||||
/* If last read was short due to end of file, return last block now */
|
||||
if(bd->writeCount<0) return bd->writeCount;
|
||||
if (bd->writeCount < 0) return bd->writeCount;
|
||||
|
||||
gotcount = 0;
|
||||
dbuf=bd->dbuf;
|
||||
pos=bd->writePos;
|
||||
current=bd->writeCurrent;
|
||||
dbuf = bd->dbuf;
|
||||
pos = bd->writePos;
|
||||
current = bd->writeCurrent;
|
||||
|
||||
/* We will always have pending decoded data to write into the output
|
||||
buffer unless this is the very first call (in which case we haven't
|
||||
@@ -539,9 +546,9 @@ static int read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
|
||||
/* If the output buffer is full, snapshot state and return */
|
||||
|
||||
if(gotcount >= len) {
|
||||
bd->writePos=pos;
|
||||
bd->writeCurrent=current;
|
||||
if (gotcount >= len) {
|
||||
bd->writePos =pos;
|
||||
bd->writeCurrent = current;
|
||||
bd->writeCopies++;
|
||||
return len;
|
||||
}
|
||||
@@ -549,8 +556,8 @@ static int read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
/* Write next byte into output buffer, updating CRC */
|
||||
|
||||
outbuf[gotcount++] = current;
|
||||
bd->writeCRC=(((bd->writeCRC)<<8)
|
||||
^bd->crc32Table[((bd->writeCRC)>>24)^current]);
|
||||
bd->writeCRC = (bd->writeCRC << 8)
|
||||
^ bd->crc32Table[(bd->writeCRC >> 24) ^ current];
|
||||
|
||||
/* Loop now if we're outputting multiple copies of this byte */
|
||||
|
||||
@@ -558,31 +565,32 @@ static int read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
--bd->writeCopies;
|
||||
continue;
|
||||
}
|
||||
decode_next_byte:
|
||||
decode_next_byte:
|
||||
if (!bd->writeCount--) break;
|
||||
/* Follow sequence vector to undo Burrows-Wheeler transform */
|
||||
previous=current;
|
||||
pos=dbuf[pos];
|
||||
current=pos&0xff;
|
||||
pos>>=8;
|
||||
previous = current;
|
||||
pos = dbuf[pos];
|
||||
current = pos & 0xff;
|
||||
pos >>= 8;
|
||||
|
||||
/* After 3 consecutive copies of the same byte, the 4th is a repeat
|
||||
count. We count down from 4 instead
|
||||
* of counting up because testing for non-zero is faster */
|
||||
|
||||
if(--bd->writeRunCountdown) {
|
||||
if(current!=previous) bd->writeRunCountdown=4;
|
||||
if (--bd->writeRunCountdown) {
|
||||
if (current != previous)
|
||||
bd->writeRunCountdown = 4;
|
||||
} else {
|
||||
|
||||
/* We have a repeated run, this byte indicates the count */
|
||||
|
||||
bd->writeCopies=current;
|
||||
current=previous;
|
||||
bd->writeRunCountdown=5;
|
||||
bd->writeCopies = current;
|
||||
current = previous;
|
||||
bd->writeRunCountdown = 5;
|
||||
|
||||
/* Sometimes there are just 3 bytes (run length 0) */
|
||||
|
||||
if(!bd->writeCopies) goto decode_next_byte;
|
||||
if (!bd->writeCopies) goto decode_next_byte;
|
||||
|
||||
/* Subtract the 1 copy we'd output anyway to get extras */
|
||||
|
||||
@@ -592,13 +600,13 @@ decode_next_byte:
|
||||
|
||||
/* Decompression of this block completed successfully */
|
||||
|
||||
bd->writeCRC=~bd->writeCRC;
|
||||
bd->totalCRC=((bd->totalCRC<<1) | (bd->totalCRC>>31)) ^ bd->writeCRC;
|
||||
bd->writeCRC = ~bd->writeCRC;
|
||||
bd->totalCRC = ((bd->totalCRC << 1) | (bd->totalCRC >> 31)) ^ bd->writeCRC;
|
||||
|
||||
/* If this block had a CRC error, force file level CRC error. */
|
||||
|
||||
if(bd->writeCRC!=bd->headerCRC) {
|
||||
bd->totalCRC=bd->headerCRC+1;
|
||||
if (bd->writeCRC != bd->headerCRC) {
|
||||
bd->totalCRC = bd->headerCRC+1;
|
||||
return RETVAL_LAST_BLOCK;
|
||||
}
|
||||
}
|
||||
@@ -606,70 +614,90 @@ decode_next_byte:
|
||||
/* Refill the intermediate buffer by Huffman-decoding next block of input */
|
||||
/* (previous is just a convenient unused temp variable here) */
|
||||
|
||||
previous=get_next_block(bd);
|
||||
if(previous) {
|
||||
bd->writeCount=previous;
|
||||
return (previous!=RETVAL_LAST_BLOCK) ? previous : gotcount;
|
||||
previous = get_next_block(bd);
|
||||
if (previous) {
|
||||
bd->writeCount = previous;
|
||||
return (previous != RETVAL_LAST_BLOCK) ? previous : gotcount;
|
||||
}
|
||||
bd->writeCRC=~0;
|
||||
pos=bd->writePos;
|
||||
current=bd->writeCurrent;
|
||||
bd->writeCRC = ~0;
|
||||
pos = bd->writePos;
|
||||
current = bd->writeCurrent;
|
||||
goto decode_next_byte;
|
||||
}
|
||||
|
||||
|
||||
/* Allocate the structure, read file header. If in_fd==-1, inbuf must contain
|
||||
a complete bunzip file (len bytes long). If in_fd!=-1, inbuf and len are
|
||||
ignored, and data is read from file handle into temporary buffer. */
|
||||
|
||||
static int start_bunzip(bunzip_data **bdp, int in_fd, unsigned char *inbuf,
|
||||
/* Because bunzip2 is used for help text unpacking, and because bb_show_usage()
|
||||
should work for NOFORK applets too, we must be extremely careful to not leak
|
||||
any allocations! */
|
||||
|
||||
int start_bunzip(bunzip_data **bdp, int in_fd, const unsigned char *inbuf,
|
||||
int len)
|
||||
{
|
||||
bunzip_data *bd;
|
||||
unsigned int i;
|
||||
const unsigned int BZh0=(((unsigned int)'B')<<24)+(((unsigned int)'Z')<<16)
|
||||
+(((unsigned int)'h')<<8)+(unsigned int)'0';
|
||||
unsigned i;
|
||||
enum {
|
||||
BZh0 = ('B' << 24) + ('Z' << 16) + ('h' << 8) + '0'
|
||||
};
|
||||
|
||||
/* Figure out how much data to allocate */
|
||||
|
||||
i=sizeof(bunzip_data);
|
||||
if(in_fd!=-1) i+=IOBUF_SIZE;
|
||||
i = sizeof(bunzip_data);
|
||||
if (in_fd != -1) i += IOBUF_SIZE;
|
||||
|
||||
/* Allocate bunzip_data. Most fields initialize to zero. */
|
||||
|
||||
bd=*bdp=xzalloc(i);
|
||||
bd = *bdp = xzalloc(i);
|
||||
|
||||
/* Setup input buffer */
|
||||
|
||||
if(-1==(bd->in_fd=in_fd)) {
|
||||
bd->inbuf=inbuf;
|
||||
bd->inbufCount=len;
|
||||
} else bd->inbuf=(unsigned char *)(bd+1);
|
||||
bd->in_fd = in_fd;
|
||||
if (-1 == in_fd) {
|
||||
/* in this case, bd->inbuf is read-only */
|
||||
bd->inbuf = (void*)inbuf; /* cast away const-ness */
|
||||
bd->inbufCount = len;
|
||||
} else
|
||||
bd->inbuf = (unsigned char *)(bd + 1);
|
||||
|
||||
/* Init the CRC32 table (big endian) */
|
||||
|
||||
bd->crc32Table = crc32_filltable(1);
|
||||
crc32_filltable(bd->crc32Table, 1);
|
||||
|
||||
/* Setup for I/O error handling via longjmp */
|
||||
|
||||
i=setjmp(bd->jmpbuf);
|
||||
if(i) return i;
|
||||
i = setjmp(bd->jmpbuf);
|
||||
if (i) return i;
|
||||
|
||||
/* Ensure that file starts with "BZh['1'-'9']." */
|
||||
|
||||
i = get_bits(bd,32);
|
||||
if (((unsigned int)(i-BZh0-1)) >= 9) return RETVAL_NOT_BZIP_DATA;
|
||||
i = get_bits(bd, 32);
|
||||
if ((unsigned)(i - BZh0 - 1) >= 9) return RETVAL_NOT_BZIP_DATA;
|
||||
|
||||
/* Fourth byte (ascii '1'-'9'), indicates block size in units of 100k of
|
||||
uncompressed data. Allocate intermediate buffer for block. */
|
||||
|
||||
bd->dbufSize=100000*(i-BZh0);
|
||||
bd->dbufSize = 100000 * (i - BZh0);
|
||||
|
||||
bd->dbuf=xmalloc(bd->dbufSize * sizeof(int));
|
||||
/* Cannot use xmalloc - may leak bd in NOFORK case! */
|
||||
bd->dbuf = malloc_or_warn(bd->dbufSize * sizeof(int));
|
||||
if (!bd->dbuf) {
|
||||
free(bd);
|
||||
xfunc_die();
|
||||
}
|
||||
return RETVAL_OK;
|
||||
}
|
||||
|
||||
/* Example usage: decompress src_fd to dst_fd. (Stops at end of bzip data,
|
||||
not end of file.) */
|
||||
void dealloc_bunzip(bunzip_data *bd)
|
||||
{
|
||||
free(bd->dbuf);
|
||||
free(bd);
|
||||
}
|
||||
|
||||
|
||||
/* Decompress src_fd to dst_fd. Stops at end of bzip data, not end of file. */
|
||||
|
||||
USE_DESKTOP(long long) int
|
||||
uncompressStream(int src_fd, int dst_fd)
|
||||
@@ -679,13 +707,14 @@ uncompressStream(int src_fd, int dst_fd)
|
||||
bunzip_data *bd;
|
||||
int i;
|
||||
|
||||
outbuf=xmalloc(IOBUF_SIZE);
|
||||
i=start_bunzip(&bd,src_fd,0,0);
|
||||
if(!i) {
|
||||
outbuf = xmalloc(IOBUF_SIZE);
|
||||
i = start_bunzip(&bd, src_fd, NULL, 0);
|
||||
if (!i) {
|
||||
for (;;) {
|
||||
if((i=read_bunzip(bd,outbuf,IOBUF_SIZE)) <= 0) break;
|
||||
if(i!=write(dst_fd,outbuf,i)) {
|
||||
i=RETVAL_UNEXPECTED_OUTPUT_EOF;
|
||||
i = read_bunzip(bd, outbuf, IOBUF_SIZE);
|
||||
if (i <= 0) break;
|
||||
if (i != safe_write(dst_fd, outbuf, i)) {
|
||||
i = RETVAL_UNEXPECTED_OUTPUT_EOF;
|
||||
break;
|
||||
}
|
||||
USE_DESKTOP(total_written += i;)
|
||||
@@ -694,19 +723,18 @@ uncompressStream(int src_fd, int dst_fd)
|
||||
|
||||
/* Check CRC and release memory */
|
||||
|
||||
if(i==RETVAL_LAST_BLOCK) {
|
||||
if (bd->headerCRC!=bd->totalCRC) {
|
||||
if (i == RETVAL_LAST_BLOCK) {
|
||||
if (bd->headerCRC != bd->totalCRC) {
|
||||
bb_error_msg("data integrity error when decompressing");
|
||||
} else {
|
||||
i=RETVAL_OK;
|
||||
i = RETVAL_OK;
|
||||
}
|
||||
} else if (i==RETVAL_UNEXPECTED_OUTPUT_EOF) {
|
||||
} else if (i == RETVAL_UNEXPECTED_OUTPUT_EOF) {
|
||||
bb_error_msg("compressed file ends unexpectedly");
|
||||
} else {
|
||||
bb_error_msg("decompression failed");
|
||||
}
|
||||
free(bd->dbuf);
|
||||
free(bd);
|
||||
dealloc_bunzip(bd);
|
||||
free(outbuf);
|
||||
|
||||
return i ? i : USE_DESKTOP(total_written) + 0;
|
||||
@@ -714,18 +742,22 @@ uncompressStream(int src_fd, int dst_fd)
|
||||
|
||||
#ifdef TESTING
|
||||
|
||||
static char * const bunzip_errors[]={NULL,"Bad file checksum","Not bzip data",
|
||||
"Unexpected input EOF","Unexpected output EOF","Data error",
|
||||
"Out of memory","Obsolete (pre 0.9.5) bzip format not supported."};
|
||||
static char *const bunzip_errors[] = {
|
||||
NULL, "Bad file checksum", "Not bzip data",
|
||||
"Unexpected input EOF", "Unexpected output EOF", "Data error",
|
||||
"Out of memory", "Obsolete (pre 0.9.5) bzip format not supported"
|
||||
};
|
||||
|
||||
/* Dumb little test thing, decompress stdin to stdout */
|
||||
int main(int argc, char *argv[])
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i=uncompressStream(0,1);
|
||||
int i = uncompressStream(0, 1);
|
||||
char c;
|
||||
|
||||
if(i<0) fprintf(stderr,"%s\n", bunzip_errors[-i]);
|
||||
else if(read(0,&c,1)) fprintf(stderr,"Trailing garbage ignored\n");
|
||||
if (i < 0)
|
||||
fprintf(stderr,"%s\n", bunzip_errors[-i]);
|
||||
else if (read(0, &c, 1))
|
||||
fprintf(stderr,"Trailing garbage ignored\n");
|
||||
return -i;
|
||||
}
|
||||
#endif
|
||||
@@ -26,9 +26,6 @@
|
||||
* [... History snipped ...]
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* Default input buffer size */
|
||||
#define IBUFSIZ 2048
|
||||
@@ -85,18 +82,18 @@ uncompress(int fd_in, int fd_out)
|
||||
{
|
||||
USE_DESKTOP(long long total_written = 0;)
|
||||
unsigned char *stackp;
|
||||
long int code;
|
||||
long code;
|
||||
int finchar;
|
||||
long int oldcode;
|
||||
long int incode;
|
||||
long oldcode;
|
||||
long incode;
|
||||
int inbits;
|
||||
int posbits;
|
||||
int outpos;
|
||||
int insize;
|
||||
int bitmask;
|
||||
long int free_ent;
|
||||
long int maxcode;
|
||||
long int maxmaxcode;
|
||||
long free_ent;
|
||||
long maxcode;
|
||||
long maxmaxcode;
|
||||
int n_bits;
|
||||
int rsize = 0;
|
||||
RESERVE_CONFIG_UBUFFER(inbuf, IBUFSIZ + 64);
|
||||
@@ -243,7 +240,7 @@ uncompress(int fd_in, int fd_out)
|
||||
}
|
||||
|
||||
/* Generate output characters in reverse order */
|
||||
while ((long int) code >= (long int) 256) {
|
||||
while ((long) code >= (long) 256) {
|
||||
*--stackp = tab_suffixof(code);
|
||||
code = tab_prefixof(code);
|
||||
}
|
||||
|
||||
@@ -1000,7 +1000,7 @@ inflate_unzip_internal(STATE_PARAM int in, int out)
|
||||
gunzip_bb = 0;
|
||||
|
||||
/* Create the crc table */
|
||||
gunzip_crc_table = crc32_filltable(0);
|
||||
gunzip_crc_table = crc32_filltable(NULL, 0);
|
||||
gunzip_crc = ~0;
|
||||
|
||||
/* Allocate space for buffer */
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
/* Accept any non-null name, its not really a filter at all */
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
/*
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
/*
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#include <fnmatch.h>
|
||||
#include <stdlib.h>
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
/* Find a string in a shell pattern list */
|
||||
|
||||
@@ -23,9 +23,9 @@ char get_header_ar(archive_handle_t *archive_handle)
|
||||
char magic[2];
|
||||
} formatted;
|
||||
} ar;
|
||||
#ifdef CONFIG_FEATURE_AR_LONG_FILENAMES
|
||||
#if ENABLE_FEATURE_AR_LONG_FILENAMES
|
||||
static char *ar_long_names;
|
||||
static unsigned int ar_long_name_size;
|
||||
static unsigned ar_long_name_size;
|
||||
#endif
|
||||
|
||||
/* dont use xread as we want to handle the error ourself */
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
* Licensed under GPL v2, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
char get_header_tar_lzma(archive_handle_t * archive_handle)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
void header_list(const file_header_t *file_header)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
void header_skip(const file_header_t *file_header ATTRIBUTE_UNUSED)
|
||||
|
||||
@@ -3,11 +3,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
#include "unarchive.h"
|
||||
|
||||
/* transformer(), more than meets the eye */
|
||||
@@ -17,9 +13,7 @@ int open_transformer(int src_fd,
|
||||
int fd_pipe[2];
|
||||
int pid;
|
||||
|
||||
if (pipe(fd_pipe) != 0) {
|
||||
bb_perror_msg_and_die("can't create pipe");
|
||||
}
|
||||
xpipe(fd_pipe);
|
||||
|
||||
pid = fork();
|
||||
if (pid == -1) {
|
||||
|
||||
@@ -3,11 +3,6 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
|
||||
@@ -3,10 +3,8 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
/* If we are reading through a pipe(), or from stdin then we can't lseek,
|
||||
* we must read and discard the data to skip over it.
|
||||
|
||||
@@ -2,11 +2,9 @@
|
||||
/*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "unarchive.h"
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
void unpack_ar_archive(archive_handle_t *ar_archive)
|
||||
{
|
||||
|
||||
+3
-2
@@ -7,7 +7,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#define RPM_HEADER_MAGIC "\216\255\350"
|
||||
@@ -185,7 +185,8 @@ int rpm_main(int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void extract_cpio_gz(int fd) {
|
||||
static void extract_cpio_gz(int fd)
|
||||
{
|
||||
archive_handle_t *archive_handle;
|
||||
unsigned char magic[2];
|
||||
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#define RPM_MAGIC "\355\253\356\333"
|
||||
|
||||
+10
-11
@@ -25,7 +25,7 @@
|
||||
|
||||
#include <fnmatch.h>
|
||||
#include <getopt.h>
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#if ENABLE_FEATURE_TAR_CREATE
|
||||
@@ -440,9 +440,8 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf,
|
||||
/* Is this a regular file? */
|
||||
if (tbInfo->hlInfo == NULL && S_ISREG(statbuf->st_mode)) {
|
||||
/* open the file we want to archive, and make sure all is well */
|
||||
inputFileFd = open(fileName, O_RDONLY);
|
||||
inputFileFd = open_or_warn(fileName, O_RDONLY);
|
||||
if (inputFileFd < 0) {
|
||||
bb_perror_msg("%s: cannot open", fileName);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -455,7 +454,7 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf,
|
||||
/* If it was a regular file, write out the body */
|
||||
if (inputFileFd >= 0) {
|
||||
size_t readSize;
|
||||
/* Wwrite the file to the archive. */
|
||||
/* Write the file to the archive. */
|
||||
/* We record size into header first, */
|
||||
/* and then write out file. If file shrinks in between, */
|
||||
/* tar will be corrupted. So we don't allow for that. */
|
||||
@@ -508,8 +507,8 @@ static int writeTarFile(const int tar_fd, const int verboseFlag,
|
||||
volatile int vfork_exec_errno = 0;
|
||||
const char *zip_exec = (gzip == 1) ? "gzip" : "bzip2";
|
||||
|
||||
if (pipe(gzipDataPipe) < 0 || pipe(gzipStatusPipe) < 0)
|
||||
bb_perror_msg_and_die("pipe");
|
||||
xpipe(gzipDataPipe);
|
||||
xpipe(gzipStatusPipe);
|
||||
|
||||
signal(SIGPIPE, SIG_IGN); /* we only want EPIPE on errors */
|
||||
|
||||
@@ -562,8 +561,9 @@ static int writeTarFile(const int tar_fd, const int verboseFlag,
|
||||
|
||||
/* Read the directory/files and iterate over them one at a time */
|
||||
while (include) {
|
||||
if (!recursive_action(include->data, TRUE, dereferenceFlag,
|
||||
FALSE, writeFileToTarball, writeFileToTarball, &tbInfo, 0))
|
||||
if (!recursive_action(include->data, ACTION_RECURSE |
|
||||
(dereferenceFlag ? ACTION_FOLLOWLINKS : 0),
|
||||
writeFileToTarball, writeFileToTarball, &tbInfo, 0))
|
||||
{
|
||||
errorFlag = TRUE;
|
||||
}
|
||||
@@ -676,7 +676,7 @@ static void handle_SIGCHLD(int status)
|
||||
/* child exited with 0 */
|
||||
return;
|
||||
/* Cannot happen?
|
||||
if(!WIFSIGNALED(status) && !WIFEXITED(status)) return; */
|
||||
if (!WIFSIGNALED(status) && !WIFEXITED(status)) return; */
|
||||
child_error = 1;
|
||||
}
|
||||
#endif
|
||||
@@ -863,10 +863,9 @@ int tar_main(int argc, char **argv)
|
||||
char *cp = last_char_is(argv[optind], '/');
|
||||
if (cp > argv[optind])
|
||||
*cp = '\0';
|
||||
llist_add_to(&tar_handle->accept, argv[optind]);
|
||||
llist_add_to_end(&tar_handle->accept, argv[optind]);
|
||||
optind++;
|
||||
}
|
||||
tar_handle->accept = llist_rev(tar_handle->accept);
|
||||
|
||||
if (tar_handle->accept || tar_handle->reject)
|
||||
tar_handle->filter = filter_accept_reject_list;
|
||||
|
||||
+4
-3
@@ -24,7 +24,7 @@
|
||||
* - central directory
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#define ZIP_FILEHEADER_MAGIC SWAP_LE32(0x04034b50)
|
||||
@@ -134,7 +134,8 @@ int unzip_main(int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 1 : /* The zip file */
|
||||
src_fn = xstrndup(optarg, strlen(optarg)+4);
|
||||
src_fn = xmalloc(strlen(optarg)+4);
|
||||
strcpy(src_fn, optarg);
|
||||
opt_range++;
|
||||
break;
|
||||
|
||||
@@ -195,7 +196,7 @@ int unzip_main(int argc, char **argv)
|
||||
src_fd = open(src_fn, O_RDONLY);
|
||||
}
|
||||
if (src_fd == -1) {
|
||||
src_fn[orig_src_fn_len] = 0;
|
||||
src_fn[orig_src_fn_len] = '\0';
|
||||
bb_error_msg_and_die("cannot open %s, %s.zip, %s.ZIP", src_fn, src_fn, src_fn);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ config SETCONSOLE
|
||||
config FEATURE_SETCONSOLE_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default n
|
||||
depends on SET_CONSOLE && GETOPT_LONG
|
||||
depends on SETCONSOLE && GETOPT_LONG
|
||||
help
|
||||
Support long options for the setconsole applet.
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
/* From <linux/vt.h> */
|
||||
enum {
|
||||
|
||||
@@ -10,10 +10,7 @@
|
||||
|
||||
/* no options, no getopt */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
int clear_main(int argc, char **argv);
|
||||
int clear_main(int argc, char **argv)
|
||||
|
||||
@@ -10,13 +10,13 @@
|
||||
|
||||
/* no options, no getopt */
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
/* From <linux/vt.h> */
|
||||
enum { VT_DISALLOCATE = 0x5608 }; /* free memory associated to vt */
|
||||
|
||||
int deallocvt_main(int argc, char *argv[]);
|
||||
int deallocvt_main(int argc, char *argv[])
|
||||
int deallocvt_main(int argc, char **argv);
|
||||
int deallocvt_main(int argc, char **argv)
|
||||
{
|
||||
/* num = 0 deallocate all unused consoles */
|
||||
int num = 0;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
/* From <linux/kd.h> */
|
||||
struct kbentry {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Loads the console font, and possibly the corresponding screen map(s).
|
||||
* (Adapted for busybox by Matej Vela.)
|
||||
*/
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
#include <sys/kd.h>
|
||||
|
||||
enum {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
#define BINARY_KEYMAP_MAGIC "bkeymap"
|
||||
|
||||
|
||||
+12
-20
@@ -10,34 +10,26 @@
|
||||
|
||||
/* getopt not needed */
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
int openvt_main(int argc, char **argv);
|
||||
int openvt_main(int argc, char **argv)
|
||||
{
|
||||
int fd;
|
||||
char vtname[sizeof(VC_FORMAT) + 2];
|
||||
|
||||
if (argc < 3) {
|
||||
if (argc < 3)
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
/* check for illegal vt number: < 1 or > 63 */
|
||||
sprintf(vtname, VC_FORMAT, (int)xatoul_range(argv[1], 1, 63));
|
||||
sprintf(vtname, VC_FORMAT, (int)xatou_range(argv[1], 1, 63));
|
||||
|
||||
if (fork() == 0) {
|
||||
/* child */
|
||||
/* leave current vt (controlling tty) */
|
||||
setsid();
|
||||
/* and grab new one */
|
||||
fd = xopen(vtname, O_RDWR);
|
||||
/* Reassign stdin, stdout and sterr */
|
||||
dup2(fd, STDIN_FILENO);
|
||||
dup2(fd, STDOUT_FILENO);
|
||||
dup2(fd, STDERR_FILENO);
|
||||
while (fd > 2) close(fd--);
|
||||
bb_daemonize_or_rexec(DAEMON_CLOSE_EXTRA_FDS, argv);
|
||||
/* grab new one */
|
||||
close(0);
|
||||
xopen(vtname, O_RDWR);
|
||||
dup2(0, STDOUT_FILENO);
|
||||
dup2(0, STDERR_FILENO);
|
||||
|
||||
BB_EXECVP(argv[2], &argv[2]);
|
||||
_exit(1);
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
BB_EXECVP(argv[2], &argv[2]);
|
||||
_exit(1);
|
||||
}
|
||||
@@ -10,10 +10,7 @@
|
||||
|
||||
/* no options, no getopt */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
int reset_main(int argc, char **argv);
|
||||
int reset_main(int argc, char **argv)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
/* no options, no getopt */
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
#define ESC "\033"
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <getopt.h>
|
||||
#include "libbb.h"
|
||||
|
||||
#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
|
||||
static const struct option setconsole_long_options[] = {
|
||||
|
||||
@@ -9,9 +9,8 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
//#include <sys/ioctl.h>
|
||||
#include "libbb.h"
|
||||
|
||||
/* From <linux/kd.h> */
|
||||
struct kbkeycode {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
int setlogcons_main(int argc, char **argv);
|
||||
int setlogcons_main(int argc, char **argv)
|
||||
|
||||
@@ -536,6 +536,21 @@ config FEATURE_SORT_BIG
|
||||
The SuSv3 sort standard is available at:
|
||||
http://www.opengroup.org/onlinepubs/007904975/utilities/sort.html
|
||||
|
||||
config SPLIT
|
||||
bool "split"
|
||||
default n
|
||||
help
|
||||
split a file into pieces.
|
||||
|
||||
config FEATURE_SPLIT_FANCY
|
||||
bool "fancy extensions"
|
||||
default n
|
||||
depends on SPLIT
|
||||
help
|
||||
Add support for features not required by SUSv3.
|
||||
Supports additional suffixes 'b' for 512 bytes,
|
||||
'g' for 1GiB for the -b option.
|
||||
|
||||
config STAT
|
||||
bool "stat"
|
||||
default n
|
||||
|
||||
@@ -60,6 +60,7 @@ lib-$(CONFIG_RMDIR) += rmdir.o
|
||||
lib-$(CONFIG_SEQ) += seq.o
|
||||
lib-$(CONFIG_SHA1SUM) += md5_sha1_sum.o
|
||||
lib-$(CONFIG_SLEEP) += sleep.o
|
||||
lib-$(CONFIG_SPLIT) += split.o
|
||||
lib-$(CONFIG_SORT) += sort.o
|
||||
lib-$(CONFIG_STAT) += stat.o
|
||||
lib-$(CONFIG_STTY) += stty.o
|
||||
|
||||
@@ -20,10 +20,9 @@
|
||||
* 3) Save some space by using strcmp(). Calling strncmp() here was silly.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
/* This is a NOFORK applet. Be very careful! */
|
||||
|
||||
int basename_main(int argc, char **argv);
|
||||
int basename_main(int argc, char **argv)
|
||||
@@ -47,5 +46,5 @@ int basename_main(int argc, char **argv)
|
||||
|
||||
puts(s);
|
||||
|
||||
fflush_stdout_and_exit(EXIT_SUCCESS);
|
||||
return fflush(stdout);
|
||||
}
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
* Major size reduction... over 50% (>1.5k) on i386.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
#define THURSDAY 4 /* for reformation */
|
||||
#define SATURDAY 6 /* 1 Jan 1 was a Saturday */
|
||||
|
||||
+16
-7
@@ -10,21 +10,30 @@
|
||||
/* BB_AUDIT SUSv3 compliant */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/cat.html */
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
/* This is a NOFORK applet. Be very careful! */
|
||||
|
||||
|
||||
int bb_cat(char **argv)
|
||||
{
|
||||
static const char *const argv_dash[] = { "-", NULL };
|
||||
FILE *f;
|
||||
|
||||
int fd;
|
||||
int retval = EXIT_SUCCESS;
|
||||
|
||||
if (!*argv) argv = (char**) &argv_dash;
|
||||
if (!*argv)
|
||||
argv = (char**) &argv_dash;
|
||||
|
||||
do {
|
||||
f = fopen_or_warn_stdin(*argv);
|
||||
if (f) {
|
||||
off_t r = bb_copyfd_eof(fileno(f), STDOUT_FILENO);
|
||||
fclose_if_not_stdin(f);
|
||||
fd = STDIN_FILENO;
|
||||
if (!LONE_DASH(*argv))
|
||||
fd = open_or_warn(*argv, O_RDONLY);
|
||||
if (fd >= 0) {
|
||||
/* This is not an xfunc - never exits */
|
||||
off_t r = bb_copyfd_eof(fd, STDOUT_FILENO);
|
||||
if (fd != STDIN_FILENO)
|
||||
close(fd);
|
||||
if (r >= 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
/* See "Cat -v considered harmful" at
|
||||
* http://cm.bell-labs.com/cm/cs/doc/84/kp.ps.gz */
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
int catv_main(int argc, char **argv);
|
||||
int catv_main(int argc, char **argv)
|
||||
|
||||
+4
-1
@@ -11,7 +11,10 @@
|
||||
/* BB_AUDIT GNU defects - unsupported long options. */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/chgrp.html */
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
/* This is a NOEXEC applet. Be very careful! */
|
||||
|
||||
|
||||
int chgrp_main(int argc, char **argv);
|
||||
int chgrp_main(int argc, char **argv)
|
||||
|
||||
+4
-3
@@ -14,7 +14,10 @@
|
||||
/* BB_AUDIT GNU defects - unsupported long options. */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/chmod.html */
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
/* This is a NOEXEC applet. Be very careful! */
|
||||
|
||||
|
||||
#define OPT_RECURSE (option_mask32 & 1)
|
||||
#define OPT_VERBOSE (USE_DESKTOP(option_mask32 & 2) SKIP_DESKTOP(0))
|
||||
@@ -101,8 +104,6 @@ int chmod_main(int argc, char **argv)
|
||||
do {
|
||||
if (!recursive_action(*argv,
|
||||
OPT_RECURSE, // recurse
|
||||
FALSE, // follow links: coreutils doesn't
|
||||
FALSE, // depth first
|
||||
fileAction, // file action
|
||||
fileAction, // dir action
|
||||
smode, // user data
|
||||
|
||||
+10
-8
@@ -11,7 +11,10 @@
|
||||
/* BB_AUDIT GNU defects - unsupported long options. */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/chown.html */
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
/* This is a NOEXEC applet. Be very careful! */
|
||||
|
||||
|
||||
#define OPT_STR ("Rh" USE_DESKTOP("vcfLHP"))
|
||||
#define BIT_RECURSE 1
|
||||
@@ -92,13 +95,12 @@ int chown_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (!recursive_action(arg,
|
||||
OPT_RECURSE, // recurse
|
||||
OPT_TRAVERSE, // follow links if -L
|
||||
FALSE, // depth first
|
||||
fileAction, // file action
|
||||
fileAction, // dir action
|
||||
chown_func, // user data
|
||||
0) // depth
|
||||
(OPT_RECURSE ? ACTION_RECURSE : 0) | /* recurse */
|
||||
(OPT_TRAVERSE ? ACTION_FOLLOWLINKS : 0),/* follow links if -L */
|
||||
fileAction, /* file action */
|
||||
fileAction, /* dir action */
|
||||
chown_func, /* user data */
|
||||
0) /* depth */
|
||||
) {
|
||||
retval = EXIT_FAILURE;
|
||||
}
|
||||
|
||||
+4
-3
@@ -9,7 +9,7 @@
|
||||
|
||||
/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
int chroot_main(int argc, char **argv);
|
||||
int chroot_main(int argc, char **argv)
|
||||
@@ -27,8 +27,9 @@ int chroot_main(int argc, char **argv)
|
||||
++argv;
|
||||
if (argc == 2) {
|
||||
argv -= 2;
|
||||
if (!(*argv = getenv("SHELL"))) {
|
||||
*argv = (char *) DEFAULT_SHELL;
|
||||
argv[0] = getenv("SHELL");
|
||||
if (!argv[0]) {
|
||||
argv[0] = (char *) DEFAULT_SHELL;
|
||||
}
|
||||
argv[1] = (char *) "-i";
|
||||
}
|
||||
|
||||
+2
-3
@@ -6,13 +6,12 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
int cksum_main(int argc, char **argv);
|
||||
int cksum_main(int argc, char **argv)
|
||||
{
|
||||
|
||||
uint32_t *crc32_table = crc32_filltable(1);
|
||||
uint32_t *crc32_table = crc32_filltable(NULL, 1);
|
||||
|
||||
FILE *fp;
|
||||
uint32_t crc;
|
||||
|
||||
+3
-3
@@ -21,16 +21,16 @@
|
||||
* in the '-l' case.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
static FILE *cmp_xfopen_input(const char * const filename)
|
||||
static FILE *cmp_xfopen_input(const char *filename)
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
fp = fopen_or_warn_stdin(filename);
|
||||
if (fp)
|
||||
return fp;
|
||||
exit(xfunc_error_retval); /* We already output an error message. */
|
||||
xfunc_die(); /* We already output an error message. */
|
||||
}
|
||||
|
||||
static const char fmt_eof[] = "cmp: EOF on %s\n";
|
||||
|
||||
+31
-45
@@ -7,43 +7,36 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
#define COMM_OPT_1 0x01
|
||||
#define COMM_OPT_2 0x02
|
||||
#define COMM_OPT_3 0x04
|
||||
|
||||
/* These three variables control behaviour if non-zero */
|
||||
|
||||
static int only_file_1;
|
||||
static int only_file_2;
|
||||
static int both;
|
||||
#define COMM_OPT_1 (1 << 0)
|
||||
#define COMM_OPT_2 (1 << 1)
|
||||
#define COMM_OPT_3 (1 << 2)
|
||||
|
||||
/* writeline outputs the input given, appropriately aligned according to class */
|
||||
static void writeline(char *line, int class)
|
||||
static void writeline(char *line, int class, int flags)
|
||||
{
|
||||
if (class == 0) {
|
||||
if (!only_file_1)
|
||||
if (flags & COMM_OPT_1)
|
||||
return;
|
||||
} else if (class == 1) {
|
||||
if (!only_file_2)
|
||||
if (flags & COMM_OPT_2)
|
||||
return;
|
||||
if (only_file_1)
|
||||
if (!(flags & COMM_OPT_1))
|
||||
putchar('\t');
|
||||
}
|
||||
else /*if (class == 2)*/ {
|
||||
if (!both)
|
||||
} else /*if (class == 2)*/ {
|
||||
if (flags & COMM_OPT_3)
|
||||
return;
|
||||
if (only_file_1)
|
||||
if (!(flags & COMM_OPT_1))
|
||||
putchar('\t');
|
||||
if (only_file_2)
|
||||
if (!(flags & COMM_OPT_2))
|
||||
putchar('\t');
|
||||
}
|
||||
fputs(line, stdout);
|
||||
}
|
||||
|
||||
/* This is the real core of the program - lines are compared here */
|
||||
static void cmp_files(char **infiles)
|
||||
int comm_main(int argc, char **argv);
|
||||
int comm_main(int argc, char **argv)
|
||||
{
|
||||
#define LINE_LEN 100
|
||||
#define BB_EOF_0 0x1
|
||||
@@ -51,12 +44,19 @@ static void cmp_files(char **infiles)
|
||||
char thisline[2][LINE_LEN];
|
||||
FILE *streams[2];
|
||||
int i;
|
||||
unsigned flags;
|
||||
|
||||
opt_complementary = "=2";
|
||||
flags = getopt32(argc, argv, "123");
|
||||
argv += optind;
|
||||
|
||||
for (i = 0; i < 2; ++i) {
|
||||
streams[i] = ((infiles[i][0] == '=' && infiles[i][1]) ? stdin : xfopen(infiles[i], "r"));
|
||||
streams[i] = (argv[i][0] == '-' && !argv[i][1]) ? stdin : xfopen(argv[i], "r");
|
||||
fgets(thisline[i], LINE_LEN, streams[i]);
|
||||
}
|
||||
|
||||
/* This is the real core of the program - lines are compared here */
|
||||
|
||||
while (*thisline[0] || *thisline[1]) {
|
||||
int order = 0;
|
||||
|
||||
@@ -78,11 +78,11 @@ static void cmp_files(char **infiles)
|
||||
}
|
||||
|
||||
if (order == 0 && !i)
|
||||
writeline(thisline[1], 2);
|
||||
writeline(thisline[1], 2, flags);
|
||||
else if (order > 0 && !(i & BB_EOF_1))
|
||||
writeline(thisline[1], 1);
|
||||
writeline(thisline[1], 1, flags);
|
||||
else if (order < 0 && !(i & BB_EOF_0))
|
||||
writeline(thisline[0], 0);
|
||||
writeline(thisline[0], 0, flags);
|
||||
|
||||
if (i & BB_EOF_0 & BB_EOF_1) {
|
||||
break;
|
||||
@@ -91,7 +91,7 @@ static void cmp_files(char **infiles)
|
||||
i = (i & BB_EOF_0 ? 1 : 0);
|
||||
while (!feof(streams[i])) {
|
||||
if ((order < 0 && i) || (order > 0 && !i))
|
||||
writeline(thisline[i], i);
|
||||
writeline(thisline[i], i, flags);
|
||||
fgets(thisline[i], LINE_LEN, streams[i]);
|
||||
}
|
||||
break;
|
||||
@@ -104,24 +104,10 @@ static void cmp_files(char **infiles)
|
||||
}
|
||||
}
|
||||
|
||||
fclose(streams[0]);
|
||||
fclose(streams[1]);
|
||||
}
|
||||
if (ENABLE_FEATURE_CLEAN_UP) {
|
||||
fclose(streams[0]);
|
||||
fclose(streams[1]);
|
||||
}
|
||||
|
||||
int comm_main(int argc, char **argv);
|
||||
int comm_main(int argc, char **argv)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
flags = getopt32(argc, argv, "123");
|
||||
|
||||
if (optind + 2 != argc)
|
||||
bb_show_usage();
|
||||
|
||||
only_file_1 = !(flags & COMM_OPT_1);
|
||||
only_file_2 = !(flags & COMM_OPT_2);
|
||||
both = !(flags & COMM_OPT_3);
|
||||
|
||||
cmp_files(argv + optind);
|
||||
exit(EXIT_SUCCESS);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+4
-1
@@ -15,9 +15,12 @@
|
||||
* Size reduction.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
#include "libcoreutils/coreutils.h"
|
||||
|
||||
/* This is a NOEXEC applet. Be very careful! */
|
||||
|
||||
|
||||
int cp_main(int argc, char **argv);
|
||||
int cp_main(int argc, char **argv)
|
||||
{
|
||||
|
||||
+4
-1
@@ -9,7 +9,10 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
/* This is a NOEXEC applet. Be very careful! */
|
||||
|
||||
|
||||
/* option vars */
|
||||
static const char optstring[] = "b:c:f:d:sn";
|
||||
|
||||
+10
-16
@@ -10,7 +10,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
/* This 'date' command supports only 2 time setting formats,
|
||||
all the GNU strftime stuff (its in libc, lets use it),
|
||||
@@ -32,16 +32,10 @@
|
||||
#define DATE_OPT_TIMESPEC 0x20
|
||||
#define DATE_OPT_HINT 0x40
|
||||
|
||||
static void xputenv(char *s)
|
||||
{
|
||||
if (putenv(s) != 0)
|
||||
bb_error_msg_and_die(bb_msg_memory_exhausted);
|
||||
}
|
||||
|
||||
static void maybe_set_utc(int opt)
|
||||
{
|
||||
if (opt & DATE_OPT_UTC)
|
||||
xputenv((char*)"TZ=UTC0");
|
||||
putenv((char*)"TZ=UTC0");
|
||||
}
|
||||
|
||||
int date_main(int argc, char **argv);
|
||||
@@ -69,15 +63,15 @@ int date_main(int argc, char **argv)
|
||||
if (!isofmt_arg) {
|
||||
ifmt = 0; /* default is date */
|
||||
} else {
|
||||
const char * const isoformats[] =
|
||||
{"date", "hours", "minutes", "seconds"};
|
||||
static const char * const isoformats[] =
|
||||
{ "date", "hours", "minutes", "seconds" };
|
||||
|
||||
for (ifmt = 0; ifmt < 4; ifmt++)
|
||||
if (!strcmp(isofmt_arg, isoformats[ifmt])) {
|
||||
break;
|
||||
}
|
||||
if (ifmt == 4) /* parse error */
|
||||
bb_show_usage();
|
||||
if (!strcmp(isofmt_arg, isoformats[ifmt]))
|
||||
goto found;
|
||||
/* parse error */
|
||||
bb_show_usage();
|
||||
found: ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,7 +201,7 @@ int date_main(int argc, char **argv)
|
||||
date_fmt[i++] = '%';
|
||||
date_fmt[i++] = 'S';
|
||||
}
|
||||
format_utc:
|
||||
format_utc:
|
||||
date_fmt[i++] = '%';
|
||||
date_fmt[i] = (opt & DATE_OPT_UTC) ? 'Z' : 'z';
|
||||
}
|
||||
|
||||
+151
-87
@@ -8,8 +8,11 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <signal.h> /* For FEATURE_DD_SIGNAL_HANDLING */
|
||||
#include "libbb.h"
|
||||
|
||||
/* This is a NOEXEC applet. Be very careful! */
|
||||
|
||||
|
||||
static const struct suffix_mult dd_suffixes[] = {
|
||||
{ "c", 1 },
|
||||
@@ -17,7 +20,7 @@ static const struct suffix_mult dd_suffixes[] = {
|
||||
{ "b", 512 },
|
||||
{ "kD", 1000 },
|
||||
{ "k", 1024 },
|
||||
{ "K", 1024 }, // compat with coreutils dd
|
||||
{ "K", 1024 }, /* compat with coreutils dd */
|
||||
{ "MD", 1000000 },
|
||||
{ "M", 1048576 },
|
||||
{ "GD", 1000000000 },
|
||||
@@ -25,18 +28,21 @@ static const struct suffix_mult dd_suffixes[] = {
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
static off_t out_full, out_part, in_full, in_part;
|
||||
struct globals {
|
||||
off_t out_full, out_part, in_full, in_part;
|
||||
};
|
||||
#define G (*(struct globals*)&bb_common_bufsiz1)
|
||||
|
||||
static void dd_output_status(int ATTRIBUTE_UNUSED cur_signal)
|
||||
{
|
||||
fprintf(stderr, "%"OFF_FMT"d+%"OFF_FMT"d records in\n"
|
||||
"%"OFF_FMT"d+%"OFF_FMT"d records out\n",
|
||||
in_full, in_part,
|
||||
out_full, out_part);
|
||||
G.in_full, G.in_part,
|
||||
G.out_full, G.out_part);
|
||||
}
|
||||
|
||||
static ssize_t full_write_or_warn(int fd, const void *buf, size_t len,
|
||||
const char* filename)
|
||||
const char * const filename)
|
||||
{
|
||||
ssize_t n = full_write(fd, buf, len);
|
||||
if (n < 0)
|
||||
@@ -44,6 +50,19 @@ static ssize_t full_write_or_warn(int fd, const void *buf, size_t len,
|
||||
return n;
|
||||
}
|
||||
|
||||
static bool write_and_stats(int fd, const void *buf, size_t len, size_t obs,
|
||||
const char * const filename)
|
||||
{
|
||||
ssize_t n = full_write_or_warn(fd, buf, len, filename);
|
||||
if (n < 0)
|
||||
return 1;
|
||||
if (n == obs)
|
||||
G.out_full++;
|
||||
else if (n) /* > 0 */
|
||||
G.out_part++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if ENABLE_LFS
|
||||
#define XATOU_SFX xatoull_sfx
|
||||
#else
|
||||
@@ -54,19 +73,44 @@ int dd_main(int argc, char **argv);
|
||||
int dd_main(int argc, char **argv)
|
||||
{
|
||||
enum {
|
||||
sync_flag = 1 << 0,
|
||||
noerror = 1 << 1,
|
||||
trunc_flag = 1 << 2,
|
||||
twobufs_flag = 1 << 3,
|
||||
SYNC_FLAG = 1 << 0,
|
||||
NOERROR = 1 << 1,
|
||||
TRUNC_FLAG = 1 << 2,
|
||||
TWOBUFS_FLAG = 1 << 3,
|
||||
};
|
||||
int flags = trunc_flag;
|
||||
static const char * const keywords[] = {
|
||||
"bs=", "count=", "seek=", "skip=", "if=", "of=",
|
||||
#if ENABLE_FEATURE_DD_IBS_OBS
|
||||
"ibs=", "obs=", "conv=", "notrunc", "sync", "noerror",
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
enum {
|
||||
OP_bs = 1,
|
||||
OP_count,
|
||||
OP_seek,
|
||||
OP_skip,
|
||||
OP_if,
|
||||
OP_of,
|
||||
#if ENABLE_FEATURE_DD_IBS_OBS
|
||||
OP_ibs,
|
||||
OP_obs,
|
||||
OP_conv,
|
||||
OP_conv_notrunc,
|
||||
OP_conv_sync,
|
||||
OP_conv_noerror,
|
||||
#endif
|
||||
};
|
||||
int flags = TRUNC_FLAG;
|
||||
size_t oc = 0, ibs = 512, obs = 512;
|
||||
ssize_t n, w;
|
||||
off_t seek = 0, skip = 0, count = OFF_T_MAX;
|
||||
int oflag, ifd, ofd;
|
||||
int ifd, ofd;
|
||||
const char *infile = NULL, *outfile = NULL;
|
||||
char *ibuf, *obuf;
|
||||
|
||||
memset(&G, 0, sizeof(G)); /* because of NOEXEC */
|
||||
|
||||
if (ENABLE_FEATURE_DD_SIGNAL_HANDLING) {
|
||||
struct sigaction sa;
|
||||
|
||||
@@ -78,70 +122,104 @@ int dd_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
for (n = 1; n < argc; n++) {
|
||||
smalluint key_len;
|
||||
smalluint what;
|
||||
char *key;
|
||||
char *arg = argv[n];
|
||||
/* Must fit into positive ssize_t */
|
||||
if (ENABLE_FEATURE_DD_IBS_OBS && !strncmp("ibs=", arg, 4))
|
||||
ibs = xatoul_range_sfx(arg+4, 0, ((size_t)-1L)/2, dd_suffixes);
|
||||
else if (ENABLE_FEATURE_DD_IBS_OBS && !strncmp("obs=", arg, 4))
|
||||
obs = xatoul_range_sfx(arg+4, 0, ((size_t)-1L)/2, dd_suffixes);
|
||||
else if (!strncmp("bs=", arg, 3))
|
||||
ibs = obs = xatoul_range_sfx(arg+3, 0, ((size_t)-1L)/2, dd_suffixes);
|
||||
/* These can be large: */
|
||||
else if (!strncmp("count=", arg, 6))
|
||||
count = XATOU_SFX(arg+6, dd_suffixes);
|
||||
else if (!strncmp("seek=", arg, 5))
|
||||
seek = XATOU_SFX(arg+5, dd_suffixes);
|
||||
else if (!strncmp("skip=", arg, 5))
|
||||
skip = XATOU_SFX(arg+5, dd_suffixes);
|
||||
|
||||
else if (!strncmp("if=", arg, 3))
|
||||
infile = arg+3;
|
||||
else if (!strncmp("of=", arg, 3))
|
||||
outfile = arg+3;
|
||||
else if (ENABLE_FEATURE_DD_IBS_OBS && !strncmp("conv=", arg, 5)) {
|
||||
arg += 5;
|
||||
while (1) {
|
||||
if (!strncmp("notrunc", arg, 7)) {
|
||||
flags &= ~trunc_flag;
|
||||
arg += 7;
|
||||
} else if (!strncmp("sync", arg, 4)) {
|
||||
flags |= sync_flag;
|
||||
arg += 4;
|
||||
} else if (!strncmp("noerror", arg, 7)) {
|
||||
flags |= noerror;
|
||||
arg += 7;
|
||||
} else {
|
||||
bb_error_msg_and_die(bb_msg_invalid_arg, arg, "conv");
|
||||
}
|
||||
if (arg[0] == '\0') break;
|
||||
if (*arg++ != ',') bb_show_usage();
|
||||
}
|
||||
} else
|
||||
//XXX:FIXME: we reject plain "dd --" This would cost ~20 bytes, so..
|
||||
//if (*arg == '-' && *++arg == '-' && !*++arg) continue;
|
||||
key = strstr(arg, "=");
|
||||
if (key == NULL)
|
||||
bb_show_usage();
|
||||
key_len = key - arg + 1;
|
||||
key = xstrndup(arg, key_len);
|
||||
what = index_in_str_array(keywords, key) + 1;
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
free(key);
|
||||
if (what == 0)
|
||||
bb_show_usage();
|
||||
arg += key_len;
|
||||
/* Must fit into positive ssize_t */
|
||||
#if ENABLE_FEATURE_DD_IBS_OBS
|
||||
if (what == OP_ibs) {
|
||||
ibs = xatoul_range_sfx(arg, 1, ((size_t)-1L)/2, dd_suffixes);
|
||||
continue;
|
||||
}
|
||||
if (what == OP_obs) {
|
||||
obs = xatoul_range_sfx(arg, 1, ((size_t)-1L)/2, dd_suffixes);
|
||||
continue;
|
||||
}
|
||||
if (what == OP_conv) {
|
||||
while (1) {
|
||||
/* find ',', replace them with nil so we can use arg for
|
||||
* index_in_str_array without copying.
|
||||
* We rely on arg being non-null, else strchr would fault.
|
||||
*/
|
||||
key = strchr(arg, ',');
|
||||
if (key)
|
||||
*key = '\0';
|
||||
what = index_in_str_array(keywords, arg) + 1;
|
||||
if (what < OP_conv_notrunc)
|
||||
bb_error_msg_and_die(bb_msg_invalid_arg, arg, "conv");
|
||||
if (what == OP_conv_notrunc)
|
||||
flags &= ~TRUNC_FLAG;
|
||||
if (what == OP_conv_sync)
|
||||
flags |= SYNC_FLAG;
|
||||
if (what == OP_conv_noerror)
|
||||
flags |= NOERROR;
|
||||
if (!key) /* no ',' left, so this was the last specifier */
|
||||
break;
|
||||
arg = key + 1; /* skip this keyword and ',' */
|
||||
}
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if (what == OP_bs) {
|
||||
ibs = obs = xatoul_range_sfx(arg, 1, ((size_t)-1L)/2, dd_suffixes);
|
||||
continue;
|
||||
}
|
||||
/* These can be large: */
|
||||
if (what == OP_count) {
|
||||
count = XATOU_SFX(arg, dd_suffixes);
|
||||
continue;
|
||||
}
|
||||
if (what == OP_seek) {
|
||||
seek = XATOU_SFX(arg, dd_suffixes);
|
||||
continue;
|
||||
}
|
||||
if (what == OP_skip) {
|
||||
skip = XATOU_SFX(arg, dd_suffixes);
|
||||
continue;
|
||||
}
|
||||
if (what == OP_if) {
|
||||
infile = arg;
|
||||
continue;
|
||||
}
|
||||
if (what == OP_of)
|
||||
outfile = arg;
|
||||
}
|
||||
|
||||
//XXX:FIXME for huge ibs or obs, malloc'ing them isn't the brightest idea ever
|
||||
ibuf = obuf = xmalloc(ibs);
|
||||
if (ibs != obs) {
|
||||
flags |= twobufs_flag;
|
||||
flags |= TWOBUFS_FLAG;
|
||||
obuf = xmalloc(obs);
|
||||
}
|
||||
|
||||
if (infile != NULL)
|
||||
ifd = xopen(infile, O_RDONLY);
|
||||
else {
|
||||
ifd = STDIN_FILENO;
|
||||
infile = bb_msg_standard_input;
|
||||
}
|
||||
|
||||
if (outfile != NULL) {
|
||||
oflag = O_WRONLY | O_CREAT;
|
||||
int oflag = O_WRONLY | O_CREAT;
|
||||
|
||||
if (!seek && (flags & trunc_flag))
|
||||
if (!seek && (flags & TRUNC_FLAG))
|
||||
oflag |= O_TRUNC;
|
||||
|
||||
ofd = xopen(outfile, oflag);
|
||||
|
||||
if (seek && (flags & trunc_flag)) {
|
||||
if (seek && (flags & TRUNC_FLAG)) {
|
||||
if (ftruncate(ofd, seek * obs) < 0) {
|
||||
struct stat st;
|
||||
|
||||
@@ -154,50 +232,45 @@ int dd_main(int argc, char **argv)
|
||||
ofd = STDOUT_FILENO;
|
||||
outfile = bb_msg_standard_output;
|
||||
}
|
||||
|
||||
if (skip) {
|
||||
if (lseek(ifd, skip * ibs, SEEK_CUR) < 0) {
|
||||
while (skip-- > 0) {
|
||||
n = safe_read(ifd, ibuf, ibs);
|
||||
if (n < 0)
|
||||
bb_perror_msg_and_die("%s", infile);
|
||||
goto die_infile;
|
||||
if (n == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (seek) {
|
||||
if (lseek(ofd, seek * obs, SEEK_CUR) < 0)
|
||||
goto die_outfile;
|
||||
}
|
||||
|
||||
while (in_full + in_part != count) {
|
||||
if (flags & noerror) {
|
||||
/* Pre-zero the buffer when doing the noerror thing */
|
||||
while (G.in_full + G.in_part != count) {
|
||||
if (flags & NOERROR) /* Pre-zero the buffer when for NOERROR */
|
||||
memset(ibuf, '\0', ibs);
|
||||
}
|
||||
|
||||
n = safe_read(ifd, ibuf, ibs);
|
||||
if (n == 0)
|
||||
break;
|
||||
if (n < 0) {
|
||||
if (flags & noerror) {
|
||||
if (flags & NOERROR) {
|
||||
n = ibs;
|
||||
bb_perror_msg("%s", infile);
|
||||
} else
|
||||
bb_perror_msg_and_die("%s", infile);
|
||||
goto die_infile;
|
||||
}
|
||||
if ((size_t)n == ibs)
|
||||
in_full++;
|
||||
G.in_full++;
|
||||
else {
|
||||
in_part++;
|
||||
if (flags & sync_flag) {
|
||||
G.in_part++;
|
||||
if (flags & SYNC_FLAG) {
|
||||
memset(ibuf + n, '\0', ibs - n);
|
||||
n = ibs;
|
||||
}
|
||||
}
|
||||
if (flags & twobufs_flag) {
|
||||
if (flags & TWOBUFS_FLAG) {
|
||||
char *tmp = ibuf;
|
||||
while (n) {
|
||||
size_t d = obs - oc;
|
||||
@@ -209,40 +282,31 @@ int dd_main(int argc, char **argv)
|
||||
tmp += d;
|
||||
oc += d;
|
||||
if (oc == obs) {
|
||||
w = full_write_or_warn(ofd, obuf, obs, outfile);
|
||||
if (w < 0) goto out_status;
|
||||
if (w == obs)
|
||||
out_full++;
|
||||
else if (w > 0)
|
||||
out_part++;
|
||||
if (write_and_stats(ofd, obuf, obs, obs, outfile))
|
||||
goto out_status;
|
||||
oc = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
w = full_write_or_warn(ofd, ibuf, n, outfile);
|
||||
if (w < 0) goto out_status;
|
||||
if (w == obs)
|
||||
out_full++;
|
||||
else if (w > 0)
|
||||
out_part++;
|
||||
}
|
||||
} else if (write_and_stats(ofd, ibuf, n, obs, outfile))
|
||||
goto out_status;
|
||||
}
|
||||
|
||||
if (ENABLE_FEATURE_DD_IBS_OBS && oc) {
|
||||
w = full_write_or_warn(ofd, obuf, oc, outfile);
|
||||
if (w < 0) goto out_status;
|
||||
if (w > 0)
|
||||
out_part++;
|
||||
G.out_part++;
|
||||
}
|
||||
if (close(ifd) < 0) {
|
||||
die_infile:
|
||||
bb_perror_msg_and_die("%s", infile);
|
||||
}
|
||||
|
||||
if (close(ofd) < 0) {
|
||||
die_outfile:
|
||||
die_outfile:
|
||||
bb_perror_msg_and_die("%s", outfile);
|
||||
}
|
||||
out_status:
|
||||
out_status:
|
||||
dd_output_status(0);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
+1
-5
@@ -18,13 +18,9 @@
|
||||
* the command line. Properly round *-blocks, Used, and Available quantities.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <mntent.h>
|
||||
#include <sys/vfs.h>
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
#ifndef CONFIG_FEATURE_HUMAN_READABLE
|
||||
static long kscale(long b, long bs)
|
||||
|
||||
+22
-12
@@ -12,7 +12,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
#define FSIZE_MAX 32768
|
||||
|
||||
@@ -997,24 +997,30 @@ static void do_diff(char *dir1, char *path1, char *dir2, char *path2)
|
||||
{
|
||||
int flags = D_HEADER;
|
||||
int val;
|
||||
char *fullpath1 = NULL; /* if -N */
|
||||
char *fullpath2 = NULL;
|
||||
|
||||
char *fullpath1 = concat_path_file(dir1, path1);
|
||||
char *fullpath2 = concat_path_file(dir2, path2);
|
||||
if (path1)
|
||||
fullpath1 = concat_path_file(dir1, path1);
|
||||
if (path2)
|
||||
fullpath2 = concat_path_file(dir2, path2);
|
||||
|
||||
if (stat(fullpath1, &stb1) != 0) {
|
||||
if (!fullpath1 || stat(fullpath1, &stb1) != 0) {
|
||||
flags |= D_EMPTY1;
|
||||
memset(&stb1, 0, sizeof(stb1));
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
if (path2) {
|
||||
free(fullpath1);
|
||||
fullpath1 = concat_path_file(dir1, path2);
|
||||
fullpath1 = concat_path_file(dir1, path2);
|
||||
}
|
||||
}
|
||||
if (stat(fullpath2, &stb2) != 0) {
|
||||
if (!fullpath2 || stat(fullpath2, &stb2) != 0) {
|
||||
flags |= D_EMPTY2;
|
||||
memset(&stb2, 0, sizeof(stb2));
|
||||
stb2.st_mode = stb1.st_mode;
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
if (path1) {
|
||||
free(fullpath2);
|
||||
fullpath2 = concat_path_file(dir2, path1);
|
||||
fullpath2 = concat_path_file(dir2, path1);
|
||||
}
|
||||
}
|
||||
|
||||
if (stb1.st_mode == 0)
|
||||
@@ -1022,7 +1028,7 @@ static void do_diff(char *dir1, char *path1, char *dir2, char *path2)
|
||||
|
||||
if (S_ISDIR(stb1.st_mode) && S_ISDIR(stb2.st_mode)) {
|
||||
printf("Common subdirectories: %s and %s\n", fullpath1, fullpath2);
|
||||
return;
|
||||
goto ret;
|
||||
}
|
||||
|
||||
if (!S_ISREG(stb1.st_mode) && !S_ISDIR(stb1.st_mode))
|
||||
@@ -1033,6 +1039,9 @@ static void do_diff(char *dir1, char *path1, char *dir2, char *path2)
|
||||
val = diffreg(fullpath1, fullpath2, flags);
|
||||
|
||||
print_status(val, fullpath1, fullpath2, NULL);
|
||||
ret:
|
||||
free(fullpath1);
|
||||
free(fullpath2);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1061,7 +1070,7 @@ static int add_to_dirlist(const char *filename,
|
||||
static char **get_dir(char *path)
|
||||
{
|
||||
dl_count = 0;
|
||||
dl = NULL;
|
||||
dl = xzalloc(sizeof(dl[0]));
|
||||
|
||||
/* If -r has been set, then the recursive_action function will be
|
||||
* used. Unfortunately, this outputs the root directory along with
|
||||
@@ -1070,7 +1079,8 @@ static char **get_dir(char *path)
|
||||
* add_to_dirlist then removes root dir prefix. */
|
||||
|
||||
if (option_mask32 & FLAG_r) {
|
||||
recursive_action(path, TRUE, TRUE, FALSE, add_to_dirlist, NULL,
|
||||
recursive_action(path, ACTION_RECURSE|ACTION_FOLLOWLINKS,
|
||||
add_to_dirlist, NULL,
|
||||
(void*)(strlen(path)+1), 0);
|
||||
} else {
|
||||
DIR *dp;
|
||||
|
||||
+4
-4
@@ -10,9 +10,9 @@
|
||||
/* BB_AUDIT SUSv3 compliant */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/dirname.html */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
/* This is a NOFORK applet. Be very careful! */
|
||||
|
||||
int dirname_main(int argc, char **argv);
|
||||
int dirname_main(int argc, char **argv)
|
||||
@@ -23,5 +23,5 @@ int dirname_main(int argc, char **argv)
|
||||
|
||||
puts(dirname(argv[1]));
|
||||
|
||||
fflush_stdout_and_exit(EXIT_SUCCESS);
|
||||
return fflush(stdout);
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
* Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
enum ConvType {
|
||||
CT_UNIX2DOS = 1,
|
||||
@@ -30,7 +30,7 @@ static int convert(char *fn)
|
||||
/*
|
||||
The file is then created with mode read/write and
|
||||
permissions 0666 for glibc 2.0.6 and earlier or
|
||||
0600 for glibc 2.0.7 and later.
|
||||
0600 for glibc 2.0.7 and later.
|
||||
*/
|
||||
snprintf(bb_common_bufsiz1, sizeof(bb_common_bufsiz1), "%sXXXXXX", fn);
|
||||
/*
|
||||
@@ -38,8 +38,8 @@ static int convert(char *fn)
|
||||
hold the full path. However if the output is truncated the
|
||||
subsequent call to mkstemp would fail.
|
||||
*/
|
||||
if ((i = mkstemp(&bb_common_bufsiz1[0])) == -1
|
||||
|| chmod(bb_common_bufsiz1, 0600) == -1) {
|
||||
i = mkstemp(&bb_common_bufsiz1[0]);
|
||||
if (i == -1 || chmod(bb_common_bufsiz1, 0600) == -1) {
|
||||
bb_perror_nomsg_and_die();
|
||||
}
|
||||
out = fdopen(i, "w+");
|
||||
@@ -82,8 +82,8 @@ static int convert(char *fn)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dos2unix_main(int argc, char *argv[]);
|
||||
int dos2unix_main(int argc, char *argv[])
|
||||
int dos2unix_main(int argc, char **argv);
|
||||
int dos2unix_main(int argc, char **argv)
|
||||
{
|
||||
int o;
|
||||
|
||||
|
||||
+3
-5
@@ -23,7 +23,7 @@
|
||||
* 4) Fixed busybox bug #1284 involving long overflow with human_readable.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
#if ENABLE_FEATURE_HUMAN_READABLE
|
||||
# if ENABLE_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
|
||||
@@ -235,10 +235,8 @@ int du_main(int argc, char **argv)
|
||||
total += du(*argv);
|
||||
slink_depth = slink_depth_save;
|
||||
} while (*++argv);
|
||||
#if ENABLE_FEATURE_CLEAN_UP
|
||||
reset_ino_dev_hashtable();
|
||||
#endif
|
||||
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
reset_ino_dev_hashtable();
|
||||
if (print_final_total) {
|
||||
print(total, "total");
|
||||
}
|
||||
|
||||
+50
-44
@@ -20,103 +20,109 @@
|
||||
* 1) In handling '\c' escape, the previous version only suppressed the
|
||||
* trailing newline. SUSv3 specifies _no_ output after '\c'.
|
||||
* 2) SUSv3 specifies that octal escapes are of the form \0{#{#{#}}}.
|
||||
* The previous version version did not allow 4-digit octals.
|
||||
* The previous version did not allow 4-digit octals.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
int bb_echo(char **argv)
|
||||
{
|
||||
#ifndef CONFIG_FEATURE_FANCY_ECHO
|
||||
#define eflag '\\'
|
||||
++argv;
|
||||
const char *arg;
|
||||
#if !ENABLE_FEATURE_FANCY_ECHO
|
||||
enum {
|
||||
eflag = '\\',
|
||||
nflag = 1, /* 1 -- print '\n' */
|
||||
};
|
||||
arg = *++argv;
|
||||
if (!arg)
|
||||
goto newline_ret;
|
||||
#else
|
||||
const char *p;
|
||||
int nflag = 1;
|
||||
int eflag = 0;
|
||||
char nflag = 1;
|
||||
char eflag = 0;
|
||||
|
||||
while (1) {
|
||||
arg = *++argv;
|
||||
if (!arg)
|
||||
goto newline_ret;
|
||||
if (*arg != '-')
|
||||
break;
|
||||
|
||||
while (*++argv && (**argv == '-')) {
|
||||
/* If it appears that we are handling options, then make sure
|
||||
* that all of the options specified are actually valid.
|
||||
* Otherwise, the string should just be echoed.
|
||||
*/
|
||||
|
||||
if (!*(p = *argv + 1)) { /* A single '-', so echo it. */
|
||||
p = arg + 1;
|
||||
if (!*p) /* A single '-', so echo it. */
|
||||
goto just_echo;
|
||||
}
|
||||
|
||||
do {
|
||||
if (strrchr("neE", *p) == 0) {
|
||||
if (!strrchr("neE", *p))
|
||||
goto just_echo;
|
||||
}
|
||||
} while (*++p);
|
||||
|
||||
/* All of the options in this arg are valid, so handle them. */
|
||||
p = *argv + 1;
|
||||
p = arg + 1;
|
||||
do {
|
||||
if (*p == 'n') {
|
||||
if (*p == 'n')
|
||||
nflag = 0;
|
||||
} else if (*p == 'e') {
|
||||
if (*p == 'e')
|
||||
eflag = '\\';
|
||||
} else {
|
||||
eflag = 0;
|
||||
}
|
||||
} while (*++p);
|
||||
}
|
||||
|
||||
just_echo:
|
||||
just_echo:
|
||||
#endif
|
||||
while (*argv) {
|
||||
while (1) {
|
||||
/* arg is already == *argv and isn't NULL */
|
||||
int c;
|
||||
|
||||
while ((c = *(*argv)++)) {
|
||||
if (!eflag) {
|
||||
/* optimization for very common case */
|
||||
fputs(arg, stdout);
|
||||
} else while ((c = *arg++)) {
|
||||
if (c == eflag) { /* Check for escape seq. */
|
||||
if (**argv == 'c') {
|
||||
if (*arg == 'c') {
|
||||
/* '\c' means cancel newline and
|
||||
* ignore all subsequent chars. */
|
||||
return 0;
|
||||
goto ret;
|
||||
}
|
||||
#ifndef CONFIG_FEATURE_FANCY_ECHO
|
||||
#if !ENABLE_FEATURE_FANCY_ECHO
|
||||
/* SUSv3 specifies that octal escapes must begin with '0'. */
|
||||
if (((unsigned int)(**argv - '1')) >= 7)
|
||||
if ( (((unsigned char)*arg) - '1') >= 7)
|
||||
#endif
|
||||
{
|
||||
/* Since SUSv3 mandates a first digit of 0, 4-digit octals
|
||||
* of the form \0### are accepted. */
|
||||
if ((**argv == '0') && (((unsigned int)(argv[0][1] - '0')) < 8)) {
|
||||
(*argv)++;
|
||||
if (*arg == '0' && ((unsigned char)(arg[1]) - '0') < 8) {
|
||||
arg++;
|
||||
}
|
||||
/* bb_process_escape_sequence can handle nul correctly */
|
||||
c = bb_process_escape_sequence((const char **) argv);
|
||||
c = bb_process_escape_sequence(&arg);
|
||||
}
|
||||
}
|
||||
putchar(c);
|
||||
}
|
||||
|
||||
if (*++argv) {
|
||||
putchar(' ');
|
||||
}
|
||||
arg = *++argv;
|
||||
if (!arg)
|
||||
break;
|
||||
putchar(' ');
|
||||
}
|
||||
|
||||
#ifdef CONFIG_FEATURE_FANCY_ECHO
|
||||
newline_ret:
|
||||
if (nflag) {
|
||||
putchar('\n');
|
||||
}
|
||||
#else
|
||||
putchar('\n');
|
||||
#endif
|
||||
return 0;
|
||||
ret:
|
||||
return fflush(stdout);
|
||||
}
|
||||
|
||||
/* This is a NOFORK applet. Be very careful! */
|
||||
|
||||
int echo_main(int argc, char** argv);
|
||||
int echo_main(int argc, char** argv)
|
||||
{
|
||||
(void)bb_echo(argv);
|
||||
fflush_stdout_and_exit(EXIT_SUCCESS);
|
||||
return bb_echo(argv);
|
||||
}
|
||||
|
||||
/*-
|
||||
|
||||
+3
-3
@@ -29,9 +29,10 @@
|
||||
* - use xfunc_error_retval
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <errno.h>
|
||||
#include <getopt.h> /* struct option */
|
||||
extern char **environ;
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
#if ENABLE_FEATURE_ENV_LONG_OPTIONS
|
||||
static const struct option env_long_options[] = {
|
||||
@@ -49,7 +50,6 @@ int env_main(int argc, char** argv)
|
||||
char **ep;
|
||||
unsigned opt;
|
||||
llist_t *unset_env = NULL;
|
||||
extern char **environ;
|
||||
|
||||
opt_complementary = "u::";
|
||||
#if ENABLE_FEATURE_ENV_LONG_OPTIONS
|
||||
|
||||
+71
-70
@@ -25,7 +25,7 @@
|
||||
|
||||
/* no getopt needed */
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
#include "xregex.h"
|
||||
|
||||
/* The kinds of value we can have. */
|
||||
@@ -62,40 +62,14 @@ struct valinfo {
|
||||
typedef struct valinfo VALUE;
|
||||
|
||||
/* The arguments given to the program, minus the program name. */
|
||||
static char **args;
|
||||
struct globals {
|
||||
char **args;
|
||||
};
|
||||
#define G (*(struct globals*)&bb_common_bufsiz1)
|
||||
|
||||
static VALUE *docolon(VALUE * sv, VALUE * pv);
|
||||
/* forward declarations */
|
||||
static VALUE *eval(void);
|
||||
static VALUE *int_value(arith_t i);
|
||||
static VALUE *str_value(const char *s);
|
||||
static int nextarg(const char *str);
|
||||
static int null(VALUE * v);
|
||||
static int toarith(VALUE * v);
|
||||
static void freev(VALUE * v);
|
||||
static void tostring(VALUE * v);
|
||||
|
||||
int expr_main(int argc, char **argv);
|
||||
int expr_main(int argc, char **argv)
|
||||
{
|
||||
VALUE *v;
|
||||
|
||||
if (argc == 1) {
|
||||
bb_error_msg_and_die("too few arguments");
|
||||
}
|
||||
|
||||
args = argv + 1;
|
||||
|
||||
v = eval();
|
||||
if (*args)
|
||||
bb_error_msg_and_die("syntax error");
|
||||
|
||||
if (v->type == integer)
|
||||
printf("%" PF_REZ "d\n", PF_REZ_TYPE v->u.i);
|
||||
else
|
||||
puts(v->u.s);
|
||||
|
||||
fflush_stdout_and_exit(null(v));
|
||||
}
|
||||
|
||||
/* Return a VALUE for I. */
|
||||
|
||||
@@ -152,7 +126,7 @@ static void tostring(VALUE * v)
|
||||
|
||||
/* Coerce V to an integer value. Return 1 on success, 0 on failure. */
|
||||
|
||||
static int toarith(VALUE * v)
|
||||
static bool toarith(VALUE * v)
|
||||
{
|
||||
if (v->type == string) {
|
||||
arith_t i;
|
||||
@@ -173,11 +147,11 @@ static int toarith(VALUE * v)
|
||||
/* Return nonzero if the next token matches STR exactly.
|
||||
STR must not be NULL. */
|
||||
|
||||
static int nextarg(const char *str)
|
||||
static bool nextarg(const char *str)
|
||||
{
|
||||
if (*args == NULL)
|
||||
if (*G.args == NULL)
|
||||
return 0;
|
||||
return strcmp(*args, str) == 0;
|
||||
return strcmp(*G.args, str) == 0;
|
||||
}
|
||||
|
||||
/* The comparison operator handling functions. */
|
||||
@@ -245,15 +219,14 @@ static VALUE *docolon(VALUE * sv, VALUE * pv)
|
||||
tostring(pv);
|
||||
|
||||
if (pv->u.s[0] == '^') {
|
||||
fprintf(stderr, "\
|
||||
bb_error_msg("\
|
||||
warning: unportable BRE: `%s': using `^' as the first character\n\
|
||||
of a basic regular expression is not portable; it is being ignored", pv->u.s);
|
||||
}
|
||||
|
||||
memset(&re_buffer, 0, sizeof(re_buffer));
|
||||
memset(re_regs, 0, sizeof(*re_regs));
|
||||
if (regcomp(&re_buffer, pv->u.s, 0) != 0)
|
||||
bb_error_msg_and_die("invalid regular expression");
|
||||
xregcomp(&re_buffer, pv->u.s, 0);
|
||||
|
||||
/* expr uses an anchored pattern match, so check that there was a
|
||||
* match and that the match starts at offset 0. */
|
||||
@@ -272,6 +245,7 @@ of a basic regular expression is not portable; it is being ignored", pv->u.s);
|
||||
else
|
||||
v = int_value(0);
|
||||
}
|
||||
//FIXME: sounds like here is a bit missing: regfree(&re_buffer);
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -281,53 +255,57 @@ static VALUE *eval7(void)
|
||||
{
|
||||
VALUE *v;
|
||||
|
||||
if (!*args)
|
||||
if (!*G.args)
|
||||
bb_error_msg_and_die("syntax error");
|
||||
|
||||
if (nextarg("(")) {
|
||||
args++;
|
||||
G.args++;
|
||||
v = eval();
|
||||
if (!nextarg(")"))
|
||||
bb_error_msg_and_die("syntax error");
|
||||
args++;
|
||||
G.args++;
|
||||
return v;
|
||||
}
|
||||
|
||||
if (nextarg(")"))
|
||||
bb_error_msg_and_die("syntax error");
|
||||
|
||||
return str_value(*args++);
|
||||
return str_value(*G.args++);
|
||||
}
|
||||
|
||||
/* Handle match, substr, index, length, and quote keywords. */
|
||||
|
||||
static VALUE *eval6(void)
|
||||
{
|
||||
VALUE *l, *r, *v, *i1, *i2;
|
||||
VALUE *l, *r, *v = NULL /* silence gcc */, *i1, *i2;
|
||||
static const char * const keywords[] = {
|
||||
"quote", "length", "match", "index", "substr", NULL
|
||||
};
|
||||
|
||||
if (nextarg("quote")) {
|
||||
args++;
|
||||
if (!*args)
|
||||
smalluint key = *G.args ? index_in_str_array(keywords, *G.args) + 1 : 0;
|
||||
if (key == 0) /* not a keyword */
|
||||
return eval7();
|
||||
G.args++; /* We have a valid token, so get the next argument. */
|
||||
if (key == 1) { /* quote */
|
||||
if (!*G.args)
|
||||
bb_error_msg_and_die("syntax error");
|
||||
return str_value(*args++);
|
||||
} else if (nextarg("length")) {
|
||||
args++;
|
||||
return str_value(*G.args++);
|
||||
}
|
||||
if (key == 2) { /* length */
|
||||
r = eval6();
|
||||
tostring(r);
|
||||
v = int_value(strlen(r->u.s));
|
||||
freev(r);
|
||||
return v;
|
||||
} else if (nextarg("match")) {
|
||||
args++;
|
||||
} else
|
||||
l = eval6();
|
||||
|
||||
if (key == 3) { /* match */
|
||||
r = eval6();
|
||||
v = docolon(l, r);
|
||||
freev(l);
|
||||
freev(r);
|
||||
return v;
|
||||
} else if (nextarg("index")) {
|
||||
args++;
|
||||
l = eval6();
|
||||
}
|
||||
if (key == 4) { /* index */
|
||||
r = eval6();
|
||||
tostring(l);
|
||||
tostring(r);
|
||||
@@ -336,10 +314,8 @@ static VALUE *eval6(void)
|
||||
v->u.i = 0;
|
||||
freev(l);
|
||||
freev(r);
|
||||
return v;
|
||||
} else if (nextarg("substr")) {
|
||||
args++;
|
||||
l = eval6();
|
||||
}
|
||||
if (key == 5) { /* substr */
|
||||
i1 = eval6();
|
||||
i2 = eval6();
|
||||
tostring(l);
|
||||
@@ -355,9 +331,9 @@ static VALUE *eval6(void)
|
||||
freev(l);
|
||||
freev(i1);
|
||||
freev(i2);
|
||||
return v;
|
||||
} else
|
||||
return eval7();
|
||||
}
|
||||
return v;
|
||||
|
||||
}
|
||||
|
||||
/* Handle : operator (pattern matching).
|
||||
@@ -369,7 +345,7 @@ static VALUE *eval5(void)
|
||||
|
||||
l = eval6();
|
||||
while (nextarg(":")) {
|
||||
args++;
|
||||
G.args++;
|
||||
r = eval6();
|
||||
v = docolon(l, r);
|
||||
freev(l);
|
||||
@@ -397,7 +373,7 @@ static VALUE *eval4(void)
|
||||
op = '%';
|
||||
else
|
||||
return l;
|
||||
args++;
|
||||
G.args++;
|
||||
r = eval5();
|
||||
val = arithmetic_common(l, r, op);
|
||||
freev(l);
|
||||
@@ -422,7 +398,7 @@ static VALUE *eval3(void)
|
||||
op = '-';
|
||||
else
|
||||
return l;
|
||||
args++;
|
||||
G.args++;
|
||||
r = eval4();
|
||||
val = arithmetic_common(l, r, op);
|
||||
freev(l);
|
||||
@@ -455,7 +431,7 @@ static VALUE *eval2(void)
|
||||
op = '>';
|
||||
else
|
||||
return l;
|
||||
args++;
|
||||
G.args++;
|
||||
r = eval3();
|
||||
toarith(l);
|
||||
toarith(r);
|
||||
@@ -474,7 +450,7 @@ static VALUE *eval1(void)
|
||||
|
||||
l = eval2();
|
||||
while (nextarg("&")) {
|
||||
args++;
|
||||
G.args++;
|
||||
r = eval2();
|
||||
if (null(l) || null(r)) {
|
||||
freev(l);
|
||||
@@ -494,7 +470,7 @@ static VALUE *eval(void)
|
||||
|
||||
l = eval1();
|
||||
while (nextarg("|")) {
|
||||
args++;
|
||||
G.args++;
|
||||
r = eval1();
|
||||
if (null(l)) {
|
||||
freev(l);
|
||||
@@ -504,3 +480,28 @@ static VALUE *eval(void)
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
int expr_main(int argc, char **argv);
|
||||
int expr_main(int argc, char **argv)
|
||||
{
|
||||
VALUE *v;
|
||||
|
||||
if (argc == 1) {
|
||||
bb_error_msg_and_die("too few arguments");
|
||||
}
|
||||
|
||||
G.args = argv + 1;
|
||||
|
||||
v = eval();
|
||||
if (*G.args)
|
||||
bb_error_msg_and_die("syntax error");
|
||||
|
||||
if (v->type == integer)
|
||||
printf("%" PF_REZ "d\n", PF_REZ_TYPE v->u.i);
|
||||
else
|
||||
puts(v->u.s);
|
||||
|
||||
fflush_stdout_and_exit(null(v));
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -10,8 +10,9 @@
|
||||
/* BB_AUDIT SUSv3 compliant */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/false.html */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
/* This is a NOFORK applet. Be very careful! */
|
||||
|
||||
int false_main(int ATTRIBUTE_UNUSED argc, char ATTRIBUTE_UNUSED **argv);
|
||||
int false_main(int ATTRIBUTE_UNUSED argc, char ATTRIBUTE_UNUSED **argv)
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
static unsigned long flags;
|
||||
#define FLAG_COUNT_BYTES 1
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
/* BB_AUDIT GNU compatible -c, -q, and -v options in 'fancy' configuration. */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/head.html */
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
static const char head_opts[] =
|
||||
"n:"
|
||||
|
||||
+4
-4
@@ -9,9 +9,9 @@
|
||||
|
||||
/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
/* This is a NOFORK applet. Be very careful! */
|
||||
|
||||
int hostid_main(int argc, char ATTRIBUTE_UNUSED **argv);
|
||||
int hostid_main(int argc, char ATTRIBUTE_UNUSED **argv)
|
||||
@@ -22,5 +22,5 @@ int hostid_main(int argc, char ATTRIBUTE_UNUSED **argv)
|
||||
|
||||
printf("%lx\n", gethostid());
|
||||
|
||||
fflush_stdout_and_exit(EXIT_SUCCESS);
|
||||
return fflush(stdout);
|
||||
}
|
||||
+1
-4
@@ -13,10 +13,7 @@
|
||||
* -Z option support: by Yuichi Nakamura <ynakam@hitachisoft.jp>
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include "libbb.h"
|
||||
|
||||
#define PRINT_REAL 1
|
||||
#define NAME_NOT_NUMBER 2
|
||||
|
||||
+5
-3
@@ -9,11 +9,12 @@
|
||||
* owner/group, will probably modify bb_make_directory(...)
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libcoreutils/coreutils.h"
|
||||
#include <libgen.h>
|
||||
#include <getopt.h> /* struct option */
|
||||
|
||||
#include "libbb.h"
|
||||
#include "libcoreutils/coreutils.h"
|
||||
|
||||
#if ENABLE_FEATURE_INSTALL_LONG_OPTIONS
|
||||
static const struct option install_long_options[] = {
|
||||
{ "directory", 0, NULL, 'd' },
|
||||
@@ -35,7 +36,8 @@ static const struct option install_long_options[] = {
|
||||
#if ENABLE_SELINUX
|
||||
static bool use_default_selinux_context = 1;
|
||||
|
||||
static void setdefaultfilecon(const char *path) {
|
||||
static void setdefaultfilecon(const char *path)
|
||||
{
|
||||
struct stat s;
|
||||
security_context_t scontext = NULL;
|
||||
|
||||
|
||||
+7
-8
@@ -2,19 +2,18 @@
|
||||
|
||||
/* BB_AUDIT SUSv3 N/A -- Apparently a busybox (obsolete?) extension. */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
/* This is a NOFORK applet. Be very careful! */
|
||||
|
||||
int length_main(int argc, char **argv);
|
||||
int length_main(int argc, char **argv)
|
||||
{
|
||||
if ((argc != 2) || (**(++argv) == '-')) {
|
||||
bb_show_usage();
|
||||
if ((argc != 2) || (**(++argv) == '-')) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
printf("%lu\n", (unsigned long)strlen(*argv));
|
||||
printf("%u\n", (unsigned)strlen(*argv));
|
||||
|
||||
fflush_stdout_and_exit(EXIT_SUCCESS);
|
||||
return fflush(stdout);
|
||||
}
|
||||
@@ -20,11 +20,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include "libbb.h"
|
||||
#include "coreutils.h"
|
||||
//#include "coreutils.h"
|
||||
|
||||
mode_t getopt_mk_fifo_nod(int argc, char **argv)
|
||||
{
|
||||
|
||||
+4
-1
@@ -11,7 +11,10 @@
|
||||
/* BB_AUDIT GNU options missing: -d, -F, -i, and -v. */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/ln.html */
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
/* This is a NOEXEC applet. Be very careful! */
|
||||
|
||||
|
||||
#define LN_SYMLINK 1
|
||||
#define LN_FORCE 2
|
||||
|
||||
+8
-8
@@ -20,23 +20,23 @@
|
||||
* a diagnostic message and an error return.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
/* This is a NOFORK applet. Be very careful! */
|
||||
|
||||
int logname_main(int argc, char ATTRIBUTE_UNUSED **argv);
|
||||
int logname_main(int argc, char ATTRIBUTE_UNUSED **argv)
|
||||
{
|
||||
const char *p;
|
||||
char buf[128];
|
||||
|
||||
if (argc > 1) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
if ((p = getlogin()) != NULL) {
|
||||
puts(p);
|
||||
fflush_stdout_and_exit(EXIT_SUCCESS);
|
||||
/* Using _r function - avoid pulling in static buffer from libc */
|
||||
if (getlogin_r(buf, sizeof(buf)) == 0) {
|
||||
puts(buf);
|
||||
return fflush(stdout);
|
||||
}
|
||||
|
||||
bb_perror_msg_and_die("getlogin");
|
||||
|
||||
+8
-5
@@ -29,8 +29,11 @@
|
||||
* 1. requires lstat (BSD) - how do you do it without?
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <getopt.h>
|
||||
#include "libbb.h"
|
||||
|
||||
/* This is a NOEXEC applet. Be very careful! */
|
||||
|
||||
|
||||
enum {
|
||||
|
||||
@@ -501,11 +504,11 @@ static struct dnode **list_dir(const char *path)
|
||||
|
||||
/* are we going to list the file- it may be . or .. or a hidden file */
|
||||
if (entry->d_name[0] == '.') {
|
||||
if ((entry->d_name[1] == 0 || (
|
||||
entry->d_name[1] == '.'
|
||||
&& entry->d_name[2] == 0))
|
||||
&& !(all_fmt & DISP_DOT))
|
||||
if ((!entry->d_name[1] || (entry->d_name[1] == '.' && !entry->d_name[2]))
|
||||
&& !(all_fmt & DISP_DOT)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
if (!(all_fmt & DISP_HIDDEN))
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
typedef enum { HASH_SHA1, HASH_MD5 } hash_algo_t;
|
||||
|
||||
@@ -38,9 +38,8 @@ static uint8_t *hash_file(const char *filename, hash_algo_t hash_algo)
|
||||
|
||||
src_fd = STDIN_FILENO;
|
||||
if (NOT_LONE_DASH(filename)) {
|
||||
src_fd = open(filename, O_RDONLY);
|
||||
src_fd = open_or_warn(filename, O_RDONLY);
|
||||
if (src_fd < 0) {
|
||||
bb_perror_msg("%s", filename);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -19,19 +19,19 @@
|
||||
/* Nov 28, 2006 Yoshinori Sato <ysato@users.sourceforge.jp>: Add SELinux Support.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h> /* struct option */
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
/* This is a NOFORK applet. Be very careful! */
|
||||
|
||||
#if ENABLE_FEATURE_MKDIR_LONG_OPTIONS
|
||||
static const struct option mkdir_long_options[] = {
|
||||
{ "mode", 1, NULL, 'm' },
|
||||
{ "mode" , 1, NULL, 'm' },
|
||||
{ "parents", 0, NULL, 'p' },
|
||||
#if ENABLE_SELINUX
|
||||
{ "context", 1, NULL, 'Z' },
|
||||
#endif
|
||||
{ 0, 0, 0, 0 }
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
+3
-5
@@ -10,10 +10,7 @@
|
||||
/* BB_AUDIT SUSv3 compliant */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/mkfifo.html */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
#include "libcoreutils/coreutils.h"
|
||||
|
||||
int mkfifo_main(int argc, char **argv);
|
||||
@@ -24,7 +21,8 @@ int mkfifo_main(int argc, char **argv)
|
||||
|
||||
mode = getopt_mk_fifo_nod(argc, argv);
|
||||
|
||||
if (!*(argv += optind)) {
|
||||
argv += optind;
|
||||
if (!*argv) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
|
||||
#include <sys/sysmacros.h> // For makedev
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
#include "libcoreutils/coreutils.h"
|
||||
|
||||
static const char modes_chars[] = { 'p', 'c', 'u', 'b', 0, 1, 1, 2 };
|
||||
|
||||
+1
-4
@@ -15,12 +15,9 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <getopt.h> /* struct option */
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
#include "libcoreutils/coreutils.h"
|
||||
|
||||
#if ENABLE_FEATURE_MV_LONG_OPTIONS
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/resource.h>
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
int nice_main(int argc, char **argv);
|
||||
int nice_main(int argc, char **argv)
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
int nohup_main(int argc, char **argv);
|
||||
int nohup_main(int argc, char **argv)
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
#if ENABLE_DESKTOP
|
||||
/* This one provides -t (busybox's own build script needs it) */
|
||||
#include "od_bloaty.c"
|
||||
|
||||
@@ -49,8 +49,7 @@ diff -u -a std bbox >bbox.diff || { echo Different!; sleep 1; }
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
#include <getopt.h>
|
||||
|
||||
#define assert(a) ((void)0)
|
||||
@@ -1312,7 +1311,6 @@ int od_main(int argc, char **argv)
|
||||
if (opt & OPT_l) decode_format_string("d4");
|
||||
if (opt & OPT_o) decode_format_string("o2");
|
||||
//if (opt & OPT_t)...
|
||||
lst_t = llist_rev(lst_t);
|
||||
while (lst_t) {
|
||||
decode_format_string(lst_t->data);
|
||||
lst_t = lst_t->link;
|
||||
|
||||
Loaded 100 of 475 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user