Compare commits

...
138 Commits
Author SHA1 Message Date
Eric Andersen 31b35a16e0 Merge with the stable branch 2001-08-23 22:05:55 +00:00
Eric Andersen a3c8481a33 A patch from Jaspreet Singh <jsingh@somanetworks.com>
fixing both a segfault and cosmetic bug in route
2001-08-23 22:05:33 +00:00
Eric Andersen b76cb68979 A patch from Shu-Hao Chang <shuhao_chang@trend.com.tw> to
fixed sed handling of multiple -e commands
2001-08-22 05:58:16 +00:00
Eric Andersen 1071ccfd25 Force BB_FEATURE_NEW_MODULE_INTERFACE and BB_FEATURE_OLD_MODULE_INTERFACE
to be mutually exclusive
2001-08-22 05:41:57 +00:00
Eric Andersen c0f9d0dce7 Add #include <sys/param.h> to ensure PATH_MAX is defined 2001-08-22 05:35:39 +00:00
Eric Andersen 5d60a46269 Fix a warning and potential segfault in lash when BB_FEATURE_CLEAN_UP
is enabled
2001-08-22 05:32:24 +00:00
Eric Andersen ac5dbd193b Fix an _old_ interface problem with a never-used feature. 2001-08-22 05:26:08 +00:00
Eric Andersen 59443965ad Scrub things and ditch uint64_t and use a custom type name
to avoid C lib compatibility problems.
2001-08-22 05:06:29 +00:00
Eric Andersen d36cdd25a5 Bump version to 0.61.pre 2001-08-22 04:16:36 +00:00
Eric Andersen 39eb040757 Patch from Rodney Brown <RDBrown@mira.net>, shrinking 1.5k
from gzip by careful optimization.  Appears to work just fine
(I've tested the changes on x86, ARM, and powerpc).
2001-08-22 04:15:47 +00:00
Eric Andersen a07c902648 Make it compile with uClibc 2001-08-22 00:10:00 +00:00
Eric Andersen 75220b55ff dfp might be used uninitialized. NULL it. 2001-08-21 23:36:32 +00:00
Eric Andersen 994c6ffd3b Disable the tinylogin apps by default. 2001-08-21 23:34:10 +00:00
Eric Andersen c61804ed59 Fix dos2unix compile problem with certain glibc versions 2001-08-21 22:34:05 +00:00
Eric Andersen f349e978c4 Initial merge of all tinylogin applets that do not require crypt.
There is some optimization that can be done to better use libbb in
these applets.  There is also redundancy between stty and getty which
could be eliminated.
 -Erik
2001-08-21 16:18:59 +00:00
Matt Kraai a3e4f455ac Fix a problem with unsatisfied backrefs (noted by Martin Bene). 2001-08-20 21:21:06 +00:00
Eric Andersen 54eceffcae some minor wording changes 2001-08-20 17:48:17 +00:00
Eric Andersen 76fa8ea790 Apply Glenn's tftp rewrite 2001-08-20 17:47:49 +00:00
Glenn L McGrath bac490fe53 Fix version comparision bug 2001-08-15 11:25:01 +00:00
Matt Kraai b6ec78161d Log all messages from a single connection, not just the first. Patch from
matthias@corelatus.com, approved by Gennady Feldman <gena01@cachier.com>.
2001-08-14 17:32:23 +00:00
Matt Kraai 0a68590314 Rewritten by Manuel Novoa III. 2001-08-14 17:10:08 +00:00
Manuel Novoa III c639a35f50 I stupidly forgot one level of pointer indirection in the cmdtxt(), calcsize(),
and copynode() table implementations.  Commit the fix but keep them disabled
until others check them out.  Uncomment "//#define CMDTXT_TABLE",
"//#define CALCSIZE_TABLE", and "//#define COPYNODE_TABLE" to try them out.
Saves over 600 bytes on i386.
2001-08-12 17:32:56 +00:00
Eric Andersen dd9173c07f Fix a merging error 2001-08-10 21:11:56 +00:00
Manuel Novoa III 16815d4b45 A few bug fixes and significant size savings. Combined effort of
Vladimir N. Oleynik dzo@simtreas.ru, Aaron Lehmann aaronl@vitelus.com,
and myself.
2001-08-10 19:36:07 +00:00
Eric Andersen 80dd0863e2 Small size optimization from Aaron Lehmann 2001-08-10 18:42:04 +00:00
Eric Andersen e20b7d844a Fix stupid grammar error. 2001-08-10 15:22:35 +00:00
Matt Kraai a7cecbc917 Commit Vladimir's simplify_path. 2001-08-10 15:05:27 +00:00
Manuel Novoa III 4fb0b51703 This corrects the _really_poor_ implementation of "broadcast +" handling
by ifconfig that someone had submitted.  It fixes 1 bug, gets rid of the
excessive bloating of a structure that is used in a static const array,
and removes the implicit struct copys by keeping only the int type needed.
It also turns this into a configurable feature (off by default).
2001-08-10 06:02:23 +00:00
Matt Kraai 6c4250c0dc Remind people to enable RPC support when using NFS mount and uClibc (thanks
to David Douthitt).
2001-08-09 21:07:10 +00:00
Matt Kraai d0b5be6da8 Remove BB_SH define entirely. 2001-08-09 21:00:15 +00:00
Matt Kraai 2338d3176b Use ferror(3) to check for errors, rather than inspecting errno. Thanks to
David Douthitt for reporting, and shame on me for writing such crappy code.
2001-08-06 16:09:09 +00:00
Matt Kraai 063c1f54ea Simplified version checking. 2001-08-06 14:18:08 +00:00
Matt Kraai 69edfecfb9 Add support for underscores in variable names. 2001-08-06 14:14:18 +00:00
Glenn L McGrath b373a8d0ca Fix exclude list handling 2001-08-04 05:28:29 +00:00
Eric Andersen 0b7d70c822 Fix up some silly messups with the debian packaging, and a dumb
bug with chroot.  I've had the package uploaded but perms set to
000, so I am going to re-tag things and re-cut the release.  Folks
who pulled from CVS in the last 30 minutes with just have to cope.
 -Erik
2001-08-02 20:56:16 +00:00
Matt Kraai 8aa0b62a88 Fix misspelling of `stabilize'. 2001-08-02 20:34:24 +00:00
Eric Andersen 9e6089ee0f Ok, here we go... 2001-08-02 19:31:08 +00:00
Matt Kraai c9dd5f945b Commit NMU changelog. 2001-08-02 15:12:16 +00:00
Eric Andersen be0c36009a More libc5 fixups
-Erik
2001-08-02 10:55:32 +00:00
Eric Andersen 23b1e5c7df Some libc5 cleanups 2001-08-02 09:58:41 +00:00
Eric Andersen 879d6c85af make_directory used mode as if it were an signed entity, but in fact
it was a mode_t which is unsigned.  Fix it to be signed...
 -Erik
2001-08-02 09:58:19 +00:00
Eric Andersen 8a915880e7 Teach libc5 about realpath
-Erik
2001-08-02 09:55:58 +00:00
Eric Andersen 95b520110d Teach libc5 what a sighandler_t is
-Erik
2001-08-02 09:52:40 +00:00
Eric Andersen deba6dea03 multibuild.pl saves us again. unix2dos requires that dos2unix
be enabled.
 -Erik
2001-08-02 09:21:17 +00:00
Eric Andersen 46bf7de5f6 Ok, if no shell is enabled, don't include any of the SH_IS_<name>
options or the build will fail
 -Erik
2001-08-02 08:48:03 +00:00
Eric Andersen ff9b4a8981 Scrub away the last leftovers from BB_FEATURE_<shell>. Good thing
for multibuild.pl -- I would have missed this stupid mess otherwise.
 -Erik
2001-08-02 08:42:58 +00:00
Eric Andersen fdbac35b33 Patch from Robert J. Osborne <rj@resourceinternational.com> that fixes
a bug in vi where the beginning of the text space was not checked
before dot is decremented for delete and escape sequences on an empty
file.
2001-08-02 05:26:41 +00:00
Eric Andersen 842757dc96 Oops. I forgot to commit this part of vodz' patch. 2001-08-02 05:18:55 +00:00
Eric Andersen 3450636169 Latest patch from vodz. Adds a check for divide by zero in the posix
math suport, cleaner math syntax error checking, moves redundant signal
string tables (from kill and ash) into libbb and provides a few
cleanups elsewhere.
2001-08-02 05:02:46 +00:00
Matt Kraai 2d91deba45 Allow multiple shells to be enabled. 2001-08-01 17:21:35 +00:00
Eric Andersen 0034443140 Fix behavior of grep -lc to match GNU grep. SuS2 is ambiguous
on the correct behavior, so acting like GNU grep seems best
 -Erik
2001-07-31 23:18:49 +00:00
Eric Andersen af6b40a1ea Silence some silly warnings 2001-07-31 22:53:36 +00:00
Eric Andersen f672c9e62f Silence a silly warning 2001-07-31 22:51:49 +00:00
Eric Andersen bb9579ffc3 Make formatting match GNU ls (we were including a spare ' ')
-Erik
2001-07-31 22:43:50 +00:00
Eric Andersen fa1c5aac51 Fix the let builtin (so we can close bug #1196) and remove the
nonstandard exp builtin.
 -Erik
2001-07-31 21:38:23 +00:00
Matt Kraai 73f6a1b058 Always write record counts to stderr. 2001-07-31 21:02:19 +00:00
Eric Andersen 221b2ea6c4 I just wrote up a simple pidof applet, closing bug #1197
-Erik
2001-07-31 19:06:07 +00:00
Matt Kraai 9a53feaa76 Give credit to Adam Slattery. 2001-07-31 16:44:16 +00:00
Eric Andersen 57c82fe7c4 I think this should be the final changelog update...
-Erik
2001-07-31 16:11:41 +00:00
Matt Kraai 51038a3f42 Don't save and restore readonly flag if BB_FEATURE_VI_READONLY isn't enabled. 2001-07-31 15:01:12 +00:00
Eric Andersen 74bcd16425 This incorporates Posix math support into ash. The Posix math support
was written by Aaron Lehmann <aaronl@vitelus.com> for busybox.  This
patch makes a few trivial changes to Aaron's code so that it can be
used (in theory) by the other shells as well...
 -Erik
2001-07-30 21:41:37 +00:00
Eric Andersen dc6647201d Simplify/clarify the shell dependant bit of Config.h 2001-07-30 19:33:00 +00:00
Eric Andersen c126f8ffb6 This depmod script will create a modules.dep file, just like the depmod
binary from modutils.  This one, however, can be run on the _host_
system (need not be run on the target) and is fully cross platform, so
even if your target is ARM or powerpc or whatever, this will still
work.  When used to support the new modprobe applet, this allows
busybox to fully supplant modutils for architectures supported by
busybox insmod.
 -Erik
2001-07-30 19:32:03 +00:00
Eric Andersen 3555fd006e Fix up the sample inittab entry per what is current.
-Erik
2001-07-30 19:28:33 +00:00
Matt Kraai 13cb842773 Rework option handling to save space. 2001-07-30 14:43:20 +00:00
Matt Kraai 547e102082 Preserve whether or not the line was previously altered when running a
subst command (discovery and patch by Jim Gleason).
2001-07-30 14:05:58 +00:00
Glenn L McGrath 7499918f30 If filename is a '-' then read from stdin to stdout 2001-07-30 04:48:50 +00:00
Glenn L McGrath 14d7ea460f Note my uuencode work 2001-07-29 06:07:35 +00:00
Glenn L McGrath b6071b6341 Fix permisions when reading from stdin 2001-07-29 06:04:26 +00:00
Glenn L McGrath eba260587a Fix broken logic when wraping encoded data into rows, also simplifies it a bit 2001-07-29 05:47:33 +00:00
Glenn L McGrath 4e664ac51d The src buffer size has to be a multiple of 3 (as i noted, but didnt do). 2001-07-28 21:34:25 +00:00
Glenn L McGrath 089decab65 Rewrite based on wget uuencode function.
Saves aprox. 200 Bytes and in future can use common code between
this and wget if BB_FEATURE_WGET_AUTHENTICATION is defined.
2001-07-28 21:06:13 +00:00
Eric Andersen 220238305f PArtial Changelog update. I'm still on vacation (I'm at a campground
near the Grand Teton Mountains in Montana at the moment and my
connection is terribly slow) so this is a partial update only,
 -Erik
2001-07-28 16:35:51 +00:00
Matt Kraai 26eeb0c9da Shorten static package description. 2001-07-26 14:45:21 +00:00
Matt Kraai f9d6aa0a86 Rename dirname variable to pathname to eliminate namespace conflict. 2001-07-26 14:26:53 +00:00
Russ Dill 4db35647dd char renamed can never be negative on ARM (rp->renamed[i] != EMPTY) 2001-07-26 05:58:40 +00:00
Eric Andersen 2835efe3da Note that m68k is supported 2001-07-25 16:58:58 +00:00
Eric Andersen 1b06419e60 Cleanup some warnings and a really obvious bug.
-Erik
2001-07-25 07:23:38 +00:00
Eric Andersen 655584b07a This fixes dos2unix and unix2dos so they behave as expected. dos2unix
was broken in the 0.52 release, and unix2dos was pretty lame...
 -Erik
2001-07-25 07:22:55 +00:00
Glenn L McGrath 6c7ac21f3a Update my email address and applets 2001-07-24 02:46:35 +00:00
Glenn L McGrath 096b151f76 note dpkg rewrite 2001-07-24 02:41:06 +00:00
Matt Kraai 439e3df653 Add support for devfs device names. 2001-07-23 14:52:08 +00:00
Eric Andersen 0139ca92ff An initial modproble implementation. Quite suboptimal still,
but it does work...
2001-07-22 23:01:03 +00:00
Eric Andersen 8d79ce8320 Some patches to make dietlibc work... 2001-07-22 23:00:15 +00:00
Eric Andersen 20aab260e2 Some adjustments, mostly from David McCullough <davidm@lineo.com> to
make busybox be more uClinux friendly.  I also adjusted Config.h for
uClinux so it will automagically disable apps the arn't going to
work without fork() and such.
 -Erik
2001-07-19 22:28:02 +00:00
Matt Kraai 0382eb8865 The -P prefix should only be prepended to filenames which are not explicitly
specified.
2001-07-19 19:13:55 +00:00
Matt Kraai e92895c038 Note that wget fix is important. 2001-07-19 17:46:17 +00:00
Matt Kraai c8eae6684b The directory name should only be prepended if one was specified. 2001-07-19 17:29:38 +00:00
Matt Kraai c1cda4a609 Add a RELEASE_BB_BUFFER macro and use it to fix a memory leak in syslogd.c
(noted by Adam Slattery).
2001-07-19 15:00:14 +00:00
Glenn L McGrath 81108e7653 Cleanup (most) memory leaks 2001-07-19 12:15:13 +00:00
Glenn L McGrath c3fbec73fb Change read_package_field interface, and rewrite using low level functions
Fixes for a few bugs that have crept into dpkg in the last few days
2001-07-18 15:47:21 +00:00
Glenn L McGrath 8d3b0497a4 Fix extract_archive so it doesnt mangle filenames, dont try and extract "./" and strip leading "./" on other files 2001-07-18 13:22:44 +00:00
Glenn L McGrath 778041f8d1 Use the unofficial -C instead of -c to --configure a package, -c conflicts with another dpkg command 2001-07-18 05:17:39 +00:00
Glenn L McGrath b9e4ce99d8 Update dpkg usage 2001-07-18 05:16:31 +00:00
Glenn L McGrath ed4492a697 More feedback to user 2001-07-18 05:03:49 +00:00
Glenn L McGrath 7b0241579c Be more verbose when configureing package, minor changes 2001-07-18 04:33:31 +00:00
Glenn L McGrath 6fc92a506a Fail silently on failure to read tar header, its unfortunate that many tar implementations must be adding unwanted crap to the end of their archives.
It makes error reporting here more trouble than its worth
2001-07-18 03:23:10 +00:00
Glenn L McGrath 4cdc607f72 Use xfopen to abort on error to prevent segfaulting later. 2001-07-18 03:13:49 +00:00
Eric Andersen bc4c030023 Cleanup from vodz 2001-07-17 01:14:06 +00:00
Eric Andersen 044228d5ec This is vodz' latest patch. Sorry it took so long...
1) ping cleanup (compile fix from this patch already applied).
    2) traceroute call not spare ntohl() now (and reduce size);
    3) Fix for functions not declared static in insmod, ash, vi and mount.
    4) a more simple API cmdedit :))
    5) adds "stopped jobs" warning to ash on Ctrl-D and fixes "ignoreeof" option
    6) reduce exporting library function index->strchr (traceroute), bzero->memset (syslogd)
2001-07-17 01:12:36 +00:00
Glenn L McGrath 51ded05b3b enum entry for unarchive to be used by tar 2001-07-14 12:38:55 +00:00
Glenn L McGrath a868ec89e8 Allow the unarchive() extract_list variable to be NULL, meaning extract all 2001-07-14 08:49:53 +00:00
Glenn L McGrath 58a5bd187d Tolerate fields with no data, e.g. "Depends: " 2001-07-14 06:25:54 +00:00
Matt Kraai 06ef16563b Allow featureless ping to compile, and featureful ping to shrink
(by Adam Slattery).
2001-07-13 20:56:27 +00:00
Glenn L McGrath ccd65c9be6 Total rewrite, uses hash tables for speed and low memory use. 2001-07-13 18:35:24 +00:00
Glenn L McGrath 3d46224b78 Return NULL if file doesnt open in deb_extract 2001-07-13 18:16:57 +00:00
Glenn L McGrath cfeb08a193 Make sure there is a trailing '\0' when extracting to buffer. 2001-07-13 17:59:48 +00:00
Glenn L McGrath 5e66a26eaa Dont setvbuff in here, must be called just after stream is initialised, glibc tolerates using it later, uclibc doesnt 2001-07-13 06:51:56 +00:00
Glenn L McGrath 26a0d9a945 Call setvbuf from here isntead of gz_open for compatability with uclibc 2001-07-13 06:49:18 +00:00
Glenn L McGrath b028e08d35 Move setvbuf calls from gz_open() to calling functions, setvbuf is only supposed to be called prior to opening the stream, glibc tolerates later use, uclibc doesnt. 2001-07-13 06:43:03 +00:00
Eric Andersen 7467c8d3b6 Patch from vodz:
Changed email address
    cmdedit API change
    optimizations for traceroute and md5sum
    added a new shared create_icmp_socket() function
2001-07-12 20:26:32 +00:00
Matt Kraai f69bfc76fa Allow assignments in the export and readonly commands. 2001-07-12 19:39:59 +00:00
Matt Kraai ab6526c8b3 Remove debugging statement. 2001-07-12 18:44:34 +00:00
Glenn L McGrath 3e94f729a5 Quiet mode, sometimes error messages arent wanted 2001-07-12 10:24:57 +00:00
Glenn L McGrath c127008840 Allow unarchive to redirect stdout (tobe used by dpkg applet) 2001-07-11 17:32:14 +00:00
Glenn L McGrath 481d19b38e Fix bug where it wasnt returning the last line of a multiline field 2001-07-11 15:43:03 +00:00
Glenn L McGrath daf0b78e1a Reverse part of my previous changes 2001-07-11 15:32:52 +00:00
Glenn L McGrath 93febe672a free coniditionally, just to make it play nice with dmalloc which is incompatable with standard free() 2001-07-11 07:25:01 +00:00
Eric Andersen c59fa37d40 Make the obj's generated from libbb/unarchive.c depend on the
Makefile, so things like setting DODMALLOC will cause them to
be recompiled
 -Erik
2001-07-11 07:24:05 +00:00
Glenn L McGrath 248c57ca43 minor dmalloc inspired cleanups 2001-07-11 07:22:17 +00:00
Glenn L McGrath 59e50f634a Unpack the filename not the package name 2001-07-11 03:30:11 +00:00
Eric Andersen 8c145dc31b Fix a stupid search and replace bug... 2001-07-10 16:57:09 +00:00
Eric Andersen 55522080c6 Patch for md5sum from Aaron Lehmann <aaronl@vitelus.com> to slim
it down a little bit.
2001-07-10 16:31:29 +00:00
Eric Andersen 5c58d283bb A traceroute applet from vodz. This could probably be slimmed down,
but will do for now...
2001-07-10 16:29:00 +00:00
Eric Andersen 91b84603d3 Cleanup from vodz 2001-07-10 16:25:34 +00:00
Eric Andersen 2a46634617 Make the rev be 0.53pre... 2001-07-10 15:24:16 +00:00
Matt Kraai 5710f9f690 Read 20 512-byte blocks at a time (like GNU tar). 2001-07-10 15:05:39 +00:00
Glenn L McGrath 654944fc36 Reverse my previous change, still cant compile with dmalloc 2001-07-10 14:33:22 +00:00
Glenn L McGrath c3d2f1287e When compiling unarchive objects link to $(LIBRARIES) incase using dmalloc 2001-07-10 14:04:30 +00:00
Matt Kraai 6199fa90e5 Update version number to 0.53pre. 2001-07-10 13:57:30 +00:00
Eric Andersen 6248355c6f vodz' latest update to ash.c 2001-07-10 06:09:16 +00:00
Eric Andersen 5a4a46a251 Patch from vodz to support 'tr a-z A-Z' syntax. 2001-07-09 21:32:29 +00:00
Eric Andersen f52947ba71 Fix the spec file so it works on redhat systems. At least I think
it will work on redhat.  At least it now works on my Debian box...
 -Erik
2001-07-09 18:34:12 +00:00
Eric Andersen aa64ba459f Minor working update 2001-07-07 16:36:29 +00:00
Eric Andersen ceece81414 Move a bit more to the old news section 2001-07-07 09:38:30 +00:00
Eric Andersen d0e5f86a10 Enable APPLETS_ALWAYS_WIN 2001-07-07 09:37:28 +00:00
Eric Andersen d0b4d3dabf Typo fix. 2001-07-07 08:47:21 +00:00
Eric Andersen 7b2dfc623b Move some stuff to the oldnews area 2001-07-07 08:44:25 +00:00
157 changed files with 14692 additions and 9455 deletions

No files matched your search

+3 -3
View File
@@ -43,8 +43,8 @@ Matt Kraai <kraai@alumni.carnegiemellon.edu>
John Lombardo <john@deltanet.com>
dirname, tr
Glenn McGrath <bug1@netconnect.com.au>
ar.c
Glenn McGrath <bug1@optushome.com.au>
ar, dpkg, dpkg-deb
Bruce Perens <bruce@pixar.com>
Original author of BusyBox. His code is still in many apps.
@@ -74,7 +74,7 @@ Enrique Zanardi <ezanardi@ull.es>
tarcat (since removed), loadkmap, various fixes, Debian maintenance
Vladimir Oleynik <dzo@simtreas.ru>
cmdedit, stty-port, locale, various fixes
cmdedit; ports: ash, stty, traceroute; locale, various fixes
and irreconcilable critic of everything not perfect.
Tim Riker <Tim@Rikers.org>
+165
View File
@@ -1,3 +1,168 @@
0.61.pre
Development Version
New Applets:
* Erik Andersen -- Merged several applets from tinylogin,
namely adduser, addgroup, deluser, delgroup, getty.
Other Changes:
* Vladimir Oleynik, Manuel Novoa III, Aaron Lehmann
-- a whole bunch of ash size optimizations
* Rodney Brown <RDBrown@mira.net>
-- Optimized gzip.c, shrinking it be ~1.5k
-Erik Andersen, --not yet released--
0.60.1
Stable Release
New Applets & New Features:
none. :)
Known Problems (to be fixed in 0.60.2)
* msh can segfault on constructs such as
for i in `ls *.c` ; do echo $i ; done
due to a memory allocation problem. This only seems to cause
problems when the backtick expands to be several k in size.
Bugfixes:
* Matt Kraai
-- Fixed msh to support underscores in variable names.
-- Fixed a sed problem with unsatisfied backrefs (the problem was
noted by Martin Bene).
-- Removed BB_SH define entirely. Now one simply picks the shell
or shells they want as BB_<foo> in Config.h
-- Fixed head to use ferror(3) to check for errors, not errno.
* Shu-Hao Chang <shuhao_chang@trend.com.tw>
-- Fixed sed handling of multiple -e commands
* Magick <magick@linux-fan.com>
-- Fixed an init bug with AskFirst and /dev/null
* Jaspreet Singh <jsingh@somanetworks.com>
-- Fixed both a segfault and cosmetic bug in route
* Erik Andersen
-- Made the insmod options BB_FEATURE_NEW_MODULE_INTERFACE and
BB_FEATURE_OLD_MODULE_INTERFACE mutually exclusive
-- xgetcwd.c now includes sys/param.h to ensure PATH_MAX is defined
-- Fixed a potential segfault with lash + BB_FEATURE_CLEAN_UP
-- Removed uint64_t from dos2unix, avoiding C lib compat. problems.
* Glenn McGrath
-- Rewrite of tftp (commands match atftp, accepts -b, can use
non-standard ports, and is smaller).
-- Fixed unarchive exclude list handling
* Manuel Novoa III
-- rewrite of simplify_path so it behaves itself (fixing some
problems with mount and other applets).
-- Fixed ifconfig 'broadcast +' handling and disabled it by default
* Matthias ? <matthias@corelatus.com>
-- Fixed syslogd to log all messages from a single connection, not
just the first.
-Erik Andersen, 23 August 2001
0.60.0
Note:
For this release I have bumped the version number to 0.60.0. This
reflects the fact that this release is intended to form a new stable
BusyBox release series. If you need to rely on a stable version of
BusyBox, you should plan on using the stable 0.60.x series. If bugs
show up then I will release 0.60.1, then 0.60.2, etc... This is also
intended to deal with the fact that the BusyBox build system will be
getting a major overhaul for the next release and I don't want that to
break products that people are shipping. To avoid that, the new build
system will be released as part of a new BusyBox development series
that will have some not-yet-decided-on odd version number. Once things
stabablize and the new build system is working for everyone, then I
will release that as a new stable release series.
Critical Bugfixes:
* Matt Kraai
-- Fixed wget output file opening (wget failed in 0.52).
-- Fixed a memory leak in syslogd (found by Adam Slattery).
* Vladimir Oleynik, Matt Kraai, Erik Andersen
-- several nasty bugs in ash and msh. msh could not assign
any variables and had debug code still enabled. ash
had several compile errors (depending on selected options)
and variable assignment problems as well.
New Applets:
* David McCullough <davidm@lineo.com> -- modprobe
* Vladimir Oleynik -- traceroute
* Erik Andersen -- pidof
New Scripts:
* David Schleef, Erik Andersen, Stuart Hughes -- depmod.pl
This is a replacement for the depmod program from the modutils
package, but is fully cross platform and is designed to run on
your host system (not on the target).
Other Changes:
* Erik Andersen
-- fixed busybox.spec so it should now work on redhat systems
-- fixed dos2unix and unix2dos so they should work once again
-- Adjustments to make busybox more uClinux friendly. Busybox
should now work on uClinux systems without needing and source
code changes (applets that won't work on uClinux systems are
now automagicaly disabled).
-- various things (cleanups, libc compatibility work, etc, etc)
* Jim Gleason <jimg@lineo.com>
-- Fixed for sed, where it failed to preserve whether or not the
line was previously altered when running a subst command.
* Matt Kraai
-- Made tar read 20 512byte blocks at a time (like GNU tar)
-- Allow msh.c assignments with the export and readonly commands.
-- Added BB_FEATURE_DEVFS to enable devfs device names.
-- Better devfs support
-- Don't save/restore vi readonly flag if vi is compiled read-only.
-- Reworked rdate option handling (is now smaller).
-- Size reduction in ping
-- Always write dd counts to stderr
-- Allow multiple shells to be enabled
* Aaron Lehmann
-- slimmed down md5sum
-- contributed a nice new (hand written, not lex/yacc) Posix math
support for ash, which is once again a full posix shell.
* Felix von Leitner <leitner@convergence.de> -- patches to make busybox
work with dietlibc.
* David McCullough
-- Adjustments to make busybox more uClinux friendly
* Glenn McGrath
-- Fixed gzip so when a filename is '-' it will use stdin/stdout
-- dpkg rewrite. Should now be compatable with the real dpkg,
but needs more testing.
-- Updates to archiving tools (gunzip/gzip/cpio/ar/etc)
-- Rewrote uuencode, will allow base64 encoding to be used by wget
* Vladimir Oleynik
-- Fixed tr to support 'tr a-z A-Z' syntax,
-- Many ash corrections, optimizations, and cleanups.
-- optimizations for traceroute, md5sum, chown, ping
-- cmdedit updates and API change
-- Namespace cleanup (i.e. adding 'static' private function calls)
-- added "stopped jobs" warning to ash on exit
* Adam Slattery
-- Fixed ping compile problem
* Robert J. Osborne <rj@resourceinternational.com>
-- fixed a vi bug with delete and escape sequences on empty files.
-Erik Andersen, 31 July 2001
0.52
Critical Bugfixes:
+64 -64
View File
@@ -7,8 +7,11 @@
//
//
// BusyBox Applications
//#define BB_ADDGROUP
//#define BB_ADDUSER
//#define BB_ADJTIMEX
//#define BB_AR
//#define BB_ASH
#define BB_BASENAME
#define BB_CAT
#define BB_CHGRP
@@ -25,6 +28,8 @@
//#define BB_DC
#define BB_DD
//#define BB_DEALLOCVT
//#define BB_DELGROUP
//#define BB_DELUSER
#define BB_DF
#define BB_DIRNAME
#define BB_DMESG
@@ -44,6 +49,7 @@
//#define BB_FREERAMDISK
//#define BB_FSCK_MINIX
//#define BB_GETOPT
//#define BB_GETTY
#define BB_GREP
#define BB_GUNZIP
#define BB_GZIP
@@ -51,6 +57,7 @@
#define BB_HEAD
//#define BB_HOSTID
//#define BB_HOSTNAME
//#define BB_HUSH
#define BB_ID
//#define BB_IFCONFIG
#define BB_INIT
@@ -58,6 +65,7 @@
#define BB_KILL
#define BB_KILLALL
#define BB_KLOGD
//#define BB_LASH
//#define BB_LENGTH
#define BB_LN
//#define BB_LOADACM
@@ -75,12 +83,15 @@
#define BB_MKNOD
#define BB_MKSWAP
//#define BB_MKTEMP
//#define BB_NC
#define BB_MODPROBE
#define BB_MORE
#define BB_MOUNT
#define BB_MSH
//#define BB_MT
#define BB_MV
//#define BB_NC
//#define BB_NSLOOKUP
#define BB_PIDOF
//#define BB_PING
//#define BB_PIVOT_ROOT
#define BB_POWEROFF
@@ -99,7 +110,6 @@
//#define BB_RPM2CPIO
#define BB_SED
//#define BB_SETKEYCODES
#define BB_SH
#define BB_SLEEP
#define BB_SORT
//#define BB_STTY
@@ -114,6 +124,7 @@
//#define BB_TFTP
#define BB_TOUCH
//#define BB_TR
//#define BB_TRACEROUTE
#define BB_TRUE_FALSE
#define BB_TTY
//#define BB_UNIX2DOS
@@ -143,40 +154,12 @@
// pretty/useful).
//
//
// If you enabled BB_SH above, you may select one of the following shells.
// You can only select ONE of the following shells. Sorry.
//
// lash is the very smallest shell (adds just 10k) and it is quite usable as
// a command prompt, but it is not suitable for any but the most trivial
// scripting (such as an initrd that calls insmod a few times) since it does
// not understand Bourne shell grammer. It does handle pipes, redirects, and
// job control though. Adding in command editing makes it very nice
// lightweight command prompt.
//#define BB_FEATURE_LASH
//
// hush is also quite small (just 18k) and it has very complete Bourne shell
// grammer. It handles if/then/else/fi just fine, but doesn't handle loops
// like for/do/done or case/esac and such. It also currently has a problem
// with job control.
//#define BB_FEATURE_HUSH
//
// msh: The minix shell (adds just 30k) is quite complete and handles things
// like for/do/done, case/esac and all the things you expect a Bourne shell to
// do. It is not always pedantically correct about Bourne shell grammer (try
// running the shell testscript "tests/sh.testcases" on it and compare vs bash)
// but for most things it works quite well. It also uses only vfork, so it can
// be used on uClinux systems. This was only recently added, so there is still
// room to shrink it further...
#define BB_FEATURE_MSH
//
// ash: This adds about 60k in the default configuration and is the most
// complete and most pedantically correct shell included with busybox. This
// shell was also recently added, and several people (mainly Vladimir and Erik)
// have been working on it. There are a number of configurable things at the
// top of ash.c as well, so check those out if you want to tweak things. The
// Posix math support is currently disabled (that bit of code was horrible) but
// will be restored for the next BusyBox release.
//#define BB_FEATURE_ASH
// If you enabled one or more of the shells, you may select which one
// should be run when sh is invoked:
//#define BB_FEATURE_SH_IS_ASH
//#define BB_FEATURE_SH_IS_HUSH
//#define BB_FEATURE_SH_IS_LASH
#define BB_FEATURE_SH_IS_MSH
//
// BusyBox will, by default, malloc space for its buffers. This costs code
// size for the call to xmalloc. You can use the following feature to have
@@ -261,6 +244,9 @@
// Enable support for mounting remote NFS volumes.
// You may need to mount with "-o nolock" if you are
// not running a local portmapper daemon...
//
// If you are using uClibc, be sure that you've already compiled
// uClibc with INCLUDE_RPC=true (contained in the Config file)
//#define BB_FEATURE_NFSMOUNT
//
// Enable support forced filesystem unmounting
@@ -283,11 +269,11 @@
#define BB_FEATURE_SORT_UNIQUE
//
// Enable command line editing in the shell.
// Only relevant if BB_SH is enabled. On by default.
// Only relevant if a shell is enabled. On by default.
#define BB_FEATURE_COMMAND_EDITING
//
// Enable tab completion in the shell. This is now working quite nicely.
// This feature adds a bit over 4k. Only relevant if BB_SH is enabled.
// This feature adds a bit over 4k. Only relevant if a shell is enabled.
#define BB_FEATURE_COMMAND_TAB_COMPLETION
//
// Attempts to match usernames in a ~-prefixed path
@@ -296,7 +282,7 @@
//Allow the shell to invoke all the compiled in BusyBox applets as if they
//were shell builtins. Nice for staticly linking an emergency rescue shell,
//among other things. Off by default.
// Only relevant if BB_SH is enabled.
// Only relevant if a shell is enabled.
//#define BB_FEATURE_SH_STANDALONE_SHELL
//
//When this is enabled, busybox shell applets can be called using full path
@@ -305,13 +291,13 @@
//will use BusyBox cat even if /bin/cat exists on the filesystem and is _not_
//busybox. Some systems want this, others do not. Choose wisely. :-) This
//only has meaning when BB_FEATURE_SH_STANDALONE_SHELL is enabled.
// Only relevant if BB_SH is enabled. Off by default.
// Only relevant if a shell is enabled. Off by default.
//#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN
//
// Uncomment this option for a fancy shell prompt that includes the
// current username and hostname. On systems that don't have usernames
// or hostnames, this can look hideous.
// Only relevant if BB_SH is enabled.
// Only relevant if a shell is enabled.
//#define BB_FEATURE_SH_FANCY_PROMPT
//
//Turn on extra fbset options
@@ -338,7 +324,7 @@
// Support for Minix filesystem, version 2
//#define BB_FEATURE_MINIX2
//
// Enable ifconfig status reporting output -- this feature adds 12k.
// Enable ifconfig status reporting output -- this feature adds 7k.
//#define BB_FEATURE_IFCONFIG_STATUS
//
// Enable ifconfig slip-specific options "keepalive" and "outfill"
@@ -350,6 +336,10 @@
// Enable ifconfig option "hw". Currently works for only with "ether".
//#define BB_FEATURE_IFCONFIG_HW
//
// Allows "broadcast +" to set broadcast automatically based on hostaddr
// and netmask, at a cost of about 100 bytes of code (i386).
//#define BB_FEATURE_IFCONFIG_BROADCAST_PLUS
//
// Enable busybox --install [-s]
// to create links (or symlinks) for all the commands that are
// compiled into the binary. (needs /proc filesystem)
@@ -405,6 +395,9 @@
// Support for TELNET to pass TERM type to remote host. Adds 384 bytes.
#define BB_FEATURE_TELNET_TTYPE
//
// Support for devfs.
//#define BB_FEATURE_DEVFS
//
// End of Features List
//
//
@@ -416,8 +409,21 @@
// Nothing beyond this point should ever be touched by
// mere mortals so leave this stuff alone.
//
#if defined BB_SH
#if defined BB_FEATURE_COMMAND_EDITING
#include <features.h>
#if defined __UCLIBC__ && ! defined __UCLIBC_HAS_MMU__
#undef BB_RPM2CPIO /* Uses gz_open(), which uses fork() */
#undef BB_DPKG_DEB /* Uses gz_open(), which uses fork() */
#undef BB_ASH /* Uses fork() */
#undef BB_HUSH /* Uses fork() */
#undef BB_LASH /* Uses fork() */
#undef BB_INIT /* Uses fork() */
#undef BB_FEATURE_TAR_GZIP /* Uses fork() */
#undef BB_SYSLOGD /* Uses daemon() */
#undef BB_KLOGD /* Uses daemon() */
#undef BB_UPDATE /* Uses daemon() */
#endif
#if defined BB_ASH || defined BB_HUSH || defined BB_LASH || defined BB_MSH
#if defined BB_FEATURE_COMMAND_EDITING
#define BB_CMDEDIT
#else
#undef BB_FEATURE_COMMAND_EDITING
@@ -425,26 +431,6 @@
#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
#undef BB_FEATURE_SH_FANCY_PROMPT
#endif
#if ! defined BB_FEATURE_LASH && ! defined BB_FEATURE_HUSH && ! defined BB_FEATURE_MSH && ! defined BB_FEATURE_ASH
#define BB_FEATURE_MSH
#endif
#if defined BB_FEATURE_ASH && (defined BB_FEATURE_LASH || defined BB_FEATURE_HUSH || defined BB_FEATURE_MSH)
#undef BB_FEATURE_LASH
#undef BB_FEATURE_HUSH
#undef BB_FEATURE_MSH
#elif defined BB_FEATURE_MSH && (defined BB_FEATURE_LASH || defined BB_FEATURE_HUSH || defined BB_FEATURE_MSH)
#undef BB_FEATURE_LASH
#undef BB_FEATURE_HUSH
#undef BB_FEATURE_ASH
#elif defined BB_FEATURE_HUSH && (defined BB_FEATURE_LASH || defined BB_FEATURE_HUSH || defined BB_FEATURE_MSH)
#undef BB_FEATURE_LASH
#undef BB_FEATURE_MSH
#undef BB_FEATURE_ASH
#elif defined BB_FEATURE_LASH && (defined BB_FEATURE_LASH || defined BB_FEATURE_HUSH || defined BB_FEATURE_MSH)
#undef BB_FEATURE_HUSH
#undef BB_FEATURE_MSH
#undef BB_FEATURE_ASH
#endif
#else
#undef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
#undef BB_FEATURE_SH_STANDALONE_SHELL
@@ -477,8 +463,22 @@
#endif
#endif
//
#ifdef BB_UNIX2DOS
#define BB_DOS2UNIX
#endif
//
#ifdef BB_SYSLOGD
#if defined BB_FEATURE_IPC_SYSLOG
#define BB_LOGREAD
#endif
#endif
//
#if defined BB_ASH && defined BB_FEATURE_SH_IS_ASH
# define shell_main ash_main
#elif defined BB_HUSH && defined BB_FEATURE_SH_IS_HUSH
# define shell_main hush_main
#elif defined BB_LASH && defined BB_FEATURE_SH_IS_LASH
# define shell_main lash_main
#elif defined BB_MSH && defined BB_FEATURE_SH_IS_MSH
# define shell_main msh_main
#endif
+22 -16
View File
@@ -18,7 +18,7 @@
#
PROG := busybox
VERSION := 0.52
VERSION := 0.61.pre
BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z")
export VERSION
@@ -48,7 +48,7 @@ DODEBUG = false
# will get fewer emails asking about how glibc NSS works). Enabling this adds
# just 1.4k to the binary size (which is a _lot_ less then glibc NSS costs).
# Note that if you want hostname resolution to work with glibc, you still need
# the libnss_* libraries. Most people will want to leave this set to false.
# the libnss_* libraries.
USE_SYSTEM_PWD_GRP = true
# This enables compiling with dmalloc ( http://dmalloc.com/ )
@@ -85,8 +85,7 @@ AR = $(CROSS)ar
STRIPTOOL = $(CROSS)strip
# To compile vs uClibc, just use the compiler wrapper built by uClibc...
# This make things very easy? Everything should compile and work as
# expected these days...
# Everything should compile and work as expected these days...
#CC = ../uClibc/extra/gcc-uClibc/i386-uclibc-gcc
# To compile vs some other alternative libc, you may need to use/adjust
@@ -227,7 +226,10 @@ ifneq ($(strip $(USE_SYSTEM_PWD_GRP)),true)
fgetpwent.c __getgrent.c grent.c getgrnam.c getgrgid.c fgetgrent.c \
initgroups.c setgroups.c
PWD_OBJS=$(patsubst %.c,$(PWD_GRP)/%.o, $(PWD_CSRC))
PWD_CFLAGS = -I$(PWD_GRP_DIR)
ifneq ($(strip $(BB_SRC_DIR)),)
PWD_CFLAGS = -I- -I.
endif
PWD_CFLAGS += -I$(PWD_GRP_DIR)
else
CFLAGS += -DUSE_SYSTEM_PWD_GRP
endif
@@ -235,7 +237,7 @@ endif
LIBBB = libbb
LIBBB_LIB = libbb.a
LIBBB_CSRC= ask_confirmation.c chomp.c concat_path_file.c copy_file.c \
copy_file_chunk.c daemon.c device_open.c error_msg.c \
copy_file_chunk.c libc5.c device_open.c error_msg.c \
error_msg_and_die.c fgets_str.c find_mount_point.c find_pid_by_name.c \
find_root_device.c full_read.c full_write.c get_console.c \
get_last_path_component.c get_line_from_file.c gz_open.c human_readable.c \
@@ -247,17 +249,19 @@ safe_read.c safe_strncpy.c syscalls.c syslog_msg_with_name.c time_string.c \
trim.c unzip.c vdprintf.c verror_msg.c vperror_msg.c wfopen.c xfuncs.c \
xgetcwd.c xreadlink.c xregcomp.c interface.c remove_file.c last_char_is.c \
copyfd.c vherror_msg.c herror_msg.c herror_msg_and_die.c xgethostbyname.c \
dirname.c make_directory.c
dirname.c make_directory.c create_icmp_socket.c u_signal_names.c arith.c \
simplify_path.c
LIBBB_OBJS=$(patsubst %.c,$(LIBBB)/%.o, $(LIBBB_CSRC))
LIBBB_CFLAGS = -I$(LIBBB)
ifneq ($(strip $(BB_SRC_DIR)),)
LIBBB_CFLAGS += -I$(BB_SRC_DIR)/$(LIBBB)
ifeq ($(strip $(BB_SRC_DIR)),)
LIBBB_CFLAGS += -I$(LIBBB)
else
LIBBB_CFLAGS = -I- -I. -I./$(LIBBB) -I$(BB_SRC_DIR)/$(LIBBB) -I$(BB_SRC_DIR)
endif
LIBBB_MSRC=libbb/messages.c
LIBBB_MESSAGES= full_version name_too_long omitting_directory not_a_directory \
memory_exhausted invalid_date invalid_option io_error dash_dash_help \
write_error too_few_args name_longer_than_foo unknown
write_error too_few_args name_longer_than_foo unknown can_not_create_raw_socket
LIBBB_MOBJ=$(patsubst %,$(LIBBB)/%.o, $(LIBBB_MESSAGES))
LIBBB_ARCSRC=libbb/unarchive.c
@@ -349,9 +353,13 @@ busybox.links: busybox.mkll Config.h applets.h
- $(SHELL) $^ >$@
nfsmount.o cmdedit.o: %.o: %.h
sh.o: cmdedit.h
ash.o hush.o lash.o msh.o: cmdedit.h
$(OBJECTS): %.o: %.c Config.h busybox.h applets.h Makefile
$(CC) -I- $(CFLAGS) -I. $(patsubst %,-I%,$(subst :, ,$(BB_SRC_DIR))) -c $< -o $*.o
ifeq ($(strip $(BB_SRC_DIR)),)
$(CC) $(CFLAGS) -I. $(patsubst %,-I%,$(subst :, ,$(BB_SRC_DIR))) -c $< -o $*.o
else
$(CC) $(CFLAGS) -I- -I. $(patsubst %,-I%,$(subst :, ,$(BB_SRC_DIR))) -c $< -o $*.o
endif
$(PWD_OBJS): %.o: %.c Config.h busybox.h applets.h Makefile
- mkdir -p $(PWD_GRP)
@@ -377,8 +385,6 @@ libbb.a: $(LIBBB_MOBJ) $(LIBBB_AROBJS) $(LIBBB_OBJS)
usage.o: usage.h
sh.o: sh.c lash.c hush.c msh.c ash.c
libbb/loop.o: libbb/loop.h
libbb/loop.h: mk_loop_h.sh
@@ -396,7 +402,7 @@ clean:
docs/busybox.lineo.com/BusyBox.html
- rm -f docs/busybox.txt docs/busybox.dvi docs/busybox.ps \
docs/busybox.pdf docs/busybox.lineo.com/busybox.html
- rm -f multibuild.log Config.h.orig
- rm -f multibuild.log Config.h.orig *.gdb *.elf
- rm -rf docs/busybox _install libpwd.a libbb.a pod2htm*
- rm -f busybox.links libbb/loop.h *~ slist.mk core applet_source_list
- find -name \*.o -exec rm -f {} \;
+33 -4
View File
@@ -11,9 +11,7 @@ the expected functionality and behave very much like their GNU counterparts.
BusyBox has been written with size-optimization and limited resources in mind.
It is also extremely modular so you can easily include or exclude commands (or
features) at compile time. This makes it easy to customize your embedded
systems. To create a working system, just add /dev, a shell, and a kernel. For
a really minimal system, you can even use the busybox shell (not Bourne
compatible, but very small and quite usable) and the busybox vi editor.
systems. To create a working system, just add /dev, /etc, and a kernel.
BusyBox was originally written to support the Debian Rescue/Install disks, but
it also makes an excellent environment for any small or embedded system.
@@ -36,7 +34,8 @@ Supported architectures:
Busybox in general will build on any architecture supported by gcc. It has
a few specialized features added for __sparc__ and __alpha__. insmod
functionality is currently limited to x86, ARM, SH3/4, powerpc, and MIPS.
functionality is currently limited to x86, ARM, SH3/4, powerpc, m68k,
and MIPS.
Supported libcs:
@@ -50,6 +49,36 @@ Supported kernels:
----------------
Shells:
lash is the very smallest shell (adds just 10k) and it is quite usable as
a command prompt, but it is not suitable for any but the most trivial
scripting (such as an initrd that calls insmod a few times) since it does
not understand Bourne shell grammer. It does handle pipes, redirects, and
job control though. Adding in command editing makes it a very nice
lightweight command prompt.
hush is also quite small (just 18k) and it has very complete Bourne shell
grammer. It handles if/then/else/fi just fine, but doesn't handle loops
like for/do/done or case/esac and such. It also currently has a problem
with job control. Using hush is not yet recommended.
msh: The minix shell (adds just 30k) is quite complete and handles things
like for/do/done, case/esac and all the things you expect a Bourne shell to
do. It is not always pedantically correct about Bourne shell grammer (try
running the shell testscript "tests/sh.testcases" on it and compare vs bash)
but for most things it works quite well. It also uses only vfork, so it can
be used on uClinux systems. This was only recently added, so there is still
room to shrink it further...
ash: This adds about 60k in the default configuration and is the most
complete and most pedantically correct shell included with busybox. This
shell was also recently added, and several people (mainly Vladimir and Erik)
have been working on it. There are a number of configurable things at the
top of ash.c as well, so check those out if you want to tweak things.
----------------
Getting help:
When you find you need help, you can check out the BusyBox mailing list
+178
View File
@@ -0,0 +1,178 @@
/* vi: set sw=4 ts=4: */
/*
* addgroup - add users to /etc/passwd and /etc/shadow
*
*
* Copyright (C) 1999 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "busybox.h"
#include "pwd_grp/pwd.h"
#include "pwd_grp/grp.h"
#define GROUP_FILE "/etc/group"
#define SHADOW_FILE "/etc/gshadow"
/* structs __________________________ */
/* data _____________________________ */
/* defaults : should this be in an external file? */
static char *default_passwd = "x";
/* make sure gr_name isn't taken, make sure gid is kosher
* return 1 on failure */
static int group_study(const char *filename, struct group *g)
{
FILE *etc_group;
gid_t desired;
struct group *grp;
const int max = 65000;
/* FIXME : make an fopen_wrapper */
etc_group = fopen(filename, "r");
if (!etc_group) {
perror_msg_and_die("%s", filename);
}
/* make sure gr_name isn't taken, make sure gid is kosher */
desired = g->gr_gid;
while ((grp = fgetgrent(etc_group))) {
if ((strcmp(grp->gr_name, g->gr_name)) == 0) {
error_msg_and_die("%s: group already in use\n", g->gr_name);
}
if ((desired) && grp->gr_gid == desired) {
error_msg_and_die("%d: gid has already been allocated\n",
desired);
}
if ((grp->gr_gid > g->gr_gid) && (grp->gr_gid < max)) {
g->gr_gid = grp->gr_gid;
}
}
fclose(etc_group);
/* gid */
if (desired) {
g->gr_gid = desired;
} else {
g->gr_gid++;
}
/* return 1; */
return 0;
}
/* append a new user to the passwd file */
static int addgroup(const char *filename, char *group, gid_t gid)
{
FILE *etc_group;
FILE *etc_gshadow;
char *gshadow = SHADOW_FILE;
struct group gr;
/* group:passwd:gid:userlist */
const char *entryfmt = "%s:%s:%d:%s\n";
/* make sure gid and group haven't already been allocated */
gr.gr_gid = gid;
gr.gr_name = group;
if (group_study(filename, &gr))
return 1;
/* add entry to group */
etc_group = fopen(filename, "a");
if (!etc_group) {
perror_msg_and_die("%s", filename);
}
fprintf(etc_group, entryfmt, group, default_passwd, gr.gr_gid, "");
fclose(etc_group);
/* add entry to gshadow if necessary */
if (access(gshadow, F_OK|W_OK) == 0) {
etc_gshadow = xfopen(gshadow, "a");
fprintf(etc_gshadow, "%s:!::\n", group);
fclose(etc_gshadow);
}
/* return 1; */
return 0;
}
/*
* addgroup will take a login_name as its first parameter.
*
* gid
*
* can be customized via command-line parameters.
* ________________________________________________________________________ */
int addgroup_main(int argc, char **argv)
{
int i;
char opt;
char *group;
gid_t gid = 0;
/* get remaining args */
for (i = 1; i < argc; i++) {
if (argv[i][0] == '-') {
opt = argv[i][1];
switch (opt) {
case 'h':
show_usage();
break;
case 'g':
gid = strtol(argv[++i], NULL, 10);
break;
default:
error_msg_and_die("addgroup: invalid option -- %c\n", opt);
}
} else {
break;
}
}
if (i >= argc) {
show_usage();
} else {
group = argv[i];
}
if (geteuid() != 0) {
error_msg_and_die
("addgroup: Only root may add a group to the system.\n");
}
/* werk */
return addgroup(GROUP_FILE, group, gid);
}
/* $Id: addgroup.c,v 1.1 2001/08/21 16:18:59 andersen Exp $ */
+366
View File
@@ -0,0 +1,366 @@
/* vi: set sw=4 ts=4: */
/*
* adduser - add users to /etc/passwd and /etc/shadow
*
*
* Copyright (C) 1999 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <shadow.h>
#include <time.h>
#include <unistd.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "busybox.h"
#include "pwd_grp/pwd.h"
#include "pwd_grp/grp.h"
#define PASSWD_FILE "/etc/passwd"
#define SHADOW_FILE "/etc/gshadow"
#if 0
# define PASSWD_FILE "passwd"
# define SHADOW_FILE "shadow"
#endif
/* structs __________________________ */
typedef struct {
uid_t u;
gid_t g;
} Id;
/* data _____________________________ */
/* defaults : should this be in an external file? */
static char *default_passwd = "x";
static char *default_gecos = "Embedix User,,,";
static char *default_home_prefix = "/home";
static char *default_shell = "/bin/sh";
/* shadow in use? */
static int shadow_enabled = 0;
/* I was doing this all over the place */
static FILE *fopen_wrapper(const char *filename, const char *mode)
{
FILE *f;
f = fopen(filename, mode);
if (f == NULL) {
fprintf(stderr, "adduser: %s: %s\n", filename, strerror(errno));
}
return f;
}
/* remix */
/* EDR recoded such that the uid may be passed in *p */
static int passwd_study(const char *filename, struct passwd *p)
{
struct passwd *pw;
FILE *passwd;
const int min = 500;
const int max = 65000;
passwd = fopen_wrapper(filename, "r");
if (!passwd)
return 4;
/* EDR if uid is out of bounds, set to min */
if ((p->pw_uid > max) || (p->pw_uid < min))
p->pw_uid = min;
/* stuff to do:
* make sure login isn't taken;
* find free uid and gid;
*/
while ((pw = fgetpwent(passwd))) {
if (strcmp(pw->pw_name, p->pw_name) == 0) {
/* return 0; */
return 1;
}
if ((pw->pw_uid >= p->pw_uid) && (pw->pw_uid < max)
&& (pw->pw_uid >= min)) {
p->pw_uid = pw->pw_uid + 1;
}
}
/* EDR check for an already existing gid */
while (getgrgid(p->pw_uid) != NULL)
p->pw_uid++;
/* EDR also check for an existing group definition */
if (getgrnam(p->pw_name) != NULL)
return 3;
/* EDR bounds check */
if ((p->pw_uid > max) || (p->pw_uid < min))
return 2;
/* EDR create new gid always = uid */
p->pw_gid = p->pw_uid;
/* return 1; */
return 0;
}
static void addgroup_wrapper(const char *login, gid_t gid)
{
int argc = 4;
char *argv[] = { "addgroup", "-g", NULL, NULL };
char group_id[8];
char group_name[32];
strncpy(group_name, login, 32);
argv[3] = group_name;
sprintf(group_id, "%d", gid);
argv[2] = group_id;
addgroup_main(argc, argv);
}
static void passwd_wrapper(const char *login)
{
char *prog = "passwd";
execlp(prog, prog, login, NULL);
error_msg_and_die("Failed to execute 'passwd', you must set the password for '%s' manually\n", login);
}
/*
* pwd_to_spwd - create entries for new spwd structure
*
* pwd_to_spwd() creates a new (struct spwd) containing the
* information in the pointed-to (struct passwd).
*/
#define DAY (24L*3600L)
#define WEEK (7*DAY)
#define SCALE DAY
static struct spwd *pwd_to_spwd(const struct passwd *pw)
{
static struct spwd sp;
/*
* Nice, easy parts first. The name and passwd map directly
* from the old password structure to the new one.
*/
sp.sp_namp = pw->pw_name;
sp.sp_pwdp = pw->pw_passwd;
/*
* Defaults used if there is no pw_age information.
*/
sp.sp_min = 0;
sp.sp_max = (10000L * DAY) / SCALE;
sp.sp_lstchg = time((time_t *) 0) / SCALE;
/*
* These fields have no corresponding information in the password
* file. They are set to uninitialized values.
*/
sp.sp_warn = -1;
sp.sp_expire = -1;
sp.sp_inact = -1;
sp.sp_flag = -1;
return &sp;
}
/* putpwent(3) remix */
static int adduser(const char *filename, struct passwd *p)
{
FILE *passwd;
int r;
FILE *shadow;
struct spwd *sp;
/* make sure everything is kosher and setup uid && gid */
passwd = fopen_wrapper(filename, "a");
if (passwd == NULL) {
/* return -1; */
return 1;
}
fseek(passwd, 0, SEEK_END);
/* if (passwd_study(filename, p) == 0) { */
r = passwd_study(filename, p);
if (r) {
if (r == 1)
error_msg("%s: login already in use\n", p->pw_name);
else if (r == 2)
error_msg("illegal uid or no uids left\n");
else if (r == 3)
error_msg("group name %s already in use\n", p->pw_name);
else
error_msg("generic error.\n");
/* return -1; */
return 1;
}
/* add to passwd */
if (putpwent(p, passwd) == -1) {
/* return -1; */
return 1;
}
fclose(passwd);
/* add to shadow if necessary */
if (shadow_enabled) {
shadow = fopen_wrapper(SHADOW_FILE, "a");
if (shadow == NULL) {
/* return -1; */
return 1;
}
fseek(shadow, 0, SEEK_END);
sp = pwd_to_spwd(p);
sp->sp_max = 99999; /* debianish */
sp->sp_warn = 7;
fprintf(shadow, "%s:!:%ld:%ld:%ld:%ld:::\n",
sp->sp_namp, sp->sp_lstchg, sp->sp_min, sp->sp_max,
sp->sp_warn);
fclose(shadow);
}
/* add to group */
/* addgroup should be responsible for dealing w/ gshadow */
addgroup_wrapper(p->pw_name, p->pw_gid);
/* Clear the umask for this process so it doesn't
* * screw up the permissions on the mkdir and chown. */
umask(0);
/* mkdir */
if (mkdir(p->pw_dir, 0755)) {
perror_msg("%s", p->pw_dir);
}
/* Set the owner and group so it is owned by the new user. */
if (chown(p->pw_dir, p->pw_uid, p->pw_gid)) {
perror_msg("%s", p->pw_dir);
}
/* Now fix up the permissions to 2755. Can't do it before now
* since chown will clear the setgid bit */
if (chmod(p->pw_dir, 02755)) {
perror_msg("%s", p->pw_dir);
}
/* interactively set passwd */
passwd_wrapper(p->pw_name);
return 0;
}
/* return current uid (root is always uid == 0, right?) */
static uid_t i_am_not_root()
{
return geteuid();
}
/*
* adduser will take a login_name as its first parameter.
*
* home
* shell
* gecos
*
* can be customized via command-line parameters.
* ________________________________________________________________________ */
int adduser_main(int argc, char **argv)
{
int i;
char opt;
char *login;
char *gecos;
char *home = NULL;
char *shell;
char path[MAXPATHLEN];
struct passwd pw;
/* init */
if (argc < 2) {
show_usage();
}
gecos = default_gecos;
shell = default_shell;
/* get args */
for (i = 1; i < argc; i++) {
if (argv[i][0] == '-') {
opt = argv[i][1];
switch (opt) {
case 'h':
home = argv[++i];
break;
case 'g':
gecos = argv[++i];
break;
case 's':
shell = argv[++i];
break;
default:
error_msg("invalid option -- %c\n", opt);
break;
}
} else {
break;
}
}
/* got root? */
if (i_am_not_root()) {
error_msg_and_die( "Only root may add a user or group to the system.\n");
}
/* get login */
if (i >= argc) {
error_msg_and_die( "adduser: no user specified\n");
}
login = argv[i];
/* create string for $HOME if not specified already */
if (!home) {
snprintf(path, MAXPATHLEN, "%s/%s", default_home_prefix, login);
path[MAXPATHLEN - 1] = 0;
home = path;
}
/* is /etc/shadow in use? */
shadow_enabled = (0 == access(SHADOW_FILE, F_OK));
/* create a passwd struct */
pw.pw_name = login;
pw.pw_passwd = default_passwd;
pw.pw_uid = 0;
pw.pw_gid = 0;
pw.pw_gecos = gecos;
pw.pw_dir = home;
pw.pw_shell = shell;
/* grand finale */
i = adduser(PASSWD_FILE, &pw);
return (i);
}
/* $Id: adduser.c,v 1.1 2001/08/21 16:18:59 andersen Exp $ */
+46 -3
View File
@@ -46,12 +46,21 @@
#ifdef BB_TEST
APPLET_NOUSAGE("[", test_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_ADDGROUP
APPLET(addgroup, addgroup_main, _BB_DIR_BIN)
#endif
#ifdef BB_ADDUSER
APPLET(adduser, adduser_main, _BB_DIR_BIN)
#endif
#ifdef BB_ADJTIMEX
APPLET(adjtimex, adjtimex_main, _BB_DIR_SBIN)
#endif
#ifdef BB_AR
APPLET(ar, ar_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_ASH
APPLET_NOUSAGE("ash", ash_main, _BB_DIR_BIN)
#endif
#ifdef BB_BASENAME
APPLET(basename, basename_main, _BB_DIR_USR_BIN)
#endif
@@ -101,6 +110,12 @@
#ifdef BB_DEALLOCVT
APPLET(deallocvt, deallocvt_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_DELGROUP
APPLET(delgroup, delgroup_main, _BB_DIR_BIN)
#endif
#ifdef BB_DELUSER
APPLET(deluser, deluser_main, _BB_DIR_BIN)
#endif
#ifdef BB_DF
APPLET(df, df_main, _BB_DIR_BIN)
#endif
@@ -164,6 +179,9 @@
#ifdef BB_GETOPT
APPLET(getopt, getopt_main, _BB_DIR_BIN)
#endif
#ifdef BB_GETTY
APPLET(getty, getty_main, _BB_DIR_SBIN)
#endif
#ifdef BB_GREP
APPLET(grep, grep_main, _BB_DIR_BIN)
#endif
@@ -185,6 +203,9 @@
#ifdef BB_HOSTNAME
APPLET(hostname, hostname_main, _BB_DIR_BIN)
#endif
#ifdef BB_HUSH
APPLET_NOUSAGE("hush", hush_main, _BB_DIR_BIN)
#endif
#ifdef BB_ID
APPLET(id, id_main, _BB_DIR_USR_BIN)
#endif
@@ -206,6 +227,9 @@
#ifdef BB_KLOGD
APPLET(klogd, klogd_main, _BB_DIR_SBIN)
#endif
#ifdef BB_LASH
APPLET(lash, lash_main, _BB_DIR_BIN)
#endif
#ifdef BB_LENGTH
APPLET(length, length_main, _BB_DIR_USR_BIN)
#endif
@@ -263,12 +287,18 @@
#ifdef BB_MKTEMP
APPLET(mktemp, mktemp_main, _BB_DIR_BIN)
#endif
#ifdef BB_MODPROBE
APPLET(modprobe, modprobe_main, _BB_DIR_SBIN)
#endif
#ifdef BB_MORE
APPLET(more, more_main, _BB_DIR_BIN)
#endif
#ifdef BB_MOUNT
APPLET(mount, mount_main, _BB_DIR_BIN)
#endif
#ifdef BB_MSH
APPLET_NOUSAGE("msh", msh_main, _BB_DIR_BIN)
#endif
#ifdef BB_MT
APPLET(mt, mt_main, _BB_DIR_BIN)
#endif
@@ -281,6 +311,9 @@
#ifdef BB_NSLOOKUP
APPLET(nslookup, nslookup_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_PIDOF
APPLET(pidof, pidof_main, _BB_DIR_BIN)
#endif
#ifdef BB_PING
APPLET(ping, ping_main, _BB_DIR_BIN)
#endif
@@ -338,8 +371,14 @@
#ifdef BB_SETKEYCODES
APPLET(setkeycodes, setkeycodes_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_SH
APPLET(sh, shell_main, _BB_DIR_BIN)
#if defined(BB_FEATURE_SH_IS_ASH) && defined(BB_ASH)
APPLET_NOUSAGE("sh", ash_main, _BB_DIR_BIN)
#elif defined(BB_FEATURE_SH_IS_HUSH) && defined(BB_HUSH)
APPLET_NOUSAGE("sh", hush_main, _BB_DIR_BIN)
#elif defined(BB_FEATURE_SH_IS_LASH) && defined(BB_LASH)
APPLET_NOUSAGE("sh", lash_main, _BB_DIR_BIN)
#elif defined(BB_FEATURE_SH_IS_MSH) && defined(BB_MSH)
APPLET_NOUSAGE("sh", msh_main, _BB_DIR_BIN)
#endif
#ifdef BB_SLEEP
APPLET(sleep, sleep_main, _BB_DIR_BIN)
@@ -386,6 +425,9 @@
#ifdef BB_TR
APPLET(tr, tr_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_TRACEROUTE
APPLET(traceroute, traceroute_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_TRUE_FALSE
APPLET(true, true_main, _BB_DIR_BIN)
#endif
@@ -402,7 +444,7 @@
APPLET(uniq, uniq_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_UNIX2DOS
APPLET(unix2dos, unix2dos_main, _BB_DIR_USR_BIN)
APPLET(unix2dos, dos2unix_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_UPDATE
APPLET(update, update_main, _BB_DIR_SBIN)
@@ -452,3 +494,4 @@
};
#endif
+88 -5
View File
@@ -1,3 +1,19 @@
#define addgroup_trivial_usage \
"[OPTIONS] <group_name>"
#define addgroup_full_usage \
"Adds a group to the system" \
"Options:\n" \
"\t-g\t\tspecify gid\n"
#define adduser_trivial_usage \
"[OPTIONS] <user_name>"
#define adduser_full_usage \
"Adds a user to the system" \
"Options:\n" \
"\t-h\t\thome directory\n" \
"\t-s\t\tshell\n" \
"\t-g\t\tGECOS string\n"
#define adjtimex_trivial_usage \
"[-q] [-o offset] [-f frequency] [-p timeconstant] [-t tick]"
#define adjtimex_full_usage \
@@ -215,6 +231,15 @@
#define deallocvt_full_usage \
"Deallocate unused virtual terminal /dev/ttyN"
#define delgroup_trivial_usage \
"GROUP"
#define delgroup_full_usage \
"Deletes group GROUP from the system"
#define deluser_trivial_usage \
"USER"
#define deluser_full_usage \
"Deletes user USER from the system"
#ifdef BB_FEATURE_HUMAN_READABLE
#define USAGE_HUMAN_READABLE(a) a
@@ -272,9 +297,14 @@
"\t-d\toutput will be in DOS format"
#define dpkg_trivial_usage \
"[-i|-r|--unpack|--configure] my.deb"
"-i package_file\n"
"[-CPru] package_name"
#define dpkg_full_usage \
"WORK IN PROGRESS, only useful for debian-installer"
"\t-i\tInstall the package\n" \
"\t-C\tConfigure an unpackaged package\n" \
"\t-P\tPurge all files of a package\n" \
"\t-r\tRemove all but the configuration files for a package\n" \
"\t-u\tUnpack a package, but dont configure it\n"
#define dpkg_deb_trivial_usage \
"[-cefItxX] FILE [argument]"
@@ -528,6 +558,22 @@
" esac\n" \
"done\n"
#define getty_trivial_usage \
"getty [OPTIONS]... baud_rate,... line [termtype]"
#define getty_full_usage \
"\nOpens a tty, prompts for a login name, then invokes /bin/login\n\n" \
"Options:\n" \
"\t-h\t\tEnable hardware (RTS/CTS) flow control.\n" \
"\t-i\t\tDo not display /etc/issue before running login.\n" \
"\t-L\t\tLocal line, so do not do carrier detect.\n" \
"\t-m\t\tGet baud rate from modem's CONNECT status message.\n" \
"\t-w\t\tWait for a CR or LF before sending /etc/issue.\n" \
"\t-l login_app\tInvoke login_app instead of /bin/login.\n" \
"\t-t timeout\tTerminate after timeout if no username is read.\n" \
"\t-I initstring\tSets the init string to send before anything else.\n" \
"\t-H login_host\tLog login_host into the utmp file as the hostname."
#define grep_trivial_usage \
"[-ihHnqvs] PATTERN [FILEs...]"
#define grep_full_usage \
@@ -1079,6 +1125,13 @@
"$ ls -la /tmp/temp.mWiLjM\n" \
"-rw------- 1 andersen andersen 0 Apr 25 17:10 /tmp/temp.mWiLjM\n"
#define modprobe_trivial_usage \
"[FILE ...]"
#define modprobe_full_usage \
"Used for hight level module loading and unloading."
#define modprobe_example_usage \
"$ modprobe cdrom\n"
#define more_trivial_usage \
"[FILE ...]"
#define more_full_usage \
@@ -1178,6 +1231,14 @@
"Name: debian\n" \
"Address: 127.0.0.1\n"
#define pidof_trivial_usage \
"process-name [process-name ...]"
#define pidof_full_usage \
"Lists the PIDs of all processes with names that match the names on the command line"
#define pidof_example_usage \
"$ pidof init\n" \
"1\n"
#ifndef BB_FEATURE_FANCY_PING
#define ping_trivial_usage "host"
#define ping_full_usage "Send ICMP ECHO_REQUEST packets to network hosts"
@@ -1345,12 +1406,12 @@
#define setkeycodes_example_usage \
"$ setkeycodes e030 127\n"
#define sh_trivial_usage \
#define lash_trivial_usage \
"[FILE]...\n" \
"or: sh -c command [args]..."
#define sh_full_usage \
#define lash_full_usage \
"lash: The BusyBox LAme SHell (command interpreter)"
#define sh_notes_usage \
#define lash_notes_usage \
"This command does not yet have proper documentation.\n" \
"\n" \
"Use lash just as you would use any other shell. It properly handles pipes,\n" \
@@ -1593,6 +1654,28 @@
"$ echo "gdkkn vnqkc" | tr [a-y] [b-z]\n" \
"hello world\n"
#define traceroute_trivial_usage \
"[-dnrv] [-m max_ttl] [-p port#] [-q nqueries]\n\
[-s src_addr] [-t tos] [-w wait] host [data size]"
#define traceroute_full_usage \
"trace the route ip packets follow going to \"host\"\n" \
"Options:\n" \
"\t-d\tset SO_DEBUG options to socket\n" \
"\t-n\tPrint hop addresses numerically rather than symbolically\n" \
"\t-r\tBypass the normal routing tables and send directly to a host\n" \
"\t-v\tVerbose output\n" \
"\t-m max_ttl\tSet the max time-to-live (max number of hops)\n" \
"\t-p port#\tSet the base UDP port number used in probes\n" \
"\t\t(default is 33434)\n" \
"\t-q nqueries\tSet the number of probes per ``ttl'' to nqueries\n" \
"\t\t(default is 3)\n" \
"\t-s src_addr\tUse the following IP address as the source address\n" \
"\t-t tos\tSet the type-of-service in probe packets to the following value\n" \
"\t\t(default 0)\n" \
"\t-w wait\tSet the time (in seconds) to wait for a response to a probe\n" \
"\t\t(default 3 sec.)."
#define true_trivial_usage \
""
#define true_full_usage \
+6 -6
View File
@@ -70,20 +70,20 @@ extern int ar_main(int argc, char **argv)
/* check ar magic */
fread(ar_magic, 1, 8, src_stream);
archive_offset = 8;
if (strncmp(ar_magic,"!<arch>",7) != 0) {
error_msg_and_die("invalid magic");
}
archive_offset = 8;
extract_names = malloc(sizeof(char *));
extract_names[0] = NULL;
/* Create a list of files to extract */
while (optind < argc) {
extract_names = xrealloc(extract_names, sizeof(char *) * (num_of_entries + 2));
extract_names[num_of_entries] = xstrdup(argv[optind]);
num_of_entries++;
*extract_names = realloc(*extract_names, num_of_entries);
extract_names[num_of_entries - 1] = xstrdup(argv[optind]);
extract_names[num_of_entries] = NULL;
optind++;
}
unarchive(src_stream, &get_header_ar, extract_function, "./", extract_names);
unarchive(src_stream, stdout, &get_header_ar, extract_function, "./", extract_names);
return EXIT_SUCCESS;
}
+6 -6
View File
@@ -70,20 +70,20 @@ extern int ar_main(int argc, char **argv)
/* check ar magic */
fread(ar_magic, 1, 8, src_stream);
archive_offset = 8;
if (strncmp(ar_magic,"!<arch>",7) != 0) {
error_msg_and_die("invalid magic");
}
archive_offset = 8;
extract_names = malloc(sizeof(char *));
extract_names[0] = NULL;
/* Create a list of files to extract */
while (optind < argc) {
extract_names = xrealloc(extract_names, sizeof(char *) * (num_of_entries + 2));
extract_names[num_of_entries] = xstrdup(argv[optind]);
num_of_entries++;
*extract_names = realloc(*extract_names, num_of_entries);
extract_names[num_of_entries - 1] = xstrdup(argv[optind]);
extract_names[num_of_entries] = NULL;
optind++;
}
unarchive(src_stream, &get_header_ar, extract_function, "./", extract_names);
unarchive(src_stream, stdout, &get_header_ar, extract_function, "./", extract_names);
return EXIT_SUCCESS;
}
+10 -7
View File
@@ -68,25 +68,28 @@ extern int cpio_main(int argc, char **argv)
}
}
if (extract_function & extract_all_to_fs && extract_function & extract_list) {
if ((extract_function & extract_all_to_fs) && (extract_function & extract_list)) {
extract_function ^= extract_all_to_fs; /* If specify t, don't extract*/
}
if (extract_function & extract_all_to_fs && extract_function & extract_verbose_list) { /* The meaning of v changes on extract */
if ((extract_function & extract_all_to_fs) && (extract_function & extract_verbose_list)) {
/* The meaning of v changes on extract */
extract_function ^= extract_verbose_list;
extract_function |= extract_list;
}
extract_names = malloc(4);
while (optind < argc) {
extract_names = xrealloc(extract_names, sizeof(char *) * (num_of_entries + 2));
extract_names[num_of_entries] = xstrdup(argv[optind]);
num_of_entries++;
*extract_names = realloc(*extract_names, num_of_entries);
extract_names[num_of_entries - 1] = xstrdup(argv[optind]);
extract_names[num_of_entries] = NULL;
optind++;
}
unarchive(src_stream, &get_header_cpio, extract_function, "./", extract_names);
if (oldmask) umask(oldmask); /* Restore umask if we changed it */
unarchive(src_stream, stdout, &get_header_cpio, extract_function, "./", extract_names);
if (oldmask) {
umask(oldmask); /* Restore umask if we changed it */
}
return EXIT_SUCCESS;
}
+1346 -755
View File
File diff suppressed because it is too large. Load diff
+9 -4
View File
@@ -110,12 +110,17 @@ extern int dpkg_deb_main(int argc, char **argv)
}
else if (arg_type == arg_type_field) {
char *field = NULL;
char *name;
char *value;
int field_start = 0;
while ((field = read_package_field(&output_buffer[field_start])) != NULL) {
field_start += (strlen(field) + 1);
if (strstr(field, argv[optind + 1]) == field) {
puts(field + strlen(argv[optind + 1]) + 2);
while (1) {
field_start += read_package_field(&output_buffer[field_start], &name, &value);
if (name == NULL) {
break;
}
if (strcmp(name, argv[optind + 1]) == 0) {
puts(value);
}
free(field);
}
+3
View File
@@ -118,6 +118,9 @@ extern int gunzip_main(int argc, char **argv)
/* Open input file */
in_file = xfopen(if_name, "r");
/* set the buffer size */
setvbuf(in_file, NULL, _IOFBF, 0x8000);
/* Get the time stamp on the input file. */
if (stat(if_name, &stat_buf) < 0) {
error_msg_and_die("Couldn't stat file %s", if_name);
+46 -28
View File
@@ -110,8 +110,7 @@ static int method; /* compression method */
#ifdef DYN_ALLOC
# define DECLARE(type, array, size) static type * array
# define ALLOC(type, array, size) { \
array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
if (array == NULL) error_msg(memory_exhausted); \
array = (type*)xcalloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
}
# define FREE(array) {if (array != NULL) free(array), array=NULL;}
#else
@@ -181,16 +180,17 @@ typedef int file_t; /* Do not use stdio */
outbuf[outcnt++] = (uch) ((w) & 0xff); \
outbuf[outcnt++] = (uch) ((ush)(w) >> 8); \
} else { \
put_byte((uch)((w) & 0xff)); \
put_byte((uch)((ush)(w) >> 8)); \
put_short_when_full(w); \
} \
}
/* Output a 32 bit value to the bit stream, lsb first */
#if 0
#define put_long(n) { \
put_short((n) & 0xffff); \
put_short(((ulg)(n)) >> 16); \
}
#endif
#define seekable() 0 /* force sequential output */
#define translate_eol 0 /* no option -a yet */
@@ -220,7 +220,6 @@ typedef int file_t; /* Do not use stdio */
#endif
/* from zip.c: */
static int zip (int in, int out);
static int file_read (char *buf, unsigned size);
@@ -248,6 +247,9 @@ static int (*read_buf) (char *buf, unsigned size);
/* from util.c: */
static void flush_outbuf (void);
static void put_short_when_full (ush);
/* lzw.h -- define the lzw functions.
* Copyright (C) 1992-1993 Jean-loup Gailly.
* This is free software; you can redistribute it and/or modify it under the
@@ -388,18 +390,11 @@ static ulg updcrc(uch *s, unsigned n)
static unsigned long crc_32_tab[256];
if (crc_table_empty) {
unsigned long csr; /* crc shift register */
unsigned long e=0; /* polynomial exclusive-or pattern */
const unsigned long e = 0xedb88320L; /* polynomial exclusive-or pattern */
int i; /* counter for all possible eight bit values */
int k; /* byte being shifted into crc apparatus */
/* terms of polynomial defining this crc (except x^32): */
static const int p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
/* Make exclusive-or pattern from polynomial (0xedb88320) */
for (i = 0; i < sizeof(p)/sizeof(int); i++)
e |= 1L << (31 - p[i]);
/* Compute and print table of CRC's, five per line */
/* Compute table of CRC's. */
crc_32_tab[0] = 0x00000000L;
for (i = 1; i < 256; i++) {
csr = i;
@@ -1206,7 +1201,6 @@ typedef struct dirent dir_type;
typedef RETSIGTYPE(*sig_type) (int);
/* ======================================================================== */
// int main (argc, argv)
// int argc;
@@ -1246,7 +1240,7 @@ int gzip_main(int argc, char **argv)
show_usage();
}
}
if (optind == argc) {
if ((optind == argc) || (strcmp(argv[optind], "-") == 0)) {
fromstdin = 1;
tostdout = 1;
}
@@ -1291,11 +1285,9 @@ int gzip_main(int argc, char **argv)
/* Open input file */
inFileNum = open(ifname, O_RDONLY);
if (inFileNum < 0)
if (inFileNum < 0 || stat(ifname, &statBuf) < 0)
perror_msg_and_die("%s", ifname);
/* Get the time stamp on the input file. */
if (stat(ifname, &statBuf) < 0)
perror_msg_and_die("%s", ifname);
time_stamp = statBuf.st_ctime;
ifile_size = statBuf.st_size;
}
@@ -1433,16 +1425,20 @@ int gzip_main(int argc, char **argv)
#define BL_CODES 19
/* number of codes used to transfer the bit lengths */
typedef uch extra_bits_t;
static const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */
/* extra bits for each length code */
static const extra_bits_t extra_lbits[LENGTH_CODES]
= { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4,
4, 4, 5, 5, 5, 5, 0 };
static const int extra_dbits[D_CODES] /* extra bits for each distance code */
/* extra bits for each distance code */
static const extra_bits_t extra_dbits[D_CODES]
= { 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,
10, 10, 11, 11, 12, 12, 13, 13 };
static const int extra_blbits[BL_CODES] /* extra bits for each bit length code */
/* extra bits for each bit length code */
static const extra_bits_t extra_blbits[BL_CODES]
= { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7 };
#define STORED_BLOCK 0
@@ -1537,7 +1533,7 @@ static ct_data bl_tree[2 * BL_CODES + 1];
typedef struct tree_desc {
ct_data *dyn_tree; /* the dynamic tree */
ct_data *static_tree; /* corresponding static tree or NULL */
const int *extra_bits; /* extra bits for each code or NULL */
const extra_bits_t *extra_bits; /* extra bits for each code or NULL */
int extra_base; /* base index for extra_bits */
int elems; /* max number of elements in the tree */
int max_length; /* max bit length for the codes */
@@ -1834,7 +1830,7 @@ static void pqdownheap(ct_data *tree, int k)
static void gen_bitlen(tree_desc *desc)
{
ct_data *tree = desc->dyn_tree;
const int *extra = desc->extra_bits;
const extra_bits_t *extra = desc->extra_bits;
int base = desc->extra_base;
int max_code = desc->max_code;
int max_length = desc->max_length;
@@ -2466,6 +2462,28 @@ static void set_file_type()
static ulg crc; /* crc on uncompressed file data */
static long header_bytes; /* number of bytes in gzip header */
static void put_short_when_full(ush w)
{
put_byte((uch)((w) & 0xff));
put_byte((uch)((ush)(w) >> 8));
}
static void put_short_function(ush n)
{
put_short(n);
}
static void put_long(ulg n)
{
put_short_function((n) & 0xffff);
put_short_function(((ulg)(n)) >> 16);
}
/* put_header_byte is used for the compressed output
* - for the initial 4 bytes that can't overflow the buffer.
*/
#define put_header_byte(c) {outbuf[outcnt++]=(uch)(c);}
/* ===========================================================================
* Deflate in to out.
* IN assertions: the input and output buffers are cleared.
@@ -2485,11 +2503,11 @@ static int zip(int in, int out)
method = DEFLATED;
put_byte(GZIP_MAGIC[0]); /* magic header */
put_byte(GZIP_MAGIC[1]);
put_byte(DEFLATED); /* compression method */
put_header_byte(GZIP_MAGIC[0]); /* magic header */
put_header_byte(GZIP_MAGIC[1]);
put_header_byte(DEFLATED); /* compression method */
put_byte(my_flags); /* general flags */
put_header_byte(my_flags); /* general flags */
put_long(time_stamp);
/* Write deflated file to zip file */
+8 -11
View File
@@ -67,7 +67,7 @@ static char *license_msg[] = {
#include <string.h>
#include "libbb.h"
FILE *in_file, *out_file;
static FILE *in_file, *out_file;
/* these are freed by gz_close */
static unsigned char *window;
@@ -91,9 +91,9 @@ static const int N_MAX = 288; /* maximum number of codes in any set */
static long bytes_out; /* number of output bytes */
static unsigned long outcnt; /* bytes in output buffer */
unsigned hufts; /* track memory usage */
unsigned long bb; /* bit buffer */
unsigned bk; /* bits in bit buffer */
static unsigned hufts; /* track memory usage */
static unsigned long bb; /* bit buffer */
static unsigned bk; /* bits in bit buffer */
typedef struct huft_s {
unsigned char e; /* number of extra bits or operation */
@@ -104,7 +104,7 @@ typedef struct huft_s {
} v;
} huft_t;
unsigned short mask_bits[] = {
static const unsigned short mask_bits[] = {
0x0000,
0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
@@ -154,7 +154,7 @@ static void make_crc_table()
* Write the output window window[0..outcnt-1] and update crc and bytes_out.
* (Used for the decompressed data only.)
*/
void flush_window()
static void flush_window(void)
{
int n;
@@ -925,9 +925,6 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
outcnt = 0;
bytes_out = 0L;
/* set the buffer size */
setvbuf(in_file, NULL, _IOFBF, 0x8000);
magic[0] = fgetc(in_file);
magic[1] = fgetc(in_file);
@@ -1024,6 +1021,6 @@ extern void gz_close(int gunzip_pid)
if (waitpid(gunzip_pid, NULL, 0) == -1) {
printf("Couldnt wait ?");
}
free(window);
free(crc_table);
free(window);
free(crc_table);
}
+8 -11
View File
@@ -67,7 +67,7 @@ static char *license_msg[] = {
#include <string.h>
#include "libbb.h"
FILE *in_file, *out_file;
static FILE *in_file, *out_file;
/* these are freed by gz_close */
static unsigned char *window;
@@ -91,9 +91,9 @@ static const int N_MAX = 288; /* maximum number of codes in any set */
static long bytes_out; /* number of output bytes */
static unsigned long outcnt; /* bytes in output buffer */
unsigned hufts; /* track memory usage */
unsigned long bb; /* bit buffer */
unsigned bk; /* bits in bit buffer */
static unsigned hufts; /* track memory usage */
static unsigned long bb; /* bit buffer */
static unsigned bk; /* bits in bit buffer */
typedef struct huft_s {
unsigned char e; /* number of extra bits or operation */
@@ -104,7 +104,7 @@ typedef struct huft_s {
} v;
} huft_t;
unsigned short mask_bits[] = {
static const unsigned short mask_bits[] = {
0x0000,
0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
@@ -154,7 +154,7 @@ static void make_crc_table()
* Write the output window window[0..outcnt-1] and update crc and bytes_out.
* (Used for the decompressed data only.)
*/
void flush_window()
static void flush_window(void)
{
int n;
@@ -925,9 +925,6 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
outcnt = 0;
bytes_out = 0L;
/* set the buffer size */
setvbuf(in_file, NULL, _IOFBF, 0x8000);
magic[0] = fgetc(in_file);
magic[1] = fgetc(in_file);
@@ -1024,6 +1021,6 @@ extern void gz_close(int gunzip_pid)
if (waitpid(gunzip_pid, NULL, 0) == -1) {
printf("Couldnt wait ?");
}
free(window);
free(crc_table);
free(window);
free(crc_table);
}
+3
View File
@@ -74,6 +74,8 @@ extern int rpm2cpio_main(int argc, char **argv)
} else {
rpmfile = fopen(argv[1], "r");
if (!rpmfile) perror_msg_and_die("Can't open rpm file");
/* set the buffer size */
setvbuf(rpmfile, NULL, _IOFBF, 0x8000);
}
fread (&lead, sizeof(struct rpm_lead), 1, rpmfile);
@@ -85,6 +87,7 @@ extern int rpm2cpio_main(int argc, char **argv)
skip_header(rpmfile);
cpiofile = gz_open(rpmfile, &gunzip_pid);
copyfd(fileno(cpiofile), fileno(stdout));
gz_close(gunzip_pid);
fclose(rpmfile);
+7 -3
View File
@@ -284,6 +284,10 @@ extern int tar_main(int argc, char **argv)
/* unzip tarFd in a seperate process */
if (unzipFlag == TRUE) {
comp_file = fdopen(tarFd, "r");
/* set the buffer size */
setvbuf(comp_file, NULL, _IOFBF, 0x8000);
if ((tarFd = fileno(gz_open(comp_file, &pid))) == EXIT_FAILURE) {
error_msg_and_die("Couldnt unzip file");
}
@@ -330,7 +334,7 @@ tarExtractRegularFile(TarInfo *header, int extractFlag, int tostdoutFlag)
size_t writeSize;
size_t readSize;
size_t actualWriteSz;
char buffer[BUFSIZ];
char buffer[20 * TAR_BLOCK_SIZE];
size_t size = header->size;
int outFd=fileno(stdout);
@@ -354,9 +358,9 @@ tarExtractRegularFile(TarInfo *header, int extractFlag, int tostdoutFlag)
if ( size > sizeof(buffer) )
writeSize = readSize = sizeof(buffer);
else {
int mod = size % 512;
int mod = size % TAR_BLOCK_SIZE;
if ( mod != 0 )
readSize = size + (512 - mod);
readSize = size + (TAR_BLOCK_SIZE - mod);
else
readSize = size;
writeSize = size;
+2074 -2511
View File
File diff suppressed because it is too large. Load diff
+3
View File
@@ -69,13 +69,16 @@ extern const struct BB_applet applets[];
#ifdef BB_FEATURE_BUFFERS_GO_ON_STACK
#define RESERVE_BB_BUFFER(buffer,len) char buffer[len]
#define RESERVE_BB_UBUFFER(buffer,len) unsigned char buffer[len]
#define RELEASE_BB_BUFFER(buffer) ((void)0)
#else
#ifdef BB_FEATURE_BUFFERS_GO_IN_BSS
#define RESERVE_BB_BUFFER(buffer,len) static char buffer[len]
#define RESERVE_BB_UBUFFER(buffer,len) static unsigned char buffer[len]
#define RELEASE_BB_BUFFER(buffer) ((void)0)
#else
#define RESERVE_BB_BUFFER(buffer,len) char *buffer=xmalloc(len)
#define RESERVE_BB_UBUFFER(buffer,len) unsigned char *buffer=xmalloc(len)
#define RELEASE_BB_BUFFER(buffer) free (buffer)
#endif
#endif
+16 -8
View File
@@ -1,13 +1,21 @@
Name: busybox
Version: 0.52
Release: 1
%define name busybox
%define epoch 0
%define version 0.61.pre
%define release %(date -I | sed -e 's/-/_/g')
%define serial 1
Name: %{name}
#Epoch: %{epoch}
Version: %{version}
Release: %{release}
Serial: %{serial}
Copyright: GPL
Group: System/Utilities
Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary.
Copyright: GPL
URL: http://busybox.lineo.com/
Source: ftp://oss.lineo.com/busybox/%{name}-%{version}.tar.gz
Buildroot: /var/tmp/%{name}-%{version}
Packager : Erik Andersen <andersen@lineo.com>
Conflicts: fileutils grep shellutils
Buildroot: /tmp/%{Name}-%{Version}
Source: %{Name}-%{Version}.tar.gz
%Description
BusyBox combines tiny versions of many common UNIX utilities into a single
@@ -19,7 +27,7 @@ their full featured GNU cousins; however, the options that are provided behave
very much like their GNU counterparts.
%Prep
%setup -q -n %{Name}-%{Version}
%setup -q -n %{name}-%{version}
%Build
make
+1 -1
View File
@@ -36,7 +36,7 @@
static long uid;
static long gid;
static int (*chown_func)() = chown;
static int (*chown_func)(const char *, __uid_t, __gid_t) = chown;
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
{
+6 -6
View File
@@ -48,17 +48,17 @@ int chroot_main(int argc, char **argv)
prog = *argv;
execvp(*argv, argv);
} else {
#ifndef BB_SH
prog = getenv("SHELL");
if (!prog)
prog = "/bin/sh";
execlp(prog, prog, NULL);
#else
#if defined shell_main && defined BB_FEATURE_SH_STANDALONE_SHELL
char shell[] = "/bin/sh";
char *shell_argv[2] = { shell, NULL };
applet_name = shell;
shell_main(1, shell_argv);
return EXIT_SUCCESS;
#else
prog = getenv("SHELL");
if (!prog)
prog = "/bin/sh";
execlp(prog, prog, NULL);
#endif
}
perror_msg_and_die("cannot execute %s", prog);
+52 -79
View File
@@ -3,7 +3,7 @@
* Termios command line History and Editting.
*
* Copyright (c) 1986-2001 may safely be consumed by a BSD or GPL license.
* Written by: Vladimir Oleynik <vodz@usa.net>
* Written by: Vladimir Oleynik <dzo@simtreas.ru>
*
* Used ideas:
* Adam Rogoyski <rogoyski@cs.utexas.edu>
@@ -123,9 +123,8 @@ volatile int handlers_sets = 0; /* Set next bites: */
enum {
SET_ATEXIT = 1, /* when atexit() has been called
and get euid,uid,gid to fast compare */
SET_TERM_HANDLERS = 2, /* set many terminates signal handlers */
SET_WCHG_HANDLERS = 4, /* winchg signal handler */
SET_RESET_TERM = 8, /* if the terminal needs to be reset upon exit */
SET_WCHG_HANDLERS = 2, /* winchg signal handler */
SET_RESET_TERM = 4, /* if the terminal needs to be reset upon exit */
};
@@ -142,10 +141,6 @@ static
#endif
char *cmdedit_prompt; /* --- "" - - "" - -"- --""-- --""--- */
/* Link into lash to reset context to 0 on ^C and such */
extern unsigned int shell_context;
#ifdef BB_FEATURE_GETUSERNAME_AND_HOMEDIR
static char *user_buf = "";
static char *home_pwd_buf = "";
@@ -169,13 +164,17 @@ static int my_gid;
#endif /* BB_FEATURE_COMMAND_TAB_COMPLETION */
/* It seems that libc5 doesn't know what a sighandler_t is... */
#if (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1)
typedef void (*sighandler_t) (int);
#endif
static void cmdedit_setwidth(int w, int redraw_flg);
static void win_changed(int nsig)
{
struct winsize win = { 0, 0, 0, 0 };
static __sighandler_t previous_SIGWINCH_handler; /* for reset */
static sighandler_t previous_SIGWINCH_handler; /* for reset */
/* emulate || signal call */
if (nsig == -SIGWINCH || nsig == SIGWINCH) {
@@ -319,6 +318,7 @@ static void put_prompt(void)
out1str(cmdedit_prompt);
cmdedit_x = cmdedit_prmt_len; /* count real x terminal position */
cursor = 0;
cmdedit_y = 0; /* new quasireal y */
}
#ifndef BB_FEATURE_SH_FANCY_PROMPT
@@ -456,7 +456,6 @@ static void redraw(int y, int back_cursor)
{
if (y > 0) /* up to start y */
printf("\033[%dA", y);
cmdedit_y = 0; /* new quasireal y */
putchar('\r');
put_prompt();
input_end(); /* rewrite */
@@ -497,14 +496,6 @@ static void input_forward(void)
}
static void clean_up_and_die(int sig)
{
goto_new_line();
if (sig != SIGINT)
exit(EXIT_SUCCESS); /* cmdedit_reset_term() called in atexit */
cmdedit_reset_term();
}
static void cmdedit_setwidth(int w, int redraw_flg)
{
cmdedit_termw = cmdedit_prmt_len + 2;
@@ -525,7 +516,7 @@ static void cmdedit_setwidth(int w, int redraw_flg)
}
}
extern void cmdedit_init(void)
static void cmdedit_init(void)
{
cmdedit_prmt_len = 0;
if ((handlers_sets & SET_WCHG_HANDLERS) == 0) {
@@ -557,14 +548,6 @@ extern void cmdedit_init(void)
handlers_sets |= SET_ATEXIT;
atexit(cmdedit_reset_term); /* be sure to do this only once */
}
if ((handlers_sets & SET_TERM_HANDLERS) == 0) {
signal(SIGKILL, clean_up_and_die);
signal(SIGINT, clean_up_and_die);
signal(SIGQUIT, clean_up_and_die);
signal(SIGTERM, clean_up_and_die);
handlers_sets |= SET_TERM_HANDLERS;
}
}
#ifdef BB_FEATURE_COMMAND_TAB_COMPLETION
@@ -1174,7 +1157,8 @@ enum {
*
*/
extern void cmdedit_read_input(char *prompt, char command[BUFSIZ])
int cmdedit_read_input(char *prompt, char command[BUFSIZ])
{
int break_out = 0;
@@ -1187,25 +1171,21 @@ extern void cmdedit_read_input(char *prompt, char command[BUFSIZ])
len = 0;
command_ps = command;
if (new_settings.c_cc[VERASE] == 0) { /* first call */
getTermSettings(0, (void *) &initial_settings);
memcpy(&new_settings, &initial_settings, sizeof(struct termios));
new_settings.c_lflag &= ~ICANON; /* unbuffered input */
/* Turn off echoing and CTRL-C, so we can trap it */
new_settings.c_lflag &= ~(ECHO | ECHONL | ISIG);
getTermSettings(0, (void *) &initial_settings);
memcpy(&new_settings, &initial_settings, sizeof(struct termios));
new_settings.c_lflag &= ~ICANON; /* unbuffered input */
/* Turn off echoing and CTRL-C, so we can trap it */
new_settings.c_lflag &= ~(ECHO | ECHONL | ISIG);
#ifndef linux
/* Hmm, in linux c_cc[] not parsed if set ~ICANON */
new_settings.c_cc[VMIN] = 1;
new_settings.c_cc[VTIME] = 0;
/* Turn off CTRL-C, so we can trap it */
/* Hmm, in linux c_cc[] not parsed if set ~ICANON */
new_settings.c_cc[VMIN] = 1;
new_settings.c_cc[VTIME] = 0;
/* Turn off CTRL-C, so we can trap it */
# ifndef _POSIX_VDISABLE
# define _POSIX_VDISABLE '\0'
# endif
new_settings.c_cc[VINTR] = _POSIX_VDISABLE;
new_settings.c_cc[VINTR] = _POSIX_VDISABLE;
#endif
}
command[0] = 0;
setTermSettings(0, (void *) &new_settings);
@@ -1220,7 +1200,7 @@ extern void cmdedit_read_input(char *prompt, char command[BUFSIZ])
fflush(stdout); /* buffered out to fast */
if (read(0, &c, 1) < 1)
if (safe_read(0, &c, 1) < 1)
/* if we can't read input then exit */
goto prepare_to_die;
@@ -1241,22 +1221,26 @@ extern void cmdedit_read_input(char *prompt, char command[BUFSIZ])
break;
case 3:
/* Control-c -- stop gathering input */
/* Link into lash to reset context to 0 on ^C and such */
shell_context = 0;
/* Go to the next line */
goto_new_line();
command[0] = 0;
return;
len = 0;
lastWasTab = FALSE;
put_prompt();
break;
case 4:
/* Control-d -- Delete one character, or exit
* if the len=0 and no chars to delete */
if (len == 0) {
prepare_to_die:
#if !defined(BB_ASH)
printf("exit");
clean_up_and_die(0);
goto_new_line();
/* cmdedit_reset_term() called in atexit */
exit(EXIT_SUCCESS);
#else
break_out = -1; /* for control stoped jobs */
break;
#endif
} else {
input_delete();
}
@@ -1307,12 +1291,12 @@ prepare_to_die:
case ESC:{
/* escape sequence follows */
if (read(0, &c, 1) < 1)
return;
if (safe_read(0, &c, 1) < 1)
goto prepare_to_die;
/* different vt100 emulations */
if (c == '[' || c == 'O') {
if (read(0, &c, 1) < 1)
return;
if (safe_read(0, &c, 1) < 1)
goto prepare_to_die;
}
switch (c) {
#ifdef BB_FEATURE_COMMAND_TAB_COMPLETION
@@ -1376,8 +1360,8 @@ prepare_to_die:
}
if (c >= '1' && c <= '9')
do
if (read(0, &c, 1) < 1)
return;
if (safe_read(0, &c, 1) < 1)
goto prepare_to_die;
while (c != '~');
break;
}
@@ -1386,8 +1370,8 @@ prepare_to_die:
#ifdef BB_FEATURE_NONPRINTABLE_INVERSE_PUT
/* Control-V -- Add non-printable symbol */
if (c == 22) {
if (read(0, &c, 1) < 1)
return;
if (safe_read(0, &c, 1) < 1)
goto prepare_to_die;
if (c == 0) {
beep();
break;
@@ -1477,32 +1461,22 @@ prepare_to_die:
num_ok_lines++;
#endif
}
if(break_out>0) {
command[len++] = '\n'; /* set '\n' */
command[len] = 0;
}
#if defined(BB_FEATURE_CLEAN_UP) && defined(BB_FEATURE_COMMAND_TAB_COMPLETION)
input_tab(0); /* strong free */
#endif
#if defined(BB_FEATURE_SH_FANCY_PROMPT)
free(cmdedit_prompt);
#endif
return;
}
/* Undo the effects of cmdedit_init(). */
extern void cmdedit_terminate(void)
{
cmdedit_reset_term();
if ((handlers_sets & SET_TERM_HANDLERS) != 0) {
signal(SIGKILL, SIG_DFL);
signal(SIGINT, SIG_DFL);
signal(SIGQUIT, SIG_DFL);
signal(SIGTERM, SIG_DFL);
signal(SIGWINCH, SIG_DFL);
handlers_sets &= ~SET_TERM_HANDLERS;
}
return len;
}
#endif /* BB_FEATURE_COMMAND_EDITING */
@@ -1515,8 +1489,6 @@ const char *memory_exhausted = "Memory exhausted";
#include <locale.h>
#endif
unsigned int shell_context;
int main(int argc, char **argv)
{
char buff[BUFSIZ];
@@ -1532,15 +1504,16 @@ int main(int argc, char **argv)
#ifdef BB_FEATURE_NONPRINTABLE_INVERSE_PUT
setlocale(LC_ALL, "");
#endif
shell_context = 1;
do {
while(1) {
int l;
cmdedit_read_input(prompt, buff);
l = strlen(buff);
if(l==0)
break;
if(l > 0 && buff[l-1] == '\n')
buff[l-1] = 0;
printf("*** cmdedit_read_input() returned line =%s=\n", buff);
} while (shell_context);
}
printf("*** cmdedit_read_input() detect ^C\n");
return 0;
}
+1 -3
View File
@@ -1,8 +1,6 @@
#ifndef CMDEDIT_H
#define CMDEDIT_H
void cmdedit_init(void);
void cmdedit_terminate(void);
void cmdedit_read_input(char* promptStr, char* command); /* read a line of input */
int cmdedit_read_input(char* promptStr, char* command);
#endif /* CMDEDIT_H */
+2 -2
View File
@@ -51,9 +51,9 @@ int dumpkmap_main(int argc, char **argv)
show_usage();
}
fd = open("/dev/tty0", O_RDWR);
fd = open(CURRENT_VC, O_RDWR);
if (fd < 0) {
perror_msg("Error opening /dev/tty0");
perror_msg("Error opening " CURRENT_VC);
return EXIT_FAILURE;
}
+2 -2
View File
@@ -37,9 +37,9 @@ int loadacm_main(int argc, char **argv)
show_usage();
}
fd = open("/dev/tty", O_RDWR);
fd = open(CURRENT_VC, O_RDWR);
if (fd < 0) {
perror_msg_and_die("Error opening /dev/tty1");
perror_msg_and_die("Error opening " CURRENT_VC);
}
if (screen_map_load(fd, stdin)) {
+2 -2
View File
@@ -46,9 +46,9 @@ extern int loadfont_main(int argc, char **argv)
if (argc != 1)
show_usage();
fd = open("/dev/tty0", O_RDWR);
fd = open(CURRENT_VC, O_RDWR);
if (fd < 0)
perror_msg_and_die("Error opening /dev/tty0");
perror_msg_and_die("Error opening " CURRENT_VC);
loadnewfont(fd);
return EXIT_SUCCESS;
+2 -2
View File
@@ -53,9 +53,9 @@ int loadkmap_main(int argc, char **argv)
if (argc != 1)
show_usage();
fd = open("/dev/tty0", O_RDWR);
fd = open(CURRENT_VC, O_RDWR);
if (fd < 0)
perror_msg_and_die("Error opening /dev/tty0");
perror_msg_and_die("Error opening " CURRENT_VC);
read(0, buff, 7);
if (0 != strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
+1 -1
View File
@@ -36,7 +36,7 @@
static long uid;
static long gid;
static int (*chown_func)() = chown;
static int (*chown_func)(const char *, __uid_t, __gid_t) = chown;
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
{
+6 -6
View File
@@ -48,17 +48,17 @@ int chroot_main(int argc, char **argv)
prog = *argv;
execvp(*argv, argv);
} else {
#ifndef BB_SH
prog = getenv("SHELL");
if (!prog)
prog = "/bin/sh";
execlp(prog, prog, NULL);
#else
#if defined shell_main && defined BB_FEATURE_SH_STANDALONE_SHELL
char shell[] = "/bin/sh";
char *shell_argv[2] = { shell, NULL };
applet_name = shell;
shell_main(1, shell_argv);
return EXIT_SUCCESS;
#else
prog = getenv("SHELL");
if (!prog)
prog = "/bin/sh";
execlp(prog, prog, NULL);
#endif
}
perror_msg_and_die("cannot execute %s", prog);
+2 -4
View File
@@ -344,10 +344,8 @@ extern int cut_main(int argc, char **argv)
int i;
FILE *file;
for (i = optind; i < argc; i++) {
file = fopen(argv[i], "r");
if (file == NULL) {
perror_msg("%s", argv[i]);
} else {
file = wfopen(argv[i], "r");
if(file) {
cut_file(file);
fclose(file);
}
+2 -6
View File
@@ -50,7 +50,6 @@ int dd_main(int argc, char **argv)
size_t bs = 512, count = -1;
ssize_t n;
off_t seek = 0, skip = 0;
FILE *statusfp;
char *infile = NULL, *outfile = NULL, *buf;
for (i = 1; i < argc; i++) {
@@ -110,12 +109,9 @@ int dd_main(int argc, char **argv)
if (ftruncate(ofd, seek * bs) < 0)
perror_msg_and_die("%s", outfile);
}
statusfp = stdout;
} else {
ofd = STDOUT_FILENO;
outfile = "standard output";
statusfp = stderr;
}
if (skip) {
@@ -151,8 +147,8 @@ int dd_main(int argc, char **argv)
out_part++;
}
fprintf(statusfp, "%ld+%ld records in\n", (long)in_full, (long)in_part);
fprintf(statusfp, "%ld+%ld records out\n", (long)out_full, (long)out_part);
fprintf(stderr, "%ld+%ld records in\n", (long)in_full, (long)in_part);
fprintf(stderr, "%ld+%ld records out\n", (long)out_full, (long)out_part);
return EXIT_SUCCESS;
}
+68 -19
View File
@@ -29,21 +29,60 @@
#include <string.h>
#include <getopt.h>
#include <unistd.h>
#include <stdint.h>
#include <fcntl.h>
#include <sys/time.h>
#include "busybox.h"
/* We are making a lame pseudo-random string generator here. in
* convert(), each pass through the while loop will add more and more
* stuff into value, which is _supposed_ to wrap. We don't care about
* it being accurate. We care about it being messy, since we then mod
* it by the sizeof(letters) and then use that as an index into letters
* to pick a random letter to add to out temporary file. */
typedef unsigned long int bb_uint64_t;
static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
// if fn is NULL then input is stdin and output is stdout
static int convert(char *fn, int ConvType) {
int c;
char *tempFn = NULL;
static int convert(char *fn, int ConvType)
{
int c, fd;
struct timeval tv;
char tempFn[BUFSIZ];
static bb_uint64_t value=0;
FILE *in = stdin, *out = stdout;
if (fn != NULL) {
if ((in = wfopen(fn, "r")) == NULL) {
if ((in = wfopen(fn, "rw")) == NULL) {
return -1;
}
if ((out = tmpfile()) == NULL) {
perror_msg(NULL);
return -2;
strcpy(tempFn, fn);
c = strlen(tempFn);
tempFn[c] = '.';
while(1) {
if (c >=BUFSIZ)
error_msg_and_die("unique name not found");
/* Get some semi random stuff to try and make a
* random filename based (and in the same dir as)
* the input file... */
gettimeofday (&tv, NULL);
value += ((bb_uint64_t) tv.tv_usec << 16) ^ tv.tv_sec ^ getpid ();
tempFn[++c] = letters[value % 62];
tempFn[c+1] = '\0';
value /= 62;
if ((fd = open(tempFn, O_RDWR | O_CREAT | O_EXCL, 0600)) < 0 ) {
continue;
}
out = fdopen(fd, "w+");
if (!out) {
close(fd);
remove(tempFn);
continue;
}
break;
}
}
@@ -51,6 +90,7 @@ static int convert(char *fn, int ConvType) {
if (c == '\r') {
if ((ConvType == CT_UNIX2DOS) && (fn != NULL)) {
// file is alredy in DOS format so it is not necessery to touch it
remove(tempFn);
if (fclose(in) < 0 || fclose(out) < 0) {
perror_msg(NULL);
return -2;
@@ -64,6 +104,7 @@ static int convert(char *fn, int ConvType) {
if (c == '\n') {
if ((ConvType == CT_DOS2UNIX) && (fn != NULL)) {
// file is alredy in UNIX format so it is not necessery to touch it
remove(tempFn);
if ((fclose(in) < 0) || (fclose(out) < 0)) {
perror_msg(NULL);
return -2;
@@ -95,29 +136,37 @@ static int convert(char *fn, int ConvType) {
}
if (fn != NULL) {
if (fclose(in) < 0 || fclose(out) < 0 ||
(in = fopen(tempFn, "r")) == NULL || (out = fopen(fn, "w")) == NULL) {
perror_msg(NULL);
return -2;
if (fclose(in) < 0 || fclose(out) < 0) {
perror_msg(NULL);
remove(tempFn);
return -2;
}
while ((c = fgetc(in)) != EOF) {
fputc(c, out);
}
if ((fclose(in) < 0) || (fclose(out) < 0)) {
perror_msg(NULL);
return -2;
/* Assume they are both on the same filesystem (which
* should be true since we put them into the same directory
* so we _should_ be ok, but you never know... */
if (rename(tempFn, fn) < 0) {
perror_msg("unable to rename '%s' as '%s'", tempFn, fn);
return -1;
}
}
return 0;
}
int dos2unix_main(int argc, char *argv[]) {
int dos2unix_main(int argc, char *argv[])
{
int ConvType = CT_AUTO;
int o;
//See if we are supposed to be doing dos2unix or unix2dos
if (argv[0][0]=='d') {
ConvType = CT_DOS2UNIX;
}
if (argv[0][0]=='u') {
ConvType = CT_UNIX2DOS;
}
// process parameters
while ((o = getopt(argc, argv, "du")) != EOF) {
switch (o) {
+1 -3
View File
@@ -22,7 +22,6 @@
*
*/
#include <errno.h>
#include <stdio.h>
#include <getopt.h>
#include <stdlib.h>
@@ -82,10 +81,9 @@ int head_main(int argc, char **argv)
printf("==> %s <==\n", argv[optind]);
}
head(len, fp);
if (errno) {
if (ferror(fp)) {
perror_msg("%s", argv[optind]);
status = EXIT_FAILURE;
errno = 0;
}
if (optind < argc - 1)
putchar('\n');
+4 -1
View File
@@ -61,6 +61,7 @@ enum {
#include <stdlib.h>
#include <fcntl.h>
#include <signal.h>
#include <termios.h>
#include <sys/ioctl.h>
#include "busybox.h"
@@ -303,6 +304,7 @@ static struct dnode **dnalloc(int num)
return(p);
}
#ifdef BB_FEATURE_LS_RECURSIVE
static void dfree(struct dnode **dnp)
{
struct dnode *cur, *next;
@@ -318,6 +320,7 @@ static void dfree(struct dnode **dnp)
}
free(dnp); /* free the array holding the dnode pointers */
}
#endif
static struct dnode **splitdnarray(struct dnode **dn, int nfiles, int which)
{
@@ -634,7 +637,7 @@ static int list_single(struct dnode *dn)
my_getpwuid(scratch, dn->dstat.st_uid);
printf("%-8.8s ", scratch);
my_getgrgid(scratch, dn->dstat.st_gid);
printf("%-8.8s ", scratch);
printf("%-8.8s", scratch);
column += 17;
break;
#endif
+42 -112
View File
@@ -63,24 +63,6 @@
/* md5.c - Functions to compute MD5 message digest of files or memory blocks
* according to the definition of MD5 in RFC 1321 from April 1992.
* Copyright (C) 1995, 1996 Free Software Foundation, Inc.
*
* NOTE: The canonical source of this file is maintained with the GNU C
* Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. */
@@ -90,34 +72,7 @@
//----------------------------------------------------------------------------
/* md5.h - Declaration of functions and data types used for MD5 sum
computing library functions.
Copyright (C) 1995, 1996 Free Software Foundation, Inc.
NOTE: The canonical source of this file is maintained with the GNU C
Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef _MD5_H
static const int _MD5_H = 1;
/* The following contortions are an attempt to use the C preprocessor
to determine an unsigned integral type that is 32 bits wide. An
alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but
doing that would require that the configure script compile and *run*
the resulting executable. Locally running cross-compiled executables
is usually not possible. */
computing library functions. */
typedef u_int32_t md5_uint32;
@@ -141,20 +96,20 @@ struct md5_ctx
/* Initialize structure containing state of computation.
(RFC 1321, 3.3: Step 3) */
extern void md5_init_ctx __P ((struct md5_ctx *ctx));
static void md5_init_ctx __P ((struct md5_ctx *ctx));
/* Starting with the result of former calls of this function (or the
initialization function update the context for the next LEN bytes
starting at BUFFER.
It is necessary that LEN is a multiple of 64!!! */
extern void md5_process_block __P ((const void *buffer, size_t len,
static void md5_process_block __P ((const void *buffer, size_t len,
struct md5_ctx *ctx));
/* Starting with the result of former calls of this function (or the
initialization function update the context for the next LEN bytes
starting at BUFFER.
It is NOT required that LEN is a multiple of 64. */
extern void md5_process_bytes __P ((const void *buffer, size_t len,
static void md5_process_bytes __P ((const void *buffer, size_t len,
struct md5_ctx *ctx));
/* Process the remaining bytes in the buffer and put result from CTX
@@ -164,30 +119,21 @@ extern void md5_process_bytes __P ((const void *buffer, size_t len,
IMPORTANT: On some systems it is required that RESBUF is correctly
aligned for a 32 bits value. */
extern void *md5_finish_ctx __P ((struct md5_ctx *ctx, void *resbuf));
static void *md5_finish_ctx __P ((struct md5_ctx *ctx, void *resbuf));
/* Put result from CTX in first 16 bytes following RESBUF. The result is
always in little endian byte order, so that a byte-wise output yields
to the wanted ASCII representation of the message digest.
IMPORTANT: On some systems it is required that RESBUF is correctly
aligned for a 32 bits value. */
extern void *md5_read_ctx __P ((const struct md5_ctx *ctx, void *resbuf));
/* Compute MD5 message digest for bytes read from STREAM. The
resulting message digest number will be written into the 16 bytes
beginning at RESBLOCK. */
extern int md5_stream __P ((FILE *stream, void *resblock));
static int md5_stream __P ((FILE *stream, void *resblock));
/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The
result is always in little endian byte order, so that a byte-wise
output yields to the wanted ASCII representation of the message
digest. */
extern void *md5_buffer __P ((const char *buffer, size_t len, void *resblock));
#endif
static void *md5_buffer __P ((const char *buffer, size_t len, void *resblock));
//----------------------------------------------------------------------------
//--------end of md5.h
@@ -221,27 +167,12 @@ void md5_init_ctx(struct md5_ctx *ctx)
ctx->buflen = 0;
}
/* Put result from CTX in first 16 bytes following RESBUF. The result
must be in little endian byte order.
IMPORTANT: On some systems it is required that RESBUF is correctly
aligned for a 32 bits value. */
void *md5_read_ctx(const struct md5_ctx *ctx, void *resbuf)
{
((md5_uint32 *) resbuf)[0] = SWAP(ctx->A);
((md5_uint32 *) resbuf)[1] = SWAP(ctx->B);
((md5_uint32 *) resbuf)[2] = SWAP(ctx->C);
((md5_uint32 *) resbuf)[3] = SWAP(ctx->D);
return resbuf;
}
/* Process the remaining bytes in the internal buffer and the usual
prolog according to the standard and write the result to RESBUF.
IMPORTANT: On some systems it is required that RESBUF is correctly
aligned for a 32 bits value. */
void *md5_finish_ctx(struct md5_ctx *ctx, void *resbuf)
static void *md5_finish_ctx(struct md5_ctx *ctx, void *resbuf)
{
/* Take yet unprocessed bytes into account. */
md5_uint32 bytes = ctx->buflen;
@@ -268,13 +199,24 @@ void *md5_finish_ctx(struct md5_ctx *ctx, void *resbuf)
/* Process last bytes. */
md5_process_block(ctx->buffer, bytes + pad + 8, ctx);
return md5_read_ctx(ctx, resbuf);
/* Put result from CTX in first 16 bytes following RESBUF. The result is
always in little endian byte order, so that a byte-wise output yields
to the wanted ASCII representation of the message digest.
IMPORTANT: On some systems it is required that RESBUF is correctly
aligned for a 32 bits value. */
((md5_uint32 *) resbuf)[0] = SWAP(ctx->A);
((md5_uint32 *) resbuf)[1] = SWAP(ctx->B);
((md5_uint32 *) resbuf)[2] = SWAP(ctx->C);
((md5_uint32 *) resbuf)[3] = SWAP(ctx->D);
return resbuf;
}
/* Compute MD5 message digest for bytes read from STREAM. The
resulting message digest number will be written into the 16 bytes
beginning at RESBLOCK. */
int md5_stream(FILE *stream, void *resblock)
static int md5_stream(FILE *stream, void *resblock)
{
/* Important: BLOCKSIZE must be a multiple of 64. */
static const int BLOCKSIZE = 4096;
@@ -326,7 +268,7 @@ static const int BLOCKSIZE = 4096;
result is always in little endian byte order, so that a byte-wise
output yields to the wanted ASCII representation of the message
digest. */
void *md5_buffer(const char *buffer, size_t len, void *resblock)
static void *md5_buffer(const char *buffer, size_t len, void *resblock)
{
struct md5_ctx ctx;
@@ -340,7 +282,7 @@ void *md5_buffer(const char *buffer, size_t len, void *resblock)
return md5_finish_ctx(&ctx, resblock);
}
void md5_process_bytes(const void *buffer, size_t len, struct md5_ctx *ctx)
static void md5_process_bytes(const void *buffer, size_t len, struct md5_ctx *ctx)
{
/* When we already have some bits in our internal buffer concatenate
both inputs first. */
@@ -388,7 +330,7 @@ void md5_process_bytes(const void *buffer, size_t len, struct md5_ctx *ctx)
/* Process LEN bytes of BUFFER, accumulating context into CTX.
It is assumed that LEN % 64 == 0. */
void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
static void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
{
md5_uint32 correct_words[16];
const md5_uint32 *words = buffer;
@@ -490,7 +432,6 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
break;
case 3:
temp += FI(B,C,D);
break;
}
temp += cwp[(int)(*pp++)] + *pc++;
temp = CYCLIC (temp, ps[i&3]);
@@ -550,6 +491,7 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
/* It is unfortunate that C does not provide an operator for
cyclic rotation. Hope the C compiler is smart enough. */
/* gcc 2.95.4 seems to be --aaronl */
#define CYCLIC(w, s) (w = (w << s) | (w >> (32 - s)))
/* Before we start, one word to the strange constants.
@@ -707,11 +649,7 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
//----------------------------------------------------------------------------
#define ISWHITE(c) ((c) == ' ' || (c) == '\t')
#define IN_CTYPE_DOMAIN(c) 1
#define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c))
#define STREQ(a, b) (strcmp ((a), (b)) == 0)
#define TOLOWER(Ch) tolower (Ch)
#define OPENOPTS(BINARY) "r"
#define ISXDIGIT(c) (isxdigit (c))
/* The minimum length of a valid digest line in a file produced
by `md5sum FILE' and read by `md5sum -c'. This length does
@@ -731,7 +669,6 @@ static int warn = 0; /* With -w, print a message to standard error warning
static int split_3(char *s,
size_t s_len,
unsigned char **u,
int *binary,
char **w)
{
size_t i = 0;
@@ -762,9 +699,8 @@ static int split_3(char *s,
s[i++] = '\0';
if (s[i] != ' ' && s[i] != '*')
if (s[i] != ' ' && s[i++] != '*')
return FALSE;
*binary = (s[i++] == '*');
/* All characters between the type indicator and end of line are
significant -- that includes leading and trailing white space. */
@@ -812,7 +748,7 @@ static int split_3(char *s,
return TRUE;
}
static int hex_digits(unsigned char const *s)
static inline int hex_digits(unsigned char const *s)
{
while (*s) {
if (!ISXDIGIT(*s))
@@ -826,21 +762,18 @@ static int hex_digits(unsigned char const *s)
put the result in *MD5_RESULT. Return non-zero upon failure, zero
to indicate success. */
static int md5_file(const char *filename,
int binary,
unsigned char *md5_result)
{
FILE *fp;
if (STREQ(filename, "-")) {
if (filename[0] == '-' && filename[1] == '\0') {
have_read_stdin = 1;
fp = stdin;
} else {
fp = fopen(filename, OPENOPTS(binary));
if (fp == NULL) {
perror_msg("%s", filename);
fp = wfopen(filename, "r");
if (fp == NULL)
return FALSE;
}
}
if (md5_stream(fp, md5_result)) {
perror_msg("%s", filename);
@@ -868,22 +801,19 @@ static int md5_check(const char *checkfile_name)
size_t line_number;
char line[BUFSIZ];
if (STREQ(checkfile_name, "-")) {
if (checkfile_name[0] == '-' && checkfile_name[1] == '\0') {
have_read_stdin = 1;
checkfile_stream = stdin;
} else {
checkfile_stream = fopen(checkfile_name, "r");
if (checkfile_stream == NULL) {
perror_msg("%s", checkfile_name);
checkfile_stream = wfopen(checkfile_name, "r");
if (checkfile_stream == NULL)
return FALSE;
}
}
line_number = 0;
do {
char *filename;
int binary;
unsigned char *md5num;
int line_length;
@@ -903,7 +833,7 @@ static int md5_check(const char *checkfile_name)
if (line[line_length - 1] == '\n')
line[--line_length] = '\0';
if (split_3(line, line_length, &md5num, &binary, &filename)
if (split_3(line, line_length, &md5num, &filename)
|| !hex_digits(md5num)) {
if (warn) {
error_msg("%s: %lu: improperly formatted MD5 checksum line",
@@ -919,7 +849,7 @@ static int md5_check(const char *checkfile_name)
++n_properly_formated_lines;
if (md5_file(filename, binary, md5buffer)) {
if (md5_file(filename, md5buffer)) {
++n_open_or_read_failures;
if (!status_only) {
printf("%s: FAILED open or read\n", filename);
@@ -930,9 +860,9 @@ static int md5_check(const char *checkfile_name)
/* Compare generated binary number with text representation
in check file. Ignore case of hex digits. */
for (cnt = 0; cnt < 16; ++cnt) {
if (TOLOWER(md5num[2 * cnt])
if (tolower(md5num[2 * cnt])
!= bin2hex[md5buffer[cnt] >> 4]
|| (TOLOWER(md5num[2 * cnt + 1])
|| (tolower(md5num[2 * cnt + 1])
!= (bin2hex[md5buffer[cnt] & 0xf])))
break;
}
@@ -997,8 +927,8 @@ int md5sum_main(int argc,
char **string = NULL;
size_t n_strings = 0;
size_t err = 0;
int file_type_specified = 0;
int binary = 0;
char file_type_specified = 0;
char binary = 0;
while ((opt = getopt(argc, argv, "g:bcstw")) != -1) {
switch (opt) {
@@ -1084,9 +1014,9 @@ int md5sum_main(int argc,
int fail;
char *file = argv[optind];
fail = md5_file (file, binary, md5buffer);
fail = md5_file (file, md5buffer);
err |= fail;
if (!fail && STREQ(file, "-")) {
if (!fail && file[0]=='-' && file[1] == '\0') {
size_t i;
for (i = 0; i < 16; ++i)
printf ("%02x", md5buffer[i]);
+1 -1
View File
@@ -24,7 +24,7 @@
David MacKenzie <djm@gnu.ai.mit.edu>
Special for busybox ported by Vladimir Oleynik <vodz@usa.net> 2001
Special for busybox ported by Vladimir Oleynik <dzo@simtreas.ru> 2001
*/
+13 -5
View File
@@ -54,7 +54,7 @@ static void convert()
if (in_index == read_chars) {
if ((read_chars = read(0, (char *) pinput, BUFSIZ)) <= 0) {
if (write(1, (char *) poutput, out_index) != out_index)
write(2, write_error, strlen(write_error));
error_msg("%s", write_error);
exit(0);
}
in_index = 0;
@@ -67,10 +67,8 @@ static void convert()
continue;
poutput[out_index++] = last = coded;
if (out_index == BUFSIZ) {
if (write(1, (char *) poutput, out_index) != out_index) {
write(2, write_error, strlen(write_error));
exit(1);
}
if (write(1, (char *) poutput, out_index) != out_index)
error_msg_and_die("%s", write_error);
out_index = 0;
}
}
@@ -105,6 +103,16 @@ static unsigned int expand(const char *arg, register unsigned char *buffer)
if (*arg == '\\') {
arg++;
*buffer++ = process_escape_sequence(&arg);
} else if (*(arg+1) == '-') {
ac = *(arg+2);
if(ac == 0) {
*buffer++ = *arg++;
continue;
}
i = *arg;
while (i <= ac)
*buffer++ = i++;
arg += 3; /* Skip the assumed a-z */
} else if (*arg == '[') {
arg++;
i = *arg++;
+13 -10
View File
@@ -201,12 +201,13 @@ static int decode (const char *inname,
const char *forced_outname)
{
struct passwd *pw;
register int n;
register char *p;
int mode, n1;
int mode;
char buf[2 * BUFSIZ];
char *outname;
int do_base64 = 0;
int res;
int dofre;
/* Search for header line. */
@@ -226,6 +227,7 @@ static int decode (const char *inname,
}
/* If the output file name is given on the command line this rules. */
dofre = FALSE;
if (forced_outname != NULL)
outname = (char *) forced_outname;
else {
@@ -246,12 +248,8 @@ static int decode (const char *inname,
error_msg("%s: No user `%s'", inname, buf + 1);
return FALSE;
}
n = strlen (pw->pw_dir);
n1 = strlen (p);
outname = (char *) alloca ((size_t) (n + n1 + 2));
memcpy (outname + n + 1, p, (size_t) (n1 + 1));
memcpy (outname, pw->pw_dir, (size_t) n);
outname[n] = '/';
outname = concat_path_file(pw->pw_dir, p);
dofre = TRUE;
}
}
@@ -261,6 +259,8 @@ static int decode (const char *inname,
|| chmod (outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO))
)) {
perror_msg("%s", outname); /* */
if (dofre)
free(outname);
return FALSE;
}
@@ -269,9 +269,12 @@ static int decode (const char *inname,
/* For each input line: */
if (do_base64)
return read_base64 (inname);
res = read_base64 (inname);
else
return read_stduu (inname);
res = read_stduu (inname);
if (dofre)
free(outname);
return res;
}
int uudecode_main (int argc,
+164 -221
View File
@@ -1,237 +1,180 @@
/* uuencode.c -- uuencode utility.
* Copyright (C) 1994, 1995 Free Software Foundation, Inc.
/* vi: set sw=4 ts=4: */
/*
* Copyright (C) 2000 by Glenn McGrath
*
* This product is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
* based on the function base64_encode from http.c in wget v1.6
* Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
*
* This product is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* You should have received a copy of the GNU General Public License
* along with this product; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* Original copyright notice is retained at the end of this file.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* Reworked to GNU style by Ian Lance Taylor, ian@airs.com, August 93. */
/* Hacked to work with BusyBox by Alfred M. Szmidt */
#include <stdio.h>
#include <errno.h>
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "busybox.h"
#define RW (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
static void encode __P ((void));
/* Pointer to the translation table we currently use. */
static const char *trans_ptr;
/* The two currently defined translation tables. The first is the
standard uuencoding, the second is base64 encoding. */
static const char uu_std[64] = {
'`', '!', '"', '#', '$', '%', '&', '\'',
'(', ')', '*', '+', ',', '-', '.', '/',
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', ':', ';', '<', '=', '>', '?',
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z', '[', '\\', ']', '^', '_'
/* Conversion table. for base 64 */
static char tbl_base64[64] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/'
};
static const char uu_base64[64] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/'
static char tbl_std[64] = {
'`', '!', '"', '#', '$', '%', '&', '\'',
'(', ')', '*', '+', ',', '-', '.', '/',
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', ':', ';', '<', '=', '>', '?',
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z', '[', '\\', ']', '^', '_'
};
/* ENC is the basic 1 character encoding function to make a char printing. */
#define ENC(Char) (trans_ptr[(Char) & 077])
/* Copy from IN to OUT, encoding as you go along. */
static void encode()
{
register int ch, n;
char *p = NULL;
char buf[80];
while (1) {
n = 0;
do {
register int m = fread (buf, 1, 45 - n, stdin);
if (m == 0)
break;
n += m;
}
while (n < 45);
if (n == 0)
break;
if (trans_ptr == uu_std)
if (putchar (ENC (n)) == EOF)
break;
for (p = buf; n > 2; n -= 3, p += 3) {
ch = *p >> 2;
ch = ENC (ch);
if (putchar (ch) == EOF)
break;
ch = ((*p << 4) & 060) | ((p[1] >> 4) & 017);
ch = ENC (ch);
if (putchar (ch) == EOF)
break;
ch = ((p[1] << 2) & 074) | ((p[2] >> 6) & 03);
ch = ENC (ch);
if (putchar (ch) == EOF)
break;
ch = p[2] & 077;
ch = ENC (ch);
if (putchar (ch) == EOF)
break;
}
if (n != 0)
break;
if (putchar ('\n') == EOF)
break;
}
while (n != 0) {
char c1 = *p;
char c2 = n == 1 ? 0 : p[1];
ch = c1 >> 2;
ch = ENC (ch);
if (putchar (ch) == EOF)
break;
ch = ((c1 << 4) & 060) | ((c2 >> 4) & 017);
ch = ENC (ch);
if (putchar (ch) == EOF)
break;
if (n == 1)
ch = trans_ptr == uu_std ? ENC ('\0') : '=';
else {
ch = (c2 << 2) & 074;
ch = ENC (ch);
}
if (putchar (ch) == EOF)
break;
ch = trans_ptr == uu_std ? ENC ('\0') : '=';
if (putchar (ch) == EOF)
break;
putchar ('\n');
break;
}
if (ferror (stdin))
error_msg("Read error");
if (trans_ptr == uu_std) {
putchar (ENC ('\0'));
putchar ('\n');
}
}
int uuencode_main (int argc,
char **argv)
{
int opt;
struct stat sb;
int mode;
trans_ptr = uu_std; /* Standard encoding is old uu format */
/* Parse any options */
while ((opt = getopt (argc, argv, "m")) > 0) {
switch (opt) {
case 'm':
trans_ptr = uu_base64;
break;
default:
show_usage();
}
}
switch (argc - optind) {
case 2:
/* Optional first argument is input file. */
if (!freopen (argv[optind], "r", stdin) || fstat (fileno (stdin), &sb)) {
perror_msg("%s", argv[optind]);
return EXIT_FAILURE;
}
mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
optind++;
break;
case 1:
mode = RW & ~umask (RW);
break;
case 0:
default:
show_usage();
}
printf("begin%s %o %s\n", trans_ptr == uu_std ? "" : "-base64",
mode, argv[optind]);
encode();
printf(trans_ptr == uu_std ? "end\n" : "====\n");
if (ferror (stdout)) {
error_msg("Write error");
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
/* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>
*
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
/*
* Encode the string S of length LENGTH to base64 format and place it
* to STORE. STORE will be 0-terminated, and must point to a writable
* buffer of at least 1+BASE64_LENGTH(length) bytes.
* where BASE64_LENGTH(len) = (4 * ((LENGTH + 2) / 3))
*/
static void uuencode (const char *s, const char *store, const int length, const char *tbl)
{
int i;
unsigned char *p = (unsigned char *)store;
/* Transform the 3x8 bits to 4x6 bits, as required by base64. */
for (i = 0; i < length; i += 3) {
*p++ = tbl[s[0] >> 2];
*p++ = tbl[((s[0] & 3) << 4) + (s[1] >> 4)];
*p++ = tbl[((s[1] & 0xf) << 2) + (s[2] >> 6)];
*p++ = tbl[s[2] & 0x3f];
s += 3;
}
/* Pad the result if necessary... */
if (i == length + 1) {
*(p - 1) = '=';
}
else if (i == length + 2) {
*(p - 1) = *(p - 2) = '=';
}
/* ...and zero-terminate it. */
*p = '\0';
}
int uuencode_main(int argc, char **argv)
{
const int src_buf_size = 60; // This *MUST* be a multiple of 3
const int dst_buf_size = 4 * ((src_buf_size + 2) / 3);
RESERVE_BB_BUFFER(src_buf, src_buf_size + 1);
RESERVE_BB_BUFFER(dst_buf, dst_buf_size + 1);
struct stat stat_buf;
FILE *src_stream = stdin;
char *tbl = tbl_std;
size_t size;
mode_t mode;
int opt;
int column = 0;
int write_size = 0;
int remaining;
int buffer_offset = 0;
while ((opt = getopt(argc, argv, "m")) != -1) {
switch (opt) {
case 'm':
tbl = tbl_base64;
break;
default:
show_usage();
}
}
switch (argc - optind) {
case 2:
src_stream = xfopen(argv[optind], "r");
stat(argv[optind], &stat_buf);
mode = stat_buf.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
if (src_stream == stdout) {
printf("NULL\n");
}
break;
case 1:
mode = 0666 & ~umask(0666);
break;
default:
show_usage();
}
printf("begin%s %o %s", tbl == tbl_std ? "" : "-base64", mode, argv[argc - 1]);
while ((size = fread(src_buf, 1, src_buf_size, src_stream)) > 0) {
/* Encode the buffer we just read in */
uuencode(src_buf, dst_buf, size, tbl);
/* Write the buffer to stdout, wrapping at 60 chars.
* This looks overly complex, but it gets tricky as
* the line has to continue to wrap correctly if we
* have to refill the buffer
*
* Improvments most welcome
*/
/* Initialise values for the new buffer */
remaining = 4 * ((size + 2) / 3);
buffer_offset = 0;
/* Write the buffer to stdout, wrapping at 60 chars
* starting from the column the last buffer ran out
*/
do {
if (remaining > (60 - column)) {
write_size = 60 - column;
}
else if (remaining < 60) {
write_size = remaining;
} else {
write_size = 60;
}
/* Setup a new row if required */
if (column == 0) {
putchar('\n');
if (tbl == tbl_std) {
putchar('M');
}
}
/* Write to the 60th column */
if (fwrite(&dst_buf[buffer_offset], 1, write_size, stdout) != write_size) {
perror("Couldnt finish writing");
}
/* Update variables based on last write */
buffer_offset += write_size;
remaining -= write_size;
column += write_size;
if (column % 60 == 0) {
column = 0;
}
} while (remaining > 0);
}
printf(tbl == tbl_std ? "\n`\nend\n" : "\n====\n");
return(EXIT_SUCCESS);
}
+10 -7
View File
@@ -68,25 +68,28 @@ extern int cpio_main(int argc, char **argv)
}
}
if (extract_function & extract_all_to_fs && extract_function & extract_list) {
if ((extract_function & extract_all_to_fs) && (extract_function & extract_list)) {
extract_function ^= extract_all_to_fs; /* If specify t, don't extract*/
}
if (extract_function & extract_all_to_fs && extract_function & extract_verbose_list) { /* The meaning of v changes on extract */
if ((extract_function & extract_all_to_fs) && (extract_function & extract_verbose_list)) {
/* The meaning of v changes on extract */
extract_function ^= extract_verbose_list;
extract_function |= extract_list;
}
extract_names = malloc(4);
while (optind < argc) {
extract_names = xrealloc(extract_names, sizeof(char *) * (num_of_entries + 2));
extract_names[num_of_entries] = xstrdup(argv[optind]);
num_of_entries++;
*extract_names = realloc(*extract_names, num_of_entries);
extract_names[num_of_entries - 1] = xstrdup(argv[optind]);
extract_names[num_of_entries] = NULL;
optind++;
}
unarchive(src_stream, &get_header_cpio, extract_function, "./", extract_names);
if (oldmask) umask(oldmask); /* Restore umask if we changed it */
unarchive(src_stream, stdout, &get_header_cpio, extract_function, "./", extract_names);
if (oldmask) {
umask(oldmask); /* Restore umask if we changed it */
}
return EXIT_SUCCESS;
}
+2 -4
View File
@@ -344,10 +344,8 @@ extern int cut_main(int argc, char **argv)
int i;
FILE *file;
for (i = optind; i < argc; i++) {
file = fopen(argv[i], "r");
if (file == NULL) {
perror_msg("%s", argv[i]);
} else {
file = wfopen(argv[i], "r");
if(file) {
cut_file(file);
fclose(file);
}
+2 -6
View File
@@ -50,7 +50,6 @@ int dd_main(int argc, char **argv)
size_t bs = 512, count = -1;
ssize_t n;
off_t seek = 0, skip = 0;
FILE *statusfp;
char *infile = NULL, *outfile = NULL, *buf;
for (i = 1; i < argc; i++) {
@@ -110,12 +109,9 @@ int dd_main(int argc, char **argv)
if (ftruncate(ofd, seek * bs) < 0)
perror_msg_and_die("%s", outfile);
}
statusfp = stdout;
} else {
ofd = STDOUT_FILENO;
outfile = "standard output";
statusfp = stderr;
}
if (skip) {
@@ -151,8 +147,8 @@ int dd_main(int argc, char **argv)
out_part++;
}
fprintf(statusfp, "%ld+%ld records in\n", (long)in_full, (long)in_part);
fprintf(statusfp, "%ld+%ld records out\n", (long)out_full, (long)out_part);
fprintf(stderr, "%ld+%ld records in\n", (long)in_full, (long)in_part);
fprintf(stderr, "%ld+%ld records out\n", (long)out_full, (long)out_part);
return EXIT_SUCCESS;
}
+48 -63
View File
@@ -9,6 +9,7 @@
// BusyBox Applications
//#define BB_ADJTIMEX
#define BB_AR
//#define BB_ASH
#define BB_BASENAME
#define BB_CAT
#define BB_CHGRP
@@ -51,6 +52,7 @@
#define BB_HEAD
//#define BB_HOSTID
//#define BB_HOSTNAME
//#define BB_HUSH
#define BB_ID
//#define BB_IFCONFIG
#define BB_INIT
@@ -58,6 +60,7 @@
#define BB_KILL
#define BB_KILLALL
#define BB_KLOGD
//#define BB_LASH
//#define BB_LENGTH
#define BB_LN
//#define BB_LOADACM
@@ -75,12 +78,15 @@
#define BB_MKNOD
#define BB_MKSWAP
//#define BB_MKTEMP
//#define BB_NC
//#define BB_MODPROBE
#define BB_MORE
#define BB_MOUNT
//#define BB_MSH
//#define BB_MT
#define BB_MV
//#define BB_NC
//#define BB_NSLOOKUP
//#define BB_PIDOF
#define BB_PING
//#define BB_PIVOT_ROOT
#define BB_POWEROFF
@@ -99,7 +105,6 @@
//#define BB_RPM2CPIO
#define BB_SED
//#define BB_SETKEYCODES
//#define BB_SH
#define BB_SLEEP
#define BB_SORT
//#define BB_STTY
@@ -114,6 +119,7 @@
//#define BB_TFTP
#define BB_TOUCH
#define BB_TR
//#define BB_TRACEROUTE
#define BB_TRUE_FALSE
#define BB_TTY
//#define BB_UNIX2DOS
@@ -143,40 +149,12 @@
// pretty/useful).
//
//
// If you enabled BB_SH above, you may select one of the following shells.
// You can only select ONE of the following shells. Sorry.
//
// lash is the very smallest shell (adds just 10k) and it is quite usable as a
// command prompt, but it is not suitable for any but the most trivial scripting
// (such as an initrd that calls insmod a few times) since it does not
// understand Bourne shell grammer. It does handle pipes, redirects, and job
// control though. Adding in command editing makes it very nice lightweight
// command prompt.
//#define BB_FEATURE_LASH
//
// hush is also quite small (just 18k) and it has very complete Bourne shell
// grammer. It handles if/then/else/fi just fine, but doesn't handle loops
// like for/do/done or case/esac and such. It also currently has a problem
// with job control.
//#define BB_FEATURE_HUSH
//
// msh: The minix shell (adds just 30k) is quite complete and handles things
// like for/do/done, case/esac and all the things you expect a Bourne shell to
// do. It is not always pedantically correct about Bourne shell grammer (try
// running the shell testscript "tests/sh.testcases" on it and compare vs
// bash) but for most things it works quite well. It also uses only vfork, so
// it can be used on uClinux systems. This was only recently added, so there is
// still room to shrink it further...
#define BB_FEATURE_MSH
//
// ash: This adds about 60k in the default configuration and is the most
// complete and most pedantically correct shell included with busybox. This
// shell was also recently added, and several people (mainly Vladimir and Erik)
// have been working on it. There are a number of configurable things at the
// top of ash.c as well, so check those out if you want to tweak things. The
// Posix math support is currently disabled (that bit of code was horrible) but
// will be restored for the next BusyBox release.
//#define BB_FEATURE_ASH
// If you enabled one or more of the shells, you may select which one
// should be run when sh is invoked:
//#define BB_FEATURE_SH_IS_ASH
//#define BB_FEATURE_SH_IS_HUSH
//#define BB_FEATURE_SH_IS_LASH
#define BB_FEATURE_SH_IS_MSH
//
// BusyBox will, by default, malloc space for its buffers. This costs code
// size for the call to xmalloc. You can use the following feature to have
@@ -283,11 +261,11 @@
#define BB_FEATURE_SORT_UNIQUE
//
// Enable command line editing in the shell.
// Only relevant if BB_SH is enabled. On by default.
// Only relevant if a shell is enabled. On by default.
#define BB_FEATURE_COMMAND_EDITING
//
// Enable tab completion in the shell. This is now working quite nicely.
// This feature adds a bit over 4k. Only relevant if BB_SH is enabled.
// This feature adds a bit over 4k. Only relevant if a shell is enabled.
#define BB_FEATURE_COMMAND_TAB_COMPLETION
//
// Attempts to match usernames in a ~-prefixed path
@@ -296,7 +274,7 @@
//Allow the shell to invoke all the compiled in BusyBox applets as if they
//were shell builtins. Nice for staticly linking an emergency rescue shell,
//among other things. Off by default.
// Only relevant if BB_SH is enabled.
// Only relevant if a shell is enabled.
//#define BB_FEATURE_SH_STANDALONE_SHELL
//
//When this is enabled, busybox shell applets can be called using full path
@@ -305,13 +283,13 @@
//will use BusyBox cat even if /bin/cat exists on the filesystem and is _not_
//busybox. Some systems want this, others do not. Choose wisely. :-) This
//only has meaning when BB_FEATURE_SH_STANDALONE_SHELL is enabled.
// Only relevant if BB_SH is enabled. Off by default.
// Only relevant if a shell is enabled. Off by default.
//#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN
//
// Uncomment this option for a fancy shell prompt that includes the
// current username and hostname. On systems that don't have usernames
// or hostnames, this can look hideous.
// Only relevant if BB_SH is enabled.
// Only relevant if a shell is enabled.
//#define BB_FEATURE_SH_FANCY_PROMPT
//
//Turn on extra fbset options
@@ -416,8 +394,21 @@
// Nothing beyond this point should ever be touched by
// mere mortals so leave this stuff alone.
//
#if defined BB_SH
#if defined BB_FEATURE_COMMAND_EDITING
#include <features.h>
#if defined __UCLIBC__ && ! defined __UCLIBC_HAS_MMU__
#undef BB_RPM2CPIO /* Uses gz_open(), which uses fork() */
#undef BB_DPKG_DEB /* Uses gz_open(), which uses fork() */
#undef BB_ASH /* Uses fork() */
#undef BB_HUSH /* Uses fork() */
#undef BB_LASH /* Uses fork() */
#undef BB_INIT /* Uses fork() */
#undef BB_FEATURE_TAR_GZIP /* Uses fork() */
#undef BB_SYSLOGD /* Uses daemon() */
#undef BB_KLOGD /* Uses daemon() */
#undef BB_UPDATE /* Uses daemon() */
#endif
#if defined BB_ASH || defined BB_HUSH || defined BB_LASH || defined BB_MSH
#if defined BB_FEATURE_COMMAND_EDITING
#define BB_CMDEDIT
#else
#undef BB_FEATURE_COMMAND_EDITING
@@ -425,26 +416,6 @@
#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
#undef BB_FEATURE_SH_FANCY_PROMPT
#endif
#if ! defined BB_FEATURE_LASH && ! defined BB_FEATURE_HUSH && ! defined BB_FEATURE_MSH && ! defined BB_FEATURE_ASH
#define BB_FEATURE_MSH
#endif
#if defined BB_FEATURE_ASH && (defined BB_FEATURE_LASH || defined BB_FEATURE_HUSH || defined BB_FEATURE_MSH)
#undef BB_FEATURE_LASH
#undef BB_FEATURE_HUSH
#undef BB_FEATURE_MSH
#elif defined BB_FEATURE_MSH && (defined BB_FEATURE_LASH || defined BB_FEATURE_HUSH || defined BB_FEATURE_MSH)
#undef BB_FEATURE_LASH
#undef BB_FEATURE_HUSH
#undef BB_FEATURE_ASH
#elif defined BB_FEATURE_HUSH && (defined BB_FEATURE_LASH || defined BB_FEATURE_HUSH || defined BB_FEATURE_MSH)
#undef BB_FEATURE_LASH
#undef BB_FEATURE_MSH
#undef BB_FEATURE_ASH
#elif defined BB_FEATURE_LASH && (defined BB_FEATURE_LASH || defined BB_FEATURE_HUSH || defined BB_FEATURE_MSH)
#undef BB_FEATURE_HUSH
#undef BB_FEATURE_MSH
#undef BB_FEATURE_ASH
#endif
#else
#undef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
#undef BB_FEATURE_SH_STANDALONE_SHELL
@@ -477,8 +448,22 @@
#endif
#endif
//
#ifdef BB_UNIX2DOS
#define BB_DOS2UNIX
#endif
//
#ifdef BB_SYSLOGD
#if defined BB_FEATURE_IPC_SYSLOG
#define BB_LOGREAD
#endif
#endif
//
#if defined BB_ASH && defined BB_FEATURE_SH_IS_ASH
# define shell_main ash_main
#elif defined BB_HUSH && defined BB_FEATURE_SH_IS_HUSH
# define shell_main hush_main
#elif defined BB_LASH && defined BB_FEATURE_SH_IS_LASH
# define shell_main lash_main
#elif defined BB_MSH && defined BB_FEATURE_SH_IS_MSH
# define shell_main msh_main
#endif
+49 -64
View File
@@ -9,6 +9,7 @@
// BusyBox Applications
//#define BB_ADJTIMEX
#define BB_AR
#define BB_ASH
#define BB_BASENAME
#define BB_CAT
#define BB_CHGRP
@@ -51,6 +52,7 @@
#define BB_HEAD
#define BB_HOSTID
#define BB_HOSTNAME
//#define BB_HUSH
#define BB_ID
#define BB_IFCONFIG
#define BB_INIT
@@ -58,6 +60,7 @@
#define BB_KILL
#define BB_KILLALL
#define BB_KLOGD
//#define BB_LASH
#define BB_LENGTH
#define BB_LN
#define BB_LOADACM
@@ -75,12 +78,15 @@
#define BB_MKNOD
#define BB_MKSWAP
#define BB_MKTEMP
#define BB_NC
//#define BB_MODPROBE
#define BB_MORE
#define BB_MOUNT
//#define BB_MSH
#define BB_MT
#define BB_MV
#define BB_NC
#define BB_NSLOOKUP
#define BB_PIDOF
#define BB_PING
#define BB_PIVOT_ROOT
#define BB_POWEROFF
@@ -99,7 +105,6 @@
#define BB_RPM2CPIO
#define BB_SED
#define BB_SETKEYCODES
#define BB_SH
#define BB_SLEEP
#define BB_SORT
#define BB_STTY
@@ -114,6 +119,7 @@
#define BB_TFTP
#define BB_TOUCH
#define BB_TR
#define BB_TRACEROUTE
#define BB_TRUE_FALSE
#define BB_TTY
#define BB_UNIX2DOS
@@ -143,40 +149,12 @@
// pretty/useful).
//
//
// If you enabled BB_SH above, you may select one of the following shells.
// You can only select ONE of the following shells. Sorry.
//
// lash is the very smallest shell (adds just 10k) and it is quite usable as a
// command prompt, but it is not suitable for any but the most trivial scripting
// (such as an initrd that calls insmod a few times) since it does not
// understand Bourne shell grammer. It does handle pipes, redirects, and job
// control though. Adding in command editing makes it very nice lightweight
// command prompt.
//#define BB_FEATURE_LASH
//
// hush is also quite small (just 18k) and it has very complete Bourne shell
// grammer. It handles if/then/else/fi just fine, but doesn't handle loops
// like for/do/done or case/esac and such. It also currently has a problem
// with job control.
//#define BB_FEATURE_HUSH
//
// msh: The minix shell (adds just 30k) is quite complete and handles things
// like for/do/done, case/esac and all the things you expect a Bourne shell to
// do. It is not always pedantically correct about Bourne shell grammer (try
// running the shell testscript "tests/sh.testcases" on it and compare vs
// bash) but for most things it works quite well. It also uses only vfork, so
// it can be used on uClinux systems. This was only recently added, so there is
// still room to shrink it further...
//#define BB_FEATURE_MSH
//
// ash: This adds about 60k in the default configuration and is the most
// complete and most pedantically correct shell included with busybox. This
// shell was also recently added, and several people (mainly Vladimir and Erik)
// have been working on it. There are a number of configurable things at the
// top of ash.c as well, so check those out if you want to tweak things. The
// Posix math support is currently disabled (that bit of code was horrible) but
// will be restored for the next BusyBox release.
#define BB_FEATURE_ASH
// If you enabled one or more of the shells, you may select which one
// should be run when sh is invoked:
#define BB_FEATURE_SH_IS_ASH
//#define BB_FEATURE_SH_IS_HUSH
//#define BB_FEATURE_SH_IS_LASH
//#define BB_FEATURE_SH_IS_MSH
//
// BusyBox will, by default, malloc space for its buffers. This costs code
// size for the call to xmalloc. You can use the following feature to have
@@ -283,11 +261,11 @@
#define BB_FEATURE_SORT_UNIQUE
//
// Enable command line editing in the shell.
// Only relevant if BB_SH is enabled. On by default.
// Only relevant if a shell is enabled. On by default.
#define BB_FEATURE_COMMAND_EDITING
//
// Enable tab completion in the shell. This is now working quite nicely.
// This feature adds a bit over 4k. Only relevant if BB_SH is enabled.
// This feature adds a bit over 4k. Only relevant if a shell is enabled.
#define BB_FEATURE_COMMAND_TAB_COMPLETION
//
// Attempts to match usernames in a ~-prefixed path
@@ -296,7 +274,7 @@
//Allow the shell to invoke all the compiled in BusyBox applets as if they
//were shell builtins. Nice for staticly linking an emergency rescue shell,
//among other things. Off by default.
// Only relevant if BB_SH is enabled.
// Only relevant if a shell is enabled.
#define BB_FEATURE_SH_STANDALONE_SHELL
//
//When this is enabled, busybox shell applets can be called using full path
@@ -305,13 +283,13 @@
//will use BusyBox cat even if /bin/cat exists on the filesystem and is _not_
//busybox. Some systems want this, others do not. Choose wisely. :-) This
//only has meaning when BB_FEATURE_SH_STANDALONE_SHELL is enabled.
// Only relevant if BB_SH is enabled. Off by default.
//#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN
// Only relevant if a shell is enabled. Off by default.
#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN
//
// Uncomment this option for a fancy shell prompt that includes the
// current username and hostname. On systems that don't have usernames
// or hostnames, this can look hideous.
// Only relevant if BB_SH is enabled.
// Only relevant if a shell is enabled.
#define BB_FEATURE_SH_FANCY_PROMPT
//
//Turn on extra fbset options
@@ -416,8 +394,21 @@
// Nothing beyond this point should ever be touched by
// mere mortals so leave this stuff alone.
//
#if defined BB_SH
#if defined BB_FEATURE_COMMAND_EDITING
#include <features.h>
#if defined __UCLIBC__ && ! defined __UCLIBC_HAS_MMU__
#undef BB_RPM2CPIO /* Uses gz_open(), which uses fork() */
#undef BB_DPKG_DEB /* Uses gz_open(), which uses fork() */
#undef BB_ASH /* Uses fork() */
#undef BB_HUSH /* Uses fork() */
#undef BB_LASH /* Uses fork() */
#undef BB_INIT /* Uses fork() */
#undef BB_FEATURE_TAR_GZIP /* Uses fork() */
#undef BB_SYSLOGD /* Uses daemon() */
#undef BB_KLOGD /* Uses daemon() */
#undef BB_UPDATE /* Uses daemon() */
#endif
#if defined BB_ASH || defined BB_HUSH || defined BB_LASH || defined BB_MSH
#if defined BB_FEATURE_COMMAND_EDITING
#define BB_CMDEDIT
#else
#undef BB_FEATURE_COMMAND_EDITING
@@ -425,26 +416,6 @@
#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
#undef BB_FEATURE_SH_FANCY_PROMPT
#endif
#if ! defined BB_FEATURE_LASH && ! defined BB_FEATURE_HUSH && ! defined BB_FEATURE_MSH && ! defined BB_FEATURE_ASH
#define BB_FEATURE_MSH
#endif
#if defined BB_FEATURE_ASH && (defined BB_FEATURE_LASH || defined BB_FEATURE_HUSH || defined BB_FEATURE_MSH)
#undef BB_FEATURE_LASH
#undef BB_FEATURE_HUSH
#undef BB_FEATURE_MSH
#elif defined BB_FEATURE_MSH && (defined BB_FEATURE_LASH || defined BB_FEATURE_HUSH || defined BB_FEATURE_MSH)
#undef BB_FEATURE_LASH
#undef BB_FEATURE_HUSH
#undef BB_FEATURE_ASH
#elif defined BB_FEATURE_HUSH && (defined BB_FEATURE_LASH || defined BB_FEATURE_HUSH || defined BB_FEATURE_MSH)
#undef BB_FEATURE_LASH
#undef BB_FEATURE_MSH
#undef BB_FEATURE_ASH
#elif defined BB_FEATURE_LASH && (defined BB_FEATURE_LASH || defined BB_FEATURE_HUSH || defined BB_FEATURE_MSH)
#undef BB_FEATURE_HUSH
#undef BB_FEATURE_MSH
#undef BB_FEATURE_ASH
#endif
#else
#undef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
#undef BB_FEATURE_SH_STANDALONE_SHELL
@@ -477,8 +448,22 @@
#endif
#endif
//
#ifdef BB_UNIX2DOS
#define BB_DOS2UNIX
#endif
//
#ifdef BB_SYSLOGD
#if defined BB_FEATURE_IPC_SYSLOG
#define BB_LOGREAD
#endif
#endif
//
#if defined BB_ASH && defined BB_FEATURE_SH_IS_ASH
# define shell_main ash_main
#elif defined BB_HUSH && defined BB_FEATURE_SH_IS_HUSH
# define shell_main hush_main
#elif defined BB_LASH && defined BB_FEATURE_SH_IS_LASH
# define shell_main lash_main
#elif defined BB_MSH && defined BB_FEATURE_SH_IS_MSH
# define shell_main msh_main
#endif
+48 -63
View File
@@ -9,6 +9,7 @@
// BusyBox Applications
//#define BB_ADJTIMEX
//#define BB_AR
//#define BB_ASH
#define BB_BASENAME
#define BB_CAT
#define BB_CHGRP
@@ -51,6 +52,7 @@
#define BB_HEAD
//#define BB_HOSTID
//#define BB_HOSTNAME
//#define BB_HUSH
#define BB_ID
//#define BB_IFCONFIG
#define BB_INIT
@@ -58,6 +60,7 @@
#define BB_KILL
#define BB_KILLALL
#define BB_KLOGD
//#define BB_LASH
//#define BB_LENGTH
#define BB_LN
//#define BB_LOADACM
@@ -75,12 +78,15 @@
#define BB_MKNOD
#define BB_MKSWAP
//#define BB_MKTEMP
//#define BB_NC
//#define BB_MODPROBE
#define BB_MORE
#define BB_MOUNT
//#define BB_MSH
//#define BB_MT
#define BB_MV
//#define BB_NC
//#define BB_NSLOOKUP
//#define BB_PIDOF
#define BB_PING
#define BB_PIVOT_ROOT
#define BB_POWEROFF
@@ -99,7 +105,6 @@
//#define BB_RPM2CPIO
#define BB_SED
//#define BB_SETKEYCODES
//#define BB_SH
#define BB_SLEEP
#define BB_SORT
//#define BB_STTY
@@ -114,6 +119,7 @@
//#define BB_TFTP
#define BB_TOUCH
#define BB_TR
//#define BB_TRACEROUTE
#define BB_TRUE_FALSE
#define BB_TTY
//#define BB_UNIX2DOS
@@ -143,40 +149,12 @@
// pretty/useful).
//
//
// If you enabled BB_SH above, you may select one of the following shells.
// You can only select ONE of the following shells. Sorry.
//
// lash is the very smallest shell (adds just 10k) and it is quite usable as a
// command prompt, but it is not suitable for any but the most trivial scripting
// (such as an initrd that calls insmod a few times) since it does not
// understand Bourne shell grammer. It does handle pipes, redirects, and job
// control though. Adding in command editing makes it very nice lightweight
// command prompt.
//#define BB_FEATURE_LASH
//
// hush is also quite small (just 18k) and it has very complete Bourne shell
// grammer. It handles if/then/else/fi just fine, but doesn't handle loops
// like for/do/done or case/esac and such. It also currently has a problem
// with job control.
//#define BB_FEATURE_HUSH
//
// msh: The minix shell (adds just 30k) is quite complete and handles things
// like for/do/done, case/esac and all the things you expect a Bourne shell to
// do. It is not always pedantically correct about Bourne shell grammer (try
// running the shell testscript "tests/sh.testcases" on it and compare vs
// bash) but for most things it works quite well. It also uses only vfork, so
// it can be used on uClinux systems. This was only recently added, so there is
// still room to shrink it further...
#define BB_FEATURE_MSH
//
// ash: This adds about 60k in the default configuration and is the most
// complete and most pedantically correct shell included with busybox. This
// shell was also recently added, and several people (mainly Vladimir and Erik)
// have been working on it. There are a number of configurable things at the
// top of ash.c as well, so check those out if you want to tweak things. The
// Posix math support is currently disabled (that bit of code was horrible) but
// will be restored for the next BusyBox release.
//#define BB_FEATURE_ASH
// If you enabled one or more of the shells, you may select which one
// should be run when sh is invoked:
//#define BB_FEATURE_SH_IS_ASH
//#define BB_FEATURE_SH_IS_HUSH
//#define BB_FEATURE_SH_IS_LASH
#define BB_FEATURE_SH_IS_MSH
//
// BusyBox will, by default, malloc space for its buffers. This costs code
// size for the call to xmalloc. You can use the following feature to have
@@ -283,11 +261,11 @@
#define BB_FEATURE_SORT_UNIQUE
//
// Enable command line editing in the shell.
// Only relevant if BB_SH is enabled. On by default.
// Only relevant if a shell is enabled. On by default.
#define BB_FEATURE_COMMAND_EDITING
//
// Enable tab completion in the shell. This is now working quite nicely.
// This feature adds a bit over 4k. Only relevant if BB_SH is enabled.
// This feature adds a bit over 4k. Only relevant if a shell is enabled.
#define BB_FEATURE_COMMAND_TAB_COMPLETION
//
// Attempts to match usernames in a ~-prefixed path
@@ -296,7 +274,7 @@
//Allow the shell to invoke all the compiled in BusyBox applets as if they
//were shell builtins. Nice for staticly linking an emergency rescue shell,
//among other things. Off by default.
// Only relevant if BB_SH is enabled.
// Only relevant if a shell is enabled.
//#define BB_FEATURE_SH_STANDALONE_SHELL
//
//When this is enabled, busybox shell applets can be called using full path
@@ -305,13 +283,13 @@
//will use BusyBox cat even if /bin/cat exists on the filesystem and is _not_
//busybox. Some systems want this, others do not. Choose wisely. :-) This
//only has meaning when BB_FEATURE_SH_STANDALONE_SHELL is enabled.
// Only relevant if BB_SH is enabled. Off by default.
// Only relevant if a shell is enabled. Off by default.
//#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN
//
// Uncomment this option for a fancy shell prompt that includes the
// current username and hostname. On systems that don't have usernames
// or hostnames, this can look hideous.
// Only relevant if BB_SH is enabled.
// Only relevant if a shell is enabled.
//#define BB_FEATURE_SH_FANCY_PROMPT
//
//Turn on extra fbset options
@@ -416,8 +394,21 @@
// Nothing beyond this point should ever be touched by
// mere mortals so leave this stuff alone.
//
#if defined BB_SH
#if defined BB_FEATURE_COMMAND_EDITING
#include <features.h>
#if defined __UCLIBC__ && ! defined __UCLIBC_HAS_MMU__
#undef BB_RPM2CPIO /* Uses gz_open(), which uses fork() */
#undef BB_DPKG_DEB /* Uses gz_open(), which uses fork() */
#undef BB_ASH /* Uses fork() */
#undef BB_HUSH /* Uses fork() */
#undef BB_LASH /* Uses fork() */
#undef BB_INIT /* Uses fork() */
#undef BB_FEATURE_TAR_GZIP /* Uses fork() */
#undef BB_SYSLOGD /* Uses daemon() */
#undef BB_KLOGD /* Uses daemon() */
#undef BB_UPDATE /* Uses daemon() */
#endif
#if defined BB_ASH || defined BB_HUSH || defined BB_LASH || defined BB_MSH
#if defined BB_FEATURE_COMMAND_EDITING
#define BB_CMDEDIT
#else
#undef BB_FEATURE_COMMAND_EDITING
@@ -425,26 +416,6 @@
#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
#undef BB_FEATURE_SH_FANCY_PROMPT
#endif
#if ! defined BB_FEATURE_LASH && ! defined BB_FEATURE_HUSH && ! defined BB_FEATURE_MSH && ! defined BB_FEATURE_ASH
#define BB_FEATURE_MSH
#endif
#if defined BB_FEATURE_ASH && (defined BB_FEATURE_LASH || defined BB_FEATURE_HUSH || defined BB_FEATURE_MSH)
#undef BB_FEATURE_LASH
#undef BB_FEATURE_HUSH
#undef BB_FEATURE_MSH
#elif defined BB_FEATURE_MSH && (defined BB_FEATURE_LASH || defined BB_FEATURE_HUSH || defined BB_FEATURE_MSH)
#undef BB_FEATURE_LASH
#undef BB_FEATURE_HUSH
#undef BB_FEATURE_ASH
#elif defined BB_FEATURE_HUSH && (defined BB_FEATURE_LASH || defined BB_FEATURE_HUSH || defined BB_FEATURE_MSH)
#undef BB_FEATURE_LASH
#undef BB_FEATURE_MSH
#undef BB_FEATURE_ASH
#elif defined BB_FEATURE_LASH && (defined BB_FEATURE_LASH || defined BB_FEATURE_HUSH || defined BB_FEATURE_MSH)
#undef BB_FEATURE_HUSH
#undef BB_FEATURE_MSH
#undef BB_FEATURE_ASH
#endif
#else
#undef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
#undef BB_FEATURE_SH_STANDALONE_SHELL
@@ -477,8 +448,22 @@
#endif
#endif
//
#ifdef BB_UNIX2DOS
#define BB_DOS2UNIX
#endif
//
#ifdef BB_SYSLOGD
#if defined BB_FEATURE_IPC_SYSLOG
#define BB_LOGREAD
#endif
#endif
//
#if defined BB_ASH && defined BB_FEATURE_SH_IS_ASH
# define shell_main ash_main
#elif defined BB_HUSH && defined BB_FEATURE_SH_IS_HUSH
# define shell_main hush_main
#elif defined BB_LASH && defined BB_FEATURE_SH_IS_LASH
# define shell_main lash_main
#elif defined BB_MSH && defined BB_FEATURE_SH_IS_MSH
# define shell_main msh_main
#endif
+13
View File
@@ -1,3 +1,16 @@
busybox (1:0.60.0-1) unstable; urgency=low
* New version released. See changelog for details.
-- Erik Andersen <andersee@debian.org> Thu, 2 Aug 2001 12:12:37 -0600
busybox (1:0.52-1.1) unstable; urgency=high
* Non-maintainer upload
* Fixed wget -P handling (closes: #106223).
-- Matt Kraai <kraai@debian.org> Wed, 25 Jul 2001 11:01:38 -0600
busybox (1:0.52-1) unstable; urgency=high
* New version released. See changelog for details.
+1 -1
View File
@@ -30,7 +30,7 @@ Depends: ${shlibs:Depends}
Conflicts: busybox
Replaces: busybox
Section: shells
Description: Provides a stand alone rescue shell with tons of builtin utilities.
Description: Standalone rescue shell with tons of builtin utilities.
BusyBox combines tiny versions of many common UNIX utilities into a single
small executable. It provides minimalist replacements for the most common
utilities you would usually find on your desktop system (i.e., ls, cp, mv,
+175
View File
@@ -0,0 +1,175 @@
/* vi: set sw=4 ts=4: */
/*
* deluser (remove lusers from the system ;) for TinyLogin
*
*
* Copyright (C) 1999 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "busybox.h"
#define PASSWD_FILE "/etc/passwd"
#define GROUP_FILE "/etc/group"
/* where to start and stop deletion */
typedef struct {
size_t start;
size_t stop;
} Bounds;
/* An interesting side-effect of boundary()'s
* implementation is that the first user (typically root)
* cannot be removed. Let's call it a feature. */
static Bounds boundary(const char *buffer, const char *login)
{
char needle[256];
char *start;
char *stop;
Bounds b;
snprintf(needle, 256, "\n%s", login);
needle[255] = 0;
start = strstr(buffer, needle);
if (!start) {
b.start = 0;
b.stop = 0;
return b;
}
start++;
stop = index(start, '\n'); /* index is a BSD-ism */
b.start = start - buffer;
b.stop = stop - buffer;
return b;
}
/* grep -v ^login (except it only deletes the first match) */
/* ...in fact, I think I'm going to simplify this later */
static int del_line_matching(char *login, char *filename)
{
char *buffer;
FILE *passwd;
size_t len;
Bounds b;
struct stat statbuf;
/* load into buffer */
passwd = fopen(filename, "r");
if (!passwd) {
return 1;
}
stat(filename, &statbuf);
len = statbuf.st_size;
buffer = (char *) malloc(len * sizeof(char));
if (!buffer) {
fclose(passwd);
return 1;
}
fread(buffer, len, sizeof(char), passwd);
fclose(passwd);
/* find the user to remove */
b = boundary(buffer, login);
if (b.stop == 0) {
free(buffer);
return 1;
}
/* write the file w/o the user */
passwd = fopen(filename, "w");
if (!passwd) {
return 1;
}
fwrite(buffer, (b.start - 1), sizeof(char), passwd);
fwrite(&buffer[b.stop], (len - b.stop), sizeof(char), passwd);
fclose(passwd);
return 0;
}
/* ________________________________________________________________________ */
int delgroup_main(int argc, char **argv)
{
/* int successful; */
int failure;
if (argc != 2) {
show_usage();
} else {
failure = del_line_matching(argv[1], GROUP_FILE);
#ifdef TLG_FEATURE_SHADOWPASSWDS
if (access(GSHADOW_FILE, W_OK) == 0) {
/* EDR the |= works if the error is not 0, so he had it wrong */
failure |= del_line_matching(argv[1], GSHADOW_FILE);
}
#endif /* TLG_FEATURE_SHADOWPASSWDS */
/* if (!successful) { */
if (failure) {
error_msg_and_die("%s: Group could not be removed\n", argv[1]);
}
}
return (EXIT_SUCCESS);
}
/* ________________________________________________________________________ */
int deluser_main(int argc, char **argv)
{
/* int successful; */
int failure;
if (argc != 2) {
show_usage();
} else {
failure = del_line_matching(argv[1], PASSWD_FILE);
/* if (!successful) { */
if (failure) {
error_msg_and_die("%s: User could not be removed from %s\n",
argv[1], PASSWD_FILE);
}
#ifdef TLG_FEATURE_SHADOWPASSWDS
failure = del_line_matching(argv[1], SHADOW_FILE);
/* if (!successful) { */
if (failure) {
error_msg_and_die("%s: User could not be removed from %s\n",
argv[1], SHADOW_FILE);
}
#endif /* TLG_FEATURE_SHADOWPASSWDS */
failure = del_line_matching(argv[1], GROUP_FILE);
/* if (!successful) { */
if (failure) {
error_msg_and_die("%s: User could not be removed from %s\n",
argv[1], GROUP_FILE);
}
}
return (EXIT_SUCCESS);
}
/* $Id: deluser.c,v 1.1 2001/08/21 16:18:59 andersen Exp $ */
+73 -128
View File
@@ -45,8 +45,7 @@ the expected functionality and behave very much like their GNU counterparts.
BusyBox has been written with size-optimization and limited resources in mind.
It is also extremely modular so you can easily include or exclude commands (or
features) at compile time. This makes it easy to customize your embedded
systems. To create a working system, just add /dev, a kernel, and a shell.
For a really minimal system, you can even use the busybox shell (not Bourne compatible, but very small and quite usable), and the busybox vi editor.
systems. To create a working system, just add /dev, /etc, and a kernel.
<p>
BusyBox is now maintained by
@@ -82,6 +81,77 @@ To subscribe, go and visit <a href="http://opensource.lineo.com/mailman/listinfo
<ul>
<li> <b>23 August 2001 -- BusyBox 0.60.1 released</b>
<br>
This is a relatively minor bug fixing release that fixes
up the bugs that have shown up in the stable release in
the last few weeks. Fortunately, nothing <em>too</em>
serious has shown up. This release only fixes bugs -- no
new features, no new applets. So without further ado,
here it is. Come and get it.
<p>
The
<a href="ftp://oss.lineo.com/busybox/Changelog">changelog</a> has all
the details. As usual BusyBox 0.60.1 can be downloaded from
<a href="ftp://oss.lineo.com/busybox">ftp://oss.lineo.com/busybox</a>.
<p>Have Fun!
<p>
<li> <b>2 August 2001 -- BusyBox 0.60.0 released</b>
<br>
I am very pleased to announce the immediate availability of
BusyBox 0.60.0. I have personally tested this release with libc5, glibc,
and <a href="http://cvs.uclinux.org/uClibc.html">uClibc</a> on
x86, ARM, and powerpc using linux 2.2 and 2.4, and I know a number
of people using it on everything from ia64 to m68k with great success.
Everything seems to be working very nicely now, so getting a nice
stable bug-free(tm) release out seems to be in order. This releases fixes
a memory leak in syslogd, a number of bugs in the ash and msh shells, and
cleans up a number of things.
<p>
Those wanting an easy way to test the 0.60.0 release with uClibc can
use <a href="http://user-mode-linux.sourceforge.net/">User-Mode Linux</a>
to give it a try by downloading and compiling
<a href="ftp://oss.lineo.com/buildroot.tar.gz">buildroot.tar.gz</a>.
You don't have to be root or reboot your machine to run test this way.
Preconfigured User-Mode Linux kernel source is also on oss.lineo.com.
<p>
Another cool thing is the nifty <a href="ftp://oss.lineo.com/busybox/tutorial/index.html">
BusyBox Tutorial</a> contributed by K Computing. This requires
a ShockWave plugin (or standalone viewer), so you may want to grab the
the GPLed shockwave viewer from <a href="http://www.swift-tools.com/Flash/flash-0.4.10.tgz">here</a>
to view the tutorial.
<p>
Finally, In case you didn't notice anything odd about the
version number of this release, let me point out that this release
is <em>not</em> 0.53, because I bumped the version number up a
bit. This reflects the fact that this release is intended to form
a new stable BusyBox release series. If you need to rely on a
stable version of BusyBox, you should plan on using the stable
0.60.x series. If bugs show up then I will release 0.60.1, then
0.60.2, etc... This is also intended to deal with the fact that
the BusyBox build system will be getting a major overhaul for the
next release and I don't want that to break products that people
are shipping. To avoid that, the new build system will be
released as part of a new BusyBox development series that will
have some not-yet-decided-on odd version number. Once things
stabilize and the new build system is working for everyone, then
I will release that as a new stable release series.
<p>
The
<a href="ftp://oss.lineo.com/busybox/Changelog">changelog</a> has all
the details. As usual BusyBox 0.60.0 can be downloaded from
<a href="ftp://oss.lineo.com/busybox">ftp://oss.lineo.com/busybox</a>.
<p>Have Fun!
<p>
<li> <b>7 July 2001 -- BusyBox 0.52 released</b>
<br>
@@ -89,7 +159,7 @@ To subscribe, go and visit <a href="http://opensource.lineo.com/mailman/listinfo
BusyBox 0.52 (the "new-and-improved rock-solid release"). This
release is the result of <em>many</em> hours of work and has tons
of bugfixes, optimizations, and cleanups. This release adds
several new applets, including several new shells (such as hust, msh,
several new applets, including several new shells (such as hush, msh,
and ash).
<p>
@@ -114,131 +184,6 @@ To subscribe, go and visit <a href="http://opensource.lineo.com/mailman/listinfo
turning off whichever applets you don't need.)
<p>
<li> <b>10 April 2001 -- BusyBox 0.51 released</b>
<br>
BusyBox 0.51 (the "rock-solid release") is now out there. This
release adds only 2 new applets: env and vi. The vi applet,
contributed by Sterling Huxley, is very functional, and is only
22k. This release fixes 3 critical bugs in the 0.50 release.
There were 2 potential segfaults in lash (the busybox shell) in
the 0.50 release which are now fixed. Another critical bug in
0.50 which is now fixed: syslogd from 0.50 could potentially
deadlock the init process and thereby break your entire system.
<p>
There are a number of improvements in this release as well. For
one thing, the wget applet is greatly improved. Dmitry Zakharov
added FTP support, and Laurence Anderson make wget fully RFC
compliant for HTTP 1.1. The mechanism for including utility
functions in previous releases was clumsy and error prone. Now
all utility functions are part of a new libbb library, which makes
maintaining utility functions much simpler. And BusyBox now
compiles on itanium systems (thanks to the Debian itanium porters
for letting me use their system!).
<p>
You can read the
<a href="ftp://oss.lineo.com/busybox/Changelog">changelog</a> for
complete details. BusyBox 0.51 can be downloaded from
<a href="ftp://oss.lineo.com/busybox">ftp://oss.lineo.com/busybox</a>.
<p>Have Fun!
<p>
<li> <b>Busybox Boot-Floppy Image</b>
<p>Because you asked for it, we have made available a <a href=
"ftp://opensource.lineo.com/busybox/busybox.floppy.img"> Busybox boot floppy
image</a>. Here's how you use it:
<ol>
<li> <a href= "ftp://opensource.lineo.com/busybox/busybox.floppy.img">
Download the image</a>
<li> dd it onto a floppy like so: <tt> dd if=busybox.floppy.img
of=/dev/fd0 ; sync </tt>
<li> Pop it in a machine and boot up.
</ol>
<p> If you want to look at the contents of the initrd image, do this:
<pre>
mount ./busybox.floppy.img /mnt -o loop -t msdos
cp /mnt/initrd.gz /tmp
umount /mnt
gunzip /tmp/initrd.gz
mount /tmp/initrd /mnt -o loop -t minix
</pre>
<li> <b>15 March 2001 -- BusyBox 0.50 released</b>
<br>
This release adds several new applets including ifconfig, route, pivot_root, stty,
and tftp, and also fixes tons of bugs. Tab completion in the
shell is now working very well, and the shell's environment variable
expansion was fixed. Tons of other things were fixed or made
smaller. For a fairly complete overview, see the
<a href="ftp://oss.lineo.com/busybox/Changelog">changelog</a>.
<p>
lash (the busybox shell) is still with us, fixed up a bit so it
now behaves itself quite nicely. It really is quite usable as
long as you don't expect it to provide Bourne shell grammer.
Standard things like pipes, redirects, command line editing, and
environment variable expansion work great. But we have found that
this shell, while very usable, does not provide an extensible
framework for adding in full Bourne shell behavior. So the first order of
business as we begin working on the next BusyBox release will be to merge in the new shell
currently in progress at
<a href="http://doolittle.faludi.com/~larry/parser.html">Larry Doolittle's website</a>.
<p>
<li> <b>27 January 2001 -- BusyBox 0.49 released</b>
<br>
Several new applets, lots of bug fixes, cleanups, and many smaller
things made nicer. Several cleanups and improvements to the shell.
For a list of the most interesting changes
you might want to look at the <a href="ftp://oss.lineo.com/busybox/Changelog">changelog</a>.
<p>
Special thanks go out to Matt Kraai and Larry Doolittle for all their
work on this release, and for keeping on top of things while I've been
out of town.
<p>
<em>Special Note</em><br>
BusyBox 0.49 was supposed to have replaced lash, the BusyBox
shell, with a new shell that understands full Bourne shell/Posix shell grammer.
Well, that simply didn't happen in time for this release. A new
shell that will eventually replace lash is already under
construction. This new shell is being developed by Larry
Doolittle, and could use all of our help. Please see the work in
progress on <a href="http://doolittle.faludi.com/~larry/parser.html">Larry's website</a>
and help out if you can. This shell will be included in the next
release of BusyBox.
<p>
<li> <b>13 December 2000 -- BusyBox 0.48 released</b>
<br>
This release fixes lots and lots of bugs. This has had some very
rigorous testing, and looks very, very clean. The usual tar
update of course: tar no longer breaks hardlinks, tar -xzf is
optionally supported, and the LRP folks will be pleased to know
that 'tar -X' and 'tar --exclude' are both now in. Applets are
now looked up using a binary search making lash (the busybox
shell) much faster. For the new debian-installer (for Debian
woody) a .udeb can now be generated.
<p>
The curious can get a list of some of the more interesting changes by reading
the <a href="ftp://oss.lineo.com/busybox/Changelog">changelog</a>.
<p>
Many thanks go out to the many many people that have contributed to
this release, especially Matt Kraai, Larry Doolittle, and Kent Robotti.
<p>
<li> <b>Old News</b>
+125
View File
@@ -41,6 +41,131 @@
<p> <li> <b>Take me back to the <a href="http://busybox.lineo.com/">BusyBox</a> web site.</b>
<hr>
<li> <b>10 April 2001 -- BusyBox 0.51 released</b>
<br>
BusyBox 0.51 (the "rock-solid release") is now out there. This
release adds only 2 new applets: env and vi. The vi applet,
contributed by Sterling Huxley, is very functional, and is only
22k. This release fixes 3 critical bugs in the 0.50 release.
There were 2 potential segfaults in lash (the busybox shell) in
the 0.50 release which are now fixed. Another critical bug in
0.50 which is now fixed: syslogd from 0.50 could potentially
deadlock the init process and thereby break your entire system.
<p>
There are a number of improvements in this release as well. For
one thing, the wget applet is greatly improved. Dmitry Zakharov
added FTP support, and Laurence Anderson make wget fully RFC
compliant for HTTP 1.1. The mechanism for including utility
functions in previous releases was clumsy and error prone. Now
all utility functions are part of a new libbb library, which makes
maintaining utility functions much simpler. And BusyBox now
compiles on itanium systems (thanks to the Debian itanium porters
for letting me use their system!).
<p>
You can read the
<a href="ftp://oss.lineo.com/busybox/Changelog">changelog</a> for
complete details. BusyBox 0.51 can be downloaded from
<a href="ftp://oss.lineo.com/busybox">ftp://oss.lineo.com/busybox</a>.
<p>Have Fun!
<p>
<li> <b>Busybox Boot-Floppy Image</b>
<p>Because you asked for it, we have made available a <a href=
"ftp://opensource.lineo.com/busybox/busybox.floppy.img"> Busybox boot floppy
image</a>. Here's how you use it:
<ol>
<li> <a href= "ftp://opensource.lineo.com/busybox/busybox.floppy.img">
Download the image</a>
<li> dd it onto a floppy like so: <tt> dd if=busybox.floppy.img
of=/dev/fd0 ; sync </tt>
<li> Pop it in a machine and boot up.
</ol>
<p> If you want to look at the contents of the initrd image, do this:
<pre>
mount ./busybox.floppy.img /mnt -o loop -t msdos
cp /mnt/initrd.gz /tmp
umount /mnt
gunzip /tmp/initrd.gz
mount /tmp/initrd /mnt -o loop -t minix
</pre>
<li> <b>15 March 2001 -- BusyBox 0.50 released</b>
<br>
This release adds several new applets including ifconfig, route, pivot_root, stty,
and tftp, and also fixes tons of bugs. Tab completion in the
shell is now working very well, and the shell's environment variable
expansion was fixed. Tons of other things were fixed or made
smaller. For a fairly complete overview, see the
<a href="ftp://oss.lineo.com/busybox/Changelog">changelog</a>.
<p>
lash (the busybox shell) is still with us, fixed up a bit so it
now behaves itself quite nicely. It really is quite usable as
long as you don't expect it to provide Bourne shell grammer.
Standard things like pipes, redirects, command line editing, and
environment variable expansion work great. But we have found that
this shell, while very usable, does not provide an extensible
framework for adding in full Bourne shell behavior. So the first order of
business as we begin working on the next BusyBox release will be to merge in the new shell
currently in progress at
<a href="http://doolittle.faludi.com/~larry/parser.html">Larry Doolittle's website</a>.
<p>
<li> <b>27 January 2001 -- BusyBox 0.49 released</b>
<br>
Several new applets, lots of bug fixes, cleanups, and many smaller
things made nicer. Several cleanups and improvements to the shell.
For a list of the most interesting changes
you might want to look at the <a href="ftp://oss.lineo.com/busybox/Changelog">changelog</a>.
<p>
Special thanks go out to Matt Kraai and Larry Doolittle for all their
work on this release, and for keeping on top of things while I've been
out of town.
<p>
<em>Special Note</em><br>
BusyBox 0.49 was supposed to have replaced lash, the BusyBox
shell, with a new shell that understands full Bourne shell/Posix shell grammer.
Well, that simply didn't happen in time for this release. A new
shell that will eventually replace lash is already under
construction. This new shell is being developed by Larry
Doolittle, and could use all of our help. Please see the work in
progress on <a href="http://doolittle.faludi.com/~larry/parser.html">Larry's website</a>
and help out if you can. This shell will be included in the next
release of BusyBox.
<p>
<li> <b>13 December 2000 -- BusyBox 0.48 released</b>
<br>
This release fixes lots and lots of bugs. This has had some very
rigorous testing, and looks very, very clean. The usual tar
update of course: tar no longer breaks hardlinks, tar -xzf is
optionally supported, and the LRP folks will be pleased to know
that 'tar -X' and 'tar --exclude' are both now in. Applets are
now looked up using a binary search making lash (the busybox
shell) much faster. For the new debian-installer (for Debian
woody) a .udeb can now be generated.
<p>
The curious can get a list of some of the more interesting changes by reading
the <a href="ftp://oss.lineo.com/busybox/Changelog">changelog</a>.
<p>
Many thanks go out to the many many people that have contributed to
this release, especially Matt Kraai, Larry Doolittle, and Kent Robotti.
<p>
<p> <li> <b>26 September 2000 -- BusyBox 0.47 released</b>
<br>
+68 -19
View File
@@ -29,21 +29,60 @@
#include <string.h>
#include <getopt.h>
#include <unistd.h>
#include <stdint.h>
#include <fcntl.h>
#include <sys/time.h>
#include "busybox.h"
/* We are making a lame pseudo-random string generator here. in
* convert(), each pass through the while loop will add more and more
* stuff into value, which is _supposed_ to wrap. We don't care about
* it being accurate. We care about it being messy, since we then mod
* it by the sizeof(letters) and then use that as an index into letters
* to pick a random letter to add to out temporary file. */
typedef unsigned long int bb_uint64_t;
static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
// if fn is NULL then input is stdin and output is stdout
static int convert(char *fn, int ConvType) {
int c;
char *tempFn = NULL;
static int convert(char *fn, int ConvType)
{
int c, fd;
struct timeval tv;
char tempFn[BUFSIZ];
static bb_uint64_t value=0;
FILE *in = stdin, *out = stdout;
if (fn != NULL) {
if ((in = wfopen(fn, "r")) == NULL) {
if ((in = wfopen(fn, "rw")) == NULL) {
return -1;
}
if ((out = tmpfile()) == NULL) {
perror_msg(NULL);
return -2;
strcpy(tempFn, fn);
c = strlen(tempFn);
tempFn[c] = '.';
while(1) {
if (c >=BUFSIZ)
error_msg_and_die("unique name not found");
/* Get some semi random stuff to try and make a
* random filename based (and in the same dir as)
* the input file... */
gettimeofday (&tv, NULL);
value += ((bb_uint64_t) tv.tv_usec << 16) ^ tv.tv_sec ^ getpid ();
tempFn[++c] = letters[value % 62];
tempFn[c+1] = '\0';
value /= 62;
if ((fd = open(tempFn, O_RDWR | O_CREAT | O_EXCL, 0600)) < 0 ) {
continue;
}
out = fdopen(fd, "w+");
if (!out) {
close(fd);
remove(tempFn);
continue;
}
break;
}
}
@@ -51,6 +90,7 @@ static int convert(char *fn, int ConvType) {
if (c == '\r') {
if ((ConvType == CT_UNIX2DOS) && (fn != NULL)) {
// file is alredy in DOS format so it is not necessery to touch it
remove(tempFn);
if (fclose(in) < 0 || fclose(out) < 0) {
perror_msg(NULL);
return -2;
@@ -64,6 +104,7 @@ static int convert(char *fn, int ConvType) {
if (c == '\n') {
if ((ConvType == CT_DOS2UNIX) && (fn != NULL)) {
// file is alredy in UNIX format so it is not necessery to touch it
remove(tempFn);
if ((fclose(in) < 0) || (fclose(out) < 0)) {
perror_msg(NULL);
return -2;
@@ -95,29 +136,37 @@ static int convert(char *fn, int ConvType) {
}
if (fn != NULL) {
if (fclose(in) < 0 || fclose(out) < 0 ||
(in = fopen(tempFn, "r")) == NULL || (out = fopen(fn, "w")) == NULL) {
perror_msg(NULL);
return -2;
if (fclose(in) < 0 || fclose(out) < 0) {
perror_msg(NULL);
remove(tempFn);
return -2;
}
while ((c = fgetc(in)) != EOF) {
fputc(c, out);
}
if ((fclose(in) < 0) || (fclose(out) < 0)) {
perror_msg(NULL);
return -2;
/* Assume they are both on the same filesystem (which
* should be true since we put them into the same directory
* so we _should_ be ok, but you never know... */
if (rename(tempFn, fn) < 0) {
perror_msg("unable to rename '%s' as '%s'", tempFn, fn);
return -1;
}
}
return 0;
}
int dos2unix_main(int argc, char *argv[]) {
int dos2unix_main(int argc, char *argv[])
{
int ConvType = CT_AUTO;
int o;
//See if we are supposed to be doing dos2unix or unix2dos
if (argv[0][0]=='d') {
ConvType = CT_DOS2UNIX;
}
if (argv[0][0]=='u') {
ConvType = CT_UNIX2DOS;
}
// process parameters
while ((o = getopt(argc, argv, "du")) != EOF) {
switch (o) {
+1346 -755
View File
File diff suppressed because it is too large. Load diff
+9 -4
View File
@@ -110,12 +110,17 @@ extern int dpkg_deb_main(int argc, char **argv)
}
else if (arg_type == arg_type_field) {
char *field = NULL;
char *name;
char *value;
int field_start = 0;
while ((field = read_package_field(&output_buffer[field_start])) != NULL) {
field_start += (strlen(field) + 1);
if (strstr(field, argv[optind + 1]) == field) {
puts(field + strlen(argv[optind + 1]) + 2);
while (1) {
field_start += read_package_field(&output_buffer[field_start], &name, &value);
if (name == NULL) {
break;
}
if (strcmp(name, argv[optind + 1]) == 0) {
puts(value);
}
free(field);
}
+2 -2
View File
@@ -51,9 +51,9 @@ int dumpkmap_main(int argc, char **argv)
show_usage();
}
fd = open("/dev/tty0", O_RDWR);
fd = open(CURRENT_VC, O_RDWR);
if (fd < 0) {
perror_msg("Error opening /dev/tty0");
perror_msg("Error opening " CURRENT_VC);
return EXIT_FAILURE;
}
+51 -14
View File
@@ -490,8 +490,23 @@ static void load_cmd_file(char *filename)
}
}
static void print_subst_w_backrefs(const char *line, const char *replace, regmatch_t *regmatch)
#define PIPE_MAGIC 0x7f
#define PIPE_GROW 64
#define pipeputc(c) \
{ if (pipeline[pipeline_idx] == PIPE_MAGIC) { \
pipeline = xrealloc(pipeline, pipeline_len+PIPE_GROW); \
memset(pipeline+pipeline_len, 0, PIPE_GROW); \
pipeline_len += PIPE_GROW; \
pipeline[pipeline_len-1] = PIPE_MAGIC; } \
pipeline[pipeline_idx++] = (c); }
static void print_subst_w_backrefs(const char *line, const char *replace,
regmatch_t *regmatch, char **pipeline_p, int *pipeline_idx_p,
int *pipeline_len_p, int matches)
{
char *pipeline = *pipeline_p;
int pipeline_idx = *pipeline_idx_p;
int pipeline_len = *pipeline_len_p;
int i;
/* go through the replacement string */
@@ -506,14 +521,15 @@ static void print_subst_w_backrefs(const char *line, const char *replace, regmat
tmpstr[1] = 0;
backref = atoi(tmpstr);
/* print out the text held in regmatch[backref] */
for (j = regmatch[backref].rm_so; j < regmatch[backref].rm_eo; j++)
fputc(line[j], stdout);
if (backref <= matches && regmatch[backref].rm_so != -1)
for (j = regmatch[backref].rm_so; j < regmatch[backref].rm_eo; j++)
pipeputc(line[j]);
}
/* if we find a backslash escaped character, print the character */
else if (replace[i] == '\\') {
++i;
fputc(replace[i], stdout);
pipeputc(replace[i]);
}
/* if we find an unescaped '&' print out the whole matched text.
@@ -523,27 +539,41 @@ static void print_subst_w_backrefs(const char *line, const char *replace, regmat
else if (replace[i] == '&' && replace[i-1] != '\\') {
int j;
for (j = regmatch[0].rm_so; j < regmatch[0].rm_eo; j++)
fputc(line[j], stdout);
pipeputc(line[j]);
}
/* nothing special, just print this char of the replacement string to stdout */
else
fputc(replace[i], stdout);
pipeputc(replace[i]);
}
*pipeline_p = pipeline;
*pipeline_idx_p = pipeline_idx;
*pipeline_len_p = pipeline_len;
}
static int do_subst_command(const struct sed_cmd *sed_cmd, const char *line)
static int do_subst_command(const struct sed_cmd *sed_cmd, char **line)
{
char *hackline = (char *)line;
char *hackline = *line;
char *pipeline = 0;
int pipeline_idx = 0;
int pipeline_len = 0;
int altered = 0;
regmatch_t *regmatch = NULL;
/* we only proceed if the substitution 'search' expression matches */
if (regexec(sed_cmd->sub_match, line, 0, NULL, 0) == REG_NOMATCH)
if (regexec(sed_cmd->sub_match, hackline, 0, NULL, 0) == REG_NOMATCH)
return 0;
/* whaddaya know, it matched. get the number of back references */
regmatch = xmalloc(sizeof(regmatch_t) * (sed_cmd->num_backrefs+1));
/* allocate more PIPE_GROW bytes
if replaced string is larger than original */
pipeline_len = strlen(hackline)+PIPE_GROW;
pipeline = xmalloc(pipeline_len);
memset(pipeline, 0, pipeline_len);
/* buffer magic */
pipeline[pipeline_len-1] = PIPE_MAGIC;
/* and now, as long as we've got a line to try matching and if we can match
* the search string, we make substitutions */
while (*hackline && (regexec(sed_cmd->sub_match, hackline,
@@ -552,10 +582,12 @@ static int do_subst_command(const struct sed_cmd *sed_cmd, const char *line)
/* print everything before the match */
for (i = 0; i < regmatch[0].rm_so; i++)
fputc(hackline[i], stdout);
pipeputc(hackline[i]);
/* then print the substitution string */
print_subst_w_backrefs(hackline, sed_cmd->replace, regmatch);
print_subst_w_backrefs(hackline, sed_cmd->replace, regmatch,
&pipeline, &pipeline_idx, &pipeline_len,
sed_cmd->num_backrefs);
/* advance past the match */
hackline += regmatch[0].rm_eo;
@@ -567,11 +599,14 @@ static int do_subst_command(const struct sed_cmd *sed_cmd, const char *line)
break;
}
puts(hackline);
for (; *hackline; hackline++) pipeputc(*hackline);
if (pipeline[pipeline_idx] == PIPE_MAGIC) pipeline[pipeline_idx] = 0;
/* cleanup */
free(regmatch);
free(*line);
*line = pipeline;
return altered;
}
@@ -650,12 +685,14 @@ static void process_file(FILE *file)
/* we print the line once, unless we were told to be quiet */
if (!be_quiet)
altered = do_subst_command(&sed_cmds[i], line);
altered |= do_subst_command(&sed_cmds[i], &line);
/* we also print the line if we were given the 'p' flag
* (this is quite possibly the second printing) */
if (sed_cmds[i].sub_p)
altered = do_subst_command(&sed_cmds[i], line);
altered |= do_subst_command(&sed_cmds[i], &line);
if (altered && (i+1 >= ncmds || sed_cmds[i+1].cmd != 's'))
puts(line);
break;
+9 -5
View File
@@ -18,8 +18,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
char *vi_Version =
"$Id: vi.c,v 1.11 2001/07/02 18:06:14 andersen Exp $";
static const char vi_Version[] =
"$Id: vi.c,v 1.15 2001/08/02 05:26:41 andersen Exp $";
/*
* To compile for standalone use:
@@ -1982,9 +1982,13 @@ static void colon(Byte * buf)
// read after current line- unless user said ":0r foo"
if (b != 0)
q = next_line(q);
#ifdef BB_FEATURE_VI_READONLY
l= readonly; // remember current files' status
#endif
ch = file_insert(fn, q, file_size(fn));
#ifdef BB_FEATURE_VI_READONLY
readonly= l;
#endif
if (ch < 0)
goto vc1; // nothing was inserted
// how many lines in text[]?
@@ -2636,12 +2640,12 @@ static Byte *char_insert(Byte * p, Byte c) // insert the char c at 'p'
cmdcnt = 0;
end_cmd_q(); // stop adding to q
strcpy((char *) status_buffer, " "); // clear the status buffer
if (p[-1] != '\n') {
if ((p[-1] != '\n') && (dot>text)) {
p--;
}
} else if (c == erase_char) { // Is this a BS
// 123456789
if (p[-1] != '\n') {
if ((p[-1] != '\n') && (dot>text)) {
p--;
p = text_hole_delete(p, p); // shrink buffer 1 char
#ifdef BB_FEATURE_VI_DOT_CMD
@@ -3554,7 +3558,7 @@ static int file_write(Byte * fn, Byte * first, Byte * last)
}
charcnt = 0;
// FIXIT- use the correct umask()
fd = open((char *) fn, (O_RDWR | O_CREAT | O_TRUNC), 0664);
fd = open((char *) fn, (O_WRONLY | O_CREAT | O_TRUNC), 0664);
if (fd < 0)
return (-1);
cnt = last - first + 1;
+16 -8
View File
@@ -1,13 +1,21 @@
Name: busybox
Version: 0.52
Release: 1
%define name busybox
%define epoch 0
%define version 0.61.pre
%define release %(date -I | sed -e 's/-/_/g')
%define serial 1
Name: %{name}
#Epoch: %{epoch}
Version: %{version}
Release: %{release}
Serial: %{serial}
Copyright: GPL
Group: System/Utilities
Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary.
Copyright: GPL
URL: http://busybox.lineo.com/
Source: ftp://oss.lineo.com/busybox/%{name}-%{version}.tar.gz
Buildroot: /var/tmp/%{name}-%{version}
Packager : Erik Andersen <andersen@lineo.com>
Conflicts: fileutils grep shellutils
Buildroot: /tmp/%{Name}-%{Version}
Source: %{Name}-%{Version}.tar.gz
%Description
BusyBox combines tiny versions of many common UNIX utilities into a single
@@ -19,7 +27,7 @@ their full featured GNU cousins; however, the options that are provided behave
very much like their GNU counterparts.
%Prep
%setup -q -n %{Name}-%{Version}
%setup -q -n %{name}-%{version}
%Build
make
+227
View File
@@ -0,0 +1,227 @@
#!/usr/bin/perl -w
# vi: set ts=4:
# Copyright (c) 2001 David Schleef <ds@schleef.org>
# Copyright (c) 2001 Erik Andersen <andersen@lineo.com>
# Copyright (c) 2001 Stuart Hughes <stuarth@lineo.com>
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
# TODO -- use strict mode...
#use strict;
use Getopt::Long;
use File::Find;
# Set up some default values
my $basedir="";
my $kernel;
my $kernelsyms;
my $stdout=1;
my $verbose=0;
# get command-line options
my %opt;
GetOptions(
\%opt,
"help|h",
"basedir|b=s" => \$basedir,
"kernel|k=s" => \$kernel,
"kernelsyms|F=s" => \$kernelsyms,
"stdout|n" => \$stdout,
"verbose|v" => \$verbose,
);
if (defined $opt{help}) {
print
"$0 [OPTION]... [basedir]\n",
"\t-h --help\t\tShow this help screen\n",
"\t-b --basedir\t\tModules base directory (defaults to /lib/modules)\n",
"\t-k --kernel\t\tKernel binary for the target\n",
"\t-F --kernelsyms\t\tKernel symbol file\n",
"\t-n --stdout\t\tWrite to stdout instead of modules.dep\n",
"\t-v --verbose\t\tPrint out lots of debugging stuff\n",
;
exit 1;
}
if($basedir !~ m-/lib/modules-) {
warn "WARNING: base directory does not match ..../lib/modules\n";
}
# Find the list of .o files living under $basedir
#if ($verbose) { printf "Locating all modules\n"; }
my($file) = "";
my(@liblist) = ();
find sub {
if ( -f $_ && ! -d $_ ) {
$file = $File::Find::name;
if ( $file =~ /.o$/ ) {
push(@liblist, $file);
if ($verbose) { printf "$file\n"; }
}
}
}, $basedir;
if ($verbose) { printf "Finished locating modules\n"; }
foreach $obj ( @liblist, $kernel ){
# turn the input file name into a target tag name
# vmlinux is a special that is only used to resolve symbols
if($obj =~ /vmlinux/) {
$tgtname = "vmlinux";
} else {
($tgtname) = $obj =~ m-(/lib/modules/.*)$-;
}
warn "MODULE = $tgtname\n" if $verbose;
# get a list of symbols
@output=`nm $obj`;
$ksymtab=grep m/ __ksymtab/, @output;
# gather the exported symbols
if($ksymtab){
# explicitly exported
foreach ( @output ) {
/ __ksymtab_(.*)$/ and do {
warn "sym = $1\n" if $verbose;
$exp->{$1} = $tgtname;
};
}
} else {
# exporting all symbols
foreach ( @output) {
/ [ABCDGRST] (.*)$/ and do {
warn "syma = $1\n" if $verbose;
$exp->{$1} = $tgtname;
};
}
}
# gather the unresolved symbols
foreach ( @output ) {
!/ __this_module/ && / U (.*)$/ and do {
warn "und = $1\n" if $verbose;
push @{$dep->{$tgtname}}, $1;
};
}
}
# reduce dependancies: remove unresolvable and resolved from vmlinux
# remove duplicates
foreach $module (keys %$dep) {
$mod->{$module} = {};
foreach (@{$dep->{$module}}) {
if( $exp->{$_} ) {
warn "resolved symbol $_ in file $exp->{$_}\n" if $verbose;
next if $exp->{$_} =~ /vmlinux/;
$mod->{$module}{$exp->{$_}} = 1;
} else {
warn "unresolved symbol $_ in file $module\n";
}
}
}
# resolve the dependancies for each module
foreach $module ( keys %$mod ) {
print "$module:\t";
@sorted = sort bydep keys %{$mod->{$module}};
print join(" \\\n\t",@sorted);
# foreach $m (@sorted ) {
# print "\t$m\n";
# }
print "\n\n";
}
sub bydep
{
foreach my $f ( keys %{$mod->{$b}} ) {
if($f eq $a) {
return 1;
}
}
return -1;
}
__END__
=head1 NAME
depmod.pl - a cross platform script to generate kernel module dependency
lists which can then be used by modprobe.
=head1 SYNOPSIS
depmod.pl [OPTION]... [FILE]...
Example:
depmod.pl -F linux/System.map target/lib/modules
=head1 DESCRIPTION
The purpose of this script is to automagically generate a list of of kernel
module dependancies. This script produces dependancy lists that should be
identical to the depmod program from the modutils package. Unlike the depmod
binary, however, depmod.pl is designed to be run on your host system, not
on your target system.
This script was written by David Schleef <ds@schleef.org> to be used in
conjunction with the BusyBox modprobe applet.
=head1 OPTIONS
=over 4
=item B<-h --help>
This displays the help message.
=item B<-b --basedir>
The base directory uner which the target's modules will be found. This
defaults to the /lib/modules directory.
=item B<-k --kernel>
Kernel binary for the target. You must either supply a kernel binary
or a kernel symbol file (using the -F option).
=item B<-F --kernelsyms>
Kernel symbol file for the target. You must supply either a kernel symbol file
kernel binary for the target (using the -k option).
=item B<-n --stdout>
Write to stdout instead of modules.dep. This is currently hard coded...
kernel binary for the target (using the -k option).
=item B<--verbose>
Be verbose (not implemented)
=back
=head1 COPYRIGHT
Copyright (c) 2001 David Schleef <ds@schleef.org>
Copyright (c) 2001 Erik Andersen <andersen@lineo.com>
Copyright (c) 2001 Stuart Hughes <stuarth@lineo.com>
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=head1 AUTHOR
David Schleef <ds@schleef.org>
=cut
# $Id: depmod.pl,v 1.1 2001/07/30 19:32:03 andersen Exp $
+22 -19
View File
@@ -24,7 +24,7 @@
# <runlevels>: The runlevels field is completely ignored.
#
# <action>: Valid actions include: sysinit, respawn, askfirst, wait, once,
# and ctrlaltdel.
# ctrlaltdel, and shutdown.
#
# Note: askfirst acts just like respawn, but before running the specified
# process it displays the line "Please press Enter to activate this
@@ -36,14 +36,19 @@
#
# <process>: Specifies the process to be executed and it's command line.
#
# Note: BusyBox init works just fine without an inittab. If no inittab
# is found, it has the following default behavior:
# ::sysinit:/etc/init.d/rcS
# ::askfirst:/bin/sh
# if it detects that /dev/console is _not_ a serial console, it will also run:
# tty2::askfirst:/bin/sh
# Note: BusyBox init works just fine without an inittab. If no inittab is
# found, it has the following default behavior:
# ::sysinit:/etc/init.d/rcS
# ::askfirst:/bin/sh
# ::ctrlaltdel:/sbin/reboot
# ::shutdown:/sbin/swapoff -a
# ::shutdown:/bin/umount -a -r
# if it detects that /dev/console is _not_ a serial console, it will
# also run:
# tty2::askfirst:/bin/sh
# tty3::askfirst:/bin/sh
# tty4::askfirst:/bin/sh
#
# Boot-time system configuration/initialization script.
# This is run first except when booting in single-user mode.
#
@@ -56,28 +61,26 @@
# login, but since we are bypassing login in this case, BusyBox lets you do
# this yourself...
#
# Start an "askfirst" shell on the console (whatever that may be).
# Start an "askfirst" shell on the console (whatever that may be)
::askfirst:-/bin/sh
#
# Start an "askfirst" shell on /dev/tty2-4
tty2::askfirst:-/bin/sh
tty3::askfirst:-/bin/sh
tty4::askfirst:-/bin/sh
# /sbin/getty invocations for selected ttys
#
tty5::respawn:/sbin/getty 38400 tty5
tty6::respawn:/sbin/getty 38400 tty6
tty4::respawn:/sbin/getty 38400 tty5
tty5::respawn:/sbin/getty 38400 tty6
# Example of how to put a getty on a serial line (for a terminal)
#
#ttyS0::respawn:/sbin/getty -L ttyS0 9600 vt100
#ttyS1::respawn:/sbin/getty -L ttyS1 9600 vt100
#::respawn:/sbin/getty -L ttyS0 9600 vt100
#::respawn:/sbin/getty -L ttyS1 9600 vt100
#
# Example how to put a getty on a modem line.
#ttyS2::respawn:/sbin/getty -x0 -s 57600 ttyS2
#::respawn:/sbin/getty 57600 ttyS2
# Stuff to do before rebooting
::ctrlaltdel:/bin/umount -a -r
::ctrlaltdel:/sbin/swapoff -a
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
::shutdown:/sbin/swapoff -a
+4 -1
View File
@@ -179,7 +179,10 @@ static void grep_file(FILE *file)
if (print_match_counts) {
if (print_filename)
printf("%s:", cur_file);
printf("%d\n", nmatches);
if (print_files_with_matches && nmatches > 0)
printf("1\n");
else
printf("%d\n", nmatches);
}
/* grep -l: print just the filename, but only if we grepped the line in the file */
+1232
View File
File diff suppressed because it is too large. Load diff
+4 -1
View File
@@ -179,7 +179,10 @@ static void grep_file(FILE *file)
if (print_match_counts) {
if (print_filename)
printf("%s:", cur_file);
printf("%d\n", nmatches);
if (print_files_with_matches && nmatches > 0)
printf("1\n");
else
printf("%d\n", nmatches);
}
/* grep -l: print just the filename, but only if we grepped the line in the file */
+3
View File
@@ -118,6 +118,9 @@ extern int gunzip_main(int argc, char **argv)
/* Open input file */
in_file = xfopen(if_name, "r");
/* set the buffer size */
setvbuf(in_file, NULL, _IOFBF, 0x8000);
/* Get the time stamp on the input file. */
if (stat(if_name, &stat_buf) < 0) {
error_msg_and_die("Couldn't stat file %s", if_name);
+46 -28
View File
@@ -110,8 +110,7 @@ static int method; /* compression method */
#ifdef DYN_ALLOC
# define DECLARE(type, array, size) static type * array
# define ALLOC(type, array, size) { \
array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
if (array == NULL) error_msg(memory_exhausted); \
array = (type*)xcalloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
}
# define FREE(array) {if (array != NULL) free(array), array=NULL;}
#else
@@ -181,16 +180,17 @@ typedef int file_t; /* Do not use stdio */
outbuf[outcnt++] = (uch) ((w) & 0xff); \
outbuf[outcnt++] = (uch) ((ush)(w) >> 8); \
} else { \
put_byte((uch)((w) & 0xff)); \
put_byte((uch)((ush)(w) >> 8)); \
put_short_when_full(w); \
} \
}
/* Output a 32 bit value to the bit stream, lsb first */
#if 0
#define put_long(n) { \
put_short((n) & 0xffff); \
put_short(((ulg)(n)) >> 16); \
}
#endif
#define seekable() 0 /* force sequential output */
#define translate_eol 0 /* no option -a yet */
@@ -220,7 +220,6 @@ typedef int file_t; /* Do not use stdio */
#endif
/* from zip.c: */
static int zip (int in, int out);
static int file_read (char *buf, unsigned size);
@@ -248,6 +247,9 @@ static int (*read_buf) (char *buf, unsigned size);
/* from util.c: */
static void flush_outbuf (void);
static void put_short_when_full (ush);
/* lzw.h -- define the lzw functions.
* Copyright (C) 1992-1993 Jean-loup Gailly.
* This is free software; you can redistribute it and/or modify it under the
@@ -388,18 +390,11 @@ static ulg updcrc(uch *s, unsigned n)
static unsigned long crc_32_tab[256];
if (crc_table_empty) {
unsigned long csr; /* crc shift register */
unsigned long e=0; /* polynomial exclusive-or pattern */
const unsigned long e = 0xedb88320L; /* polynomial exclusive-or pattern */
int i; /* counter for all possible eight bit values */
int k; /* byte being shifted into crc apparatus */
/* terms of polynomial defining this crc (except x^32): */
static const int p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
/* Make exclusive-or pattern from polynomial (0xedb88320) */
for (i = 0; i < sizeof(p)/sizeof(int); i++)
e |= 1L << (31 - p[i]);
/* Compute and print table of CRC's, five per line */
/* Compute table of CRC's. */
crc_32_tab[0] = 0x00000000L;
for (i = 1; i < 256; i++) {
csr = i;
@@ -1206,7 +1201,6 @@ typedef struct dirent dir_type;
typedef RETSIGTYPE(*sig_type) (int);
/* ======================================================================== */
// int main (argc, argv)
// int argc;
@@ -1246,7 +1240,7 @@ int gzip_main(int argc, char **argv)
show_usage();
}
}
if (optind == argc) {
if ((optind == argc) || (strcmp(argv[optind], "-") == 0)) {
fromstdin = 1;
tostdout = 1;
}
@@ -1291,11 +1285,9 @@ int gzip_main(int argc, char **argv)
/* Open input file */
inFileNum = open(ifname, O_RDONLY);
if (inFileNum < 0)
if (inFileNum < 0 || stat(ifname, &statBuf) < 0)
perror_msg_and_die("%s", ifname);
/* Get the time stamp on the input file. */
if (stat(ifname, &statBuf) < 0)
perror_msg_and_die("%s", ifname);
time_stamp = statBuf.st_ctime;
ifile_size = statBuf.st_size;
}
@@ -1433,16 +1425,20 @@ int gzip_main(int argc, char **argv)
#define BL_CODES 19
/* number of codes used to transfer the bit lengths */
typedef uch extra_bits_t;
static const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */
/* extra bits for each length code */
static const extra_bits_t extra_lbits[LENGTH_CODES]
= { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4,
4, 4, 5, 5, 5, 5, 0 };
static const int extra_dbits[D_CODES] /* extra bits for each distance code */
/* extra bits for each distance code */
static const extra_bits_t extra_dbits[D_CODES]
= { 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,
10, 10, 11, 11, 12, 12, 13, 13 };
static const int extra_blbits[BL_CODES] /* extra bits for each bit length code */
/* extra bits for each bit length code */
static const extra_bits_t extra_blbits[BL_CODES]
= { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7 };
#define STORED_BLOCK 0
@@ -1537,7 +1533,7 @@ static ct_data bl_tree[2 * BL_CODES + 1];
typedef struct tree_desc {
ct_data *dyn_tree; /* the dynamic tree */
ct_data *static_tree; /* corresponding static tree or NULL */
const int *extra_bits; /* extra bits for each code or NULL */
const extra_bits_t *extra_bits; /* extra bits for each code or NULL */
int extra_base; /* base index for extra_bits */
int elems; /* max number of elements in the tree */
int max_length; /* max bit length for the codes */
@@ -1834,7 +1830,7 @@ static void pqdownheap(ct_data *tree, int k)
static void gen_bitlen(tree_desc *desc)
{
ct_data *tree = desc->dyn_tree;
const int *extra = desc->extra_bits;
const extra_bits_t *extra = desc->extra_bits;
int base = desc->extra_base;
int max_code = desc->max_code;
int max_length = desc->max_length;
@@ -2466,6 +2462,28 @@ static void set_file_type()
static ulg crc; /* crc on uncompressed file data */
static long header_bytes; /* number of bytes in gzip header */
static void put_short_when_full(ush w)
{
put_byte((uch)((w) & 0xff));
put_byte((uch)((ush)(w) >> 8));
}
static void put_short_function(ush n)
{
put_short(n);
}
static void put_long(ulg n)
{
put_short_function((n) & 0xffff);
put_short_function(((ulg)(n)) >> 16);
}
/* put_header_byte is used for the compressed output
* - for the initial 4 bytes that can't overflow the buffer.
*/
#define put_header_byte(c) {outbuf[outcnt++]=(uch)(c);}
/* ===========================================================================
* Deflate in to out.
* IN assertions: the input and output buffers are cleared.
@@ -2485,11 +2503,11 @@ static int zip(int in, int out)
method = DEFLATED;
put_byte(GZIP_MAGIC[0]); /* magic header */
put_byte(GZIP_MAGIC[1]);
put_byte(DEFLATED); /* compression method */
put_header_byte(GZIP_MAGIC[0]); /* magic header */
put_header_byte(GZIP_MAGIC[1]);
put_header_byte(DEFLATED); /* compression method */
put_byte(my_flags); /* general flags */
put_header_byte(my_flags); /* general flags */
put_long(time_stamp);
/* Write deflated file to zip file */
+1 -3
View File
@@ -22,7 +22,6 @@
*
*/
#include <errno.h>
#include <stdio.h>
#include <getopt.h>
#include <stdlib.h>
@@ -82,10 +81,9 @@ int head_main(int argc, char **argv)
printf("==> %s <==\n", argv[optind]);
}
head(len, fp);
if (errno) {
if (ferror(fp)) {
perror_msg("%s", argv[optind]);
status = EXIT_FAILURE;
errno = 0;
}
if (optind < argc - 1)
putchar('\n');
+6 -9
View File
@@ -112,7 +112,7 @@
#else
#define applet_name "hush"
#include "standalone.h"
#define shell_main main
#define hush_main main
#undef BB_FEATURE_SH_FANCY_PROMPT
#endif
@@ -237,10 +237,6 @@ unsigned int global_argc;
unsigned int last_return_code;
extern char **environ; /* This is in <unistd.h>, but protected with __USE_GNU */
/* Variables we export */
unsigned int shell_context; /* Used in cmdedit.c to reset the
* context when someone hits ^C */
/* "globals" within this file */
static char *ifs;
static char map[256];
@@ -883,7 +879,6 @@ static void get_user_input(struct in_str *i)
** child processes (rob@sysgo.de)
*/
cmdedit_read_input(prompt_str, the_command);
cmdedit_terminate();
#else
fputs(prompt_str, stdout);
fflush(stdout);
@@ -1411,6 +1406,7 @@ static int run_pipe_real(struct pipe *pi)
/* Set the handling for job control signals back to the default. */
signal(SIGINT, SIG_DFL);
signal(SIGQUIT, SIG_DFL);
signal(SIGTERM, SIG_DFL);
signal(SIGTSTP, SIG_DFL);
signal(SIGTTIN, SIG_DFL);
signal(SIGTTOU, SIG_DFL);
@@ -2551,6 +2547,7 @@ static void setup_job_control()
/* Ignore interactive and job-control signals. */
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
signal(SIGTERM, SIG_IGN);
signal(SIGTSTP, SIG_IGN);
signal(SIGTTIN, SIG_IGN);
signal(SIGTTOU, SIG_IGN);
@@ -2565,7 +2562,7 @@ static void setup_job_control()
tcsetpgrp(shell_terminal, shell_pgrp);
}
int shell_main(int argc, char **argv)
int hush_main(int argc, char **argv)
{
int opt;
FILE *input;
@@ -2575,8 +2572,8 @@ int shell_main(int argc, char **argv)
global_argc = argc;
global_argv = argv;
/* (re?) initialize globals. Sometimes shell_main() ends up calling
* shell_main(), therefore we cannot rely on the BSS to zero out this
/* (re?) initialize globals. Sometimes hush_main() ends up calling
* hush_main(), therefore we cannot rely on the BSS to zero out this
* stuff. Reset these to 0 every time. */
ifs = NULL;
/* map[] is taken care of with call to update_ifs_map() */
+7 -19
View File
@@ -15,7 +15,7 @@
* Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* $Id: ifconfig.c,v 1.11 2001/07/07 05:19:52 andersen Exp $
* $Id: ifconfig.c,v 1.12 2001/08/10 06:02:23 mjn3 Exp $
*
*/
@@ -110,8 +110,6 @@
#define A_NETMASK 0x20 /* Set if netmask (check for multiple sets). */
#define A_SET_AFTER 0x40 /* Set a flag at the end. */
#define A_COLON_CHK 0x80 /* Is this needed? See below. */
#define A_HOSTNAME 0x100 /* Set if it is ip addr. */
#define A_BROADCAST 0x200 /* Set if it is broadcast addr. */
/*
* These defines are for dealing with the A_CAST_TYPE field.
@@ -141,12 +139,12 @@
#define ARG_IRQ (A_ARG_REQ | A_MAP_UCHAR)
#define ARG_DSTADDR (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE)
#define ARG_NETMASK (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE | A_NETMASK)
#define ARG_BROADCAST (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER | A_BROADCAST)
#define ARG_BROADCAST (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER)
#define ARG_HW (A_ARG_REQ | A_CAST_HOST_COPY_IN_ETHER)
#define ARG_POINTOPOINT (A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER)
#define ARG_KEEPALIVE (A_ARG_REQ | A_CAST_CHAR_PTR)
#define ARG_OUTFILL (A_ARG_REQ | A_CAST_CHAR_PTR)
#define ARG_HOSTNAME (A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER | A_COLON_CHK | A_HOSTNAME)
#define ARG_HOSTNAME (A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER | A_COLON_CHK)
/*
@@ -162,7 +160,7 @@ struct arg1opt {
struct options {
const char *name;
const unsigned char flags;
const unsigned int arg_flags;
const unsigned char arg_flags;
const unsigned short selector;
};
@@ -248,7 +246,6 @@ int ifconfig_main(int argc, char **argv)
{
struct ifreq ifr;
struct sockaddr_in sai;
struct sockaddr_in sai_hostname, sai_netmask;
#ifdef BB_FEATURE_IFCONFIG_HW
struct sockaddr sa;
#endif
@@ -259,8 +256,8 @@ int ifconfig_main(int argc, char **argv)
int selector;
char *p;
char host[128];
unsigned int mask;
unsigned int did_flags;
unsigned char mask;
unsigned char did_flags;
goterr = 0;
did_flags = 0;
@@ -334,7 +331,7 @@ int ifconfig_main(int argc, char **argv)
}
} else { /* got an arg so process it */
HOSTNAME:
did_flags |= (mask & (A_NETMASK|A_HOSTNAME));
did_flags |= (mask & A_NETMASK);
if (mask & A_CAST_HOST_COPY) {
#ifdef BB_FEATURE_IFCONFIG_HW
if (mask & A_CAST_RESOLVE) {
@@ -345,20 +342,11 @@ int ifconfig_main(int argc, char **argv)
if (!strcmp(host, "default")) {
/* Default is special, meaning 0.0.0.0. */
sai.sin_addr.s_addr = INADDR_ANY;
} else if ((!strcmp(host, "+")) && (mask & A_BROADCAST) &&
(did_flags & (A_NETMASK|A_HOSTNAME))) {
/* + is special, meaning broadcast is derived. */
sai.sin_addr.s_addr = (~sai_netmask.sin_addr.s_addr) |
(sai_hostname.sin_addr.s_addr & sai_netmask.sin_addr.s_addr);
} else if (inet_aton(host, &sai.sin_addr) == 0) {
/* It's not a dotted quad. */
++goterr;
continue;
}
if(mask & A_HOSTNAME)
sai_hostname = sai;
if(mask & A_NETMASK)
sai_netmask = sai;
p = (char *) &sai;
#ifdef BB_FEATURE_IFCONFIG_HW
} else { /* A_CAST_HOST_COPY_IN_ETHER */
+46 -3
View File
@@ -46,12 +46,21 @@
#ifdef BB_TEST
APPLET_NOUSAGE("[", test_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_ADDGROUP
APPLET(addgroup, addgroup_main, _BB_DIR_BIN)
#endif
#ifdef BB_ADDUSER
APPLET(adduser, adduser_main, _BB_DIR_BIN)
#endif
#ifdef BB_ADJTIMEX
APPLET(adjtimex, adjtimex_main, _BB_DIR_SBIN)
#endif
#ifdef BB_AR
APPLET(ar, ar_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_ASH
APPLET_NOUSAGE("ash", ash_main, _BB_DIR_BIN)
#endif
#ifdef BB_BASENAME
APPLET(basename, basename_main, _BB_DIR_USR_BIN)
#endif
@@ -101,6 +110,12 @@
#ifdef BB_DEALLOCVT
APPLET(deallocvt, deallocvt_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_DELGROUP
APPLET(delgroup, delgroup_main, _BB_DIR_BIN)
#endif
#ifdef BB_DELUSER
APPLET(deluser, deluser_main, _BB_DIR_BIN)
#endif
#ifdef BB_DF
APPLET(df, df_main, _BB_DIR_BIN)
#endif
@@ -164,6 +179,9 @@
#ifdef BB_GETOPT
APPLET(getopt, getopt_main, _BB_DIR_BIN)
#endif
#ifdef BB_GETTY
APPLET(getty, getty_main, _BB_DIR_SBIN)
#endif
#ifdef BB_GREP
APPLET(grep, grep_main, _BB_DIR_BIN)
#endif
@@ -185,6 +203,9 @@
#ifdef BB_HOSTNAME
APPLET(hostname, hostname_main, _BB_DIR_BIN)
#endif
#ifdef BB_HUSH
APPLET_NOUSAGE("hush", hush_main, _BB_DIR_BIN)
#endif
#ifdef BB_ID
APPLET(id, id_main, _BB_DIR_USR_BIN)
#endif
@@ -206,6 +227,9 @@
#ifdef BB_KLOGD
APPLET(klogd, klogd_main, _BB_DIR_SBIN)
#endif
#ifdef BB_LASH
APPLET(lash, lash_main, _BB_DIR_BIN)
#endif
#ifdef BB_LENGTH
APPLET(length, length_main, _BB_DIR_USR_BIN)
#endif
@@ -263,12 +287,18 @@
#ifdef BB_MKTEMP
APPLET(mktemp, mktemp_main, _BB_DIR_BIN)
#endif
#ifdef BB_MODPROBE
APPLET(modprobe, modprobe_main, _BB_DIR_SBIN)
#endif
#ifdef BB_MORE
APPLET(more, more_main, _BB_DIR_BIN)
#endif
#ifdef BB_MOUNT
APPLET(mount, mount_main, _BB_DIR_BIN)
#endif
#ifdef BB_MSH
APPLET_NOUSAGE("msh", msh_main, _BB_DIR_BIN)
#endif
#ifdef BB_MT
APPLET(mt, mt_main, _BB_DIR_BIN)
#endif
@@ -281,6 +311,9 @@
#ifdef BB_NSLOOKUP
APPLET(nslookup, nslookup_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_PIDOF
APPLET(pidof, pidof_main, _BB_DIR_BIN)
#endif
#ifdef BB_PING
APPLET(ping, ping_main, _BB_DIR_BIN)
#endif
@@ -338,8 +371,14 @@
#ifdef BB_SETKEYCODES
APPLET(setkeycodes, setkeycodes_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_SH
APPLET(sh, shell_main, _BB_DIR_BIN)
#if defined(BB_FEATURE_SH_IS_ASH) && defined(BB_ASH)
APPLET_NOUSAGE("sh", ash_main, _BB_DIR_BIN)
#elif defined(BB_FEATURE_SH_IS_HUSH) && defined(BB_HUSH)
APPLET_NOUSAGE("sh", hush_main, _BB_DIR_BIN)
#elif defined(BB_FEATURE_SH_IS_LASH) && defined(BB_LASH)
APPLET_NOUSAGE("sh", lash_main, _BB_DIR_BIN)
#elif defined(BB_FEATURE_SH_IS_MSH) && defined(BB_MSH)
APPLET_NOUSAGE("sh", msh_main, _BB_DIR_BIN)
#endif
#ifdef BB_SLEEP
APPLET(sleep, sleep_main, _BB_DIR_BIN)
@@ -386,6 +425,9 @@
#ifdef BB_TR
APPLET(tr, tr_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_TRACEROUTE
APPLET(traceroute, traceroute_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_TRUE_FALSE
APPLET(true, true_main, _BB_DIR_BIN)
#endif
@@ -402,7 +444,7 @@
APPLET(uniq, uniq_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_UNIX2DOS
APPLET(unix2dos, unix2dos_main, _BB_DIR_USR_BIN)
APPLET(unix2dos, dos2unix_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_UPDATE
APPLET(update, update_main, _BB_DIR_SBIN)
@@ -452,3 +494,4 @@
};
#endif
+3
View File
@@ -69,13 +69,16 @@ extern const struct BB_applet applets[];
#ifdef BB_FEATURE_BUFFERS_GO_ON_STACK
#define RESERVE_BB_BUFFER(buffer,len) char buffer[len]
#define RESERVE_BB_UBUFFER(buffer,len) unsigned char buffer[len]
#define RELEASE_BB_BUFFER(buffer) ((void)0)
#else
#ifdef BB_FEATURE_BUFFERS_GO_IN_BSS
#define RESERVE_BB_BUFFER(buffer,len) static char buffer[len]
#define RESERVE_BB_UBUFFER(buffer,len) static unsigned char buffer[len]
#define RELEASE_BB_BUFFER(buffer) ((void)0)
#else
#define RESERVE_BB_BUFFER(buffer,len) char *buffer=xmalloc(len)
#define RESERVE_BB_UBUFFER(buffer,len) unsigned char *buffer=xmalloc(len)
#define RELEASE_BB_BUFFER(buffer) free (buffer)
#endif
#endif
+44 -5
View File
@@ -41,11 +41,13 @@
#include "../busybox.h"
#endif
#if __GNU_LIBRARY__ < 5
#if (__GNU_LIBRARY__ < 5) && (!defined __dietlibc__)
/* libc5 doesn't define socklen_t */
typedef unsigned int socklen_t;
/* libc5 doesn't implement BSD 4.4 daemon() */
extern int daemon (int nochdir, int noclose);
/* libc5 doesn't implement strtok_r */
char *strtok_r(char *s, const char *delim, char **ptrptr);
#endif
/* Some useful definitions */
@@ -212,6 +214,8 @@ char *xreadlink(const char *path);
char *concat_path_file(const char *path, const char *filename);
char *last_char_is(const char *s, int c);
extern long arith (const char *startbuf, int *errcode);
typedef struct file_headers_s {
char *name;
char *link_name;
@@ -237,13 +241,15 @@ enum extract_functions_e {
extract_control_tar_gz = 128,
extract_unzip_only = 256,
extract_unconditional = 512,
extract_create_leading_dirs = 1024
extract_create_leading_dirs = 1024,
extract_quiet = 2048,
extract_exclude_list = 4096
};
char *unarchive(FILE *src_stream, file_header_t *(*get_header)(FILE *),
char *unarchive(FILE *src_stream, FILE *out_stream, file_header_t *(*get_header)(FILE *),
const int extract_function, const char *prefix, char **extract_names);
char *deb_extract(const char *package_filename, FILE *out_stream, const int extract_function,
const char *prefix, const char *filename);
char *read_package_field(const char *package_buffer);
int read_package_field(const char *package_buffer, char **field_name, char **field_value);
char *fgets_str(FILE *file, const char *terminating_string);
extern int unzip(FILE *l_in_file, FILE *l_out_file);
@@ -251,10 +257,14 @@ extern void gz_close(int gunzip_pid);
extern FILE *gz_open(FILE *compressed_file, int *pid);
extern struct hostent *xgethostbyname(const char *name);
extern int create_icmp_socket(void);
char *dirname (const char *path);
int make_directory (char *path, mode_t mode, int flags);
int make_directory (char *path, long mode, int flags);
const char *u_signal_names(const char *str_sig, int *signo, int startnum);
char *simplify_path(const char *path);
#define CT_AUTO 0
#define CT_UNIX2DOS 1
@@ -283,5 +293,34 @@ extern const char * const write_error;
extern const char * const too_few_args;
extern const char * const name_longer_than_foo;
extern const char * const unknown;
extern const char * const can_not_create_raw_socket;
#ifdef BB_FEATURE_DEVFS
# define CURRENT_VC "/dev/vc/0"
# define VC_1 "/dev/vc/1"
# define VC_2 "/dev/vc/2"
# define VC_3 "/dev/vc/3"
# define VC_4 "/dev/vc/4"
# define VC_5 "/dev/vc/5"
# define SC_0 "/dev/tts/0"
# define SC_1 "/dev/tts/1"
# define VC_FORMAT "/dev/vc/%d"
# define SC_FORMAT "/dev/tts/%d"
#else
# define CURRENT_VC "/dev/tty0"
# define VC_1 "/dev/tty1"
# define VC_2 "/dev/tty2"
# define VC_3 "/dev/tty3"
# define VC_4 "/dev/tty4"
# define VC_5 "/dev/tty5"
# define SC_0 "/dev/ttyS0"
# define SC_1 "/dev/ttyS1"
# define VC_FORMAT "/dev/tty%d"
# define SC_FORMAT "/dev/ttyS%d"
#endif
/* The following devices are the same on devfs and non-devfs systems. */
#define CURRENT_TTY "/dev/tty"
#define CONSOLE_DEV "/dev/console"
#endif /* __LIBBB_H__ */
+88 -5
View File
@@ -1,3 +1,19 @@
#define addgroup_trivial_usage \
"[OPTIONS] <group_name>"
#define addgroup_full_usage \
"Adds a group to the system" \
"Options:\n" \
"\t-g\t\tspecify gid\n"
#define adduser_trivial_usage \
"[OPTIONS] <user_name>"
#define adduser_full_usage \
"Adds a user to the system" \
"Options:\n" \
"\t-h\t\thome directory\n" \
"\t-s\t\tshell\n" \
"\t-g\t\tGECOS string\n"
#define adjtimex_trivial_usage \
"[-q] [-o offset] [-f frequency] [-p timeconstant] [-t tick]"
#define adjtimex_full_usage \
@@ -215,6 +231,15 @@
#define deallocvt_full_usage \
"Deallocate unused virtual terminal /dev/ttyN"
#define delgroup_trivial_usage \
"GROUP"
#define delgroup_full_usage \
"Deletes group GROUP from the system"
#define deluser_trivial_usage \
"USER"
#define deluser_full_usage \
"Deletes user USER from the system"
#ifdef BB_FEATURE_HUMAN_READABLE
#define USAGE_HUMAN_READABLE(a) a
@@ -272,9 +297,14 @@
"\t-d\toutput will be in DOS format"
#define dpkg_trivial_usage \
"[-i|-r|--unpack|--configure] my.deb"
"-i package_file\n"
"[-CPru] package_name"
#define dpkg_full_usage \
"WORK IN PROGRESS, only useful for debian-installer"
"\t-i\tInstall the package\n" \
"\t-C\tConfigure an unpackaged package\n" \
"\t-P\tPurge all files of a package\n" \
"\t-r\tRemove all but the configuration files for a package\n" \
"\t-u\tUnpack a package, but dont configure it\n"
#define dpkg_deb_trivial_usage \
"[-cefItxX] FILE [argument]"
@@ -528,6 +558,22 @@
" esac\n" \
"done\n"
#define getty_trivial_usage \
"getty [OPTIONS]... baud_rate,... line [termtype]"
#define getty_full_usage \
"\nOpens a tty, prompts for a login name, then invokes /bin/login\n\n" \
"Options:\n" \
"\t-h\t\tEnable hardware (RTS/CTS) flow control.\n" \
"\t-i\t\tDo not display /etc/issue before running login.\n" \
"\t-L\t\tLocal line, so do not do carrier detect.\n" \
"\t-m\t\tGet baud rate from modem's CONNECT status message.\n" \
"\t-w\t\tWait for a CR or LF before sending /etc/issue.\n" \
"\t-l login_app\tInvoke login_app instead of /bin/login.\n" \
"\t-t timeout\tTerminate after timeout if no username is read.\n" \
"\t-I initstring\tSets the init string to send before anything else.\n" \
"\t-H login_host\tLog login_host into the utmp file as the hostname."
#define grep_trivial_usage \
"[-ihHnqvs] PATTERN [FILEs...]"
#define grep_full_usage \
@@ -1079,6 +1125,13 @@
"$ ls -la /tmp/temp.mWiLjM\n" \
"-rw------- 1 andersen andersen 0 Apr 25 17:10 /tmp/temp.mWiLjM\n"
#define modprobe_trivial_usage \
"[FILE ...]"
#define modprobe_full_usage \
"Used for hight level module loading and unloading."
#define modprobe_example_usage \
"$ modprobe cdrom\n"
#define more_trivial_usage \
"[FILE ...]"
#define more_full_usage \
@@ -1178,6 +1231,14 @@
"Name: debian\n" \
"Address: 127.0.0.1\n"
#define pidof_trivial_usage \
"process-name [process-name ...]"
#define pidof_full_usage \
"Lists the PIDs of all processes with names that match the names on the command line"
#define pidof_example_usage \
"$ pidof init\n" \
"1\n"
#ifndef BB_FEATURE_FANCY_PING
#define ping_trivial_usage "host"
#define ping_full_usage "Send ICMP ECHO_REQUEST packets to network hosts"
@@ -1345,12 +1406,12 @@
#define setkeycodes_example_usage \
"$ setkeycodes e030 127\n"
#define sh_trivial_usage \
#define lash_trivial_usage \
"[FILE]...\n" \
"or: sh -c command [args]..."
#define sh_full_usage \
#define lash_full_usage \
"lash: The BusyBox LAme SHell (command interpreter)"
#define sh_notes_usage \
#define lash_notes_usage \
"This command does not yet have proper documentation.\n" \
"\n" \
"Use lash just as you would use any other shell. It properly handles pipes,\n" \
@@ -1593,6 +1654,28 @@
"$ echo "gdkkn vnqkc" | tr [a-y] [b-z]\n" \
"hello world\n"
#define traceroute_trivial_usage \
"[-dnrv] [-m max_ttl] [-p port#] [-q nqueries]\n\
[-s src_addr] [-t tos] [-w wait] host [data size]"
#define traceroute_full_usage \
"trace the route ip packets follow going to \"host\"\n" \
"Options:\n" \
"\t-d\tset SO_DEBUG options to socket\n" \
"\t-n\tPrint hop addresses numerically rather than symbolically\n" \
"\t-r\tBypass the normal routing tables and send directly to a host\n" \
"\t-v\tVerbose output\n" \
"\t-m max_ttl\tSet the max time-to-live (max number of hops)\n" \
"\t-p port#\tSet the base UDP port number used in probes\n" \
"\t\t(default is 33434)\n" \
"\t-q nqueries\tSet the number of probes per ``ttl'' to nqueries\n" \
"\t\t(default is 3)\n" \
"\t-s src_addr\tUse the following IP address as the source address\n" \
"\t-t tos\tSet the type-of-service in probe packets to the following value\n" \
"\t\t(default 0)\n" \
"\t-w wait\tSet the time (in seconds) to wait for a response to a probe\n" \
"\t\t(default 3 sec.)."
#define true_trivial_usage \
""
#define true_full_usage \
+10 -18
View File
@@ -84,7 +84,7 @@ static const int RB_DISABLE_CAD = 0;
static const int RB_AUTOBOOT = 0x01234567;
#endif
#if __GNU_LIBRARY__ > 5
#if (__GNU_LIBRARY__ > 5) || defined(__dietlibc__)
#include <sys/reboot.h>
#define init_reboot(magic) reboot(magic)
#else
@@ -117,13 +117,6 @@ static const int RB_AUTOBOOT = 0x01234567;
#endif
#define VT_PRIMARY "/dev/tty1" /* Primary virtual console */
#define VT_SECONDARY "/dev/tty2" /* Virtual console */
#define VT_THIRD "/dev/tty3" /* Virtual console */
#define VT_FOURTH "/dev/tty4" /* Virtual console */
#define VT_LOG "/dev/tty5" /* Virtual console */
#define SERIAL_CON0 "/dev/ttyS0" /* Primary serial console */
#define SERIAL_CON1 "/dev/ttyS1" /* Serial console */
#define SHELL "/bin/sh" /* Default shell */
#define LOGIN_SHELL "-" SHELL /* Default login shell */
#define INITTAB "/etc/inittab" /* inittab file location */
@@ -176,10 +169,10 @@ struct initActionTag {
static initAction *initActionList = NULL;
static char *secondConsole = VT_SECONDARY;
static char *thirdConsole = VT_THIRD;
static char *fourthConsole = VT_FOURTH;
static char *log = VT_LOG;
static char *secondConsole = VC_2;
static char *thirdConsole = VC_3;
static char *fourthConsole = VC_4;
static char *log = VC_5;
static int kernelVersion = 0;
static char termType[32] = "TERM=linux";
static char console[32] = _PATH_CONSOLE;
@@ -341,20 +334,19 @@ static void console_init()
else if ((s = getenv("console")) != NULL) {
/* remap tty[ab] to /dev/ttyS[01] */
if (strcmp(s, "ttya") == 0)
safe_strncpy(console, SERIAL_CON0, sizeof(console));
safe_strncpy(console, SC_0, sizeof(console));
else if (strcmp(s, "ttyb") == 0)
safe_strncpy(console, SERIAL_CON1, sizeof(console));
safe_strncpy(console, SC_1, sizeof(console));
}
#endif
else {
/* 2.2 kernels: identify the real console backend and try to use it */
if (ioctl(0, TIOCGSERIAL, &sr) == 0) {
/* this is a serial console */
snprintf(console, sizeof(console) - 1, "/dev/ttyS%d", sr.line);
snprintf(console, sizeof(console) - 1, SC_FORMAT, sr.line);
} else if (ioctl(0, VT_GETSTATE, &vt) == 0) {
/* this is linux virtual tty */
snprintf(console, sizeof(console) - 1, "/dev/tty%d",
vt.v_active);
snprintf(console, sizeof(console) - 1, VC_FORMAT, vt.v_active);
} else {
safe_strncpy(console, _PATH_CONSOLE, sizeof(console));
tried_devcons++;
@@ -371,7 +363,7 @@ static void console_init()
/* Can't open selected console -- try vt1 */
if (!tried_vtprimary) {
tried_vtprimary++;
safe_strncpy(console, VT_PRIMARY, sizeof(console));
safe_strncpy(console, VC_1, sizeof(console));
continue;
}
break;
+10 -18
View File
@@ -84,7 +84,7 @@ static const int RB_DISABLE_CAD = 0;
static const int RB_AUTOBOOT = 0x01234567;
#endif
#if __GNU_LIBRARY__ > 5
#if (__GNU_LIBRARY__ > 5) || defined(__dietlibc__)
#include <sys/reboot.h>
#define init_reboot(magic) reboot(magic)
#else
@@ -117,13 +117,6 @@ static const int RB_AUTOBOOT = 0x01234567;
#endif
#define VT_PRIMARY "/dev/tty1" /* Primary virtual console */
#define VT_SECONDARY "/dev/tty2" /* Virtual console */
#define VT_THIRD "/dev/tty3" /* Virtual console */
#define VT_FOURTH "/dev/tty4" /* Virtual console */
#define VT_LOG "/dev/tty5" /* Virtual console */
#define SERIAL_CON0 "/dev/ttyS0" /* Primary serial console */
#define SERIAL_CON1 "/dev/ttyS1" /* Serial console */
#define SHELL "/bin/sh" /* Default shell */
#define LOGIN_SHELL "-" SHELL /* Default login shell */
#define INITTAB "/etc/inittab" /* inittab file location */
@@ -176,10 +169,10 @@ struct initActionTag {
static initAction *initActionList = NULL;
static char *secondConsole = VT_SECONDARY;
static char *thirdConsole = VT_THIRD;
static char *fourthConsole = VT_FOURTH;
static char *log = VT_LOG;
static char *secondConsole = VC_2;
static char *thirdConsole = VC_3;
static char *fourthConsole = VC_4;
static char *log = VC_5;
static int kernelVersion = 0;
static char termType[32] = "TERM=linux";
static char console[32] = _PATH_CONSOLE;
@@ -341,20 +334,19 @@ static void console_init()
else if ((s = getenv("console")) != NULL) {
/* remap tty[ab] to /dev/ttyS[01] */
if (strcmp(s, "ttya") == 0)
safe_strncpy(console, SERIAL_CON0, sizeof(console));
safe_strncpy(console, SC_0, sizeof(console));
else if (strcmp(s, "ttyb") == 0)
safe_strncpy(console, SERIAL_CON1, sizeof(console));
safe_strncpy(console, SC_1, sizeof(console));
}
#endif
else {
/* 2.2 kernels: identify the real console backend and try to use it */
if (ioctl(0, TIOCGSERIAL, &sr) == 0) {
/* this is a serial console */
snprintf(console, sizeof(console) - 1, "/dev/ttyS%d", sr.line);
snprintf(console, sizeof(console) - 1, SC_FORMAT, sr.line);
} else if (ioctl(0, VT_GETSTATE, &vt) == 0) {
/* this is linux virtual tty */
snprintf(console, sizeof(console) - 1, "/dev/tty%d",
vt.v_active);
snprintf(console, sizeof(console) - 1, VC_FORMAT, vt.v_active);
} else {
safe_strncpy(console, _PATH_CONSOLE, sizeof(console));
tried_devcons++;
@@ -371,7 +363,7 @@ static void console_init()
/* Can't open selected console -- try vt1 */
if (!tried_vtprimary) {
tried_vtprimary++;
safe_strncpy(console, VT_PRIMARY, sizeof(console));
safe_strncpy(console, VC_1, sizeof(console));
continue;
}
break;
+78 -106
View File
@@ -1,7 +1,10 @@
/* vi: set sw=4 ts=4: */
/*
* Mini insmod implementation for busybox
* This version of insmod now supports x86, ARM, SH3/4, powerpc, and MIPS.
*
* This version of insmod supports x86, ARM, SH3/4, powerpc, m68k,
* and MIPS.
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>
@@ -64,6 +67,7 @@
#include "busybox.h"
#ifdef BB_FEATURE_NEW_MODULE_INTERFACE
# undef BB_FEATURE_OLD_MODULE_INTERFACE
# define new_sys_init_module init_module
#else
# define old_sys_init_module init_module
@@ -130,7 +134,7 @@
#ifndef MODUTILS_MODULE_H
static const int MODUTILS_MODULE_H = 1;
#ident "$Id: insmod.c,v 1.67 2001/06/28 21:36:06 andersen Exp $"
#ident "$Id: insmod.c,v 1.73 2001/08/22 05:41:57 andersen Exp $"
/* This file contains the structures used by the 2.0 and 2.1 kernels.
We do not use the kernel headers directly because we do not wish
@@ -347,7 +351,7 @@ int delete_module(const char *);
#ifndef MODUTILS_OBJ_H
static const int MODUTILS_OBJ_H = 1;
#ident "$Id: insmod.c,v 1.67 2001/06/28 21:36:06 andersen Exp $"
#ident "$Id: insmod.c,v 1.73 2001/08/22 05:41:57 andersen Exp $"
/* The relocatable object is manipulated using elfin types. */
@@ -537,78 +541,75 @@ struct obj_symbol_patch
/* Generic object manipulation routines. */
unsigned long obj_elf_hash(const char *);
static unsigned long obj_elf_hash(const char *);
unsigned long obj_elf_hash_n(const char *, unsigned long len);
static unsigned long obj_elf_hash_n(const char *, unsigned long len);
struct obj_symbol *obj_add_symbol (struct obj_file *f, const char *name,
unsigned long symidx, int info, int secidx,
ElfW(Addr) value, unsigned long size);
struct obj_symbol *obj_find_symbol (struct obj_file *f,
static struct obj_symbol *obj_find_symbol (struct obj_file *f,
const char *name);
ElfW(Addr) obj_symbol_final_value(struct obj_file *f,
static ElfW(Addr) obj_symbol_final_value(struct obj_file *f,
struct obj_symbol *sym);
void obj_set_symbol_compare(struct obj_file *f,
#ifdef BB_FEATURE_INSMOD_VERSION_CHECKING
static void obj_set_symbol_compare(struct obj_file *f,
int (*cmp)(const char *, const char *),
unsigned long (*hash)(const char *));
#endif
struct obj_section *obj_find_section (struct obj_file *f,
static struct obj_section *obj_find_section (struct obj_file *f,
const char *name);
void obj_insert_section_load_order (struct obj_file *f,
static void obj_insert_section_load_order (struct obj_file *f,
struct obj_section *sec);
struct obj_section *obj_create_alloced_section (struct obj_file *f,
static struct obj_section *obj_create_alloced_section (struct obj_file *f,
const char *name,
unsigned long align,
unsigned long size);
struct obj_section *obj_create_alloced_section_first (struct obj_file *f,
static struct obj_section *obj_create_alloced_section_first (struct obj_file *f,
const char *name,
unsigned long align,
unsigned long size);
void *obj_extend_section (struct obj_section *sec, unsigned long more);
static void *obj_extend_section (struct obj_section *sec, unsigned long more);
int obj_string_patch(struct obj_file *f, int secidx, ElfW(Addr) offset,
static int obj_string_patch(struct obj_file *f, int secidx, ElfW(Addr) offset,
const char *string);
int obj_symbol_patch(struct obj_file *f, int secidx, ElfW(Addr) offset,
static int obj_symbol_patch(struct obj_file *f, int secidx, ElfW(Addr) offset,
struct obj_symbol *sym);
int obj_check_undefineds(struct obj_file *f);
static int obj_check_undefineds(struct obj_file *f);
void obj_allocate_commons(struct obj_file *f);
static void obj_allocate_commons(struct obj_file *f);
unsigned long obj_load_size (struct obj_file *f);
static unsigned long obj_load_size (struct obj_file *f);
int obj_relocate (struct obj_file *f, ElfW(Addr) base);
static int obj_relocate (struct obj_file *f, ElfW(Addr) base);
struct obj_file *obj_load(FILE *f, int loadprogbits);
static struct obj_file *obj_load(FILE *f, int loadprogbits);
int obj_create_image (struct obj_file *f, char *image);
static int obj_create_image (struct obj_file *f, char *image);
/* Architecture specific manipulation routines. */
struct obj_file *arch_new_file (void);
static struct obj_file *arch_new_file (void);
struct obj_section *arch_new_section (void);
static struct obj_section *arch_new_section (void);
struct obj_symbol *arch_new_symbol (void);
static struct obj_symbol *arch_new_symbol (void);
enum obj_reloc arch_apply_relocation (struct obj_file *f,
static enum obj_reloc arch_apply_relocation (struct obj_file *f,
struct obj_section *targsec,
struct obj_section *symsec,
struct obj_symbol *sym,
ElfW(RelM) *rel, ElfW(Addr) value);
int arch_create_got (struct obj_file *f);
static int arch_create_got (struct obj_file *f);
struct new_module;
int arch_init_module (struct obj_file *f, struct new_module *);
static int arch_init_module (struct obj_file *f, struct new_module *);
#endif /* obj.h */
//----------------------------------------------------------------------------
@@ -624,10 +625,10 @@ static const int STRVERSIONLEN = 32;
/*======================================================================*/
int flag_force_load = 0;
int flag_autoclean = 0;
int flag_verbose = 0;
int flag_export = 1;
static int flag_force_load = 0;
static int flag_autoclean = 0;
static int flag_verbose = 0;
static int flag_export = 1;
/*======================================================================*/
@@ -700,12 +701,12 @@ struct external_module {
struct new_module_symbol *syms;
};
struct new_module_symbol *ksyms;
size_t nksyms;
static struct new_module_symbol *ksyms;
static size_t nksyms;
struct external_module *ext_modules;
int n_ext_modules;
int n_ext_modules_used;
static struct external_module *ext_modules;
static int n_ext_modules;
static int n_ext_modules_used;
extern int delete_module(const char *);
static char m_filename[FILENAME_MAX + 1];
@@ -740,7 +741,7 @@ static int check_module_name_match(const char *filename, struct stat *statbuf,
/*======================================================================*/
struct obj_file *arch_new_file(void)
static struct obj_file *arch_new_file(void)
{
struct arch_file *f;
f = xmalloc(sizeof(*f));
@@ -758,12 +759,12 @@ struct obj_file *arch_new_file(void)
return &f->root;
}
struct obj_section *arch_new_section(void)
static struct obj_section *arch_new_section(void)
{
return xmalloc(sizeof(struct obj_section));
}
struct obj_symbol *arch_new_symbol(void)
static struct obj_symbol *arch_new_symbol(void)
{
struct arch_symbol *sym;
sym = xmalloc(sizeof(*sym));
@@ -778,7 +779,7 @@ struct obj_symbol *arch_new_symbol(void)
return &sym->root;
}
enum obj_reloc
static enum obj_reloc
arch_apply_relocation(struct obj_file *f,
struct obj_section *targsec,
struct obj_section *symsec,
@@ -1140,7 +1141,7 @@ arch_apply_relocation(struct obj_file *f,
return ret;
}
int arch_create_got(struct obj_file *f)
static int arch_create_got(struct obj_file *f)
{
#if defined(BB_USE_GOT_ENTRIES) || defined(BB_USE_PLT_ENTRIES)
struct arch_file *ifile = (struct arch_file *) f;
@@ -1271,7 +1272,7 @@ int arch_create_got(struct obj_file *f)
return 1;
}
int arch_init_module(struct obj_file *f, struct new_module *mod)
static int arch_init_module(struct obj_file *f, struct new_module *mod)
{
return 1;
}
@@ -1280,7 +1281,7 @@ int arch_init_module(struct obj_file *f, struct new_module *mod)
/*======================================================================*/
/* Standard ELF hash function. */
inline unsigned long obj_elf_hash_n(const char *name, unsigned long n)
static inline unsigned long obj_elf_hash_n(const char *name, unsigned long n)
{
unsigned long h = 0;
unsigned long g;
@@ -1298,38 +1299,12 @@ inline unsigned long obj_elf_hash_n(const char *name, unsigned long n)
return h;
}
unsigned long obj_elf_hash(const char *name)
static unsigned long obj_elf_hash(const char *name)
{
return obj_elf_hash_n(name, strlen(name));
}
#ifdef BB_FEATURE_INSMOD_VERSION_CHECKING
/* Get the kernel version in the canonical integer form. */
static int get_kernel_version(char str[STRVERSIONLEN])
{
struct utsname uts_info;
char *p, *q;
int a, b, c;
if (uname(&uts_info) < 0)
return -1;
strncpy(str, uts_info.release, STRVERSIONLEN);
p = uts_info.release;
a = strtoul(p, &p, 10);
if (*p != '.')
return -1;
b = strtoul(p + 1, &p, 10);
if (*p != '.')
return -1;
c = strtoul(p + 1, &q, 10);
if (p + 1 == q)
return -1;
return a << 16 | b << 8 | c;
}
/* String comparison for non-co-versioned kernel and module. */
static int ncv_strcmp(const char *a, const char *b)
@@ -1355,7 +1330,7 @@ static unsigned long ncv_symbol_hash(const char *str)
return obj_elf_hash_n(str, len);
}
void
static void
obj_set_symbol_compare(struct obj_file *f,
int (*cmp) (const char *, const char *),
unsigned long (*hash) (const char *))
@@ -1383,8 +1358,8 @@ obj_set_symbol_compare(struct obj_file *f,
#endif /* BB_FEATURE_INSMOD_VERSION_CHECKING */
struct obj_symbol *obj_add_symbol(struct obj_file *f, const char *name,
static struct obj_symbol *
obj_add_symbol(struct obj_file *f, const char *name,
unsigned long symidx, int info,
int secidx, ElfW(Addr) value,
unsigned long size)
@@ -1478,7 +1453,8 @@ struct obj_symbol *obj_add_symbol(struct obj_file *f, const char *name,
return sym;
}
struct obj_symbol *obj_find_symbol(struct obj_file *f, const char *name)
static struct obj_symbol *
obj_find_symbol(struct obj_file *f, const char *name)
{
struct obj_symbol *sym;
unsigned long hash = f->symbol_hash(name) % HASH_BUCKETS;
@@ -1490,7 +1466,7 @@ struct obj_symbol *obj_find_symbol(struct obj_file *f, const char *name)
return NULL;
}
ElfW(Addr)
static ElfW(Addr)
obj_symbol_final_value(struct obj_file * f, struct obj_symbol * sym)
{
if (sym) {
@@ -1504,7 +1480,7 @@ ElfW(Addr)
}
}
struct obj_section *obj_find_section(struct obj_file *f, const char *name)
static struct obj_section *obj_find_section(struct obj_file *f, const char *name)
{
int i, n = f->header.e_shnum;
@@ -1537,7 +1513,7 @@ static int obj_load_order_prio(struct obj_section *a)
return ac;
}
void
static void
obj_insert_section_load_order(struct obj_file *f, struct obj_section *sec)
{
struct obj_section **p;
@@ -1549,7 +1525,7 @@ obj_insert_section_load_order(struct obj_file *f, struct obj_section *sec)
*p = sec;
}
struct obj_section *obj_create_alloced_section(struct obj_file *f,
static struct obj_section *obj_create_alloced_section(struct obj_file *f,
const char *name,
unsigned long align,
unsigned long size)
@@ -1575,7 +1551,7 @@ struct obj_section *obj_create_alloced_section(struct obj_file *f,
return sec;
}
struct obj_section *obj_create_alloced_section_first(struct obj_file *f,
static struct obj_section *obj_create_alloced_section_first(struct obj_file *f,
const char *name,
unsigned long align,
unsigned long size)
@@ -1604,7 +1580,7 @@ struct obj_section *obj_create_alloced_section_first(struct obj_file *f,
return sec;
}
void *obj_extend_section(struct obj_section *sec, unsigned long more)
static void *obj_extend_section(struct obj_section *sec, unsigned long more)
{
unsigned long oldsize = sec->header.sh_size;
if (more) {
@@ -1614,7 +1590,6 @@ void *obj_extend_section(struct obj_section *sec, unsigned long more)
}
/* Conditionally add the symbols from the given symbol set to the
new module. */
@@ -2631,7 +2606,7 @@ new_init_module(const char *m_name, struct obj_file *f,
/*======================================================================*/
int
static int
obj_string_patch(struct obj_file *f, int secidx, ElfW(Addr) offset,
const char *string)
{
@@ -2660,7 +2635,7 @@ obj_string_patch(struct obj_file *f, int secidx, ElfW(Addr) offset,
return 1;
}
int
static int
obj_symbol_patch(struct obj_file *f, int secidx, ElfW(Addr) offset,
struct obj_symbol *sym)
{
@@ -2676,7 +2651,7 @@ obj_symbol_patch(struct obj_file *f, int secidx, ElfW(Addr) offset,
return 1;
}
int obj_check_undefineds(struct obj_file *f)
static int obj_check_undefineds(struct obj_file *f)
{
unsigned long i;
int ret = 1;
@@ -2698,7 +2673,7 @@ int obj_check_undefineds(struct obj_file *f)
return ret;
}
void obj_allocate_commons(struct obj_file *f)
static void obj_allocate_commons(struct obj_file *f)
{
struct common_entry {
struct common_entry *next;
@@ -2807,7 +2782,7 @@ void obj_allocate_commons(struct obj_file *f)
}
}
unsigned long obj_load_size(struct obj_file *f)
static unsigned long obj_load_size(struct obj_file *f)
{
unsigned long dot = 0;
struct obj_section *sec;
@@ -2828,7 +2803,7 @@ unsigned long obj_load_size(struct obj_file *f)
return dot;
}
int obj_relocate(struct obj_file *f, ElfW(Addr) base)
static int obj_relocate(struct obj_file *f, ElfW(Addr) base)
{
int i, n = f->header.e_shnum;
int ret = 1;
@@ -2958,7 +2933,7 @@ int obj_relocate(struct obj_file *f, ElfW(Addr) base)
return ret;
}
int obj_create_image(struct obj_file *f, char *image)
static int obj_create_image(struct obj_file *f, char *image)
{
struct obj_section *sec;
ElfW(Addr) base = f->baseaddr;
@@ -2980,7 +2955,7 @@ int obj_create_image(struct obj_file *f, char *image)
/*======================================================================*/
struct obj_file *obj_load(FILE * fp, int loadprogbits)
static struct obj_file *obj_load(FILE * fp, int loadprogbits)
{
struct obj_file *f;
ElfW(Shdr) * section_headers;
@@ -3186,9 +3161,8 @@ struct obj_file *obj_load(FILE * fp, int loadprogbits)
* kernel for the module
*/
int obj_load_progbits(FILE * fp, struct obj_file* f)
static int obj_load_progbits(FILE * fp, struct obj_file* f, char* imagebase)
{
char* imagebase = (char*) f->imagebase;
ElfW(Addr) base = f->baseaddr;
struct obj_section* sec;
@@ -3204,7 +3178,7 @@ int obj_load_progbits(FILE * fp, struct obj_file* f)
sec->contents = imagebase + (sec->header.sh_addr - base);
fseek(fp, sec->header.sh_offset, SEEK_SET);
if (fread(sec->contents, sec->header.sh_size, 1, fp) != 1) {
errorMsg("error reading ELF section data: %s\n", strerror(errno));
error_msg("error reading ELF section data: %s\n", strerror(errno));
return 0;
}
@@ -3249,8 +3223,7 @@ extern int insmod_main( int argc, char **argv)
int exit_status = EXIT_FAILURE;
int m_has_modinfo;
#ifdef BB_FEATURE_INSMOD_VERSION_CHECKING
int k_version;
char k_strversion[STRVERSIONLEN];
struct utsname uts_info;
char m_strversion[STRVERSIONLEN];
int m_version;
int m_crcs;
@@ -3365,7 +3338,8 @@ extern int insmod_main( int argc, char **argv)
#ifdef BB_FEATURE_INSMOD_VERSION_CHECKING
/* Version correspondence? */
k_version = get_kernel_version(k_strversion);
if (uname(&uts_info) < 0)
uts_info.release[0] = '\0';
if (m_has_modinfo) {
m_version = new_get_module_version(f, m_strversion);
} else {
@@ -3377,17 +3351,17 @@ extern int insmod_main( int argc, char **argv)
}
}
if (strncmp(k_strversion, m_strversion, STRVERSIONLEN) != 0) {
if (strncmp(uts_info.release, m_strversion, STRVERSIONLEN) != 0) {
if (flag_force_load) {
error_msg("Warning: kernel-module version mismatch\n"
"\t%s was compiled for kernel version %s\n"
"\twhile this kernel is version %s",
m_filename, m_strversion, k_strversion);
m_filename, m_strversion, uts_info.release);
} else {
error_msg("kernel-module version mismatch\n"
"\t%s was compiled for kernel version %s\n"
"\twhile this kernel is version %s.",
m_filename, m_strversion, k_strversion);
m_filename, m_strversion, uts_info.release);
goto out;
}
}
@@ -3484,9 +3458,7 @@ extern int insmod_main( int argc, char **argv)
* the PROGBITS section was not loaded by the obj_load
* now we can load them directly into the kernel memory
*/
// f->imagebase = (char*) m_addr;
f->imagebase = (ElfW(Addr)) m_addr;
if (!obj_load_progbits(fp, f)) {
if (!obj_load_progbits(fp, f, (char*)m_addr)) {
delete_module(m_name);
goto out;
}
+19 -124
View File
@@ -34,96 +34,11 @@
static const int KILL = 0;
static const int KILLALL = 1;
struct signal_name {
const char *name;
int number;
};
static const struct signal_name signames[] = {
/* POSIX signals */
{ "HUP", SIGHUP }, /* 1 */
{ "INT", SIGINT }, /* 2 */
{ "QUIT", SIGQUIT }, /* 3 */
{ "ILL", SIGILL }, /* 4 */
{ "ABRT", SIGABRT }, /* 6 */
{ "FPE", SIGFPE }, /* 8 */
{ "KILL", SIGKILL }, /* 9 */
{ "SEGV", SIGSEGV }, /* 11 */
{ "PIPE", SIGPIPE }, /* 13 */
{ "ALRM", SIGALRM }, /* 14 */
{ "TERM", SIGTERM }, /* 15 */
{ "USR1", SIGUSR1 }, /* 10 (arm,i386,m68k,ppc), 30 (alpha,sparc*), 16 (mips) */
{ "USR2", SIGUSR2 }, /* 12 (arm,i386,m68k,ppc), 31 (alpha,sparc*), 17 (mips) */
{ "CHLD", SIGCHLD }, /* 17 (arm,i386,m68k,ppc), 20 (alpha,sparc*), 18 (mips) */
{ "CONT", SIGCONT }, /* 18 (arm,i386,m68k,ppc), 19 (alpha,sparc*), 25 (mips) */
{ "STOP", SIGSTOP }, /* 19 (arm,i386,m68k,ppc), 17 (alpha,sparc*), 23 (mips) */
{ "TSTP", SIGTSTP }, /* 20 (arm,i386,m68k,ppc), 18 (alpha,sparc*), 24 (mips) */
{ "TTIN", SIGTTIN }, /* 21 (arm,i386,m68k,ppc,alpha,sparc*), 26 (mips) */
{ "TTOU", SIGTTOU }, /* 22 (arm,i386,m68k,ppc,alpha,sparc*), 27 (mips) */
/* Miscellaneous other signals */
#ifdef SIGTRAP
{ "TRAP", SIGTRAP }, /* 5 */
#endif
#ifdef SIGIOT
{ "IOT", SIGIOT }, /* 6, same as SIGABRT */
#endif
#ifdef SIGEMT
{ "EMT", SIGEMT }, /* 7 (mips,alpha,sparc*) */
#endif
#ifdef SIGBUS
{ "BUS", SIGBUS }, /* 7 (arm,i386,m68k,ppc), 10 (mips,alpha,sparc*) */
#endif
#ifdef SIGSYS
{ "SYS", SIGSYS }, /* 12 (mips,alpha,sparc*) */
#endif
#ifdef SIGSTKFLT
{ "STKFLT", SIGSTKFLT }, /* 16 (arm,i386,m68k,ppc) */
#endif
#ifdef SIGURG
{ "URG", SIGURG }, /* 23 (arm,i386,m68k,ppc), 16 (alpha,sparc*), 21 (mips) */
#endif
#ifdef SIGIO
{ "IO", SIGIO }, /* 29 (arm,i386,m68k,ppc), 23 (alpha,sparc*), 22 (mips) */
#endif
#ifdef SIGPOLL
{ "POLL", SIGPOLL }, /* same as SIGIO */
#endif
#ifdef SIGCLD
{ "CLD", SIGCLD }, /* same as SIGCHLD (mips) */
#endif
#ifdef SIGXCPU
{ "XCPU", SIGXCPU }, /* 24 (arm,i386,m68k,ppc,alpha,sparc*), 30 (mips) */
#endif
#ifdef SIGXFSZ
{ "XFSZ", SIGXFSZ }, /* 25 (arm,i386,m68k,ppc,alpha,sparc*), 31 (mips) */
#endif
#ifdef SIGVTALRM
{ "VTALRM", SIGVTALRM }, /* 26 (arm,i386,m68k,ppc,alpha,sparc*), 28 (mips) */
#endif
#ifdef SIGPROF
{ "PROF", SIGPROF }, /* 27 (arm,i386,m68k,ppc,alpha,sparc*), 29 (mips) */
#endif
#ifdef SIGPWR
{ "PWR", SIGPWR }, /* 30 (arm,i386,m68k,ppc), 29 (alpha,sparc*), 19 (mips) */
#endif
#ifdef SIGINFO
{ "INFO", SIGINFO }, /* 29 (alpha) */
#endif
#ifdef SIGLOST
{ "LOST", SIGLOST }, /* 29 (arm,i386,m68k,ppc,sparc*) */
#endif
#ifdef SIGWINCH
{ "WINCH", SIGWINCH }, /* 28 (arm,i386,m68k,ppc,alpha,sparc*), 20 (mips) */
#endif
#ifdef SIGUNUSED
{ "UNUSED", SIGUNUSED }, /* 31 (arm,i386,m68k,ppc) */
#endif
{0, 0}
};
extern int kill_main(int argc, char **argv)
{
int whichApp, sig = SIGTERM;
const char *name;
#ifdef BB_KILLALL
/* Figure out what we are trying to do here */
@@ -142,53 +57,37 @@ extern int kill_main(int argc, char **argv)
while (*++(*argv)) {
switch (**argv) {
case 'l':
{
if(argc>1) {
for(argv++; *argv; argv++) {
name = u_signal_names(*argv, &sig, -1);
if(name!=NULL)
printf("%s\n", name);
}
} else {
int col = 0;
const struct signal_name *s = signames;
while (s->name != 0) {
col +=
fprintf(stderr, "%2d) %-8s", s->number,
(s++)->name);
for(sig=1; sig < NSIG; sig++) {
name = u_signal_names(0, &sig, 1);
if(name==NULL) /* unnamed */
continue;
col += printf("%2d) %-16s", sig, name);
if (col > 60) {
fprintf(stderr, "\n");
printf("\n");
col = 0;
}
}
fprintf(stderr, "\n\n");
return EXIT_SUCCESS;
printf("\n");
}
break;
return EXIT_SUCCESS;
case '-':
show_usage();
default:
{
if (isdigit(**argv)) {
sig = atoi(*argv);
if (sig < 0 || sig >= NSIG)
goto end;
else {
argc--;
argv++;
goto do_it_now;
}
} else {
const struct signal_name *s = signames;
while (s->name != 0) {
if (strcasecmp(s->name, *argv) == 0) {
sig = s->number;
name = u_signal_names(*argv, &sig, 0);
if(name==NULL)
error_msg_and_die( "bad signal name: %s", *argv);
argc--;
argv++;
goto do_it_now;
}
s++;
}
if (s->name == 0)
goto end;
}
}
}
argc--;
argv++;
}
@@ -240,8 +139,4 @@ extern int kill_main(int argc, char **argv)
#endif
return EXIT_SUCCESS;
end:
error_msg_and_die( "bad signal name: %s", *argv);
}
+4 -8
View File
@@ -170,9 +170,7 @@ static struct built_in_command bltins_forking[] = {
};
/* Variables we export */
unsigned int shell_context; /* Used in cmdedit.c to reset the
context when someone hits ^C */
static int shell_context; /* Type prompt trigger (PS1 or PS2) */
/* Globals that are static to this file */
@@ -716,7 +714,6 @@ static int get_command(FILE * source, char *command)
** child processes (rob@sysgo.de)
*/
cmdedit_read_input(prompt_str, command);
cmdedit_terminate();
return 0;
#else
fputs(prompt_str, stdout);
@@ -1510,8 +1507,8 @@ static int busy_loop(FILE * input)
#ifdef BB_FEATURE_CLEAN_UP
void free_memory(void)
{
if (cwd) {
free(cwd);
if (cwd && cwd!=unknown) {
free((char*)cwd);
}
if (local_pending_command)
free(local_pending_command);
@@ -1548,7 +1545,7 @@ static void setup_job_control()
tcsetpgrp(shell_terminal, shell_pgrp);
}
int shell_main(int argc_l, char **argv_l)
int lash_main(int argc_l, char **argv_l)
{
int opt, interactive=FALSE;
FILE *input = stdin;
@@ -1557,7 +1554,6 @@ int shell_main(int argc_l, char **argv_l)
/* These variables need re-initializing when recursing */
last_jobid = 0;
shell_context = 0;
local_pending_command = NULL;
close_me_head = NULL;
job_list.head = NULL;
+263
View File
@@ -0,0 +1,263 @@
/* Copyright (c) 2001 Aaron Lehmann <aaronl@vitelus.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* This is my infix parser/evaluator. It is optimized for size, intended
* as a replacement for yacc-based parsers. However, it may well be faster
* than a comparable parser writen in yacc. The supported operators are
* listed in #defines below. Parens, order of operations, and error handling
* are supported. This code is threadsafe. */
/* To use the routine, call it with an expression string. It returns an
* integer result. You will also need to define an "error" function
* that takes printf arguments and _does not return_, or modify the code
* to use another error mechanism. */
#include <stdlib.h>
#include <string.h>
#include "libbb.h"
typedef char operator;
#define tok_decl(prec,id) (((id)<<5)|(prec))
#define PREC(op) ((op)&0x1F)
#define TOK_LPAREN tok_decl(0,0)
#define TOK_OR tok_decl(1,0)
#define TOK_AND tok_decl(2,0)
#define TOK_BOR tok_decl(3,0)
#define TOK_BXOR tok_decl(4,0)
#define TOK_BAND tok_decl(5,0)
#define TOK_EQ tok_decl(6,0)
#define TOK_NE tok_decl(6,1)
#define TOK_LT tok_decl(7,0)
#define TOK_GT tok_decl(7,1)
#define TOK_GE tok_decl(7,2)
#define TOK_LE tok_decl(7,3)
#define TOK_LSHIFT tok_decl(8,0)
#define TOK_RSHIFT tok_decl(8,1)
#define TOK_ADD tok_decl(9,0)
#define TOK_SUB tok_decl(9,1)
#define TOK_MUL tok_decl(10,0)
#define TOK_DIV tok_decl(10,1)
#define TOK_REM tok_decl(10,2)
#define UNARYPREC 14
#define TOK_BNOT tok_decl(UNARYPREC,0)
#define TOK_NOT tok_decl(UNARYPREC,1)
#define TOK_UMINUS tok_decl(UNARYPREC,2)
#define TOK_NUM tok_decl(15,0)
#define ARITH_APPLY(op) arith_apply(op, numstack, &numstackptr)
#define NUMPTR (*numstackptr)
static short arith_apply(operator op, long *numstack, long **numstackptr)
{
if (NUMPTR == numstack) goto err;
if (op == TOK_UMINUS)
NUMPTR[-1] *= -1;
else if (op == TOK_NOT)
NUMPTR[-1] = !(NUMPTR[-1]);
else if (op == TOK_BNOT)
NUMPTR[-1] = ~(NUMPTR[-1]);
/* Binary operators */
else {
if (NUMPTR-1 == numstack) goto err;
--NUMPTR;
if (op == TOK_BOR)
NUMPTR[-1] |= *NUMPTR;
else if (op == TOK_OR)
NUMPTR[-1] = *NUMPTR || NUMPTR[-1];
else if (op == TOK_BAND)
NUMPTR[-1] &= *NUMPTR;
else if (op == TOK_AND)
NUMPTR[-1] = NUMPTR[-1] && *NUMPTR;
else if (op == TOK_EQ)
NUMPTR[-1] = (NUMPTR[-1] == *NUMPTR);
else if (op == TOK_NE)
NUMPTR[-1] = (NUMPTR[-1] != *NUMPTR);
else if (op == TOK_GE)
NUMPTR[-1] = (NUMPTR[-1] >= *NUMPTR);
else if (op == TOK_RSHIFT)
NUMPTR[-1] >>= *NUMPTR;
else if (op == TOK_LSHIFT)
NUMPTR[-1] <<= *NUMPTR;
else if (op == TOK_GT)
NUMPTR[-1] = (NUMPTR[-1] > *NUMPTR);
else if (op == TOK_LT)
NUMPTR[-1] = (NUMPTR[-1] < *NUMPTR);
else if (op == TOK_LE)
NUMPTR[-1] = (NUMPTR[-1] <= *NUMPTR);
else if (op == TOK_MUL)
NUMPTR[-1] *= *NUMPTR;
else if (op == TOK_DIV) {
if(*NUMPTR==0)
return -2;
NUMPTR[-1] /= *NUMPTR;
}
else if (op == TOK_REM) {
if(*NUMPTR==0)
return -2;
NUMPTR[-1] %= *NUMPTR;
}
else if (op == TOK_ADD)
NUMPTR[-1] += *NUMPTR;
else if (op == TOK_SUB)
NUMPTR[-1] -= *NUMPTR;
}
return 0;
err: return(-1);
}
extern long arith (const char *startbuf, int *errcode)
{
register char arithval;
const char *expr = startbuf;
operator lasttok = TOK_MUL, op;
size_t datasizes = strlen(startbuf);
unsigned char prec;
long *numstack, *numstackptr;
operator *stack = alloca(datasizes * sizeof(operator)), *stackptr = stack;
*errcode = 0;
numstack = alloca((datasizes/2+1)*sizeof(long)), numstackptr = numstack;
while ((arithval = *expr)) {
if (arithval == ' ' || arithval == '\n' || arithval == '\t')
goto prologue;
if ((unsigned)arithval-'0' <= 9) /* isdigit */ {
*numstackptr++ = strtol(expr, (char **) &expr, 10);
lasttok = TOK_NUM;
continue;
} if (arithval == '(') {
*stackptr++ = TOK_LPAREN;
lasttok = TOK_LPAREN;
goto prologue;
} if (arithval == ')') {
lasttok = TOK_NUM;
while (stackptr != stack) {
op = *--stackptr;
if (op == TOK_LPAREN)
goto prologue;
*errcode = ARITH_APPLY(op);
if(*errcode) return *errcode;
}
goto err; /* Mismatched parens */
} if (arithval == '|') {
if (*++expr == '|')
op = TOK_OR;
else {
--expr;
op = TOK_BOR;
}
} else if (arithval == '&') {
if (*++expr == '&')
op = TOK_AND;
else {
--expr;
op = TOK_BAND;
}
} else if (arithval == '=') {
if (*++expr != '=') goto err; /* Unknown token */
op = TOK_EQ;
} else if (arithval == '!') {
if (*++expr == '=')
op = TOK_NE;
else {
--expr;
op = TOK_NOT;
}
} else if (arithval == '>') {
switch (*++expr) {
case '=':
op = TOK_GE;
break;
case '>':
op = TOK_RSHIFT;
break;
default:
--expr;
op = TOK_GT;
}
} else if (arithval == '<') {
switch (*++expr) {
case '=':
op = TOK_LE;
break;
case '<':
op = TOK_LSHIFT;
break;
default:
--expr;
op = TOK_LT;
}
} else if (arithval == '*')
op = TOK_MUL;
else if (arithval == '/')
op = TOK_DIV;
else if (arithval == '%')
op = TOK_REM;
else if (arithval == '+') {
if (lasttok != TOK_NUM) goto prologue; /* Unary plus */
op = TOK_ADD;
} else if (arithval == '-')
op = (lasttok == TOK_NUM) ? TOK_SUB : TOK_UMINUS;
else if (arithval == '~')
op = TOK_BNOT;
else goto err; /* Unknown token */
prec = PREC(op);
if (prec != UNARYPREC)
while (stackptr != stack && PREC(stackptr[-1]) >= prec) {
*errcode = ARITH_APPLY(*--stackptr);
if(*errcode) return *errcode;
}
*stackptr++ = op;
lasttok = op;
prologue: ++expr;
} /* yay */
while (stackptr != stack) {
*errcode = ARITH_APPLY(*--stackptr);
if(*errcode) return *errcode;
}
if (numstackptr != numstack+1) {
err:
*errcode = -1;
return -1;
/* NOTREACHED */
}
return *numstack;
}
+1 -1
View File
@@ -17,7 +17,7 @@ extern char *concat_path_file(const char *path, const char *filename)
if (!path)
path="";
lc = last_char_is(path, '/');
if (filename[0] == '/')
while (*filename == '/')
filename++;
outbuf = xmalloc(strlen(path)+strlen(filename)+1+(lc==NULL));
sprintf(outbuf, "%s%s%s", path, (lc==NULL)? "/" : "", filename);
+1 -1
View File
@@ -131,7 +131,7 @@ int copy_file(const char *source, const char *dest, int flags)
status = -1;
}
} else if (S_ISREG(source_stat.st_mode)) {
FILE *sfp, *dfp;
FILE *sfp, *dfp=NULL;
if (dest_exists) {
if (flags & FILEUTILS_INTERACTIVE) {
+37
View File
@@ -0,0 +1,37 @@
/* vi: set sw=4 ts=4: */
/*
* Utility routines.
*
* create raw socket for icmp protocol test permision
* and drop root privilegies if running setuid
*
*/
#include <sys/types.h>
#include <netdb.h>
#include <sys/socket.h>
#include <errno.h>
#include <unistd.h>
#include "libbb.h"
int create_icmp_socket(void)
{
struct protoent *proto;
int sock;
proto = getprotobyname("icmp");
/* if getprotobyname failed, just silently force
* proto->p_proto to have the correct value for "icmp" */
if ((sock = socket(AF_INET, SOCK_RAW,
(proto ? proto->p_proto : 1))) < 0) { /* 1 == ICMP */
if (errno == EPERM)
error_msg_and_die("permission denied. (are you root?)");
else
perror_msg_and_die(can_not_create_raw_socket);
}
/* drop root privs if running setuid */
setuid(getuid());
return sock;
}
+4 -4
View File
@@ -98,15 +98,15 @@ int get_console_fd(char *tty_name)
return fd;
}
fd = open_a_console("/dev/tty");
fd = open_a_console(CURRENT_TTY);
if (fd >= 0)
return fd;
fd = open_a_console("/dev/tty0");
fd = open_a_console(CURRENT_VC);
if (fd >= 0)
return fd;
fd = open_a_console("/dev/console");
fd = open_a_console(CONSOLE_DEV);
if (fd >= 0)
return fd;
@@ -114,7 +114,7 @@ int get_console_fd(char *tty_name)
if (is_a_console(fd))
return fd;
error_msg("Couldnt get a file descriptor referring to the console");
error_msg("Couldn't get a file descriptor referring to the console");
return -1; /* total failure */
}
+2 -2
View File
@@ -15,7 +15,7 @@ extern FILE *gz_open(FILE *compressed_file, int *pid)
return(NULL);
}
if ((*pid = fork()) == -1) {
error_msg("fork failured");
error_msg("fork failed");
return(NULL);
}
if (*pid==0) {
@@ -29,7 +29,7 @@ extern FILE *gz_open(FILE *compressed_file, int *pid)
}
close(unzip_pipe[1]);
if (unzip_pipe[0] == -1) {
error_msg("Couldnt initialise gzip stream");
error_msg("gzip stream init failed");
}
return(fdopen(unzip_pipe[0], "r"));
}
+5 -2
View File
@@ -3,7 +3,7 @@
* that either displays or sets the characteristics of
* one or more of the system's networking interfaces.
*
* Version: $Id: interface.c,v 1.3 2001/06/01 21:47:15 andersen Exp $
* Version: $Id: interface.c,v 1.4 2001/07/19 22:28:02 andersen Exp $
*
* Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
* and others. Copyright 1993 MicroWalt Corporation
@@ -78,7 +78,9 @@
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#if 0
#include <arpa/nameser.h>
#endif
#include "libbb.h"
#define _(x) x
@@ -455,9 +457,11 @@ static int INET_rresolve(char *name, size_t len, struct sockaddr_in *s_in,
#ifdef DEBUG
fprintf (stderr, "getnetbyaddr (%08lx)\n", host_ad);
#endif
#if 0
np = getnetbyaddr(host_ad, AF_INET);
if (np != NULL)
safe_strncpy(name, np->n_name, len);
#endif
}
if ((ent == NULL) && (np == NULL))
safe_strncpy(name, inet_ntoa(s_in->sin_addr), len);
@@ -1068,7 +1072,6 @@ static int if_readconf(void)
struct ifconf ifc;
struct ifreq *ifr;
int n, err = -1;
/* XXX Should this re-use the global skfd? */
int skfd2;
/* SIOCGIFCONF currently seems to only work properly on AF_INET sockets
+44 -5
View File
@@ -41,11 +41,13 @@
#include "../busybox.h"
#endif
#if __GNU_LIBRARY__ < 5
#if (__GNU_LIBRARY__ < 5) && (!defined __dietlibc__)
/* libc5 doesn't define socklen_t */
typedef unsigned int socklen_t;
/* libc5 doesn't implement BSD 4.4 daemon() */
extern int daemon (int nochdir, int noclose);
/* libc5 doesn't implement strtok_r */
char *strtok_r(char *s, const char *delim, char **ptrptr);
#endif
/* Some useful definitions */
@@ -212,6 +214,8 @@ char *xreadlink(const char *path);
char *concat_path_file(const char *path, const char *filename);
char *last_char_is(const char *s, int c);
extern long arith (const char *startbuf, int *errcode);
typedef struct file_headers_s {
char *name;
char *link_name;
@@ -237,13 +241,15 @@ enum extract_functions_e {
extract_control_tar_gz = 128,
extract_unzip_only = 256,
extract_unconditional = 512,
extract_create_leading_dirs = 1024
extract_create_leading_dirs = 1024,
extract_quiet = 2048,
extract_exclude_list = 4096
};
char *unarchive(FILE *src_stream, file_header_t *(*get_header)(FILE *),
char *unarchive(FILE *src_stream, FILE *out_stream, file_header_t *(*get_header)(FILE *),
const int extract_function, const char *prefix, char **extract_names);
char *deb_extract(const char *package_filename, FILE *out_stream, const int extract_function,
const char *prefix, const char *filename);
char *read_package_field(const char *package_buffer);
int read_package_field(const char *package_buffer, char **field_name, char **field_value);
char *fgets_str(FILE *file, const char *terminating_string);
extern int unzip(FILE *l_in_file, FILE *l_out_file);
@@ -251,10 +257,14 @@ extern void gz_close(int gunzip_pid);
extern FILE *gz_open(FILE *compressed_file, int *pid);
extern struct hostent *xgethostbyname(const char *name);
extern int create_icmp_socket(void);
char *dirname (const char *path);
int make_directory (char *path, mode_t mode, int flags);
int make_directory (char *path, long mode, int flags);
const char *u_signal_names(const char *str_sig, int *signo, int startnum);
char *simplify_path(const char *path);
#define CT_AUTO 0
#define CT_UNIX2DOS 1
@@ -283,5 +293,34 @@ extern const char * const write_error;
extern const char * const too_few_args;
extern const char * const name_longer_than_foo;
extern const char * const unknown;
extern const char * const can_not_create_raw_socket;
#ifdef BB_FEATURE_DEVFS
# define CURRENT_VC "/dev/vc/0"
# define VC_1 "/dev/vc/1"
# define VC_2 "/dev/vc/2"
# define VC_3 "/dev/vc/3"
# define VC_4 "/dev/vc/4"
# define VC_5 "/dev/vc/5"
# define SC_0 "/dev/tts/0"
# define SC_1 "/dev/tts/1"
# define VC_FORMAT "/dev/vc/%d"
# define SC_FORMAT "/dev/tts/%d"
#else
# define CURRENT_VC "/dev/tty0"
# define VC_1 "/dev/tty1"
# define VC_2 "/dev/tty2"
# define VC_3 "/dev/tty3"
# define VC_4 "/dev/tty4"
# define VC_5 "/dev/tty5"
# define SC_0 "/dev/ttyS0"
# define SC_1 "/dev/ttyS1"
# define VC_FORMAT "/dev/tty%d"
# define SC_FORMAT "/dev/ttyS%d"
#endif
/* The following devices are the same on devfs and non-devfs systems. */
#define CURRENT_TTY "/dev/tty"
#define CONSOLE_DEV "/dev/console"
#endif /* __LIBBB_H__ */
+75 -9
View File
@@ -1,4 +1,77 @@
/* vi: set sw=4 ts=4: */
#include <features.h>
#include <string.h>
#include <stdio.h>
#include <fcntl.h>
#include <paths.h>
#include <unistd.h>
#if __GNU_LIBRARY__ < 5
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
/*
* Modified by Manuel Novoa III Mar 1, 2001
*
* Converted original strtok.c code of strtok to __strtok_r.
* Cleaned up logic and reduced code size.
*/
char *strtok_r(char *s, const char *delim, char **save_ptr)
{
char *token;
token = 0; /* Initialize to no token. */
if (s == 0) { /* If not first time called... */
s = *save_ptr; /* restart from where we left off. */
}
if (s != 0) { /* If not finished... */
*save_ptr = 0;
s += strspn(s, delim); /* Skip past any leading delimiters. */
if (*s != '\0') { /* We have a token. */
token = s;
*save_ptr = strpbrk(token, delim); /* Find token's end. */
if (*save_ptr != 0) {
/* Terminate the token and make SAVE_PTR point past it. */
*(*save_ptr)++ = '\0';
}
}
}
return token;
}
/* Basically getdelim() with the delimiter hard wired to '\n' */
ssize_t getline(char **linebuf, size_t *n, FILE *file)
{
return (getdelim (linebuf, n, '\n', file));
}
/*
* daemon implementation for uClibc
*
@@ -26,14 +99,6 @@
* Original copyright notice is retained at the end of this file.
*/
#include <features.h>
#include <fcntl.h>
#include <paths.h>
#include <unistd.h>
#if __GNU_LIBRARY__ < 5
int daemon( int nochdir, int noclose )
{
int fd;
@@ -62,7 +127,6 @@ int daemon( int nochdir, int noclose )
}
return(0);
}
#endif
/*-
@@ -99,3 +163,5 @@ int daemon( int nochdir, int noclose )
*/
#endif
+1 -1
View File
@@ -33,7 +33,7 @@
* Also create parent directories as necessary if flags contains
* FILEUTILS_RECUR. */
int make_directory (char *path, mode_t mode, int flags)
int make_directory (char *path, long mode, int flags)
{
if (!(flags & FILEUTILS_RECUR)) {
if (mkdir (path, 0777) < 0) {
+3
View File
@@ -62,3 +62,6 @@
const char * const unknown = "(unknown)";
#endif
#ifdef L_can_not_create_raw_socket
const char * const can_not_create_raw_socket = "can`t create raw socket";
#endif
+78 -17
View File
@@ -3,28 +3,89 @@
#include "libbb.h"
/*
* Returns a [multi-line] package field
* Gets the next package field from package_buffer, seperated into the field name
* and field value, it returns the int offset to the first character of the next field
*/
extern char *read_package_field(const char *package_buffer)
int read_package_field(const char *package_buffer, char **field_name, char **field_value)
{
char *field = NULL;
int field_length = 0;
int buffer_length = 0;
int offset_name_start = 0;
int offset_name_end = 0;
int offset_value_start = 0;
int offset_value_end = 0;
int offset = 0;
int next_offset;
int name_length;
int value_length;
int exit_flag = FALSE;
buffer_length = strlen(package_buffer);
while ((field = strchr(&package_buffer[field_length], '\n')) != NULL) {
field_length = buffer_length - strlen(field);
if (package_buffer[field_length + 1] != ' ') {
break;
} else {
field_length++;
}
if (package_buffer == NULL) {
*field_name = NULL;
*field_value = NULL;
return(-1);
}
if (field_length == 0) {
return(NULL);
while (1) {
next_offset = offset + 1;
switch (package_buffer[offset]) {
case('\0'):
exit_flag = TRUE;
break;
case(':'):
if (offset_name_end == 0) {
offset_name_end = offset;
offset_value_start = next_offset;
}
/* TODO: Name might still have trailing spaces if ':' isnt
* immediately after name */
break;
case('\n'):
/* TODO: The char next_offset may be out of bounds */
if (package_buffer[next_offset] != ' ') {
exit_flag = TRUE;
break;
}
case('\t'):
case(' '):
/* increment the value start point if its a just filler */
if (offset_name_start == offset) {
offset_name_start++;
}
if (offset_value_start == offset) {
offset_value_start++;
}
break;
}
if (exit_flag == TRUE) {
/* Check that the names are valid */
offset_value_end = offset;
name_length = offset_name_end - offset_name_start;
value_length = offset_value_end - offset_value_start;
if (name_length == 0) {
break;
}
if ((name_length > 0) && (value_length > 0)) {
break;
}
/* If not valid, start fresh with next field */
exit_flag = FALSE;
offset_name_start = offset + 1;
offset_name_end = 0;
offset_value_start = offset + 1;
offset_value_end = offset + 1;
offset++;
}
offset++;
}
if (name_length == 0) {
*field_name = NULL;
} else {
return(xstrndup(package_buffer, field_length));
*field_name = xstrndup(&package_buffer[offset_name_start], name_length);
}
if (value_length > 0) {
*field_value = xstrndup(&package_buffer[offset_value_start], value_length);
} else {
*field_value = NULL;
}
return(next_offset);
}
+67
View File
@@ -0,0 +1,67 @@
/* vi: set sw=4 ts=4: */
/*
* simplify_path implementation for busybox
*
*
* Copyright (C) 2001 Manuel Novoa III <mjn3@opensource.lineo.com>
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <stdlib.h>
#include "libbb.h"
char *simplify_path(const char *path)
{
char *s, *start, *p;
if (path[0] == '/')
start = xstrdup(path);
else {
s = xgetcwd(NULL);
start = concat_path_file(s, path);
free(s);
}
p = s = start;
do {
if (*p == '/') {
if (*s == '/') { /* skip duplicate (or initial) slash */
continue;
} else if (*s == '.') {
if (s[1] == '/' || s[1] == 0) { /* remove extra '.' */
continue;
} else if ((s[1] == '.') && (s[2] == '/' || s[2] == 0)) {
++s;
if (p > start) {
while (*--p != '/'); /* omit previous dir */
}
continue;
}
}
}
*++p = *s;
} while (*++s);
if ((p == start) || (*p != '/')) { /* not a trailing slash */
++p; /* so keep last character */
}
*p = 0;
return start;
}
+166
View File
@@ -0,0 +1,166 @@
#include <signal.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
struct signal_name {
const char *name;
int number;
};
static const struct signal_name signames[] = {
/* POSIX signals */
{ "EXIT", 0 }, /* 0 */
{ "HUP", SIGHUP }, /* 1 */
{ "INT", SIGINT }, /* 2 */
{ "QUIT", SIGQUIT }, /* 3 */
{ "ILL", SIGILL }, /* 4 */
{ "ABRT", SIGABRT }, /* 6 */
{ "FPE", SIGFPE }, /* 8 */
{ "KILL", SIGKILL }, /* 9 */
{ "SEGV", SIGSEGV }, /* 11 */
{ "PIPE", SIGPIPE }, /* 13 */
{ "ALRM", SIGALRM }, /* 14 */
{ "TERM", SIGTERM }, /* 15 */
{ "USR1", SIGUSR1 }, /* 10 (arm,i386,m68k,ppc), 30 (alpha,sparc*), 16 (mips) */
{ "USR2", SIGUSR2 }, /* 12 (arm,i386,m68k,ppc), 31 (alpha,sparc*), 17 (mips) */
{ "CHLD", SIGCHLD }, /* 17 (arm,i386,m68k,ppc), 20 (alpha,sparc*), 18 (mips) */
{ "CONT", SIGCONT }, /* 18 (arm,i386,m68k,ppc), 19 (alpha,sparc*), 25 (mips) */
{ "STOP", SIGSTOP }, /* 19 (arm,i386,m68k,ppc), 17 (alpha,sparc*), 23 (mips) */
{ "TSTP", SIGTSTP }, /* 20 (arm,i386,m68k,ppc), 18 (alpha,sparc*), 24 (mips) */
{ "TTIN", SIGTTIN }, /* 21 (arm,i386,m68k,ppc,alpha,sparc*), 26 (mips) */
{ "TTOU", SIGTTOU }, /* 22 (arm,i386,m68k,ppc,alpha,sparc*), 27 (mips) */
/* Miscellaneous other signals */
#ifdef SIGTRAP
{ "TRAP", SIGTRAP }, /* 5 */
#endif
#ifdef SIGIOT
{ "IOT", SIGIOT }, /* 6, same as SIGABRT */
#endif
#ifdef SIGEMT
{ "EMT", SIGEMT }, /* 7 (mips,alpha,sparc*) */
#endif
#ifdef SIGBUS
{ "BUS", SIGBUS }, /* 7 (arm,i386,m68k,ppc), 10 (mips,alpha,sparc*) */
#endif
#ifdef SIGSYS
{ "SYS", SIGSYS }, /* 12 (mips,alpha,sparc*) */
#endif
#ifdef SIGSTKFLT
{ "STKFLT", SIGSTKFLT }, /* 16 (arm,i386,m68k,ppc) */
#endif
#ifdef SIGURG
{ "URG", SIGURG }, /* 23 (arm,i386,m68k,ppc), 16 (alpha,sparc*), 21 (mips) */
#endif
#ifdef SIGIO
{ "IO", SIGIO }, /* 29 (arm,i386,m68k,ppc), 23 (alpha,sparc*), 22 (mips) */
#endif
#ifdef SIGPOLL
{ "POLL", SIGPOLL }, /* same as SIGIO */
#endif
#ifdef SIGCLD
{ "CLD", SIGCLD }, /* same as SIGCHLD (mips) */
#endif
#ifdef SIGXCPU
{ "XCPU", SIGXCPU }, /* 24 (arm,i386,m68k,ppc,alpha,sparc*), 30 (mips) */
#endif
#ifdef SIGXFSZ
{ "XFSZ", SIGXFSZ }, /* 25 (arm,i386,m68k,ppc,alpha,sparc*), 31 (mips) */
#endif
#ifdef SIGVTALRM
{ "VTALRM", SIGVTALRM }, /* 26 (arm,i386,m68k,ppc,alpha,sparc*), 28 (mips) */
#endif
#ifdef SIGPROF
{ "PROF", SIGPROF }, /* 27 (arm,i386,m68k,ppc,alpha,sparc*), 29 (mips) */
#endif
#ifdef SIGPWR
{ "PWR", SIGPWR }, /* 30 (arm,i386,m68k,ppc), 29 (alpha,sparc*), 19 (mips) */
#endif
#ifdef SIGINFO
{ "INFO", SIGINFO }, /* 29 (alpha) */
#endif
#ifdef SIGLOST
{ "LOST", SIGLOST }, /* 29 (arm,i386,m68k,ppc,sparc*) */
#endif
#ifdef SIGWINCH
{ "WINCH", SIGWINCH }, /* 28 (arm,i386,m68k,ppc,alpha,sparc*), 20 (mips) */
#endif
#ifdef SIGUNUSED
{ "UNUSED", SIGUNUSED }, /* 31 (arm,i386,m68k,ppc) */
#endif
{0, 0}
};
/*
if str_sig == NULL returned signal name [*signo],
if str_sig != NULL - set *signo from signal_name,
findings with digit number or with or without SIG-prefix name
if startnum=0 flag for support finding zero signal,
but str_sig="0" always found, (hmm - standart or realize?)
if startnum<0 returned reverse signal_number <-> signal_name
if found error - returned NULL
*/
const char *
u_signal_names(const char *str_sig, int *signo, int startnum)
{
static char retstr[16];
const struct signal_name *s = signames;
static const char prefix[] = "SIG";
const char *sptr;
if(startnum)
s++;
if(str_sig==NULL) {
while (s->name != 0) {
if(s->number == *signo)
break;
s++;
}
} else {
if (isdigit(((unsigned char)*str_sig))) {
char *endp;
long int sn = strtol(str_sig, &endp, 10);
/* test correct and overflow */
if(*endp == 0 && sn >= 0 && sn < NSIG) {
*signo = (int)sn;
/* test for unnamed */
sptr = u_signal_names(0, signo, 0);
if(sptr==NULL)
return NULL;
if(sn!=0)
sptr += 3;
return sptr;
}
} else {
sptr = str_sig;
while (s->name != 0) {
if (strcasecmp(s->name, sptr) == 0) {
*signo = s->number;
if(startnum<0) {
sprintf(retstr, "%d", *signo);
return retstr;
}
break;
}
if(s!=signames && sptr == str_sig &&
strncasecmp(sptr, prefix, 3) == 0) {
sptr += 3; /* strlen(prefix) */
continue;
}
sptr = str_sig;
s++;
}
}
}
if(s->name==0)
return NULL;
if(s!=signames)
strcpy(retstr, prefix);
else
retstr[0] = 0;
return strcat(retstr, s->name);
}
+69 -31
View File
@@ -82,8 +82,11 @@ char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *f
/* strip leading '/' in filename to extract as prefix may not be dir */
/* Cant use concat_path_file here as prefix might not be a directory */
char *path = file_entry->name;
if (*path == '/') {
path++;
if (strncmp("./", path, 2) == 0) {
path += 2;
if (strlen(path) == 0) {
return(NULL);
}
}
full_name = xmalloc(strlen(prefix) + strlen(path) + 1);
strcpy(full_name, prefix);
@@ -91,7 +94,6 @@ char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *f
} else {
full_name = file_entry->name;
}
if (function & extract_to_stdout) {
if (S_ISREG(file_entry->mode)) {
copy_file_chunk(src_stream, out_stream, file_entry->size);
@@ -102,6 +104,7 @@ char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *f
if (S_ISREG(file_entry->mode)) {
buffer = (char *) xmalloc(file_entry->size + 1);
fread(buffer, 1, file_entry->size, src_stream);
buffer[file_entry->size] = '\0';
archive_offset += file_entry->size;
return(buffer);
}
@@ -116,15 +119,19 @@ char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *f
unlink(full_name); /* Directories might not be empty etc */
}
} else {
error_msg("%s not created: newer or same age file exists", file_entry->name);
seek_sub_file(src_stream, file_entry->size);
if ((function & extract_quiet) != extract_quiet) {
error_msg("%s not created: newer or same age file exists", file_entry->name);
}
seek_sub_file(src_stream, file_entry->size);
return (NULL);
}
}
if (function & extract_create_leading_dirs) { /* Create leading directories with default umask */
char *parent = dirname(full_name);
if (make_directory (parent, -1, FILEUTILS_RECUR) != 0) {
error_msg("couldn't create leading directories");
if ((function & extract_quiet) != extract_quiet) {
error_msg("couldn't create leading directories");
}
}
free (parent);
}
@@ -132,8 +139,10 @@ char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *f
case S_IFREG:
if (file_entry->link_name) { /* Found a cpio hard link */
if (link(file_entry->link_name, full_name) != 0) {
perror_msg("Cannot link from %s to '%s'",
file_entry->name, file_entry->link_name);
if ((function & extract_quiet) != extract_quiet) {
perror_msg("Cannot link from %s to '%s'",
file_entry->name, file_entry->link_name);
}
}
} else {
if ((dst_stream = wfopen(full_name, "w")) == NULL) {
@@ -148,13 +157,17 @@ char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *f
case S_IFDIR:
if (stat_res != 0) {
if (mkdir(full_name, file_entry->mode) < 0) {
perror_msg("extract_archive: ");
if ((function & extract_quiet) != extract_quiet) {
perror_msg("extract_archive: ");
}
}
}
break;
case S_IFLNK:
if (symlink(file_entry->link_name, full_name) < 0) {
perror_msg("Cannot create symlink from %s to '%s'", file_entry->name, file_entry->link_name);
if ((function & extract_quiet) != extract_quiet) {
perror_msg("Cannot create symlink from %s to '%s'", file_entry->name, file_entry->link_name);
}
return NULL;
}
break;
@@ -163,7 +176,9 @@ char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *f
case S_IFCHR:
case S_IFIFO:
if (mknod(full_name, file_entry->mode, file_entry->device) == -1) {
perror_msg("Cannot create node %s", file_entry->name);
if ((function & extract_quiet) != extract_quiet) {
perror_msg("Cannot create node %s", file_entry->name);
}
return NULL;
}
break;
@@ -173,7 +188,7 @@ char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *f
* file pointed to, so dont try and change the date or mode, lchown does
* does the right thing, but isnt available in older versions of libc */
if (S_ISLNK(file_entry->mode)) {
#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
#if (__GLIBC__ > 2) && (__GLIBC_MINOR__ > 1)
lchown(full_name, file_entry->uid, file_entry->gid);
#endif
} else {
@@ -211,30 +226,44 @@ char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *f
#endif
#ifdef L_unarchive
char *unarchive(FILE *src_stream, file_header_t *(*get_headers)(FILE *),
char *unarchive(FILE *src_stream, FILE *out_stream, file_header_t *(*get_headers)(FILE *),
const int extract_function, const char *prefix, char **extract_names)
{
file_header_t *file_entry;
int found;
int extract_flag;
int i;
char *buffer = NULL;
archive_offset = 0;
while ((file_entry = get_headers(src_stream)) != NULL) {
found = FALSE;
if (extract_names[0] != NULL) {
extract_flag = TRUE;
if (extract_names != NULL) {
int found_flag = FALSE;
for(i = 0; extract_names[i] != 0; i++) {
if (strcmp(extract_names[i], file_entry->name) == 0) {
found = TRUE;
found_flag = TRUE;
break;
}
}
if (!found) {
/* seek past the data entry */
seek_sub_file(src_stream, file_entry->size);
continue;
if (extract_function & extract_exclude_list) {
if (found_flag == TRUE) {
extract_flag = FALSE;
}
} else {
/* If its not found in the include list dont extract it */
if (found_flag == FALSE) {
extract_flag = FALSE;
}
}
}
if (extract_flag == TRUE) {
buffer = extract_archive(src_stream, out_stream, file_entry, extract_function, prefix);
} else {
/* seek past the data entry */
seek_sub_file(src_stream, file_entry->size);
}
buffer = extract_archive(src_stream, stdout, file_entry, extract_function, prefix);
}
return(buffer);
}
@@ -259,7 +288,6 @@ file_header_t *get_header_ar(FILE *src_stream)
static char *ar_long_names;
if (fread(ar.raw, 1, 60, src_stream) != 60) {
free (ar_long_names);
return(NULL);
}
archive_offset += 60;
@@ -375,7 +403,8 @@ file_header_t *get_header_cpio(FILE *src_stream)
case '1': /* "newc" header format */
cpio_entry = (file_header_t *) xcalloc(1, sizeof(file_header_t));
sscanf(cpio_header, "%6c%8x%8x%8x%8x%8x%8lx%8lx%16c%8x%8x%8x%8c",
dummy, &inode, &cpio_entry->mode, &cpio_entry->uid, &cpio_entry->gid,
dummy, &inode, (unsigned int*)&cpio_entry->mode,
(unsigned int*)&cpio_entry->uid, (unsigned int*)&cpio_entry->gid,
&nlink, &cpio_entry->mtime, &cpio_entry->size,
dummy, &major, &minor, &namesize, dummy);
@@ -478,7 +507,9 @@ file_header_t *get_header_tar(FILE *tar_stream)
}
if (fread(tar.raw, 1, 512, tar_stream) != 512) {
error_msg("Couldnt read header");
/* Unfortunatly its common for tar files to have all sorts of
* trailing garbage, fail silently */
// error_msg("Couldnt read header");
return(NULL);
}
archive_offset += 512;
@@ -529,16 +560,18 @@ char *deb_extract(const char *package_filename, FILE *out_stream,
FILE *deb_stream;
FILE *uncompressed_stream = NULL;
file_header_t *ar_header = NULL;
char **file_list = NULL;
char *output_buffer = NULL;
char *ared_file = NULL;
char ar_magic[8];
char **file_list;
int gunzip_pid;
file_list = malloc(sizeof(char *));
file_list[0] = xstrdup(filename);
file_list[1] = NULL;
if (filename != NULL) {
file_list = xmalloc(sizeof(char *) * 2);
file_list[0] = xstrdup(filename);
file_list[1] = NULL;
}
if (extract_function & extract_control_tar_gz) {
ared_file = xstrdup("control.tar.gz");
}
@@ -548,6 +581,11 @@ char *deb_extract(const char *package_filename, FILE *out_stream,
/* open the debian package to be worked on */
deb_stream = wfopen(package_filename, "r");
if (deb_stream == NULL) {
return(NULL);
}
/* set the buffer size */
setvbuf(deb_stream, NULL, _IOFBF, 0x8000);
/* check ar magic */
fread(ar_magic, 1, 8, deb_stream);
@@ -561,7 +599,7 @@ char *deb_extract(const char *package_filename, FILE *out_stream,
/* open a stream of decompressed data */
uncompressed_stream = gz_open(deb_stream, &gunzip_pid);
archive_offset = 0;
output_buffer = unarchive(uncompressed_stream, get_header_tar, extract_function, prefix, file_list);
output_buffer = unarchive(uncompressed_stream, out_stream, get_header_tar, extract_function, prefix, file_list);
}
seek_sub_file(deb_stream, ar_header->size);
}
+8 -11
View File
@@ -67,7 +67,7 @@ static char *license_msg[] = {
#include <string.h>
#include "libbb.h"
FILE *in_file, *out_file;
static FILE *in_file, *out_file;
/* these are freed by gz_close */
static unsigned char *window;
@@ -91,9 +91,9 @@ static const int N_MAX = 288; /* maximum number of codes in any set */
static long bytes_out; /* number of output bytes */
static unsigned long outcnt; /* bytes in output buffer */
unsigned hufts; /* track memory usage */
unsigned long bb; /* bit buffer */
unsigned bk; /* bits in bit buffer */
static unsigned hufts; /* track memory usage */
static unsigned long bb; /* bit buffer */
static unsigned bk; /* bits in bit buffer */
typedef struct huft_s {
unsigned char e; /* number of extra bits or operation */
@@ -104,7 +104,7 @@ typedef struct huft_s {
} v;
} huft_t;
unsigned short mask_bits[] = {
static const unsigned short mask_bits[] = {
0x0000,
0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
@@ -154,7 +154,7 @@ static void make_crc_table()
* Write the output window window[0..outcnt-1] and update crc and bytes_out.
* (Used for the decompressed data only.)
*/
void flush_window()
static void flush_window(void)
{
int n;
@@ -925,9 +925,6 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
outcnt = 0;
bytes_out = 0L;
/* set the buffer size */
setvbuf(in_file, NULL, _IOFBF, 0x8000);
magic[0] = fgetc(in_file);
magic[1] = fgetc(in_file);
@@ -1024,6 +1021,6 @@ extern void gz_close(int gunzip_pid)
if (waitpid(gunzip_pid, NULL, 0) == -1) {
printf("Couldnt wait ?");
}
free(window);
free(crc_table);
free(window);
free(crc_table);
}
+1
View File
@@ -10,6 +10,7 @@
#include <errno.h>
#include <unistd.h>
#include <limits.h>
#include <sys/param.h>
#include "libbb.h"
/* Amount to increase buffer size by in each try. */
+2 -2
View File
@@ -37,9 +37,9 @@ int loadacm_main(int argc, char **argv)
show_usage();
}
fd = open("/dev/tty", O_RDWR);
fd = open(CURRENT_VC, O_RDWR);
if (fd < 0) {
perror_msg_and_die("Error opening /dev/tty1");
perror_msg_and_die("Error opening " CURRENT_VC);
}
if (screen_map_load(fd, stdin)) {
+2 -2
View File
@@ -46,9 +46,9 @@ extern int loadfont_main(int argc, char **argv)
if (argc != 1)
show_usage();
fd = open("/dev/tty0", O_RDWR);
fd = open(CURRENT_VC, O_RDWR);
if (fd < 0)
perror_msg_and_die("Error opening /dev/tty0");
perror_msg_and_die("Error opening " CURRENT_VC);
loadnewfont(fd);
return EXIT_SUCCESS;
+2 -2
View File
@@ -53,9 +53,9 @@ int loadkmap_main(int argc, char **argv)
if (argc != 1)
show_usage();
fd = open("/dev/tty0", O_RDWR);
fd = open(CURRENT_VC, O_RDWR);
if (fd < 0)
perror_msg_and_die("Error opening /dev/tty0");
perror_msg_and_die("Error opening " CURRENT_VC);
read(0, buff, 7);
if (0 != strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
Loaded 100 of 157 files, more files were not shown because too many files have changed in this diff. Show more