diff options
| author | Ron Yorston <rmy@pobox.com> | 2017-11-03 14:16:08 +0000 |
|---|---|---|
| committer | Ron Yorston <rmy@pobox.com> | 2017-11-03 14:16:08 +0000 |
| commit | d6ce08aeb85b3698ddaa281016b70e16aeb9fb35 (patch) | |
| tree | 02ad9bc0684859515fe891f3d6b0a1086e0db156 | |
| parent | ab450021a99ba66126cc6d668fb06ec3829a572b (diff) | |
| parent | a5060b8364faa7c677c8950f1315c451403b0660 (diff) | |
| download | busybox-w32-d6ce08aeb85b3698ddaa281016b70e16aeb9fb35.tar.gz busybox-w32-d6ce08aeb85b3698ddaa281016b70e16aeb9fb35.tar.bz2 busybox-w32-d6ce08aeb85b3698ddaa281016b70e16aeb9fb35.zip | |
Merge branch 'busybox' into merge
200 files changed, 732 insertions, 503 deletions
diff --git a/NOFORK_NOEXEC.lst b/NOFORK_NOEXEC.lst index 4e53d7204..72c33ddd7 100644 --- a/NOFORK_NOEXEC.lst +++ b/NOFORK_NOEXEC.lst | |||
| @@ -144,7 +144,7 @@ flash_unlock - hardware | |||
| 144 | flashcp - hardware | 144 | flashcp - hardware |
| 145 | flock - spawner, changes state (file locks), let's play safe and not be noexec | 145 | flock - spawner, changes state (file locks), let's play safe and not be noexec |
| 146 | fold - noexec. runner | 146 | fold - noexec. runner |
| 147 | free - noexec. nofork candidate(struct globals, needs to close /proc/meminfo fd) | 147 | free - NOFORK |
| 148 | freeramdisk - noexec. leaks: open+ioctl_or_perror_and_die | 148 | freeramdisk - noexec. leaks: open+ioctl_or_perror_and_die |
| 149 | fsck - interactive, longterm | 149 | fsck - interactive, longterm |
| 150 | fsck.minix - needs ^C | 150 | fsck.minix - needs ^C |
diff --git a/archival/libarchive/common.c b/archival/libarchive/common.c index 389cb7856..25c7bddad 100644 --- a/archival/libarchive/common.c +++ b/archival/libarchive/common.c | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | /* | 2 | /* |
| 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 4 | */ | 4 | */ |
| 5 | |||
| 6 | #include "libbb.h" | 5 | #include "libbb.h" |
| 7 | #include "bb_archive.h" | 6 | #include "bb_archive.h" |
| 8 | 7 | ||
diff --git a/archival/libarchive/data_align.c b/archival/libarchive/data_align.c index a6b84a440..f61fdd93f 100644 --- a/archival/libarchive/data_align.c +++ b/archival/libarchive/data_align.c | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | /* | 2 | /* |
| 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 4 | */ | 4 | */ |
| 5 | |||
| 6 | #include "libbb.h" | 5 | #include "libbb.h" |
| 7 | #include "bb_archive.h" | 6 | #include "bb_archive.h" |
| 8 | 7 | ||
diff --git a/archival/libarchive/data_extract_all.c b/archival/libarchive/data_extract_all.c index e658444e0..d3a6df5e8 100644 --- a/archival/libarchive/data_extract_all.c +++ b/archival/libarchive/data_extract_all.c | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | /* | 2 | /* |
| 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 4 | */ | 4 | */ |
| 5 | |||
| 6 | #include "libbb.h" | 5 | #include "libbb.h" |
| 7 | #include "bb_archive.h" | 6 | #include "bb_archive.h" |
| 8 | 7 | ||
diff --git a/archival/libarchive/data_extract_to_command.c b/archival/libarchive/data_extract_to_command.c index 5d8769382..1114a95cb 100644 --- a/archival/libarchive/data_extract_to_command.c +++ b/archival/libarchive/data_extract_to_command.c | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | /* | 2 | /* |
| 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 4 | */ | 4 | */ |
| 5 | |||
| 6 | #include "libbb.h" | 5 | #include "libbb.h" |
| 7 | #include "bb_archive.h" | 6 | #include "bb_archive.h" |
| 8 | 7 | ||
diff --git a/archival/libarchive/data_extract_to_stdout.c b/archival/libarchive/data_extract_to_stdout.c index f849f3b42..520041329 100644 --- a/archival/libarchive/data_extract_to_stdout.c +++ b/archival/libarchive/data_extract_to_stdout.c | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | /* | 2 | /* |
| 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 4 | */ | 4 | */ |
| 5 | |||
| 6 | #include "libbb.h" | 5 | #include "libbb.h" |
| 7 | #include "bb_archive.h" | 6 | #include "bb_archive.h" |
| 8 | 7 | ||
diff --git a/archival/libarchive/data_skip.c b/archival/libarchive/data_skip.c index 588167f01..1a608227e 100644 --- a/archival/libarchive/data_skip.c +++ b/archival/libarchive/data_skip.c | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | /* | 2 | /* |
| 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 4 | */ | 4 | */ |
| 5 | |||
| 6 | #include "libbb.h" | 5 | #include "libbb.h" |
| 7 | #include "bb_archive.h" | 6 | #include "bb_archive.h" |
| 8 | 7 | ||
diff --git a/archival/libarchive/decompress_bunzip2.c b/archival/libarchive/decompress_bunzip2.c index 803702f75..bec89edd3 100644 --- a/archival/libarchive/decompress_bunzip2.c +++ b/archival/libarchive/decompress_bunzip2.c | |||
| @@ -1,14 +1,14 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* Small bzip2 deflate implementation, by Rob Landley (rob@landley.net). | 2 | /* |
| 3 | 3 | * Small bzip2 deflate implementation, by Rob Landley (rob@landley.net). | |
| 4 | Based on bzip2 decompression code by Julian R Seward (jseward@acm.org), | 4 | * |
| 5 | which also acknowledges contributions by Mike Burrows, David Wheeler, | 5 | * Based on bzip2 decompression code by Julian R Seward (jseward@acm.org), |
| 6 | Peter Fenwick, Alistair Moffat, Radford Neal, Ian H. Witten, | 6 | * which also acknowledges contributions by Mike Burrows, David Wheeler, |
| 7 | Robert Sedgewick, and Jon L. Bentley. | 7 | * Peter Fenwick, Alistair Moffat, Radford Neal, Ian H. Witten, |
| 8 | 8 | * Robert Sedgewick, and Jon L. Bentley. | |
| 9 | Licensed under GPLv2 or later, see file LICENSE in this source tree. | 9 | * |
| 10 | */ | 10 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 11 | 11 | */ | |
| 12 | /* | 12 | /* |
| 13 | Size and speed optimizations by Manuel Novoa III (mjn3@codepoet.org). | 13 | Size and speed optimizations by Manuel Novoa III (mjn3@codepoet.org). |
| 14 | 14 | ||
| @@ -38,7 +38,6 @@ | |||
| 38 | 38 | ||
| 39 | Manuel | 39 | Manuel |
| 40 | */ | 40 | */ |
| 41 | |||
| 42 | #include "libbb.h" | 41 | #include "libbb.h" |
| 43 | #include "bb_archive.h" | 42 | #include "bb_archive.h" |
| 44 | 43 | ||
| @@ -157,15 +156,15 @@ static unsigned get_bits(bunzip_data *bd, int bits_wanted) | |||
| 157 | static int get_next_block(bunzip_data *bd) | 156 | static int get_next_block(bunzip_data *bd) |
| 158 | { | 157 | { |
| 159 | struct group_data *hufGroup; | 158 | struct group_data *hufGroup; |
| 160 | int dbufCount, dbufSize, groupCount, *base, *limit, selector, | 159 | int groupCount, *base, *limit, selector, |
| 161 | i, j, runPos, symCount, symTotal, nSelectors, byteCount[256]; | 160 | i, j, symCount, symTotal, nSelectors, byteCount[256]; |
| 162 | int runCnt = runCnt; /* for compiler */ | ||
| 163 | uint8_t uc, symToByte[256], mtfSymbol[256], *selectors; | 161 | uint8_t uc, symToByte[256], mtfSymbol[256], *selectors; |
| 164 | uint32_t *dbuf; | 162 | uint32_t *dbuf; |
| 165 | unsigned origPtr, t; | 163 | unsigned origPtr, t; |
| 164 | unsigned dbufCount, runPos; | ||
| 165 | unsigned runCnt = runCnt; /* for compiler */ | ||
| 166 | 166 | ||
| 167 | dbuf = bd->dbuf; | 167 | dbuf = bd->dbuf; |
| 168 | dbufSize = bd->dbufSize; | ||
| 169 | selectors = bd->selectors; | 168 | selectors = bd->selectors; |
| 170 | 169 | ||
| 171 | /* In bbox, we are ok with aborting through setjmp which is set up in start_bunzip */ | 170 | /* In bbox, we are ok with aborting through setjmp which is set up in start_bunzip */ |
| @@ -188,7 +187,7 @@ static int get_next_block(bunzip_data *bd) | |||
| 188 | it didn't actually work. */ | 187 | it didn't actually work. */ |
| 189 | if (get_bits(bd, 1)) return RETVAL_OBSOLETE_INPUT; | 188 | if (get_bits(bd, 1)) return RETVAL_OBSOLETE_INPUT; |
| 190 | origPtr = get_bits(bd, 24); | 189 | origPtr = get_bits(bd, 24); |
| 191 | if ((int)origPtr > dbufSize) return RETVAL_DATA_ERROR; | 190 | if (origPtr > bd->dbufSize) return RETVAL_DATA_ERROR; |
| 192 | 191 | ||
| 193 | /* mapping table: if some byte values are never used (encoding things | 192 | /* mapping table: if some byte values are never used (encoding things |
| 194 | like ascii text), the compression code removes the gaps to have fewer | 193 | like ascii text), the compression code removes the gaps to have fewer |
| @@ -436,7 +435,14 @@ static int get_next_block(bunzip_data *bd) | |||
| 436 | symbols, but a run of length 0 doesn't mean anything in this | 435 | symbols, but a run of length 0 doesn't mean anything in this |
| 437 | context). Thus space is saved. */ | 436 | context). Thus space is saved. */ |
| 438 | runCnt += (runPos << nextSym); /* +runPos if RUNA; +2*runPos if RUNB */ | 437 | runCnt += (runPos << nextSym); /* +runPos if RUNA; +2*runPos if RUNB */ |
| 439 | if (runPos < dbufSize) runPos <<= 1; | 438 | //The 32-bit overflow of runCnt wasn't yet seen, but probably can happen. |
| 439 | //This would be the fix (catches too large count way before it can overflow): | ||
| 440 | // if (runCnt > bd->dbufSize) { | ||
| 441 | // dbg("runCnt:%u > dbufSize:%u RETVAL_DATA_ERROR", | ||
| 442 | // runCnt, bd->dbufSize); | ||
| 443 | // return RETVAL_DATA_ERROR; | ||
| 444 | // } | ||
| 445 | if (runPos < bd->dbufSize) runPos <<= 1; | ||
| 440 | goto end_of_huffman_loop; | 446 | goto end_of_huffman_loop; |
| 441 | } | 447 | } |
| 442 | 448 | ||
| @@ -446,14 +452,15 @@ static int get_next_block(bunzip_data *bd) | |||
| 446 | literal used is the one at the head of the mtfSymbol array.) */ | 452 | literal used is the one at the head of the mtfSymbol array.) */ |
| 447 | if (runPos != 0) { | 453 | if (runPos != 0) { |
| 448 | uint8_t tmp_byte; | 454 | uint8_t tmp_byte; |
| 449 | if (dbufCount + runCnt > dbufSize) { | 455 | if (dbufCount + runCnt > bd->dbufSize) { |
| 450 | dbg("dbufCount:%d+runCnt:%d %d > dbufSize:%d RETVAL_DATA_ERROR", | 456 | dbg("dbufCount:%u+runCnt:%u %u > dbufSize:%u RETVAL_DATA_ERROR", |
| 451 | dbufCount, runCnt, dbufCount + runCnt, dbufSize); | 457 | dbufCount, runCnt, dbufCount + runCnt, bd->dbufSize); |
| 452 | return RETVAL_DATA_ERROR; | 458 | return RETVAL_DATA_ERROR; |
| 453 | } | 459 | } |
| 454 | tmp_byte = symToByte[mtfSymbol[0]]; | 460 | tmp_byte = symToByte[mtfSymbol[0]]; |
| 455 | byteCount[tmp_byte] += runCnt; | 461 | byteCount[tmp_byte] += runCnt; |
| 456 | while (--runCnt >= 0) dbuf[dbufCount++] = (uint32_t)tmp_byte; | 462 | while ((int)--runCnt >= 0) |
| 463 | dbuf[dbufCount++] = (uint32_t)tmp_byte; | ||
| 457 | runPos = 0; | 464 | runPos = 0; |
| 458 | } | 465 | } |
| 459 | 466 | ||
| @@ -467,7 +474,7 @@ static int get_next_block(bunzip_data *bd) | |||
| 467 | first symbol in the mtf array, position 0, would have been handled | 474 | first symbol in the mtf array, position 0, would have been handled |
| 468 | as part of a run above. Therefore 1 unused mtf position minus | 475 | as part of a run above. Therefore 1 unused mtf position minus |
| 469 | 2 non-literal nextSym values equals -1.) */ | 476 | 2 non-literal nextSym values equals -1.) */ |
| 470 | if (dbufCount >= dbufSize) return RETVAL_DATA_ERROR; | 477 | if (dbufCount >= bd->dbufSize) return RETVAL_DATA_ERROR; |
| 471 | i = nextSym - 1; | 478 | i = nextSym - 1; |
| 472 | uc = mtfSymbol[i]; | 479 | uc = mtfSymbol[i]; |
| 473 | 480 | ||
diff --git a/archival/libarchive/decompress_gunzip.c b/archival/libarchive/decompress_gunzip.c index 74d364379..14a901792 100644 --- a/archival/libarchive/decompress_gunzip.c +++ b/archival/libarchive/decompress_gunzip.c | |||
| @@ -32,7 +32,6 @@ | |||
| 32 | * | 32 | * |
| 33 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 33 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 34 | */ | 34 | */ |
| 35 | |||
| 36 | #include <setjmp.h> | 35 | #include <setjmp.h> |
| 37 | #include "libbb.h" | 36 | #include "libbb.h" |
| 38 | #include "bb_archive.h" | 37 | #include "bb_archive.h" |
diff --git a/archival/libarchive/decompress_uncompress.c b/archival/libarchive/decompress_uncompress.c index 034ed502d..1517559c6 100644 --- a/archival/libarchive/decompress_uncompress.c +++ b/archival/libarchive/decompress_uncompress.c | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* uncompress for busybox -- (c) 2002 Robert Griebl | 2 | /* |
| 3 | * uncompress for busybox -- (c) 2002 Robert Griebl | ||
| 3 | * | 4 | * |
| 4 | * based on the original compress42.c source | 5 | * based on the original compress42.c source |
| 5 | * (see disclaimer below) | 6 | * (see disclaimer below) |
| 6 | */ | 7 | */ |
| 7 | |||
| 8 | /* (N)compress42.c - File compression ala IEEE Computer, Mar 1992. | 8 | /* (N)compress42.c - File compression ala IEEE Computer, Mar 1992. |
| 9 | * | 9 | * |
| 10 | * Authors: | 10 | * Authors: |
| @@ -21,9 +21,7 @@ | |||
| 21 | * marc@suse.de : a small security fix for a buffer overflow | 21 | * marc@suse.de : a small security fix for a buffer overflow |
| 22 | * | 22 | * |
| 23 | * [... History snipped ...] | 23 | * [... History snipped ...] |
| 24 | * | ||
| 25 | */ | 24 | */ |
| 26 | |||
| 27 | #include "libbb.h" | 25 | #include "libbb.h" |
| 28 | #include "bb_archive.h" | 26 | #include "bb_archive.h" |
| 29 | 27 | ||
diff --git a/archival/libarchive/decompress_unlzma.c b/archival/libarchive/decompress_unlzma.c index a9040877e..be4342414 100644 --- a/archival/libarchive/decompress_unlzma.c +++ b/archival/libarchive/decompress_unlzma.c | |||
| @@ -450,8 +450,12 @@ unpack_lzma_stream(transformer_state_t *xstate) | |||
| 450 | IF_NOT_FEATURE_LZMA_FAST(string:) | 450 | IF_NOT_FEATURE_LZMA_FAST(string:) |
| 451 | do { | 451 | do { |
| 452 | uint32_t pos = buffer_pos - rep0; | 452 | uint32_t pos = buffer_pos - rep0; |
| 453 | if ((int32_t)pos < 0) | 453 | if ((int32_t)pos < 0) { |
| 454 | pos += header.dict_size; | 454 | pos += header.dict_size; |
| 455 | /* bug 10436 has an example file where this triggers: */ | ||
| 456 | if ((int32_t)pos < 0) | ||
| 457 | goto bad; | ||
| 458 | } | ||
| 455 | previous_byte = buffer[pos]; | 459 | previous_byte = buffer[pos]; |
| 456 | IF_NOT_FEATURE_LZMA_FAST(one_byte2:) | 460 | IF_NOT_FEATURE_LZMA_FAST(one_byte2:) |
| 457 | buffer[buffer_pos++] = previous_byte; | 461 | buffer[buffer_pos++] = previous_byte; |
diff --git a/archival/libarchive/filter_accept_all.c b/archival/libarchive/filter_accept_all.c index c33f7d3e3..5a0ee9c60 100644 --- a/archival/libarchive/filter_accept_all.c +++ b/archival/libarchive/filter_accept_all.c | |||
| @@ -4,7 +4,6 @@ | |||
| 4 | * | 4 | * |
| 5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 6 | */ | 6 | */ |
| 7 | |||
| 8 | #include "libbb.h" | 7 | #include "libbb.h" |
| 9 | #include "bb_archive.h" | 8 | #include "bb_archive.h" |
| 10 | 9 | ||
diff --git a/archival/libarchive/filter_accept_list.c b/archival/libarchive/filter_accept_list.c index a2d4b23e9..32f806574 100644 --- a/archival/libarchive/filter_accept_list.c +++ b/archival/libarchive/filter_accept_list.c | |||
| @@ -4,7 +4,6 @@ | |||
| 4 | * | 4 | * |
| 5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 6 | */ | 6 | */ |
| 7 | |||
| 8 | #include "libbb.h" | 7 | #include "libbb.h" |
| 9 | #include "bb_archive.h" | 8 | #include "bb_archive.h" |
| 10 | 9 | ||
diff --git a/archival/libarchive/filter_accept_list_reassign.c b/archival/libarchive/filter_accept_list_reassign.c index b9acfbc05..826c5c29d 100644 --- a/archival/libarchive/filter_accept_list_reassign.c +++ b/archival/libarchive/filter_accept_list_reassign.c | |||
| @@ -1,10 +1,9 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (C) 2002 by Glenn McGrath | 3 | * Copyright (C) 2002 by Glenn McGrath |
| 4 | * | 4 | * |
| 5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 6 | */ | 6 | */ |
| 7 | |||
| 8 | #include "libbb.h" | 7 | #include "libbb.h" |
| 9 | #include "bb_archive.h" | 8 | #include "bb_archive.h" |
| 10 | 9 | ||
diff --git a/archival/libarchive/filter_accept_reject_list.c b/archival/libarchive/filter_accept_reject_list.c index 248374941..939e626fa 100644 --- a/archival/libarchive/filter_accept_reject_list.c +++ b/archival/libarchive/filter_accept_reject_list.c | |||
| @@ -4,7 +4,6 @@ | |||
| 4 | * | 4 | * |
| 5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 6 | */ | 6 | */ |
| 7 | |||
| 8 | #include "libbb.h" | 7 | #include "libbb.h" |
| 9 | #include "bb_archive.h" | 8 | #include "bb_archive.h" |
| 10 | 9 | ||
diff --git a/archival/libarchive/find_list_entry.c b/archival/libarchive/find_list_entry.c index 56032c65a..37726bd3d 100644 --- a/archival/libarchive/find_list_entry.c +++ b/archival/libarchive/find_list_entry.c | |||
| @@ -4,7 +4,6 @@ | |||
| 4 | * | 4 | * |
| 5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 6 | */ | 6 | */ |
| 7 | |||
| 8 | #include <fnmatch.h> | 7 | #include <fnmatch.h> |
| 9 | #include "libbb.h" | 8 | #include "libbb.h" |
| 10 | #include "bb_archive.h" | 9 | #include "bb_archive.h" |
diff --git a/archival/libarchive/get_header_ar.c b/archival/libarchive/get_header_ar.c index c66bb3ee7..1809ec396 100644 --- a/archival/libarchive/get_header_ar.c +++ b/archival/libarchive/get_header_ar.c | |||
| @@ -1,9 +1,9 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* Copyright 2001 Glenn McGrath. | 2 | /* |
| 3 | * Copyright 2001 Glenn McGrath. | ||
| 3 | * | 4 | * |
| 4 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 5 | */ | 6 | */ |
| 6 | |||
| 7 | #include "libbb.h" | 7 | #include "libbb.h" |
| 8 | #include "bb_archive.h" | 8 | #include "bb_archive.h" |
| 9 | #include "ar.h" | 9 | #include "ar.h" |
diff --git a/archival/libarchive/get_header_cpio.c b/archival/libarchive/get_header_cpio.c index badd4a841..75fc6a406 100644 --- a/archival/libarchive/get_header_cpio.c +++ b/archival/libarchive/get_header_cpio.c | |||
| @@ -1,9 +1,9 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* Copyright 2002 Laurence Anderson | 2 | /* |
| 3 | * Copyright 2002 Laurence Anderson | ||
| 3 | * | 4 | * |
| 4 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 5 | */ | 6 | */ |
| 6 | |||
| 7 | #include "libbb.h" | 7 | #include "libbb.h" |
| 8 | #include "bb_archive.h" | 8 | #include "bb_archive.h" |
| 9 | 9 | ||
diff --git a/archival/libarchive/get_header_tar.c b/archival/libarchive/get_header_tar.c index c7e3bc16e..aeb54190f 100644 --- a/archival/libarchive/get_header_tar.c +++ b/archival/libarchive/get_header_tar.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* Licensed under GPLv2 or later, see file LICENSE in this source tree. | 2 | /* |
| 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | ||
| 3 | * | 4 | * |
| 4 | * FIXME: | 5 | * FIXME: |
| 5 | * In privileged mode if uname and gname map to a uid and gid then use the | 6 | * In privileged mode if uname and gname map to a uid and gid then use the |
| @@ -10,7 +11,6 @@ | |||
| 10 | * Opengroup's ustar interchange format, | 11 | * Opengroup's ustar interchange format, |
| 11 | * http://www.opengroup.org/onlinepubs/007904975/utilities/pax.html | 12 | * http://www.opengroup.org/onlinepubs/007904975/utilities/pax.html |
| 12 | */ | 13 | */ |
| 13 | |||
| 14 | #include "libbb.h" | 14 | #include "libbb.h" |
| 15 | #include "bb_archive.h" | 15 | #include "bb_archive.h" |
| 16 | 16 | ||
diff --git a/archival/libarchive/get_header_tar_bz2.c b/archival/libarchive/get_header_tar_bz2.c index 78f78a858..c021720ac 100644 --- a/archival/libarchive/get_header_tar_bz2.c +++ b/archival/libarchive/get_header_tar_bz2.c | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | /* | 2 | /* |
| 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 4 | */ | 4 | */ |
| 5 | |||
| 6 | #include "libbb.h" | 5 | #include "libbb.h" |
| 7 | #include "bb_archive.h" | 6 | #include "bb_archive.h" |
| 8 | 7 | ||
diff --git a/archival/libarchive/get_header_tar_gz.c b/archival/libarchive/get_header_tar_gz.c index b11f503dc..793b161a1 100644 --- a/archival/libarchive/get_header_tar_gz.c +++ b/archival/libarchive/get_header_tar_gz.c | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | /* | 2 | /* |
| 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 4 | */ | 4 | */ |
| 5 | |||
| 6 | #include "libbb.h" | 5 | #include "libbb.h" |
| 7 | #include "bb_archive.h" | 6 | #include "bb_archive.h" |
| 8 | 7 | ||
diff --git a/archival/libarchive/get_header_tar_lzma.c b/archival/libarchive/get_header_tar_lzma.c index d228cbc13..15d10adb8 100644 --- a/archival/libarchive/get_header_tar_lzma.c +++ b/archival/libarchive/get_header_tar_lzma.c | |||
| @@ -5,7 +5,6 @@ | |||
| 5 | * | 5 | * |
| 6 | * Licensed under GPLv2, see file LICENSE in this source tree. | 6 | * Licensed under GPLv2, see file LICENSE in this source tree. |
| 7 | */ | 7 | */ |
| 8 | |||
| 9 | #include "libbb.h" | 8 | #include "libbb.h" |
| 10 | #include "bb_archive.h" | 9 | #include "bb_archive.h" |
| 11 | 10 | ||
diff --git a/archival/libarchive/get_header_tar_xz.c b/archival/libarchive/get_header_tar_xz.c index 7bf3b3b56..852c989ce 100644 --- a/archival/libarchive/get_header_tar_xz.c +++ b/archival/libarchive/get_header_tar_xz.c | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | /* | 2 | /* |
| 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 4 | */ | 4 | */ |
| 5 | |||
| 6 | #include "libbb.h" | 5 | #include "libbb.h" |
| 7 | #include "bb_archive.h" | 6 | #include "bb_archive.h" |
| 8 | 7 | ||
diff --git a/archival/libarchive/header_verbose_list.c b/archival/libarchive/header_verbose_list.c index 87dd82136..be5140f8b 100644 --- a/archival/libarchive/header_verbose_list.c +++ b/archival/libarchive/header_verbose_list.c | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | /* | 2 | /* |
| 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 4 | */ | 4 | */ |
| 5 | |||
| 6 | #include "libbb.h" | 5 | #include "libbb.h" |
| 7 | #include "bb_archive.h" | 6 | #include "bb_archive.h" |
| 8 | 7 | ||
diff --git a/archival/libarchive/init_handle.c b/archival/libarchive/init_handle.c index dcba6666f..4c64dac58 100644 --- a/archival/libarchive/init_handle.c +++ b/archival/libarchive/init_handle.c | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | /* | 2 | /* |
| 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 4 | */ | 4 | */ |
| 5 | |||
| 6 | #include "libbb.h" | 5 | #include "libbb.h" |
| 7 | #include "bb_archive.h" | 6 | #include "bb_archive.h" |
| 8 | 7 | ||
diff --git a/archival/libarchive/open_transformer.c b/archival/libarchive/open_transformer.c index 7d912152c..0160a64fe 100644 --- a/archival/libarchive/open_transformer.c +++ b/archival/libarchive/open_transformer.c | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | /* | 2 | /* |
| 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 4 | */ | 4 | */ |
| 5 | |||
| 6 | #include "libbb.h" | 5 | #include "libbb.h" |
| 7 | #include "bb_archive.h" | 6 | #include "bb_archive.h" |
| 8 | 7 | ||
diff --git a/archival/libarchive/seek_by_jump.c b/archival/libarchive/seek_by_jump.c index 4fcd99ac8..232d97e53 100644 --- a/archival/libarchive/seek_by_jump.c +++ b/archival/libarchive/seek_by_jump.c | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | /* | 2 | /* |
| 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 4 | */ | 4 | */ |
| 5 | |||
| 6 | #include "libbb.h" | 5 | #include "libbb.h" |
| 7 | #include "bb_archive.h" | 6 | #include "bb_archive.h" |
| 8 | 7 | ||
diff --git a/archival/libarchive/seek_by_read.c b/archival/libarchive/seek_by_read.c index c0fde9660..df2346354 100644 --- a/archival/libarchive/seek_by_read.c +++ b/archival/libarchive/seek_by_read.c | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | /* | 2 | /* |
| 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 4 | */ | 4 | */ |
| 5 | |||
| 6 | #include "libbb.h" | 5 | #include "libbb.h" |
| 7 | #include "bb_archive.h" | 6 | #include "bb_archive.h" |
| 8 | 7 | ||
diff --git a/archival/libarchive/unpack_ar_archive.c b/archival/libarchive/unpack_ar_archive.c index 0bc030349..4f9f89874 100644 --- a/archival/libarchive/unpack_ar_archive.c +++ b/archival/libarchive/unpack_ar_archive.c | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | /* | 2 | /* |
| 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 4 | */ | 4 | */ |
| 5 | |||
| 6 | #include "libbb.h" | 5 | #include "libbb.h" |
| 7 | #include "bb_archive.h" | 6 | #include "bb_archive.h" |
| 8 | #include "ar.h" | 7 | #include "ar.h" |
diff --git a/archival/libarchive/unsafe_prefix.c b/archival/libarchive/unsafe_prefix.c index 9994f4d94..33e487bf9 100644 --- a/archival/libarchive/unsafe_prefix.c +++ b/archival/libarchive/unsafe_prefix.c | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | /* | 2 | /* |
| 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 4 | */ | 4 | */ |
| 5 | |||
| 6 | #include "libbb.h" | 5 | #include "libbb.h" |
| 7 | #include "bb_archive.h" | 6 | #include "bb_archive.h" |
| 8 | 7 | ||
diff --git a/console-tools/setconsole.c b/console-tools/setconsole.c index bad2b76e4..7f0f9c711 100644 --- a/console-tools/setconsole.c +++ b/console-tools/setconsole.c | |||
| @@ -1,9 +1,9 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* | 2 | /* |
| 3 | * setconsole.c - redirect system console output | 3 | * setconsole.c - redirect system console output |
| 4 | * | 4 | * |
| 5 | * Copyright (C) 2004,2005 Enrik Berkhan <Enrik.Berkhan@inka.de> | 5 | * Copyright (C) 2004,2005 Enrik Berkhan <Enrik.Berkhan@inka.de> |
| 6 | * Copyright (C) 2008 Bernhard Reutner-Fischer | 6 | * Copyright (C) 2008 Bernhard Reutner-Fischer |
| 7 | * | 7 | * |
| 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 9 | */ | 9 | */ |
diff --git a/coreutils/basename.c b/coreutils/basename.c index 566aeebda..812a5e63e 100644 --- a/coreutils/basename.c +++ b/coreutils/basename.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | /* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org) | 9 | /* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org) |
| 11 | * | 10 | * |
| 12 | * Changes: | 11 | * Changes: |
diff --git a/coreutils/date.c b/coreutils/date.c index 5b15ce778..87dc3bbd0 100644 --- a/coreutils/date.c +++ b/coreutils/date.c | |||
| @@ -36,8 +36,8 @@ | |||
| 36 | //config:# defaults to "no": stat's nanosecond field is a bit non-portable | 36 | //config:# defaults to "no": stat's nanosecond field is a bit non-portable |
| 37 | //config:config FEATURE_DATE_NANO | 37 | //config:config FEATURE_DATE_NANO |
| 38 | //config: bool "Support %[num]N nanosecond format specifier" | 38 | //config: bool "Support %[num]N nanosecond format specifier" |
| 39 | //config: default n | 39 | //config: default n # syscall(__NR_clock_gettime) |
| 40 | //config: depends on DATE # syscall(__NR_clock_gettime) | 40 | //config: depends on DATE |
| 41 | //config: select PLATFORM_LINUX | 41 | //config: select PLATFORM_LINUX |
| 42 | //config: help | 42 | //config: help |
| 43 | //config: Support %[num]N format specifier. Adds ~250 bytes of code. | 43 | //config: Support %[num]N format specifier. Adds ~250 bytes of code. |
| @@ -203,6 +203,7 @@ int date_main(int argc UNUSED_PARAM, char **argv) | |||
| 203 | IF_FEATURE_DATE_ISOFMT(, &isofmt_arg, &fmt_str2dt) | 203 | IF_FEATURE_DATE_ISOFMT(, &isofmt_arg, &fmt_str2dt) |
| 204 | ); | 204 | ); |
| 205 | argv += optind; | 205 | argv += optind; |
| 206 | |||
| 206 | maybe_set_utc(opt); | 207 | maybe_set_utc(opt); |
| 207 | 208 | ||
| 208 | if (ENABLE_FEATURE_DATE_ISOFMT && (opt & OPT_TIMESPEC)) { | 209 | if (ENABLE_FEATURE_DATE_ISOFMT && (opt & OPT_TIMESPEC)) { |
| @@ -301,8 +302,6 @@ int date_main(int argc UNUSED_PARAM, char **argv) | |||
| 301 | tm_time.tm_isdst = -1; | 302 | tm_time.tm_isdst = -1; |
| 302 | ts.tv_sec = validate_tm_time(date_str, &tm_time); | 303 | ts.tv_sec = validate_tm_time(date_str, &tm_time); |
| 303 | 304 | ||
| 304 | maybe_set_utc(opt); | ||
| 305 | |||
| 306 | /* if setting time, set it */ | 305 | /* if setting time, set it */ |
| 307 | if ((opt & OPT_SET) && stime(&ts.tv_sec) < 0) { | 306 | if ((opt & OPT_SET) && stime(&ts.tv_sec) < 0) { |
| 308 | bb_perror_msg("can't set date"); | 307 | bb_perror_msg("can't set date"); |
diff --git a/coreutils/df.c b/coreutils/df.c index 121da970b..4076b5fec 100644 --- a/coreutils/df.c +++ b/coreutils/df.c | |||
| @@ -77,7 +77,7 @@ | |||
| 77 | //usage: "/dev/sda3 17381728 17107080 274648 98% /\n" | 77 | //usage: "/dev/sda3 17381728 17107080 274648 98% /\n" |
| 78 | 78 | ||
| 79 | #include <mntent.h> | 79 | #include <mntent.h> |
| 80 | #include <sys/vfs.h> | 80 | #include <sys/statvfs.h> |
| 81 | #include "libbb.h" | 81 | #include "libbb.h" |
| 82 | #include "unicode.h" | 82 | #include "unicode.h" |
| 83 | 83 | ||
| @@ -98,7 +98,7 @@ int df_main(int argc UNUSED_PARAM, char **argv) | |||
| 98 | unsigned opt; | 98 | unsigned opt; |
| 99 | FILE *mount_table; | 99 | FILE *mount_table; |
| 100 | struct mntent *mount_entry; | 100 | struct mntent *mount_entry; |
| 101 | struct statfs s; | 101 | struct statvfs s; |
| 102 | 102 | ||
| 103 | enum { | 103 | enum { |
| 104 | OPT_KILO = (1 << 0), | 104 | OPT_KILO = (1 << 0), |
| @@ -211,7 +211,7 @@ int df_main(int argc UNUSED_PARAM, char **argv) | |||
| 211 | mount_point = mount_entry->mnt_dir; | 211 | mount_point = mount_entry->mnt_dir; |
| 212 | fs_type = mount_entry->mnt_type; | 212 | fs_type = mount_entry->mnt_type; |
| 213 | 213 | ||
| 214 | if (statfs(mount_point, &s) != 0) { | 214 | if (statvfs(mount_point, &s) != 0) { |
| 215 | bb_simple_perror_msg(mount_point); | 215 | bb_simple_perror_msg(mount_point); |
| 216 | goto set_error; | 216 | goto set_error; |
| 217 | } | 217 | } |
diff --git a/coreutils/fold.c b/coreutils/fold.c index 286db228d..1e26dde0c 100644 --- a/coreutils/fold.c +++ b/coreutils/fold.c | |||
| @@ -1,14 +1,15 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* fold -- wrap each input line to fit in specified width. | 2 | /* |
| 3 | 3 | * fold -- wrap each input line to fit in specified width. | |
| 4 | Written by David MacKenzie, djm@gnu.ai.mit.edu. | 4 | * |
| 5 | Copyright (C) 91, 1995-2002 Free Software Foundation, Inc. | 5 | * Written by David MacKenzie, djm@gnu.ai.mit.edu. |
| 6 | 6 | * Copyright (C) 91, 1995-2002 Free Software Foundation, Inc. | |
| 7 | Modified for busybox based on coreutils v 5.0 | 7 | * |
| 8 | Copyright (C) 2003 Glenn McGrath | 8 | * Modified for busybox based on coreutils v 5.0 |
| 9 | 9 | * Copyright (C) 2003 Glenn McGrath | |
| 10 | Licensed under GPLv2 or later, see file LICENSE in this source tree. | 10 | * |
| 11 | */ | 11 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 12 | */ | ||
| 12 | //config:config FOLD | 13 | //config:config FOLD |
| 13 | //config: bool "fold (4.6 kb)" | 14 | //config: bool "fold (4.6 kb)" |
| 14 | //config: default y | 15 | //config: default y |
diff --git a/coreutils/libcoreutils/coreutils.h b/coreutils/libcoreutils/coreutils.h index 307d0330a..ad102e423 100644 --- a/coreutils/libcoreutils/coreutils.h +++ b/coreutils/libcoreutils/coreutils.h | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | /* | 2 | /* |
| 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 4 | */ | 4 | */ |
| 5 | |||
| 6 | #ifndef COREUTILS_H | 5 | #ifndef COREUTILS_H |
| 7 | #define COREUTILS_H 1 | 6 | #define COREUTILS_H 1 |
| 8 | 7 | ||
diff --git a/coreutils/libcoreutils/cp_mv_stat.c b/coreutils/libcoreutils/cp_mv_stat.c index 5ba07ecc3..26c0e1645 100644 --- a/coreutils/libcoreutils/cp_mv_stat.c +++ b/coreutils/libcoreutils/cp_mv_stat.c | |||
| @@ -17,9 +17,7 @@ | |||
| 17 | * You should have received a copy of the GNU General Public License | 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software | 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 | * | ||
| 21 | */ | 20 | */ |
| 22 | |||
| 23 | #include "libbb.h" | 21 | #include "libbb.h" |
| 24 | #include "coreutils.h" | 22 | #include "coreutils.h" |
| 25 | 23 | ||
diff --git a/coreutils/libcoreutils/getopt_mk_fifo_nod.c b/coreutils/libcoreutils/getopt_mk_fifo_nod.c index 47375ff91..dafe70edf 100644 --- a/coreutils/libcoreutils/getopt_mk_fifo_nod.c +++ b/coreutils/libcoreutils/getopt_mk_fifo_nod.c | |||
| @@ -17,9 +17,7 @@ | |||
| 17 | * You should have received a copy of the GNU General Public License | 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software | 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 | * | ||
| 21 | */ | 20 | */ |
| 22 | |||
| 23 | #include "libbb.h" | 21 | #include "libbb.h" |
| 24 | #include "coreutils.h" | 22 | #include "coreutils.h" |
| 25 | 23 | ||
diff --git a/coreutils/md5_sha1_sum.c b/coreutils/md5_sha1_sum.c index 89d6cec0b..ccdfd6855 100644 --- a/coreutils/md5_sha1_sum.c +++ b/coreutils/md5_sha1_sum.c | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (C) 2003 Glenn L. McGrath | 3 | * Copyright (C) 2003 Glenn L. McGrath |
| 4 | * Copyright (C) 2003-2004 Erik Andersen | 4 | * Copyright (C) 2003-2004 Erik Andersen |
| 5 | * | 5 | * |
| 6 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 6 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 7 | */ | 7 | */ |
diff --git a/coreutils/mktemp.c b/coreutils/mktemp.c index d4ff883fa..c041fedf7 100644 --- a/coreutils/mktemp.c +++ b/coreutils/mktemp.c | |||
| @@ -2,13 +2,11 @@ | |||
| 2 | /* | 2 | /* |
| 3 | * Mini mktemp implementation for busybox | 3 | * Mini mktemp implementation for busybox |
| 4 | * | 4 | * |
| 5 | * | ||
| 6 | * Copyright (C) 2000 by Daniel Jacobowitz | 5 | * Copyright (C) 2000 by Daniel Jacobowitz |
| 7 | * Written by Daniel Jacobowitz <dan@debian.org> | 6 | * Written by Daniel Jacobowitz <dan@debian.org> |
| 8 | * | 7 | * |
| 9 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 10 | */ | 9 | */ |
| 11 | |||
| 12 | /* Coreutils 6.12 man page says: | 10 | /* Coreutils 6.12 man page says: |
| 13 | * mktemp [OPTION]... [TEMPLATE] | 11 | * mktemp [OPTION]... [TEMPLATE] |
| 14 | * Create a temporary file or directory, safely, and print its name. If | 12 | * Create a temporary file or directory, safely, and print its name. If |
diff --git a/coreutils/nohup.c b/coreutils/nohup.c index 8a70ec4df..ae136e085 100644 --- a/coreutils/nohup.c +++ b/coreutils/nohup.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* nohup - invoke a utility immune to hangups. | 2 | /* |
| 3 | * nohup - invoke a utility immune to hangups. | ||
| 3 | * | 4 | * |
| 4 | * Busybox version based on nohup specification at | 5 | * Busybox version based on nohup specification at |
| 5 | * http://www.opengroup.org/onlinepubs/007904975/utilities/nohup.html | 6 | * http://www.opengroup.org/onlinepubs/007904975/utilities/nohup.html |
diff --git a/coreutils/printf.c b/coreutils/printf.c index 353cfc608..a666ff7ac 100644 --- a/coreutils/printf.c +++ b/coreutils/printf.c | |||
| @@ -1,41 +1,40 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* printf - format and print data | 2 | /* |
| 3 | 3 | * printf - format and print data | |
| 4 | Copyright 1999 Dave Cinege | 4 | * |
| 5 | Portions copyright (C) 1990-1996 Free Software Foundation, Inc. | 5 | * Copyright 1999 Dave Cinege |
| 6 | 6 | * Portions copyright (C) 1990-1996 Free Software Foundation, Inc. | |
| 7 | Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * |
| 8 | */ | 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 9 | 9 | */ | |
| 10 | /* Usage: printf format [argument...] | 10 | /* Usage: printf format [argument...] |
| 11 | 11 | * | |
| 12 | A front end to the printf function that lets it be used from the shell. | 12 | * A front end to the printf function that lets it be used from the shell. |
| 13 | 13 | * | |
| 14 | Backslash escapes: | 14 | * Backslash escapes: |
| 15 | 15 | * | |
| 16 | \" = double quote | 16 | * \" = double quote |
| 17 | \\ = backslash | 17 | * \\ = backslash |
| 18 | \a = alert (bell) | 18 | * \a = alert (bell) |
| 19 | \b = backspace | 19 | * \b = backspace |
| 20 | \c = produce no further output | 20 | * \c = produce no further output |
| 21 | \f = form feed | 21 | * \f = form feed |
| 22 | \n = new line | 22 | * \n = new line |
| 23 | \r = carriage return | 23 | * \r = carriage return |
| 24 | \t = horizontal tab | 24 | * \t = horizontal tab |
| 25 | \v = vertical tab | 25 | * \v = vertical tab |
| 26 | \0ooo = octal number (ooo is 0 to 3 digits) | 26 | * \0ooo = octal number (ooo is 0 to 3 digits) |
| 27 | \xhhh = hexadecimal number (hhh is 1 to 3 digits) | 27 | * \xhhh = hexadecimal number (hhh is 1 to 3 digits) |
| 28 | 28 | * | |
| 29 | Additional directive: | 29 | * Additional directive: |
| 30 | 30 | * | |
| 31 | %b = print an argument string, interpreting backslash escapes | 31 | * %b = print an argument string, interpreting backslash escapes |
| 32 | 32 | * | |
| 33 | The 'format' argument is re-used as many times as necessary | 33 | * The 'format' argument is re-used as many times as necessary |
| 34 | to convert all of the given arguments. | 34 | * to convert all of the given arguments. |
| 35 | 35 | * | |
| 36 | David MacKenzie <djm@gnu.ai.mit.edu> | 36 | * David MacKenzie <djm@gnu.ai.mit.edu> |
| 37 | */ | 37 | */ |
| 38 | |||
| 39 | /* 19990508 Busy Boxed! Dave Cinege */ | 38 | /* 19990508 Busy Boxed! Dave Cinege */ |
| 40 | 39 | ||
| 41 | //config:config PRINTF | 40 | //config:config PRINTF |
diff --git a/coreutils/realpath.c b/coreutils/realpath.c index f9c630135..aa878fcd2 100644 --- a/coreutils/realpath.c +++ b/coreutils/realpath.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org) | 2 | /* |
| 3 | * Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org) | ||
| 3 | * | 4 | * |
| 4 | * Now does proper error checking on output and returns a failure exit code | 5 | * Now does proper error checking on output and returns a failure exit code |
| 5 | * if one or more paths cannot be resolved. | 6 | * if one or more paths cannot be resolved. |
diff --git a/coreutils/stty.c b/coreutils/stty.c index b6e836364..424d909cf 100644 --- a/coreutils/stty.c +++ b/coreutils/stty.c | |||
| @@ -1,24 +1,25 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* stty -- change and print terminal line settings | 2 | /* |
| 3 | Copyright (C) 1990-1999 Free Software Foundation, Inc. | 3 | * stty -- change and print terminal line settings |
| 4 | 4 | * Copyright (C) 1990-1999 Free Software Foundation, Inc. | |
| 5 | Licensed under GPLv2 or later, see file LICENSE in this source tree. | 5 | * |
| 6 | */ | 6 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 7 | */ | ||
| 7 | /* Usage: stty [-ag] [-F device] [setting...] | 8 | /* Usage: stty [-ag] [-F device] [setting...] |
| 8 | 9 | * | |
| 9 | Options: | 10 | * Options: |
| 10 | -a Write all current settings to stdout in human-readable form. | 11 | * -a Write all current settings to stdout in human-readable form. |
| 11 | -g Write all current settings to stdout in stty-readable form. | 12 | * -g Write all current settings to stdout in stty-readable form. |
| 12 | -F Open and use the specified device instead of stdin | 13 | * -F Open and use the specified device instead of stdin |
| 13 | 14 | * | |
| 14 | If no args are given, write to stdout the baud rate and settings that | 15 | * If no args are given, write to stdout the baud rate and settings that |
| 15 | have been changed from their defaults. Mode reading and changes | 16 | * have been changed from their defaults. Mode reading and changes |
| 16 | are done on the specified device, or stdin if none was specified. | 17 | * are done on the specified device, or stdin if none was specified. |
| 17 | 18 | * | |
| 18 | David MacKenzie <djm@gnu.ai.mit.edu> | 19 | * David MacKenzie <djm@gnu.ai.mit.edu> |
| 19 | 20 | * | |
| 20 | Special for busybox ported by Vladimir Oleynik <dzo@simtreas.ru> 2001 | 21 | * Special for busybox ported by Vladimir Oleynik <dzo@simtreas.ru> 2001 |
| 21 | */ | 22 | */ |
| 22 | //config:config STTY | 23 | //config:config STTY |
| 23 | //config: bool "stty (8.6 kb)" | 24 | //config: bool "stty (8.6 kb)" |
| 24 | //config: default y | 25 | //config: default y |
diff --git a/coreutils/tr.c b/coreutils/tr.c index c5872434a..10284e1c9 100644 --- a/coreutils/tr.c +++ b/coreutils/tr.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | /* | 2 | /* |
| 3 | * Mini tr implementation for busybox | 3 | * Mini tr implementation for busybox |
| 4 | * | 4 | * |
| 5 | ** Copyright (c) 1987,1997, Prentice Hall All rights reserved. | 5 | * Copyright (c) 1987,1997, Prentice Hall All rights reserved. |
| 6 | * | 6 | * |
| 7 | * The name of Prentice Hall may not be used to endorse or promote | 7 | * The name of Prentice Hall may not be used to endorse or promote |
| 8 | * products derived from this software without specific prior | 8 | * products derived from this software without specific prior |
diff --git a/coreutils/uname.c b/coreutils/uname.c index bb2d1fe8d..57039b1bf 100644 --- a/coreutils/uname.c +++ b/coreutils/uname.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* uname -- print system information | 2 | /* |
| 3 | * uname -- print system information | ||
| 3 | * Copyright (C) 1989-1999 Free Software Foundation, Inc. | 4 | * Copyright (C) 1989-1999 Free Software Foundation, Inc. |
| 4 | * | 5 | * |
| 5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 6 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
diff --git a/coreutils/unlink.c b/coreutils/unlink.c index 56309b1c7..61b108a84 100644 --- a/coreutils/unlink.c +++ b/coreutils/unlink.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* unlink for busybox | 2 | /* |
| 3 | * unlink for busybox | ||
| 3 | * | 4 | * |
| 4 | * Copyright (C) 2014 Isaac Dunham <ibid.ag@gmail.com> | 5 | * Copyright (C) 2014 Isaac Dunham <ibid.ag@gmail.com> |
| 5 | * | 6 | * |
diff --git a/coreutils/uuencode.c b/coreutils/uuencode.c index d6e077430..aa53b14a6 100644 --- a/coreutils/uuencode.c +++ b/coreutils/uuencode.c | |||
| @@ -1,9 +1,9 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (C) 2000 by Glenn McGrath | 3 | * Copyright (C) 2000 by Glenn McGrath |
| 4 | * | 4 | * |
| 5 | * based on the function base64_encode from http.c in wget v1.6 | 5 | * based on the function base64_encode from http.c in wget v1.6 |
| 6 | * Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc. | 6 | * Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc. |
| 7 | * | 7 | * |
| 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 9 | */ | 9 | */ |
diff --git a/coreutils/who.c b/coreutils/who.c index cfe0c921e..80226c3d6 100644 --- a/coreutils/who.c +++ b/coreutils/who.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /*---------------------------------------------------------------------- | 2 | /* |
| 3 | * Mini who is used to display user name, login time, | 3 | * Mini who is used to display user name, login time, |
| 4 | * idle time and host name. | 4 | * idle time and host name. |
| 5 | * | 5 | * |
| @@ -13,8 +13,6 @@ | |||
| 13 | * Copyright (c) 2002 AYR Networks, Inc. | 13 | * Copyright (c) 2002 AYR Networks, Inc. |
| 14 | * | 14 | * |
| 15 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 15 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 16 | * | ||
| 17 | *---------------------------------------------------------------------- | ||
| 18 | */ | 16 | */ |
| 19 | //config:config WHO | 17 | //config:config WHO |
| 20 | //config: bool "who (3.7 kb)" | 18 | //config: bool "who (3.7 kb)" |
diff --git a/editors/vi.c b/editors/vi.c index 8393eb825..b54dd98dc 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
| @@ -1038,7 +1038,7 @@ static void colon(char *buf) | |||
| 1038 | } | 1038 | } |
| 1039 | if (cnt < 0) { | 1039 | if (cnt < 0) { |
| 1040 | if (cnt == -1) | 1040 | if (cnt == -1) |
| 1041 | status_line_bold("Write error: %s", strerror(errno)); | 1041 | status_line_bold("Write error: "STRERROR_FMT STRERROR_ERRNO); |
| 1042 | } else { | 1042 | } else { |
| 1043 | modified_count = 0; | 1043 | modified_count = 0; |
| 1044 | last_modified_count = -1; | 1044 | last_modified_count = -1; |
| @@ -3183,7 +3183,7 @@ static void status_line_bold(const char *format, ...) | |||
| 3183 | 3183 | ||
| 3184 | static void status_line_bold_errno(const char *fn) | 3184 | static void status_line_bold_errno(const char *fn) |
| 3185 | { | 3185 | { |
| 3186 | status_line_bold("'%s' %s", fn, strerror(errno)); | 3186 | status_line_bold("'%s' "STRERROR_FMT, fn STRERROR_ERRNO); |
| 3187 | } | 3187 | } |
| 3188 | 3188 | ||
| 3189 | // format status buffer | 3189 | // format status buffer |
| @@ -4113,7 +4113,7 @@ static void do_cmd(int c) | |||
| 4113 | cnt = file_write(current_filename, text, end - 1); | 4113 | cnt = file_write(current_filename, text, end - 1); |
| 4114 | if (cnt < 0) { | 4114 | if (cnt < 0) { |
| 4115 | if (cnt == -1) | 4115 | if (cnt == -1) |
| 4116 | status_line_bold("Write error: %s", strerror(errno)); | 4116 | status_line_bold("Write error: "STRERROR_FMT STRERROR_ERRNO); |
| 4117 | } else if (cnt == (end - 1 - text + 1)) { | 4117 | } else if (cnt == (end - 1 - text + 1)) { |
| 4118 | editing = 0; | 4118 | editing = 0; |
| 4119 | } | 4119 | } |
diff --git a/findutils/grep.c b/findutils/grep.c index f72175afb..fc6de4b69 100644 --- a/findutils/grep.c +++ b/findutils/grep.c | |||
| @@ -639,11 +639,28 @@ static void load_regexes_from_file(llist_t *fopt) | |||
| 639 | } | 639 | } |
| 640 | 640 | ||
| 641 | static int FAST_FUNC file_action_grep(const char *filename, | 641 | static int FAST_FUNC file_action_grep(const char *filename, |
| 642 | struct stat *statbuf UNUSED_PARAM, | 642 | struct stat *statbuf, |
| 643 | void* matched, | 643 | void* matched, |
| 644 | int depth UNUSED_PARAM) | 644 | int depth UNUSED_PARAM) |
| 645 | { | 645 | { |
| 646 | FILE *file = fopen_for_read(filename); | 646 | FILE *file; |
| 647 | |||
| 648 | /* If we are given a link to a directory, we should bail out now, rather | ||
| 649 | * than trying to open the "file" and hoping getline gives us nothing, | ||
| 650 | * since that is not portable across operating systems (FreeBSD for | ||
| 651 | * example will return the raw directory contents). */ | ||
| 652 | if (S_ISLNK(statbuf->st_mode)) { | ||
| 653 | struct stat sb; | ||
| 654 | if (stat(filename, &sb) != 0) { | ||
| 655 | if (!SUPPRESS_ERR_MSGS) | ||
| 656 | bb_simple_perror_msg(filename); | ||
| 657 | return 0; | ||
| 658 | } | ||
| 659 | if (S_ISDIR(sb.st_mode)) | ||
| 660 | return 1; | ||
| 661 | } | ||
| 662 | |||
| 663 | file = fopen_for_read(filename); | ||
| 647 | if (file == NULL) { | 664 | if (file == NULL) { |
| 648 | if (!SUPPRESS_ERR_MSGS) | 665 | if (!SUPPRESS_ERR_MSGS) |
| 649 | bb_simple_perror_msg(filename); | 666 | bb_simple_perror_msg(filename); |
diff --git a/include/libbb.h b/include/libbb.h index 136bc33f5..5be5684da 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
| @@ -168,6 +168,17 @@ | |||
| 168 | #ifndef HAVE_XTABS | 168 | #ifndef HAVE_XTABS |
| 169 | # define XTABS TAB3 | 169 | # define XTABS TAB3 |
| 170 | #endif | 170 | #endif |
| 171 | /* | ||
| 172 | * Use '%m' to append error string on platforms that support it, | ||
| 173 | * '%s' and strerror() on those that don't. | ||
| 174 | */ | ||
| 175 | #ifdef HAVE_PRINTF_PERCENTM | ||
| 176 | # define STRERROR_FMT "%m" | ||
| 177 | # define STRERROR_ERRNO /*nothing*/ | ||
| 178 | #else | ||
| 179 | # define STRERROR_FMT "%s" | ||
| 180 | # define STRERROR_ERRNO ,strerror(errno) | ||
| 181 | #endif | ||
| 171 | 182 | ||
| 172 | 183 | ||
| 173 | /* Some libc's forget to declare these, do it ourself */ | 184 | /* Some libc's forget to declare these, do it ourself */ |
diff --git a/init/init.c b/init/init.c index 64e5c3e0b..6f3374eac 100644 --- a/init/init.c +++ b/init/init.c | |||
| @@ -391,8 +391,10 @@ static int open_stdio_to_tty(const char* tty_name) | |||
| 391 | /* fd can be only < 0 or 0: */ | 391 | /* fd can be only < 0 or 0: */ |
| 392 | fd = device_open(tty_name, O_RDWR); | 392 | fd = device_open(tty_name, O_RDWR); |
| 393 | if (fd) { | 393 | if (fd) { |
| 394 | message(L_LOG | L_CONSOLE, "can't open %s: %s", | 394 | message(L_LOG | L_CONSOLE, "can't open %s: "STRERROR_FMT, |
| 395 | tty_name, strerror(errno)); | 395 | tty_name |
| 396 | STRERROR_ERRNO | ||
| 397 | ); | ||
| 396 | return 0; /* failure */ | 398 | return 0; /* failure */ |
| 397 | } | 399 | } |
| 398 | dup2(STDIN_FILENO, STDOUT_FILENO); | 400 | dup2(STDIN_FILENO, STDOUT_FILENO); |
| @@ -469,7 +471,7 @@ static void init_exec(const char *command) | |||
| 469 | } | 471 | } |
| 470 | /* Here command never contains the dash, cmd[0] might */ | 472 | /* Here command never contains the dash, cmd[0] might */ |
| 471 | BB_EXECVP(command, cmd); | 473 | BB_EXECVP(command, cmd); |
| 472 | message(L_LOG | L_CONSOLE, "can't run '%s': %s", command, strerror(errno)); | 474 | message(L_LOG | L_CONSOLE, "can't run '%s': "STRERROR_FMT, command STRERROR_ERRNO); |
| 473 | /* returns if execvp fails */ | 475 | /* returns if execvp fails */ |
| 474 | } | 476 | } |
| 475 | 477 | ||
| @@ -1062,6 +1064,12 @@ int init_main(int argc UNUSED_PARAM, char **argv) | |||
| 1062 | #endif | 1064 | #endif |
| 1063 | 1065 | ||
| 1064 | if (!DEBUG_INIT) { | 1066 | if (!DEBUG_INIT) { |
| 1067 | /* Some users send poweroff signals to init VERY early. | ||
| 1068 | * To handle this, mask signals early, | ||
| 1069 | * and unmask them only after signal handlers are installed. | ||
| 1070 | */ | ||
| 1071 | sigprocmask_allsigs(SIG_BLOCK); | ||
| 1072 | |||
| 1065 | /* Expect to be invoked as init with PID=1 or be invoked as linuxrc */ | 1073 | /* Expect to be invoked as init with PID=1 or be invoked as linuxrc */ |
| 1066 | if (getpid() != 1 | 1074 | if (getpid() != 1 |
| 1067 | && (!ENABLE_LINUXRC || applet_name[0] != 'l') /* not linuxrc? */ | 1075 | && (!ENABLE_LINUXRC || applet_name[0] != 'l') /* not linuxrc? */ |
| @@ -1104,29 +1112,6 @@ int init_main(int argc UNUSED_PARAM, char **argv) | |||
| 1104 | message(L_CONSOLE | L_LOG, "init started: %s", bb_banner); | 1112 | message(L_CONSOLE | L_LOG, "init started: %s", bb_banner); |
| 1105 | #endif | 1113 | #endif |
| 1106 | 1114 | ||
| 1107 | #if 0 | ||
| 1108 | /* It's 2013, does anyone really still depend on this? */ | ||
| 1109 | /* If you do, consider adding swapon to sysinit actions then! */ | ||
| 1110 | /* struct sysinfo is linux-specific */ | ||
| 1111 | # ifdef __linux__ | ||
| 1112 | /* Make sure there is enough memory to do something useful. */ | ||
| 1113 | /*if (ENABLE_SWAPONOFF) - WRONG: we may have non-bbox swapon*/ { | ||
| 1114 | struct sysinfo info; | ||
| 1115 | |||
| 1116 | if (sysinfo(&info) == 0 | ||
| 1117 | && (info.mem_unit ? info.mem_unit : 1) * (long long)info.totalram < 1024*1024 | ||
| 1118 | ) { | ||
| 1119 | message(L_CONSOLE, "Low memory, forcing swapon"); | ||
| 1120 | /* swapon -a requires /proc typically */ | ||
| 1121 | new_init_action(SYSINIT, "mount -t proc proc /proc", ""); | ||
| 1122 | /* Try to turn on swap */ | ||
| 1123 | new_init_action(SYSINIT, "swapon -a", ""); | ||
| 1124 | run_actions(SYSINIT); /* wait and removing */ | ||
| 1125 | } | ||
| 1126 | } | ||
| 1127 | # endif | ||
| 1128 | #endif | ||
| 1129 | |||
| 1130 | /* Check if we are supposed to be in single user mode */ | 1115 | /* Check if we are supposed to be in single user mode */ |
| 1131 | if (argv[1] | 1116 | if (argv[1] |
| 1132 | && (strcmp(argv[1], "single") == 0 || strcmp(argv[1], "-s") == 0 || LONE_CHAR(argv[1], '1')) | 1117 | && (strcmp(argv[1], "single") == 0 || strcmp(argv[1], "-s") == 0 || LONE_CHAR(argv[1], '1')) |
| @@ -1202,6 +1187,8 @@ int init_main(int argc UNUSED_PARAM, char **argv) | |||
| 1202 | + (1 << SIGHUP) /* reread /etc/inittab */ | 1187 | + (1 << SIGHUP) /* reread /etc/inittab */ |
| 1203 | #endif | 1188 | #endif |
| 1204 | , record_signo); | 1189 | , record_signo); |
| 1190 | |||
| 1191 | sigprocmask_allsigs(SIG_UNBLOCK); | ||
| 1205 | } | 1192 | } |
| 1206 | 1193 | ||
| 1207 | /* Now run everything that needs to be run */ | 1194 | /* Now run everything that needs to be run */ |
diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 71ee0dd07..89f76443c 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c | |||
| @@ -11,7 +11,6 @@ | |||
| 11 | * | 11 | * |
| 12 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 12 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 13 | */ | 13 | */ |
| 14 | |||
| 15 | /* We are trying to not use printf, this benefits the case when selected | 14 | /* We are trying to not use printf, this benefits the case when selected |
| 16 | * applets are really simple. Example: | 15 | * applets are really simple. Example: |
| 17 | * | 16 | * |
diff --git a/libbb/ask_confirmation.c b/libbb/ask_confirmation.c index d95729cc9..6fbed89f4 100644 --- a/libbb/ask_confirmation.c +++ b/libbb/ask_confirmation.c | |||
| @@ -6,12 +6,11 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | #include "libbb.h" | ||
| 9 | 10 | ||
| 10 | /* Read a line from stdin. If the first non-whitespace char is 'y' or 'Y', | 11 | /* Read a line from stdin. If the first non-whitespace char is 'y' or 'Y', |
| 11 | * return 1. Otherwise return 0. | 12 | * return 1. Otherwise return 0. |
| 12 | */ | 13 | */ |
| 13 | #include "libbb.h" | ||
| 14 | |||
| 15 | int FAST_FUNC bb_ask_confirmation(void) | 14 | int FAST_FUNC bb_ask_confirmation(void) |
| 16 | { | 15 | { |
| 17 | char first = 0; | 16 | char first = 0; |
diff --git a/libbb/bb_askpass.c b/libbb/bb_askpass.c index c2580b9eb..aae35ec41 100644 --- a/libbb/bb_askpass.c +++ b/libbb/bb_askpass.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | 10 | ||
| 12 | /* do nothing signal handler */ | 11 | /* do nothing signal handler */ |
diff --git a/libbb/bb_do_delay.c b/libbb/bb_do_delay.c index 05c879fb9..65541704b 100644 --- a/libbb/bb_do_delay.c +++ b/libbb/bb_do_delay.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | 10 | ||
| 12 | void FAST_FUNC bb_do_delay(int seconds) | 11 | void FAST_FUNC bb_do_delay(int seconds) |
diff --git a/libbb/bb_pwd.c b/libbb/bb_pwd.c index dca0a150b..32ff83a42 100644 --- a/libbb/bb_pwd.c +++ b/libbb/bb_pwd.c | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | * | 7 | * |
| 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 9 | */ | 9 | */ |
| 10 | |||
| 11 | #include "libbb.h" | 10 | #include "libbb.h" |
| 12 | 11 | ||
| 13 | /* TODO: maybe change API to return malloced data? | 12 | /* TODO: maybe change API to return malloced data? |
diff --git a/libbb/bb_qsort.c b/libbb/bb_qsort.c index a54e7236a..505045533 100644 --- a/libbb/bb_qsort.c +++ b/libbb/bb_qsort.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | 10 | ||
| 12 | int /* not FAST_FUNC! */ bb_pstrcmp(const void *a, const void *b) | 11 | int /* not FAST_FUNC! */ bb_pstrcmp(const void *a, const void *b) |
diff --git a/libbb/bb_strtod.c b/libbb/bb_strtod.c index 5dde78414..5e1d0535e 100644 --- a/libbb/bb_strtod.c +++ b/libbb/bb_strtod.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | #include <math.h> /* just for HUGE_VAL */ | 10 | #include <math.h> /* just for HUGE_VAL */ |
| 12 | 11 | ||
diff --git a/libbb/bb_strtonum.c b/libbb/bb_strtonum.c index 949f26bee..2185017b0 100644 --- a/libbb/bb_strtonum.c +++ b/libbb/bb_strtonum.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | 10 | ||
| 12 | /* On exit: errno = 0 only if there was non-empty, '\0' terminated value | 11 | /* On exit: errno = 0 only if there was non-empty, '\0' terminated value |
diff --git a/libbb/bbunit.c b/libbb/bbunit.c index db67b1081..5f8d980a3 100644 --- a/libbb/bbunit.c +++ b/libbb/bbunit.c | |||
| @@ -6,9 +6,9 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | //applet:IF_UNIT_TEST(APPLET(unit, BB_DIR_USR_BIN, BB_SUID_DROP)) | ||
| 9 | 10 | ||
| 10 | //kbuild:lib-$(CONFIG_UNIT_TEST) += bbunit.o | 11 | //kbuild:lib-$(CONFIG_UNIT_TEST) += bbunit.o |
| 11 | //applet:IF_UNIT_TEST(APPLET(unit, BB_DIR_USR_BIN, BB_SUID_DROP)) | ||
| 12 | 12 | ||
| 13 | //usage:#define unit_trivial_usage | 13 | //usage:#define unit_trivial_usage |
| 14 | //usage: "" | 14 | //usage: "" |
diff --git a/libbb/change_identity.c b/libbb/change_identity.c index 431f72c8c..20d7c5f2d 100644 --- a/libbb/change_identity.c +++ b/libbb/change_identity.c | |||
| @@ -27,7 +27,6 @@ | |||
| 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 28 | * SUCH DAMAGE. | 28 | * SUCH DAMAGE. |
| 29 | */ | 29 | */ |
| 30 | |||
| 31 | #include "libbb.h" | 30 | #include "libbb.h" |
| 32 | 31 | ||
| 33 | /* Become the user and group(s) specified by PW. */ | 32 | /* Become the user and group(s) specified by PW. */ |
diff --git a/libbb/chomp.c b/libbb/chomp.c index cb92befb1..3757bff2e 100644 --- a/libbb/chomp.c +++ b/libbb/chomp.c | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | * | 7 | * |
| 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 9 | */ | 9 | */ |
| 10 | |||
| 11 | #include "libbb.h" | 10 | #include "libbb.h" |
| 12 | 11 | ||
| 13 | void FAST_FUNC chomp(char *s) | 12 | void FAST_FUNC chomp(char *s) |
diff --git a/libbb/compare_string_array.c b/libbb/compare_string_array.c index 2f51237a3..01a9df0e2 100644 --- a/libbb/compare_string_array.c +++ b/libbb/compare_string_array.c | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | /* | 2 | /* |
| 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 4 | */ | 4 | */ |
| 5 | |||
| 6 | #include "libbb.h" | 5 | #include "libbb.h" |
| 7 | 6 | ||
| 8 | /* | 7 | /* |
diff --git a/libbb/concat_path_file.c b/libbb/concat_path_file.c index 9ed295996..5b4b7f113 100644 --- a/libbb/concat_path_file.c +++ b/libbb/concat_path_file.c | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | * | 7 | * |
| 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 9 | */ | 9 | */ |
| 10 | #include "libbb.h" | ||
| 10 | 11 | ||
| 11 | /* Concatenate path and filename to new allocated buffer. | 12 | /* Concatenate path and filename to new allocated buffer. |
| 12 | * Add '/' only as needed (no duplicate // are produced). | 13 | * Add '/' only as needed (no duplicate // are produced). |
| @@ -14,8 +15,6 @@ | |||
| 14 | * filename should not be NULL. | 15 | * filename should not be NULL. |
| 15 | */ | 16 | */ |
| 16 | 17 | ||
| 17 | #include "libbb.h" | ||
| 18 | |||
| 19 | char* FAST_FUNC concat_path_file(const char *path, const char *filename) | 18 | char* FAST_FUNC concat_path_file(const char *path, const char *filename) |
| 20 | { | 19 | { |
| 21 | char *lc; | 20 | char *lc; |
diff --git a/libbb/concat_subpath_file.c b/libbb/concat_subpath_file.c index c9167d492..bc2ee96ca 100644 --- a/libbb/concat_subpath_file.c +++ b/libbb/concat_subpath_file.c | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | #include "libbb.h" | ||
| 9 | 10 | ||
| 10 | /* | 11 | /* |
| 11 | This function make special for recursive actions with usage | 12 | This function make special for recursive actions with usage |
| @@ -13,8 +14,6 @@ | |||
| 13 | and skipping "." and ".." directory entries | 14 | and skipping "." and ".." directory entries |
| 14 | */ | 15 | */ |
| 15 | 16 | ||
| 16 | #include "libbb.h" | ||
| 17 | |||
| 18 | char* FAST_FUNC concat_subpath_file(const char *path, const char *f) | 17 | char* FAST_FUNC concat_subpath_file(const char *path, const char *f) |
| 19 | { | 18 | { |
| 20 | if (f && DOT_OR_DOTDOT(f)) | 19 | if (f && DOT_OR_DOTDOT(f)) |
diff --git a/libbb/copyfd.c b/libbb/copyfd.c index 921fe3f81..dd0517cd6 100644 --- a/libbb/copyfd.c +++ b/libbb/copyfd.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | #if ENABLE_FEATURE_USE_SENDFILE | 10 | #if ENABLE_FEATURE_USE_SENDFILE |
| 12 | # include <sys/sendfile.h> | 11 | # include <sys/sendfile.h> |
diff --git a/libbb/correct_password.c b/libbb/correct_password.c index 51928f68d..a6f7d9b3d 100644 --- a/libbb/correct_password.c +++ b/libbb/correct_password.c | |||
| @@ -27,7 +27,6 @@ | |||
| 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 28 | * SUCH DAMAGE. | 28 | * SUCH DAMAGE. |
| 29 | */ | 29 | */ |
| 30 | |||
| 31 | #include "libbb.h" | 30 | #include "libbb.h" |
| 32 | 31 | ||
| 33 | #define SHADOW_BUFSIZE 256 | 32 | #define SHADOW_BUFSIZE 256 |
diff --git a/libbb/crc32.c b/libbb/crc32.c index 0711ca84e..b00b580d0 100644 --- a/libbb/crc32.c +++ b/libbb/crc32.c | |||
| @@ -15,7 +15,6 @@ | |||
| 15 | * | 15 | * |
| 16 | * Licensed under GPLv2, see file LICENSE in this source tree. | 16 | * Licensed under GPLv2, see file LICENSE in this source tree. |
| 17 | */ | 17 | */ |
| 18 | |||
| 19 | #include "libbb.h" | 18 | #include "libbb.h" |
| 20 | 19 | ||
| 21 | uint32_t *global_crc32_table; | 20 | uint32_t *global_crc32_table; |
diff --git a/libbb/default_error_retval.c b/libbb/default_error_retval.c index 4f6395fa2..fc6a5364a 100644 --- a/libbb/default_error_retval.c +++ b/libbb/default_error_retval.c | |||
| @@ -4,7 +4,6 @@ | |||
| 4 | * | 4 | * |
| 5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 6 | */ | 6 | */ |
| 7 | |||
| 8 | /* Seems silly to copyright a global variable. ;-) Oh well. | 7 | /* Seems silly to copyright a global variable. ;-) Oh well. |
| 9 | * | 8 | * |
| 10 | * At least one applet (cmp) returns a value different from the typical | 9 | * At least one applet (cmp) returns a value different from the typical |
| @@ -12,7 +11,6 @@ | |||
| 12 | * by the applet. I suppose we could use a wrapper function to set it, but | 11 | * by the applet. I suppose we could use a wrapper function to set it, but |
| 13 | * that too seems silly. | 12 | * that too seems silly. |
| 14 | */ | 13 | */ |
| 15 | |||
| 16 | #include "libbb.h" | 14 | #include "libbb.h" |
| 17 | 15 | ||
| 18 | uint8_t xfunc_error_retval = EXIT_FAILURE; | 16 | uint8_t xfunc_error_retval = EXIT_FAILURE; |
diff --git a/libbb/device_open.c b/libbb/device_open.c index a8fe2fcb4..e5639c712 100644 --- a/libbb/device_open.c +++ b/libbb/device_open.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | 10 | ||
| 12 | /* try to open up the specified device */ | 11 | /* try to open up the specified device */ |
diff --git a/libbb/die_if_bad_username.c b/libbb/die_if_bad_username.c index cf1297bd6..46f103340 100644 --- a/libbb/die_if_bad_username.c +++ b/libbb/die_if_bad_username.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | 10 | ||
| 12 | /* To avoid problems, the username should consist only of | 11 | /* To avoid problems, the username should consist only of |
diff --git a/libbb/dump.c b/libbb/dump.c index e23b71294..db91fcfe7 100644 --- a/libbb/dump.c +++ b/libbb/dump.c | |||
| @@ -10,7 +10,6 @@ | |||
| 10 | * | 10 | * |
| 11 | * Original copyright notice is retained at the end of this file. | 11 | * Original copyright notice is retained at the end of this file. |
| 12 | */ | 12 | */ |
| 13 | |||
| 14 | #include "libbb.h" | 13 | #include "libbb.h" |
| 15 | #include "dump.h" | 14 | #include "dump.h" |
| 16 | 15 | ||
diff --git a/libbb/executable.c b/libbb/executable.c index 5f0ff8c6e..b28f020e0 100644 --- a/libbb/executable.c +++ b/libbb/executable.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | 10 | ||
| 12 | /* check if path points to an executable file; | 11 | /* check if path points to an executable file; |
diff --git a/libbb/fclose_nonstdin.c b/libbb/fclose_nonstdin.c index 1b1441347..7d5331063 100644 --- a/libbb/fclose_nonstdin.c +++ b/libbb/fclose_nonstdin.c | |||
| @@ -6,14 +6,12 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | #include "libbb.h" | ||
| 9 | 10 | ||
| 10 | /* A number of standard utilities can accept multiple command line args | 11 | /* A number of standard utilities can accept multiple command line args |
| 11 | * of '-' for stdin, according to SUSv3. So we encapsulate the check | 12 | * of '-' for stdin, according to SUSv3. So we encapsulate the check |
| 12 | * here to save a little space. | 13 | * here to save a little space. |
| 13 | */ | 14 | */ |
| 14 | |||
| 15 | #include "libbb.h" | ||
| 16 | |||
| 17 | int FAST_FUNC fclose_if_not_stdin(FILE *f) | 15 | int FAST_FUNC fclose_if_not_stdin(FILE *f) |
| 18 | { | 16 | { |
| 19 | /* Some more paranoid applets want ferror() check too */ | 17 | /* Some more paranoid applets want ferror() check too */ |
diff --git a/libbb/fflush_stdout_and_exit.c b/libbb/fflush_stdout_and_exit.c index b4bed865f..4c689c0fb 100644 --- a/libbb/fflush_stdout_and_exit.c +++ b/libbb/fflush_stdout_and_exit.c | |||
| @@ -6,13 +6,11 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | #include "libbb.h" | ||
| 9 | 10 | ||
| 10 | /* Attempt to fflush(stdout), and exit with an error code if stdout is | 11 | /* Attempt to fflush(stdout), and exit with an error code if stdout is |
| 11 | * in an error state. | 12 | * in an error state. |
| 12 | */ | 13 | */ |
| 13 | |||
| 14 | #include "libbb.h" | ||
| 15 | |||
| 16 | void FAST_FUNC fflush_stdout_and_exit(int retval) | 14 | void FAST_FUNC fflush_stdout_and_exit(int retval) |
| 17 | { | 15 | { |
| 18 | xfunc_error_retval = retval; | 16 | xfunc_error_retval = retval; |
diff --git a/libbb/fgets_str.c b/libbb/fgets_str.c index 89210a3c9..1a7f2e9e0 100644 --- a/libbb/fgets_str.c +++ b/libbb/fgets_str.c | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | * | 7 | * |
| 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 9 | */ | 9 | */ |
| 10 | |||
| 11 | #include "libbb.h" | 10 | #include "libbb.h" |
| 12 | 11 | ||
| 13 | static char *xmalloc_fgets_internal(FILE *file, const char *terminating_string, int chop_off, size_t *maxsz_p) | 12 | static char *xmalloc_fgets_internal(FILE *file, const char *terminating_string, int chop_off, size_t *maxsz_p) |
diff --git a/libbb/find_mount_point.c b/libbb/find_mount_point.c index 1308d9b65..341c30102 100644 --- a/libbb/find_mount_point.c +++ b/libbb/find_mount_point.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | #include <mntent.h> | 10 | #include <mntent.h> |
| 12 | 11 | ||
diff --git a/libbb/find_pid_by_name.c b/libbb/find_pid_by_name.c index 22afa1ce5..52debb171 100644 --- a/libbb/find_pid_by_name.c +++ b/libbb/find_pid_by_name.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | 10 | ||
| 12 | /* | 11 | /* |
diff --git a/libbb/find_root_device.c b/libbb/find_root_device.c index 8436cd664..d560f3ec3 100644 --- a/libbb/find_root_device.c +++ b/libbb/find_root_device.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | 10 | ||
| 12 | /* Find block device /dev/XXX which contains specified file | 11 | /* Find block device /dev/XXX which contains specified file |
diff --git a/libbb/full_write.c b/libbb/full_write.c index 777fbd910..2b7983f4c 100644 --- a/libbb/full_write.c +++ b/libbb/full_write.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | 10 | ||
| 12 | /* | 11 | /* |
diff --git a/libbb/get_console.c b/libbb/get_console.c index 96b339ca7..0b53524aa 100644 --- a/libbb/get_console.c +++ b/libbb/get_console.c | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | * | 7 | * |
| 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 9 | */ | 9 | */ |
| 10 | |||
| 11 | #include "libbb.h" | 10 | #include "libbb.h" |
| 12 | 11 | ||
| 13 | /* From <linux/kd.h> */ | 12 | /* From <linux/kd.h> */ |
diff --git a/libbb/get_line_from_file.c b/libbb/get_line_from_file.c index 2038fac7d..4e09ddc80 100644 --- a/libbb/get_line_from_file.c +++ b/libbb/get_line_from_file.c | |||
| @@ -8,7 +8,6 @@ | |||
| 8 | * | 8 | * |
| 9 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 9 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 10 | */ | 10 | */ |
| 11 | |||
| 12 | #include "libbb.h" | 11 | #include "libbb.h" |
| 13 | 12 | ||
| 14 | char* FAST_FUNC bb_get_chunk_from_file(FILE *file, int *end) | 13 | char* FAST_FUNC bb_get_chunk_from_file(FILE *file, int *end) |
diff --git a/libbb/getpty.c b/libbb/getpty.c index 391d729f2..5d24ca930 100644 --- a/libbb/getpty.c +++ b/libbb/getpty.c | |||
| @@ -5,7 +5,6 @@ | |||
| 5 | * | 5 | * |
| 6 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 6 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 7 | */ | 7 | */ |
| 8 | |||
| 9 | #include "libbb.h" | 8 | #include "libbb.h" |
| 10 | 9 | ||
| 11 | #define DEBUG 0 | 10 | #define DEBUG 0 |
diff --git a/libbb/hash_md5_sha.c b/libbb/hash_md5_sha.c index 2a7247430..a53a382ce 100644 --- a/libbb/hash_md5_sha.c +++ b/libbb/hash_md5_sha.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | 10 | ||
| 12 | #define NEED_SHA512 (ENABLE_SHA512SUM || ENABLE_USE_BB_CRYPT_SHA) | 11 | #define NEED_SHA512 (ENABLE_SHA512SUM || ENABLE_USE_BB_CRYPT_SHA) |
diff --git a/libbb/human_readable.c b/libbb/human_readable.c index b4e0ef181..09221a186 100644 --- a/libbb/human_readable.c +++ b/libbb/human_readable.c | |||
| @@ -22,7 +22,6 @@ | |||
| 22 | * | 22 | * |
| 23 | * Licensed under GPLv2, see file LICENSE in this source tree. | 23 | * Licensed under GPLv2, see file LICENSE in this source tree. |
| 24 | */ | 24 | */ |
| 25 | |||
| 26 | #include "libbb.h" | 25 | #include "libbb.h" |
| 27 | 26 | ||
| 28 | const char* FAST_FUNC make_human_readable_str(unsigned long long val, | 27 | const char* FAST_FUNC make_human_readable_str(unsigned long long val, |
diff --git a/libbb/in_ether.c b/libbb/in_ether.c index 161c8ea3c..c9cf6a99b 100644 --- a/libbb/in_ether.c +++ b/libbb/in_ether.c | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | /* | 2 | /* |
| 3 | * Utility routines. | 3 | * Utility routines. |
| 4 | */ | 4 | */ |
| 5 | |||
| 6 | //kbuild:lib-$(CONFIG_ARP) += in_ether.o | 5 | //kbuild:lib-$(CONFIG_ARP) += in_ether.o |
| 7 | //kbuild:lib-$(CONFIG_IFCONFIG) += in_ether.o | 6 | //kbuild:lib-$(CONFIG_IFCONFIG) += in_ether.o |
| 8 | //kbuild:lib-$(CONFIG_IFENSLAVE) += in_ether.o | 7 | //kbuild:lib-$(CONFIG_IFENSLAVE) += in_ether.o |
diff --git a/libbb/inet_common.c b/libbb/inet_common.c index 04259f47b..e9fbde7dc 100644 --- a/libbb/inet_common.c +++ b/libbb/inet_common.c | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | * | 7 | * |
| 8 | * Licensed under GPLv2, see file LICENSE in this source tree. | 8 | * Licensed under GPLv2, see file LICENSE in this source tree. |
| 9 | */ | 9 | */ |
| 10 | |||
| 11 | #include "libbb.h" | 10 | #include "libbb.h" |
| 12 | #include "inet_common.h" | 11 | #include "inet_common.h" |
| 13 | 12 | ||
diff --git a/libbb/inode_hash.c b/libbb/inode_hash.c index bfed6567c..770d1a286 100644 --- a/libbb/inode_hash.c +++ b/libbb/inode_hash.c | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | * | 7 | * |
| 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 9 | */ | 9 | */ |
| 10 | |||
| 11 | #include "libbb.h" | 10 | #include "libbb.h" |
| 12 | 11 | ||
| 13 | typedef struct ino_dev_hash_bucket_struct { | 12 | typedef struct ino_dev_hash_bucket_struct { |
diff --git a/libbb/isdirectory.c b/libbb/isdirectory.c index ba6c52ce8..6225a34b2 100644 --- a/libbb/isdirectory.c +++ b/libbb/isdirectory.c | |||
| @@ -7,8 +7,6 @@ | |||
| 7 | * | 7 | * |
| 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 9 | */ | 9 | */ |
| 10 | |||
| 11 | #include <sys/stat.h> | ||
| 12 | #include "libbb.h" | 10 | #include "libbb.h" |
| 13 | 11 | ||
| 14 | /* | 12 | /* |
diff --git a/libbb/kernel_version.c b/libbb/kernel_version.c index 9b6c62299..7769a091b 100644 --- a/libbb/kernel_version.c +++ b/libbb/kernel_version.c | |||
| @@ -6,12 +6,10 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | /* After libbb.h, since it needs sys/types.h on some systems */ | 10 | /* After libbb.h, since it needs sys/types.h on some systems */ |
| 12 | #include <sys/utsname.h> /* for uname(2) */ | 11 | #include <sys/utsname.h> /* for uname(2) */ |
| 13 | 12 | ||
| 14 | |||
| 15 | /* Returns current kernel version encoded as major*65536 + minor*256 + patch, | 13 | /* Returns current kernel version encoded as major*65536 + minor*256 + patch, |
| 16 | * so, for example, to check if the kernel is greater than 2.2.11: | 14 | * so, for example, to check if the kernel is greater than 2.2.11: |
| 17 | * | 15 | * |
diff --git a/libbb/last_char_is.c b/libbb/last_char_is.c index 65e6cdf04..66f2e3635 100644 --- a/libbb/last_char_is.c +++ b/libbb/last_char_is.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | 10 | ||
| 12 | /* Find out if the last character of a string matches the one given. | 11 | /* Find out if the last character of a string matches the one given. |
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index d85057e72..c0edb7399 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
| @@ -37,11 +37,6 @@ | |||
| 37 | * | 37 | * |
| 38 | * Unicode in PS1 is not fully supported: prompt length calulation is wrong, | 38 | * Unicode in PS1 is not fully supported: prompt length calulation is wrong, |
| 39 | * resulting in line wrap problems with long (multi-line) input. | 39 | * resulting in line wrap problems with long (multi-line) input. |
| 40 | * | ||
| 41 | * Multi-line PS1 (e.g. PS1="\n[\w]\n$ ") has problems with history | ||
| 42 | * browsing: up/down arrows result in scrolling. | ||
| 43 | * It stems from simplistic "cmdedit_y = cmdedit_prmt_len / cmdedit_termw" | ||
| 44 | * calculation of how many lines the prompt takes. | ||
| 45 | */ | 40 | */ |
| 46 | #include "busybox.h" | 41 | #include "busybox.h" |
| 47 | #include "NUM_APPLETS.h" | 42 | #include "NUM_APPLETS.h" |
| @@ -133,7 +128,7 @@ struct lineedit_statics { | |||
| 133 | 128 | ||
| 134 | unsigned cmdedit_x; /* real x (col) terminal position */ | 129 | unsigned cmdedit_x; /* real x (col) terminal position */ |
| 135 | unsigned cmdedit_y; /* pseudoreal y (row) terminal position */ | 130 | unsigned cmdedit_y; /* pseudoreal y (row) terminal position */ |
| 136 | unsigned cmdedit_prmt_len; /* length of prompt (without colors etc) */ | 131 | unsigned cmdedit_prmt_len; /* on-screen length of last/sole prompt line */ |
| 137 | 132 | ||
| 138 | unsigned cursor; | 133 | unsigned cursor; |
| 139 | int command_len; /* must be signed */ | 134 | int command_len; /* must be signed */ |
| @@ -143,6 +138,7 @@ struct lineedit_statics { | |||
| 143 | CHAR_T *command_ps; | 138 | CHAR_T *command_ps; |
| 144 | 139 | ||
| 145 | const char *cmdedit_prompt; | 140 | const char *cmdedit_prompt; |
| 141 | const char *prompt_last_line; /* last/sole prompt line */ | ||
| 146 | 142 | ||
| 147 | #if ENABLE_USERNAME_OR_HOMEDIR | 143 | #if ENABLE_USERNAME_OR_HOMEDIR |
| 148 | char *user_buf; | 144 | char *user_buf; |
| @@ -185,6 +181,7 @@ extern struct lineedit_statics *const lineedit_ptr_to_statics; | |||
| 185 | #define command_len (S.command_len ) | 181 | #define command_len (S.command_len ) |
| 186 | #define command_ps (S.command_ps ) | 182 | #define command_ps (S.command_ps ) |
| 187 | #define cmdedit_prompt (S.cmdedit_prompt ) | 183 | #define cmdedit_prompt (S.cmdedit_prompt ) |
| 184 | #define prompt_last_line (S.prompt_last_line) | ||
| 188 | #define user_buf (S.user_buf ) | 185 | #define user_buf (S.user_buf ) |
| 189 | #define home_pwd_buf (S.home_pwd_buf ) | 186 | #define home_pwd_buf (S.home_pwd_buf ) |
| 190 | #define matches (S.matches ) | 187 | #define matches (S.matches ) |
| @@ -473,14 +470,20 @@ static void beep(void) | |||
| 473 | bb_putchar('\007'); | 470 | bb_putchar('\007'); |
| 474 | } | 471 | } |
| 475 | 472 | ||
| 476 | static void put_prompt(void) | 473 | /* Full or last/sole prompt line, reset edit cursor, calculate terminal cursor. |
| 474 | * cmdedit_y is always calculated for the last/sole prompt line. | ||
| 475 | */ | ||
| 476 | static void put_prompt_custom(bool is_full) | ||
| 477 | { | 477 | { |
| 478 | fputs(cmdedit_prompt, stdout); | 478 | fputs((is_full ? cmdedit_prompt : prompt_last_line), stdout); |
| 479 | cursor = 0; | 479 | cursor = 0; |
| 480 | cmdedit_y = cmdedit_prmt_len / cmdedit_termw; /* new quasireal y */ | 480 | cmdedit_y = cmdedit_prmt_len / cmdedit_termw; /* new quasireal y */ |
| 481 | cmdedit_x = cmdedit_prmt_len % cmdedit_termw; | 481 | cmdedit_x = cmdedit_prmt_len % cmdedit_termw; |
| 482 | } | 482 | } |
| 483 | 483 | ||
| 484 | #define put_prompt_last_line() put_prompt_custom(0) | ||
| 485 | #define put_prompt() put_prompt_custom(1) | ||
| 486 | |||
| 484 | /* Move back one character */ | 487 | /* Move back one character */ |
| 485 | /* (optimized for slow terminals) */ | 488 | /* (optimized for slow terminals) */ |
| 486 | static void input_backward(unsigned num) | 489 | static void input_backward(unsigned num) |
| @@ -547,7 +550,7 @@ static void input_backward(unsigned num) | |||
| 547 | printf("\r" ESC"[%uA", cmdedit_y); | 550 | printf("\r" ESC"[%uA", cmdedit_y); |
| 548 | cmdedit_y = 0; | 551 | cmdedit_y = 0; |
| 549 | sv_cursor = cursor; | 552 | sv_cursor = cursor; |
| 550 | put_prompt(); /* sets cursor to 0 */ | 553 | put_prompt_last_line(); /* sets cursor to 0 */ |
| 551 | while (cursor < sv_cursor) | 554 | while (cursor < sv_cursor) |
| 552 | put_cur_glyph_and_inc_cursor(); | 555 | put_cur_glyph_and_inc_cursor(); |
| 553 | } else { | 556 | } else { |
| @@ -568,18 +571,27 @@ static void input_backward(unsigned num) | |||
| 568 | } | 571 | } |
| 569 | } | 572 | } |
| 570 | 573 | ||
| 571 | /* draw prompt, editor line, and clear tail */ | 574 | /* See redraw and draw_full below */ |
| 572 | static void redraw(int y, int back_cursor) | 575 | static void draw_custom(int y, int back_cursor, bool is_full) |
| 573 | { | 576 | { |
| 574 | if (y > 0) /* up y lines */ | 577 | if (y > 0) /* up y lines */ |
| 575 | printf(ESC"[%uA", y); | 578 | printf(ESC"[%uA", y); |
| 576 | bb_putchar('\r'); | 579 | bb_putchar('\r'); |
| 577 | put_prompt(); | 580 | put_prompt_custom(is_full); |
| 578 | put_till_end_and_adv_cursor(); | 581 | put_till_end_and_adv_cursor(); |
| 579 | printf(SEQ_CLEAR_TILL_END_OF_SCREEN); | 582 | printf(SEQ_CLEAR_TILL_END_OF_SCREEN); |
| 580 | input_backward(back_cursor); | 583 | input_backward(back_cursor); |
| 581 | } | 584 | } |
| 582 | 585 | ||
| 586 | /* Move y lines up, draw last/sole prompt line, editor line[s], and clear tail. | ||
| 587 | * goal: redraw the prompt+input+cursor in-place, overwriting the previous */ | ||
| 588 | #define redraw(y, back_cursor) draw_custom((y), (back_cursor), 0) | ||
| 589 | |||
| 590 | /* Like above, but without moving up, and while using all the prompt lines. | ||
| 591 | * goal: draw a full prompt+input+cursor unrelated to a previous position. | ||
| 592 | * note: cmdedit_y always ends up relating to the last/sole prompt line */ | ||
| 593 | #define draw_full(back_cursor) draw_custom(0, (back_cursor), 1) | ||
| 594 | |||
| 583 | /* Delete the char in front of the cursor, optionally saving it | 595 | /* Delete the char in front of the cursor, optionally saving it |
| 584 | * for later putback */ | 596 | * for later putback */ |
| 585 | #if !ENABLE_FEATURE_EDITING_VI | 597 | #if !ENABLE_FEATURE_EDITING_VI |
| @@ -1159,7 +1171,7 @@ static NOINLINE void input_tab(smallint *lastWasTab) | |||
| 1159 | int sav_cursor = cursor; | 1171 | int sav_cursor = cursor; |
| 1160 | goto_new_line(); | 1172 | goto_new_line(); |
| 1161 | showfiles(); | 1173 | showfiles(); |
| 1162 | redraw(0, command_len - sav_cursor); | 1174 | draw_full(command_len - sav_cursor); |
| 1163 | } | 1175 | } |
| 1164 | return; | 1176 | return; |
| 1165 | } | 1177 | } |
| @@ -1835,14 +1847,37 @@ static void ask_terminal(void) | |||
| 1835 | #define ask_terminal() ((void)0) | 1847 | #define ask_terminal() ((void)0) |
| 1836 | #endif | 1848 | #endif |
| 1837 | 1849 | ||
| 1850 | /* Note about multi-line PS1 (e.g. "\n\w \u@\h\n> ") and prompt redrawing: | ||
| 1851 | * | ||
| 1852 | * If the prompt has any newlines, after we print it once we use only its last | ||
| 1853 | * line to redraw in-place, which makes it simpler to calculate how many lines | ||
| 1854 | * we should move the cursor up to align the redraw (cmdedit_y). The earlier | ||
| 1855 | * prompt lines just stay on screen and we redraw below them. | ||
| 1856 | * | ||
| 1857 | * Use cases for all prompt lines beyond the initial draw: | ||
| 1858 | * - After clear-screen (^L) or after displaying tab-completion choices, we | ||
| 1859 | * print the full prompt, as it isn't redrawn in-place. | ||
| 1860 | * - During terminal resize we could try to redraw all lines, but we don't, | ||
| 1861 | * because it requires delicate alignment, it's good enough with only the | ||
| 1862 | * last line, and doing it wrong is arguably worse than not doing it at all. | ||
| 1863 | * | ||
| 1864 | * Terminology wise, if it doesn't mention "full", then it means the last/sole | ||
| 1865 | * prompt line. We use the prompt (last/sole line) while redrawing in-place, | ||
| 1866 | * and the full where we need a fresh one unrelated to an earlier position. | ||
| 1867 | * | ||
| 1868 | * If PS1 is not multiline, the last/sole line and the full are the same string. | ||
| 1869 | */ | ||
| 1870 | |||
| 1838 | /* Called just once at read_line_input() init time */ | 1871 | /* Called just once at read_line_input() init time */ |
| 1839 | #if !ENABLE_FEATURE_EDITING_FANCY_PROMPT | 1872 | #if !ENABLE_FEATURE_EDITING_FANCY_PROMPT |
| 1840 | static void parse_and_put_prompt(const char *prmt_ptr) | 1873 | static void parse_and_put_prompt(const char *prmt_ptr) |
| 1841 | { | 1874 | { |
| 1842 | const char *p; | 1875 | const char *p; |
| 1843 | cmdedit_prompt = prmt_ptr; | 1876 | cmdedit_prompt = prompt_last_line = prmt_ptr; |
| 1844 | p = strrchr(prmt_ptr, '\n'); | 1877 | p = strrchr(prmt_ptr, '\n'); |
| 1845 | cmdedit_prmt_len = unicode_strwidth(p ? p+1 : prmt_ptr); | 1878 | if (p) |
| 1879 | prompt_last_line = p + 1; | ||
| 1880 | cmdedit_prmt_len = unicode_strwidth(prompt_last_line); | ||
| 1846 | put_prompt(); | 1881 | put_prompt(); |
| 1847 | } | 1882 | } |
| 1848 | #else | 1883 | #else |
| @@ -2035,7 +2070,11 @@ static void parse_and_put_prompt(const char *prmt_ptr) | |||
| 2035 | if (cwd_buf != (char *)bb_msg_unknown) | 2070 | if (cwd_buf != (char *)bb_msg_unknown) |
| 2036 | free(cwd_buf); | 2071 | free(cwd_buf); |
| 2037 | # endif | 2072 | # endif |
| 2038 | cmdedit_prompt = prmt_mem_ptr; | 2073 | /* see comment (above this function) about multiline prompt redrawing */ |
| 2074 | cmdedit_prompt = prompt_last_line = prmt_mem_ptr; | ||
| 2075 | prmt_ptr = strrchr(cmdedit_prompt, '\n'); | ||
| 2076 | if (prmt_ptr) | ||
| 2077 | prompt_last_line = prmt_ptr + 1; | ||
| 2039 | put_prompt(); | 2078 | put_prompt(); |
| 2040 | } | 2079 | } |
| 2041 | #endif | 2080 | #endif |
| @@ -2207,7 +2246,7 @@ static int32_t reverse_i_search(int timeout) | |||
| 2207 | match_buf[0] = '\0'; | 2246 | match_buf[0] = '\0'; |
| 2208 | 2247 | ||
| 2209 | /* Save and replace the prompt */ | 2248 | /* Save and replace the prompt */ |
| 2210 | saved_prompt = cmdedit_prompt; | 2249 | saved_prompt = prompt_last_line; |
| 2211 | saved_prmt_len = cmdedit_prmt_len; | 2250 | saved_prmt_len = cmdedit_prmt_len; |
| 2212 | goto set_prompt; | 2251 | goto set_prompt; |
| 2213 | 2252 | ||
| @@ -2280,10 +2319,10 @@ static int32_t reverse_i_search(int timeout) | |||
| 2280 | cursor = match - matched_history_line; | 2319 | cursor = match - matched_history_line; |
| 2281 | //FIXME: cursor position for Unicode case | 2320 | //FIXME: cursor position for Unicode case |
| 2282 | 2321 | ||
| 2283 | free((char*)cmdedit_prompt); | 2322 | free((char*)prompt_last_line); |
| 2284 | set_prompt: | 2323 | set_prompt: |
| 2285 | cmdedit_prompt = xasprintf("(reverse-i-search)'%s': ", match_buf); | 2324 | prompt_last_line = xasprintf("(reverse-i-search)'%s': ", match_buf); |
| 2286 | cmdedit_prmt_len = unicode_strwidth(cmdedit_prompt); | 2325 | cmdedit_prmt_len = unicode_strwidth(prompt_last_line); |
| 2287 | goto do_redraw; | 2326 | goto do_redraw; |
| 2288 | } | 2327 | } |
| 2289 | } | 2328 | } |
| @@ -2303,8 +2342,8 @@ static int32_t reverse_i_search(int timeout) | |||
| 2303 | if (matched_history_line) | 2342 | if (matched_history_line) |
| 2304 | command_len = load_string(matched_history_line); | 2343 | command_len = load_string(matched_history_line); |
| 2305 | 2344 | ||
| 2306 | free((char*)cmdedit_prompt); | 2345 | free((char*)prompt_last_line); |
| 2307 | cmdedit_prompt = saved_prompt; | 2346 | prompt_last_line = saved_prompt; |
| 2308 | cmdedit_prmt_len = saved_prmt_len; | 2347 | cmdedit_prmt_len = saved_prmt_len; |
| 2309 | redraw(cmdedit_y, command_len - cursor); | 2348 | redraw(cmdedit_y, command_len - cursor); |
| 2310 | 2349 | ||
| @@ -2524,8 +2563,9 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman | |||
| 2524 | case CTRL('L'): | 2563 | case CTRL('L'): |
| 2525 | vi_case(CTRL('L')|VI_CMDMODE_BIT:) | 2564 | vi_case(CTRL('L')|VI_CMDMODE_BIT:) |
| 2526 | /* Control-l -- clear screen */ | 2565 | /* Control-l -- clear screen */ |
| 2527 | printf(ESC"[H"); /* cursor to top,left */ | 2566 | /* cursor to top,left; clear to the end of screen */ |
| 2528 | redraw(0, command_len - cursor); | 2567 | printf(ESC"[H" ESC"[J"); |
| 2568 | draw_full(command_len - cursor); | ||
| 2529 | break; | 2569 | break; |
| 2530 | #if MAX_HISTORY > 0 | 2570 | #if MAX_HISTORY > 0 |
| 2531 | case CTRL('N'): | 2571 | case CTRL('N'): |
diff --git a/libbb/llist.c b/libbb/llist.c index 032e9fac8..e964a9b72 100644 --- a/libbb/llist.c +++ b/libbb/llist.c | |||
| @@ -9,7 +9,6 @@ | |||
| 9 | * | 9 | * |
| 10 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 10 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 11 | */ | 11 | */ |
| 12 | |||
| 13 | #include "libbb.h" | 12 | #include "libbb.h" |
| 14 | 13 | ||
| 15 | /* Add data to the start of the linked list. */ | 14 | /* Add data to the start of the linked list. */ |
diff --git a/libbb/login.c b/libbb/login.c index 5a7acfcf0..7f593d80d 100644 --- a/libbb/login.c +++ b/libbb/login.c | |||
| @@ -8,7 +8,6 @@ | |||
| 8 | * | 8 | * |
| 9 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 9 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 10 | */ | 10 | */ |
| 11 | |||
| 12 | #include "libbb.h" | 11 | #include "libbb.h" |
| 13 | /* After libbb.h, since it needs sys/types.h on some systems */ | 12 | /* After libbb.h, since it needs sys/types.h on some systems */ |
| 14 | #include <sys/utsname.h> | 13 | #include <sys/utsname.h> |
diff --git a/libbb/make_directory.c b/libbb/make_directory.c index 3e171ff02..6422c863f 100644 --- a/libbb/make_directory.c +++ b/libbb/make_directory.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | /* Mar 5, 2003 Manuel Novoa III | 9 | /* Mar 5, 2003 Manuel Novoa III |
| 11 | * | 10 | * |
| 12 | * This is the main work function for the 'mkdir' applet. As such, it | 11 | * This is the main work function for the 'mkdir' applet. As such, it |
| @@ -21,7 +20,6 @@ | |||
| 21 | * To set specific permissions on 'path', pass the appropriate 'mode' | 20 | * To set specific permissions on 'path', pass the appropriate 'mode' |
| 22 | * val. Otherwise, pass -1 to get default permissions. | 21 | * val. Otherwise, pass -1 to get default permissions. |
| 23 | */ | 22 | */ |
| 24 | |||
| 25 | #include "libbb.h" | 23 | #include "libbb.h" |
| 26 | 24 | ||
| 27 | /* This function is used from NOFORK applets. It must not allocate anything */ | 25 | /* This function is used from NOFORK applets. It must not allocate anything */ |
diff --git a/libbb/match_fstype.c b/libbb/match_fstype.c index 6046bc6db..1e2269c5e 100644 --- a/libbb/match_fstype.c +++ b/libbb/match_fstype.c | |||
| @@ -9,7 +9,6 @@ | |||
| 9 | * | 9 | * |
| 10 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 10 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 11 | */ | 11 | */ |
| 12 | |||
| 13 | #include "libbb.h" | 12 | #include "libbb.h" |
| 14 | 13 | ||
| 15 | int FAST_FUNC fstype_matches(const char *fstype, const char *comma_list) | 14 | int FAST_FUNC fstype_matches(const char *fstype, const char *comma_list) |
diff --git a/libbb/messages.c b/libbb/messages.c index 3c0b921cf..31721a3b3 100644 --- a/libbb/messages.c +++ b/libbb/messages.c | |||
| @@ -4,7 +4,6 @@ | |||
| 4 | * | 4 | * |
| 5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 6 | */ | 6 | */ |
| 7 | |||
| 8 | #include "libbb.h" | 7 | #include "libbb.h" |
| 9 | 8 | ||
| 10 | /* allow default system PATH to be extended via CFLAGS */ | 9 | /* allow default system PATH to be extended via CFLAGS */ |
diff --git a/libbb/mode_string.c b/libbb/mode_string.c index c387b42cb..6c5c08acd 100644 --- a/libbb/mode_string.c +++ b/libbb/mode_string.c | |||
| @@ -6,15 +6,7 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | /* Aug 13, 2003 | ||
| 11 | * Fix a bug reported by junkio@cox.net involving the mode_chars index. | ||
| 12 | */ | ||
| 13 | |||
| 14 | |||
| 15 | #include <assert.h> | 9 | #include <assert.h> |
| 16 | #include <sys/stat.h> | ||
| 17 | |||
| 18 | #include "libbb.h" | 10 | #include "libbb.h" |
| 19 | 11 | ||
| 20 | #if ( S_ISUID != 04000 ) || ( S_ISGID != 02000 ) || ( S_ISVTX != 01000 ) \ | 12 | #if ( S_ISUID != 04000 ) || ( S_ISGID != 02000 ) || ( S_ISVTX != 01000 ) \ |
diff --git a/libbb/mtab.c b/libbb/mtab.c index 22bff6490..131705ddb 100644 --- a/libbb/mtab.c +++ b/libbb/mtab.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include <mntent.h> | 9 | #include <mntent.h> |
| 11 | #include "libbb.h" | 10 | #include "libbb.h" |
| 12 | 11 | ||
diff --git a/libbb/nuke_str.c b/libbb/nuke_str.c index 56b808bc7..240e68004 100644 --- a/libbb/nuke_str.c +++ b/libbb/nuke_str.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | //kbuild:lib-y += nuke_str.o | 9 | //kbuild:lib-y += nuke_str.o |
| 11 | 10 | ||
| 12 | #include "libbb.h" | 11 | #include "libbb.h" |
diff --git a/libbb/parse_mode.c b/libbb/parse_mode.c index bddd39bca..dc65860f6 100644 --- a/libbb/parse_mode.c +++ b/libbb/parse_mode.c | |||
| @@ -6,11 +6,10 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | #include "libbb.h" | ||
| 9 | 10 | ||
| 10 | /* http://www.opengroup.org/onlinepubs/007904975/utilities/chmod.html */ | 11 | /* http://www.opengroup.org/onlinepubs/007904975/utilities/chmod.html */ |
| 11 | 12 | ||
| 12 | #include "libbb.h" | ||
| 13 | |||
| 14 | /* This function is used from NOFORK applets. It must not allocate anything */ | 13 | /* This function is used from NOFORK applets. It must not allocate anything */ |
| 15 | 14 | ||
| 16 | #define FILEMODEBITS (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) | 15 | #define FILEMODEBITS (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) |
diff --git a/libbb/percent_decode.c b/libbb/percent_decode.c index 9a9d80c4a..e5e42f0b5 100644 --- a/libbb/percent_decode.c +++ b/libbb/percent_decode.c | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | /* | 2 | /* |
| 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 4 | */ | 4 | */ |
| 5 | |||
| 6 | //kbuild:lib-y += percent_decode.o | 5 | //kbuild:lib-y += percent_decode.o |
| 7 | 6 | ||
| 8 | #include "libbb.h" | 7 | #include "libbb.h" |
diff --git a/libbb/print_flags.c b/libbb/print_flags.c index eaec731e5..0ebe842be 100644 --- a/libbb/print_flags.c +++ b/libbb/print_flags.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* Print string that matches bit masked flags | 2 | /* |
| 3 | * Print string that matches bit masked flags | ||
| 3 | * | 4 | * |
| 4 | * Copyright (C) 2008 Natanael Copa <natanael.copa@gmail.com> | 5 | * Copyright (C) 2008 Natanael Copa <natanael.copa@gmail.com> |
| 5 | * | 6 | * |
diff --git a/libbb/printable.c b/libbb/printable.c index 9a423431e..224dde406 100644 --- a/libbb/printable.c +++ b/libbb/printable.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | 10 | ||
| 12 | void FAST_FUNC fputc_printable(int ch, FILE *file) | 11 | void FAST_FUNC fputc_printable(int ch, FILE *file) |
diff --git a/libbb/process_escape_sequence.c b/libbb/process_escape_sequence.c index 346ecfa1e..59d0d3ea8 100644 --- a/libbb/process_escape_sequence.c +++ b/libbb/process_escape_sequence.c | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | * | 7 | * |
| 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 9 | */ | 9 | */ |
| 10 | |||
| 11 | #include "libbb.h" | 10 | #include "libbb.h" |
| 12 | 11 | ||
| 13 | #define WANT_HEX_ESCAPES 1 | 12 | #define WANT_HEX_ESCAPES 1 |
diff --git a/libbb/procps.c b/libbb/procps.c index 6f971a116..2484ab2d9 100644 --- a/libbb/procps.c +++ b/libbb/procps.c | |||
| @@ -8,7 +8,6 @@ | |||
| 8 | * | 8 | * |
| 9 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 9 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 10 | */ | 10 | */ |
| 11 | |||
| 12 | #include "libbb.h" | 11 | #include "libbb.h" |
| 13 | 12 | ||
| 14 | 13 | ||
diff --git a/libbb/ptr_to_globals.c b/libbb/ptr_to_globals.c index 1074538f3..8ba9cd154 100644 --- a/libbb/ptr_to_globals.c +++ b/libbb/ptr_to_globals.c | |||
| @@ -4,7 +4,6 @@ | |||
| 4 | * | 4 | * |
| 5 | * Licensed under GPLv2, see file LICENSE in this source tree. | 5 | * Licensed under GPLv2, see file LICENSE in this source tree. |
| 6 | */ | 6 | */ |
| 7 | |||
| 8 | #include <errno.h> | 7 | #include <errno.h> |
| 9 | 8 | ||
| 10 | struct globals; | 9 | struct globals; |
diff --git a/libbb/pw_encrypt.c b/libbb/pw_encrypt.c index fe06a8fe6..1edf4b6f0 100644 --- a/libbb/pw_encrypt.c +++ b/libbb/pw_encrypt.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | 10 | ||
| 12 | /* static const uint8_t ascii64[] ALIGN1 = | 11 | /* static const uint8_t ascii64[] ALIGN1 = |
diff --git a/libbb/recursive_action.c b/libbb/recursive_action.c index 8f2b8b932..0831ecc3a 100644 --- a/libbb/recursive_action.c +++ b/libbb/recursive_action.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | 10 | ||
| 12 | #undef DEBUG_RECURS_ACTION | 11 | #undef DEBUG_RECURS_ACTION |
diff --git a/libbb/remove_file.c b/libbb/remove_file.c index eaca293d9..8a1324393 100644 --- a/libbb/remove_file.c +++ b/libbb/remove_file.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | 10 | ||
| 12 | /* Used from NOFORK applets. Must not allocate anything */ | 11 | /* Used from NOFORK applets. Must not allocate anything */ |
diff --git a/libbb/replace.c b/libbb/replace.c index 8711f957d..a661d96e6 100644 --- a/libbb/replace.c +++ b/libbb/replace.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | //kbuild:lib-y += replace.o | 9 | //kbuild:lib-y += replace.o |
| 11 | 10 | ||
| 12 | #include "libbb.h" | 11 | #include "libbb.h" |
diff --git a/libbb/run_shell.c b/libbb/run_shell.c index 3bb58bb6f..a0420d982 100644 --- a/libbb/run_shell.c +++ b/libbb/run_shell.c | |||
| @@ -27,7 +27,6 @@ | |||
| 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 28 | * SUCH DAMAGE. | 28 | * SUCH DAMAGE. |
| 29 | */ | 29 | */ |
| 30 | |||
| 31 | #include "libbb.h" | 30 | #include "libbb.h" |
| 32 | #if ENABLE_SELINUX | 31 | #if ENABLE_SELINUX |
| 33 | #include <selinux/selinux.h> /* for setexeccon */ | 32 | #include <selinux/selinux.h> /* for setexeccon */ |
diff --git a/libbb/safe_gethostname.c b/libbb/safe_gethostname.c index cac99ae03..b22e30ea3 100644 --- a/libbb/safe_gethostname.c +++ b/libbb/safe_gethostname.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | /* | 9 | /* |
| 11 | * SUSv2 guarantees that "Host names are limited to 255 bytes" | 10 | * SUSv2 guarantees that "Host names are limited to 255 bytes" |
| 12 | * POSIX.1-2001 guarantees that "Host names (not including the terminating | 11 | * POSIX.1-2001 guarantees that "Host names (not including the terminating |
| @@ -23,7 +22,6 @@ | |||
| 23 | * Host software MUST handle host names of up to 63 characters and | 22 | * Host software MUST handle host names of up to 63 characters and |
| 24 | * SHOULD handle host names of up to 255 characters. | 23 | * SHOULD handle host names of up to 255 characters. |
| 25 | */ | 24 | */ |
| 26 | |||
| 27 | #include "libbb.h" | 25 | #include "libbb.h" |
| 28 | #include <sys/utsname.h> | 26 | #include <sys/utsname.h> |
| 29 | 27 | ||
diff --git a/libbb/safe_poll.c b/libbb/safe_poll.c index b492a8151..cf93a9774 100644 --- a/libbb/safe_poll.c +++ b/libbb/safe_poll.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | 10 | ||
| 12 | /* Wrapper which restarts poll on EINTR or ENOMEM. | 11 | /* Wrapper which restarts poll on EINTR or ENOMEM. |
diff --git a/libbb/safe_strncpy.c b/libbb/safe_strncpy.c index 5eb0db0bd..9570aacd7 100644 --- a/libbb/safe_strncpy.c +++ b/libbb/safe_strncpy.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | 10 | ||
| 12 | /* Like strncpy but make sure the resulting string is always 0 terminated. */ | 11 | /* Like strncpy but make sure the resulting string is always 0 terminated. */ |
diff --git a/libbb/safe_write.c b/libbb/safe_write.c index aad50f5e0..12bb438b7 100644 --- a/libbb/safe_write.c +++ b/libbb/safe_write.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | 10 | ||
| 12 | ssize_t FAST_FUNC safe_write(int fd, const void *buf, size_t count) | 11 | ssize_t FAST_FUNC safe_write(int fd, const void *buf, size_t count) |
diff --git a/libbb/setup_environment.c b/libbb/setup_environment.c index 7ac22cd92..c583206f0 100644 --- a/libbb/setup_environment.c +++ b/libbb/setup_environment.c | |||
| @@ -27,7 +27,6 @@ | |||
| 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 28 | * SUCH DAMAGE. | 28 | * SUCH DAMAGE. |
| 29 | */ | 29 | */ |
| 30 | |||
| 31 | #include "libbb.h" | 30 | #include "libbb.h" |
| 32 | 31 | ||
| 33 | #if ENABLE_PLATFORM_MINGW32 | 32 | #if ENABLE_PLATFORM_MINGW32 |
diff --git a/libbb/signals.c b/libbb/signals.c index 56512473a..3f589321c 100644 --- a/libbb/signals.c +++ b/libbb/signals.c | |||
| @@ -8,7 +8,6 @@ | |||
| 8 | * | 8 | * |
| 9 | * Licensed under GPLv2, see file LICENSE in this source tree. | 9 | * Licensed under GPLv2, see file LICENSE in this source tree. |
| 10 | */ | 10 | */ |
| 11 | |||
| 12 | #include "libbb.h" | 11 | #include "libbb.h" |
| 13 | 12 | ||
| 14 | /* All known arches use small ints for signals */ | 13 | /* All known arches use small ints for signals */ |
diff --git a/libbb/skip_whitespace.c b/libbb/skip_whitespace.c index b6cfbba4d..4df5d9e4d 100644 --- a/libbb/skip_whitespace.c +++ b/libbb/skip_whitespace.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | 10 | ||
| 12 | char* FAST_FUNC skip_whitespace(const char *s) | 11 | char* FAST_FUNC skip_whitespace(const char *s) |
diff --git a/libbb/speed_table.c b/libbb/speed_table.c index 11ced01d0..967cf8de8 100644 --- a/libbb/speed_table.c +++ b/libbb/speed_table.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | 10 | ||
| 12 | struct speed_map { | 11 | struct speed_map { |
diff --git a/libbb/strrstr.c b/libbb/strrstr.c index 93d970a1b..a173b034f 100644 --- a/libbb/strrstr.c +++ b/libbb/strrstr.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | 10 | ||
| 12 | /* | 11 | /* |
diff --git a/libbb/trim.c b/libbb/trim.c index e47fec74e..e360ba138 100644 --- a/libbb/trim.c +++ b/libbb/trim.c | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | * | 7 | * |
| 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 9 | */ | 9 | */ |
| 10 | |||
| 11 | #include "libbb.h" | 10 | #include "libbb.h" |
| 12 | 11 | ||
| 13 | char* FAST_FUNC trim(char *s) | 12 | char* FAST_FUNC trim(char *s) |
diff --git a/libbb/udp_io.c b/libbb/udp_io.c index 6e3ef484e..68355e6c4 100644 --- a/libbb/udp_io.c +++ b/libbb/udp_io.c | |||
| @@ -8,6 +8,10 @@ | |||
| 8 | */ | 8 | */ |
| 9 | #include "libbb.h" | 9 | #include "libbb.h" |
| 10 | 10 | ||
| 11 | #if defined(IPV6_PKTINFO) && !defined(IPV6_RECVPKTINFO) | ||
| 12 | # define IPV6_RECVPKTINFO IPV6_PKTINFO | ||
| 13 | #endif | ||
| 14 | |||
| 11 | /* | 15 | /* |
| 12 | * This asks kernel to let us know dst addr/port of incoming packets | 16 | * This asks kernel to let us know dst addr/port of incoming packets |
| 13 | * We don't check for errors here. Not supported == won't be used | 17 | * We don't check for errors here. Not supported == won't be used |
| @@ -18,8 +22,8 @@ socket_want_pktinfo(int fd UNUSED_PARAM) | |||
| 18 | #ifdef IP_PKTINFO | 22 | #ifdef IP_PKTINFO |
| 19 | setsockopt_1(fd, IPPROTO_IP, IP_PKTINFO); | 23 | setsockopt_1(fd, IPPROTO_IP, IP_PKTINFO); |
| 20 | #endif | 24 | #endif |
| 21 | #if ENABLE_FEATURE_IPV6 && defined(IPV6_PKTINFO) | 25 | #if ENABLE_FEATURE_IPV6 && defined(IPV6_RECVPKTINFO) |
| 22 | setsockopt_1(fd, IPPROTO_IPV6, IPV6_PKTINFO); | 26 | setsockopt_1(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO); |
| 23 | #endif | 27 | #endif |
| 24 | } | 28 | } |
| 25 | 29 | ||
diff --git a/libbb/uuencode.c b/libbb/uuencode.c index f7b248492..f32a3da7d 100644 --- a/libbb/uuencode.c +++ b/libbb/uuencode.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | 10 | ||
| 12 | /* Conversion table. for base 64 */ | 11 | /* Conversion table. for base 64 */ |
diff --git a/libbb/wfopen.c b/libbb/wfopen.c index 76dc8b82a..20fe18b23 100644 --- a/libbb/wfopen.c +++ b/libbb/wfopen.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | 10 | ||
| 12 | FILE* FAST_FUNC fopen_or_warn(const char *path, const char *mode) | 11 | FILE* FAST_FUNC fopen_or_warn(const char *path, const char *mode) |
diff --git a/libbb/wfopen_input.c b/libbb/wfopen_input.c index d8b1c4a36..872464248 100644 --- a/libbb/wfopen_input.c +++ b/libbb/wfopen_input.c | |||
| @@ -6,14 +6,13 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | #include "libbb.h" | ||
| 9 | 10 | ||
| 10 | /* A number of applets need to open a file for reading, where the filename | 11 | /* A number of applets need to open a file for reading, where the filename |
| 11 | * is a command line arg. Since often that arg is '-' (meaning stdin), | 12 | * is a command line arg. Since often that arg is '-' (meaning stdin), |
| 12 | * we avoid testing everywhere by consolidating things in this routine. | 13 | * we avoid testing everywhere by consolidating things in this routine. |
| 13 | */ | 14 | */ |
| 14 | 15 | ||
| 15 | #include "libbb.h" | ||
| 16 | |||
| 17 | FILE* FAST_FUNC fopen_or_warn_stdin(const char *filename) | 16 | FILE* FAST_FUNC fopen_or_warn_stdin(const char *filename) |
| 18 | { | 17 | { |
| 19 | FILE *fp = stdin; | 18 | FILE *fp = stdin; |
diff --git a/libbb/write.c b/libbb/write.c index 2d67a7281..dd64b0032 100644 --- a/libbb/write.c +++ b/libbb/write.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | 10 | ||
| 12 | /* Open file and write string str to it, close file. | 11 | /* Open file and write string str to it, close file. |
diff --git a/libbb/xatonum.c b/libbb/xatonum.c index b63b7f54d..7639a62aa 100644 --- a/libbb/xatonum.c +++ b/libbb/xatonum.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | 10 | ||
| 12 | #define type long long | 11 | #define type long long |
diff --git a/libbb/xconnect.c b/libbb/xconnect.c index 523bb62b1..a6127508b 100644 --- a/libbb/xconnect.c +++ b/libbb/xconnect.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include <sys/types.h> | 9 | #include <sys/types.h> |
| 11 | #include <sys/socket.h> /* netinet/in.h needs it */ | 10 | #include <sys/socket.h> /* netinet/in.h needs it */ |
| 12 | #include <netinet/in.h> | 11 | #include <netinet/in.h> |
diff --git a/libbb/xfunc_die.c b/libbb/xfunc_die.c index 73f7998e5..25b99066d 100644 --- a/libbb/xfunc_die.c +++ b/libbb/xfunc_die.c | |||
| @@ -6,12 +6,11 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | #include "libbb.h" | ||
| 9 | 10 | ||
| 10 | /* Keeping it separate allows to NOT pull in stdio for VERY small applets. | 11 | /* Keeping it separate allows to NOT pull in stdio for VERY small applets. |
| 11 | * Try building busybox with only "true" enabled... */ | 12 | * Try building busybox with only "true" enabled... */ |
| 12 | 13 | ||
| 13 | #include "libbb.h" | ||
| 14 | |||
| 15 | void (*die_func)(void); | 14 | void (*die_func)(void); |
| 16 | 15 | ||
| 17 | void FAST_FUNC xfunc_die(void) | 16 | void FAST_FUNC xfunc_die(void) |
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index 0dfb3e2d9..43ae98065 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c | |||
| @@ -8,7 +8,6 @@ | |||
| 8 | * | 8 | * |
| 9 | * Licensed under GPLv2, see file LICENSE in this source tree. | 9 | * Licensed under GPLv2, see file LICENSE in this source tree. |
| 10 | */ | 10 | */ |
| 11 | |||
| 12 | /* We need to have separate xfuncs.c and xfuncs_printf.c because | 11 | /* We need to have separate xfuncs.c and xfuncs_printf.c because |
| 13 | * with current linkers, even with section garbage collection, | 12 | * with current linkers, even with section garbage collection, |
| 14 | * if *.o module references any of XXXprintf functions, you pull in | 13 | * if *.o module references any of XXXprintf functions, you pull in |
| @@ -21,7 +20,6 @@ | |||
| 21 | * | 20 | * |
| 22 | * TODO: move xmalloc() and xatonum() here. | 21 | * TODO: move xmalloc() and xatonum() here. |
| 23 | */ | 22 | */ |
| 24 | |||
| 25 | #include "libbb.h" | 23 | #include "libbb.h" |
| 26 | 24 | ||
| 27 | /* Turn on nonblocking I/O on a fd */ | 25 | /* Turn on nonblocking I/O on a fd */ |
| @@ -357,6 +355,15 @@ int FAST_FUNC get_termios_and_make_raw(int fd, struct termios *newterm, struct t | |||
| 357 | */ | 355 | */ |
| 358 | } | 356 | } |
| 359 | if (flags & TERMIOS_RAW_INPUT) { | 357 | if (flags & TERMIOS_RAW_INPUT) { |
| 358 | #ifndef IMAXBEL | ||
| 359 | # define IMAXBEL 0 | ||
| 360 | #endif | ||
| 361 | #ifndef IUCLC | ||
| 362 | # define IUCLC 0 | ||
| 363 | #endif | ||
| 364 | #ifndef IXANY | ||
| 365 | # define IXANY 0 | ||
| 366 | #endif | ||
| 360 | /* IXOFF=0: disable sending XON/XOFF if input buf is full */ | 367 | /* IXOFF=0: disable sending XON/XOFF if input buf is full */ |
| 361 | /* IXON=0: input XON/XOFF chars are not special */ | 368 | /* IXON=0: input XON/XOFF chars are not special */ |
| 362 | /* dont convert anything on input */ | 369 | /* dont convert anything on input */ |
diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c index b6ccd82b2..7032e5f8f 100644 --- a/libbb/xfuncs_printf.c +++ b/libbb/xfuncs_printf.c | |||
| @@ -8,7 +8,6 @@ | |||
| 8 | * | 8 | * |
| 9 | * Licensed under GPLv2, see file LICENSE in this source tree. | 9 | * Licensed under GPLv2, see file LICENSE in this source tree. |
| 10 | */ | 10 | */ |
| 11 | |||
| 12 | /* We need to have separate xfuncs.c and xfuncs_printf.c because | 11 | /* We need to have separate xfuncs.c and xfuncs_printf.c because |
| 13 | * with current linkers, even with section garbage collection, | 12 | * with current linkers, even with section garbage collection, |
| 14 | * if *.o module references any of XXXprintf functions, you pull in | 13 | * if *.o module references any of XXXprintf functions, you pull in |
| @@ -19,7 +18,6 @@ | |||
| 19 | * which do not pull in printf, directly or indirectly. | 18 | * which do not pull in printf, directly or indirectly. |
| 20 | * xfunc_printf.c contains those which do. | 19 | * xfunc_printf.c contains those which do. |
| 21 | */ | 20 | */ |
| 22 | |||
| 23 | #include "libbb.h" | 21 | #include "libbb.h" |
| 24 | 22 | ||
| 25 | 23 | ||
diff --git a/libbb/xgetcwd.c b/libbb/xgetcwd.c index 71720d323..7f9088bda 100644 --- a/libbb/xgetcwd.c +++ b/libbb/xgetcwd.c | |||
| @@ -8,7 +8,6 @@ | |||
| 8 | * | 8 | * |
| 9 | * Licensed under GPLv2, see file LICENSE in this source tree. | 9 | * Licensed under GPLv2, see file LICENSE in this source tree. |
| 10 | */ | 10 | */ |
| 11 | |||
| 12 | #include "libbb.h" | 11 | #include "libbb.h" |
| 13 | 12 | ||
| 14 | /* Return the current directory, newly allocated, arbitrarily long. | 13 | /* Return the current directory, newly allocated, arbitrarily long. |
diff --git a/libbb/xreadlink.c b/libbb/xreadlink.c index 2c5a9ef39..b3118b433 100644 --- a/libbb/xreadlink.c +++ b/libbb/xreadlink.c | |||
| @@ -5,7 +5,6 @@ | |||
| 5 | * | 5 | * |
| 6 | * Licensed under GPLv2, see file LICENSE in this source tree. | 6 | * Licensed under GPLv2, see file LICENSE in this source tree. |
| 7 | */ | 7 | */ |
| 8 | |||
| 9 | #include "libbb.h" | 8 | #include "libbb.h" |
| 10 | 9 | ||
| 11 | /* Some systems (eg Hurd) do not have MAXSYMLINKS definition, | 10 | /* Some systems (eg Hurd) do not have MAXSYMLINKS definition, |
diff --git a/libbb/xrealloc_vector.c b/libbb/xrealloc_vector.c index e8d31b7e4..dda5f3f7d 100644 --- a/libbb/xrealloc_vector.c +++ b/libbb/xrealloc_vector.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | 10 | ||
| 12 | /* Resize (grow) malloced vector. | 11 | /* Resize (grow) malloced vector. |
diff --git a/libbb/xregcomp.c b/libbb/xregcomp.c index 344028f44..5870012d0 100644 --- a/libbb/xregcomp.c +++ b/libbb/xregcomp.c | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | * | 7 | * |
| 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 9 | */ | 9 | */ |
| 10 | |||
| 11 | #include "libbb.h" | 10 | #include "libbb.h" |
| 12 | #include "xregex.h" | 11 | #include "xregex.h" |
| 13 | 12 | ||
diff --git a/libpwdgrp/pwd_grp.c b/libpwdgrp/pwd_grp.c index c9bbc8bda..b44ada432 100644 --- a/libpwdgrp/pwd_grp.c +++ b/libpwdgrp/pwd_grp.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* Copyright (C) 2014 Tito Ragusa <farmatito@tiscali.it> | 2 | /* |
| 3 | * Copyright (C) 2014 Tito Ragusa <farmatito@tiscali.it> | ||
| 3 | * | 4 | * |
| 4 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 5 | */ | 6 | */ |
| @@ -28,7 +29,6 @@ | |||
| 28 | * implemented, if you need a particular missing function it should be | 29 | * implemented, if you need a particular missing function it should be |
| 29 | * easy to write it by using the internal common code. | 30 | * easy to write it by using the internal common code. |
| 30 | */ | 31 | */ |
| 31 | |||
| 32 | #include "libbb.h" | 32 | #include "libbb.h" |
| 33 | 33 | ||
| 34 | struct const_passdb { | 34 | struct const_passdb { |
diff --git a/mailutils/sendmail.c b/mailutils/sendmail.c index defbd9552..4ca91fad8 100644 --- a/mailutils/sendmail.c +++ b/mailutils/sendmail.c | |||
| @@ -150,7 +150,13 @@ static char *sane_address(char *str) | |||
| 150 | trim(str); | 150 | trim(str); |
| 151 | s = str; | 151 | s = str; |
| 152 | while (*s) { | 152 | while (*s) { |
| 153 | if (!isalnum(*s) && !strchr("+_-.@", *s)) { | 153 | /* Standard allows these chars in username without quoting: |
| 154 | * /!#$%&'*+-=?^_`{|}~ | ||
| 155 | * and allows dot (.) with some restrictions. | ||
| 156 | * I chose to only allow a saner subset. | ||
| 157 | * I propose to expand it only on user's request. | ||
| 158 | */ | ||
| 159 | if (!isalnum(*s) && !strchr("=+_-.@", *s)) { | ||
| 154 | bb_error_msg("bad address '%s'", str); | 160 | bb_error_msg("bad address '%s'", str); |
| 155 | /* returning "": */ | 161 | /* returning "": */ |
| 156 | str[0] = '\0'; | 162 | str[0] = '\0'; |
diff --git a/miscutils/bbconfig.c b/miscutils/bbconfig.c index bcc9caa7c..2151c622c 100644 --- a/miscutils/bbconfig.c +++ b/miscutils/bbconfig.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* This file was released into the public domain by Paul Fox. | 2 | /* |
| 3 | * This file was released into the public domain by Paul Fox. | ||
| 3 | */ | 4 | */ |
| 4 | //config:config BBCONFIG | 5 | //config:config BBCONFIG |
| 5 | //config: bool "bbconfig (9.7 kb)" | 6 | //config: bool "bbconfig (9.7 kb)" |
diff --git a/miscutils/devmem.c b/miscutils/devmem.c index 624054770..51ac3f22f 100644 --- a/miscutils/devmem.c +++ b/miscutils/devmem.c | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2000, Jan-Derk Bakker (J.D.Bakker@its.tudelft.nl) | ||
| 3 | * Copyright (C) 2008, BusyBox Team. -solar 4/26/08 | ||
| 2 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 4 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 3 | * Copyright (C) 2000, Jan-Derk Bakker (J.D.Bakker@its.tudelft.nl) | ||
| 4 | * Copyright (C) 2008, BusyBox Team. -solar 4/26/08 | ||
| 5 | */ | 5 | */ |
| 6 | //config:config DEVMEM | 6 | //config:config DEVMEM |
| 7 | //config: bool "devmem (2.5 kb)" | 7 | //config: bool "devmem (2.5 kb)" |
diff --git a/miscutils/flash_eraseall.c b/miscutils/flash_eraseall.c index a6ce41f27..fab21291c 100644 --- a/miscutils/flash_eraseall.c +++ b/miscutils/flash_eraseall.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* eraseall.c -- erase the whole of a MTD device | 2 | /* |
| 3 | * eraseall.c -- erase the whole of a MTD device | ||
| 3 | * | 4 | * |
| 4 | * Ported to busybox from mtd-utils. | 5 | * Ported to busybox from mtd-utils. |
| 5 | * | 6 | * |
diff --git a/miscutils/flash_lock_unlock.c b/miscutils/flash_lock_unlock.c index 6f2c049f4..12f72efaf 100644 --- a/miscutils/flash_lock_unlock.c +++ b/miscutils/flash_lock_unlock.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* Ported to busybox from mtd-utils. | 2 | /* |
| 3 | * Ported to busybox from mtd-utils. | ||
| 3 | * | 4 | * |
| 4 | * Licensed under GPLv2, see file LICENSE in this source tree. | 5 | * Licensed under GPLv2, see file LICENSE in this source tree. |
| 5 | */ | 6 | */ |
diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c index fc392d9dc..82f9842bd 100644 --- a/miscutils/i2c_tools.c +++ b/miscutils/i2c_tools.c | |||
| @@ -562,14 +562,19 @@ int i2cset_main(int argc, char **argv) | |||
| 562 | opt_m = (1 << 2), opt_r = (1 << 3); | 562 | opt_m = (1 << 2), opt_r = (1 << 3); |
| 563 | 563 | ||
| 564 | int bus_num, bus_addr, data_addr, mode = I2C_SMBUS_BYTE, pec = 0; | 564 | int bus_num, bus_addr, data_addr, mode = I2C_SMBUS_BYTE, pec = 0; |
| 565 | int val, blen = 0, mask = 0, fd, status; | 565 | int val, blen, mask, fd, status; |
| 566 | unsigned char block[I2C_SMBUS_BLOCK_MAX]; | 566 | unsigned char block[I2C_SMBUS_BLOCK_MAX]; |
| 567 | char *opt_m_arg = NULL; | 567 | char *opt_m_arg = NULL; |
| 568 | unsigned opts; | 568 | unsigned opts; |
| 569 | 569 | ||
| 570 | opts = getopt32(argv, "^" "fym:r" "\0" "-3"/*from 3 to ? args*/, &opt_m_arg); | 570 | opts = getopt32(argv, "^" |
| 571 | "fym:r" | ||
| 572 | "\0" "-3", /* minimum 3 args */ | ||
| 573 | &opt_m_arg | ||
| 574 | ); | ||
| 571 | argv += optind; | 575 | argv += optind; |
| 572 | argc -= optind; | 576 | argc -= optind; |
| 577 | argc--; /* now argv[argc] is last arg */ | ||
| 573 | 578 | ||
| 574 | bus_num = i2c_bus_lookup(argv[0]); | 579 | bus_num = i2c_bus_lookup(argv[0]); |
| 575 | bus_addr = i2c_parse_bus_addr(argv[1]); | 580 | bus_addr = i2c_parse_bus_addr(argv[1]); |
| @@ -579,20 +584,26 @@ int i2cset_main(int argc, char **argv) | |||
| 579 | if (!argv[4] && argv[3][0] != 'c') { | 584 | if (!argv[4] && argv[3][0] != 'c') { |
| 580 | mode = I2C_SMBUS_BYTE_DATA; /* Implicit b */ | 585 | mode = I2C_SMBUS_BYTE_DATA; /* Implicit b */ |
| 581 | } else { | 586 | } else { |
| 582 | switch (argv[argc-1][0]) { | 587 | switch (argv[argc][0]) { |
| 583 | case 'c': /* Already set */ break; | 588 | case 'c': /* Already set */ |
| 584 | case 'b': mode = I2C_SMBUS_BYTE_DATA; break; | 589 | break; |
| 585 | case 'w': mode = I2C_SMBUS_WORD_DATA; break; | 590 | case 'b': mode = I2C_SMBUS_BYTE_DATA; |
| 586 | case 's': mode = I2C_SMBUS_BLOCK_DATA; break; | 591 | break; |
| 587 | case 'i': mode = I2C_SMBUS_I2C_BLOCK_DATA; break; | 592 | case 'w': mode = I2C_SMBUS_WORD_DATA; |
| 593 | break; | ||
| 594 | case 's': mode = I2C_SMBUS_BLOCK_DATA; | ||
| 595 | break; | ||
| 596 | case 'i': mode = I2C_SMBUS_I2C_BLOCK_DATA; | ||
| 597 | break; | ||
| 588 | default: | 598 | default: |
| 589 | bb_error_msg("invalid mode"); | 599 | bb_error_msg("invalid mode"); |
| 590 | bb_show_usage(); | 600 | bb_show_usage(); |
| 591 | } | 601 | } |
| 592 | 602 | ||
| 593 | pec = argv[argc-1][1] == 'p'; | 603 | pec = (argv[argc][1] == 'p'); |
| 594 | if (mode == I2C_SMBUS_BLOCK_DATA || | 604 | if (mode == I2C_SMBUS_BLOCK_DATA |
| 595 | mode == I2C_SMBUS_I2C_BLOCK_DATA) { | 605 | || mode == I2C_SMBUS_I2C_BLOCK_DATA |
| 606 | ) { | ||
| 596 | if (pec && mode == I2C_SMBUS_I2C_BLOCK_DATA) | 607 | if (pec && mode == I2C_SMBUS_I2C_BLOCK_DATA) |
| 597 | bb_error_msg_and_die( | 608 | bb_error_msg_and_die( |
| 598 | "PEC not supported for I2C " | 609 | "PEC not supported for I2C " |
| @@ -606,6 +617,8 @@ int i2cset_main(int argc, char **argv) | |||
| 606 | } | 617 | } |
| 607 | 618 | ||
| 608 | /* Prepare the value(s) to be written according to current mode. */ | 619 | /* Prepare the value(s) to be written according to current mode. */ |
| 620 | mask = 0; | ||
| 621 | blen = 0; | ||
| 609 | switch (mode) { | 622 | switch (mode) { |
| 610 | case I2C_SMBUS_BYTE_DATA: | 623 | case I2C_SMBUS_BYTE_DATA: |
| 611 | val = xstrtou_range(argv[3], 0, 0, 0xff); | 624 | val = xstrtou_range(argv[3], 0, 0, 0xff); |
| @@ -615,8 +628,9 @@ int i2cset_main(int argc, char **argv) | |||
| 615 | break; | 628 | break; |
| 616 | case I2C_SMBUS_BLOCK_DATA: | 629 | case I2C_SMBUS_BLOCK_DATA: |
| 617 | case I2C_SMBUS_I2C_BLOCK_DATA: | 630 | case I2C_SMBUS_I2C_BLOCK_DATA: |
| 618 | for (blen = 3; blen < (argc - 1); blen++) | 631 | for (blen = 3; blen < argc; blen++) |
| 619 | block[blen] = xstrtou_range(argv[blen], 0, 0, 0xff); | 632 | block[blen - 3] = xstrtou_range(argv[blen], 0, 0, 0xff); |
| 633 | blen -= 3; | ||
| 620 | val = -1; | 634 | val = -1; |
| 621 | break; | 635 | break; |
| 622 | default: | 636 | default: |
diff --git a/miscutils/lsscsi.c b/miscutils/lsscsi.c index d7cd51056..0aaa01ded 100644 --- a/miscutils/lsscsi.c +++ b/miscutils/lsscsi.c | |||
| @@ -25,6 +25,8 @@ | |||
| 25 | 25 | ||
| 26 | #include "libbb.h" | 26 | #include "libbb.h" |
| 27 | 27 | ||
| 28 | static const char scsi_dir[] ALIGN1 = "/sys/bus/scsi/devices"; | ||
| 29 | |||
| 28 | static char *get_line(const char *filename, char *buf, unsigned *bufsize_p) | 30 | static char *get_line(const char *filename, char *buf, unsigned *bufsize_p) |
| 29 | { | 31 | { |
| 30 | unsigned bufsize = *bufsize_p; | 32 | unsigned bufsize = *bufsize_p; |
| @@ -53,7 +55,7 @@ int lsscsi_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
| 53 | struct dirent *de; | 55 | struct dirent *de; |
| 54 | DIR *dir; | 56 | DIR *dir; |
| 55 | 57 | ||
| 56 | xchdir("/sys/bus/scsi/devices"); | 58 | xchdir(scsi_dir); |
| 57 | 59 | ||
| 58 | dir = xopendir("."); | 60 | dir = xopendir("."); |
| 59 | while ((de = readdir(dir)) != NULL) { | 61 | while ((de = readdir(dir)) != NULL) { |
| @@ -112,7 +114,10 @@ int lsscsi_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
| 112 | ); | 114 | ); |
| 113 | /* TODO: also output device column, e.g. "/dev/sdX" */ | 115 | /* TODO: also output device column, e.g. "/dev/sdX" */ |
| 114 | 116 | ||
| 115 | xchdir(".."); | 117 | /* chdir("..") may not work as expected, |
| 118 | * since we might have followed a symlink. | ||
| 119 | */ | ||
| 120 | xchdir(scsi_dir); | ||
| 116 | } | 121 | } |
| 117 | 122 | ||
| 118 | if (ENABLE_FEATURE_CLEAN_UP) | 123 | if (ENABLE_FEATURE_CLEAN_UP) |
diff --git a/miscutils/time.c b/miscutils/time.c index 65dbcdcf3..61f078755 100644 --- a/miscutils/time.c +++ b/miscutils/time.c | |||
| @@ -1,13 +1,14 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* 'time' utility to display resource usage of processes. | 2 | /* |
| 3 | Copyright (C) 1990, 91, 92, 93, 96 Free Software Foundation, Inc. | 3 | * 'time' utility to display resource usage of processes. |
| 4 | 4 | * Copyright (C) 1990, 91, 92, 93, 96 Free Software Foundation, Inc. | |
| 5 | Licensed under GPLv2, see file LICENSE in this source tree. | 5 | * |
| 6 | */ | 6 | * Licensed under GPLv2, see file LICENSE in this source tree. |
| 7 | */ | ||
| 7 | /* Originally written by David Keppel <pardo@cs.washington.edu>. | 8 | /* Originally written by David Keppel <pardo@cs.washington.edu>. |
| 8 | Heavily modified by David MacKenzie <djm@gnu.ai.mit.edu>. | 9 | * Heavily modified by David MacKenzie <djm@gnu.ai.mit.edu>. |
| 9 | Heavily modified for busybox by Erik Andersen <andersen@codepoet.org> | 10 | * Heavily modified for busybox by Erik Andersen <andersen@codepoet.org> |
| 10 | */ | 11 | */ |
| 11 | //config:config TIME | 12 | //config:config TIME |
| 12 | //config: bool "time (7 kb)" | 13 | //config: bool "time (7 kb)" |
| 13 | //config: default y | 14 | //config: default y |
| @@ -441,11 +442,16 @@ int time_main(int argc UNUSED_PARAM, char **argv) | |||
| 441 | output_format = posix_format; | 442 | output_format = posix_format; |
| 442 | output_fd = STDERR_FILENO; | 443 | output_fd = STDERR_FILENO; |
| 443 | if (opt & OPT_o) { | 444 | if (opt & OPT_o) { |
| 445 | #ifndef O_CLOEXEC | ||
| 446 | # define O_CLOEXEC 0 | ||
| 447 | #endif | ||
| 444 | output_fd = xopen(output_filename, | 448 | output_fd = xopen(output_filename, |
| 445 | (opt & OPT_a) /* append? */ | 449 | (opt & OPT_a) /* append? */ |
| 446 | ? (O_CREAT | O_WRONLY | O_CLOEXEC | O_APPEND) | 450 | ? (O_CREAT | O_WRONLY | O_CLOEXEC | O_APPEND) |
| 447 | : (O_CREAT | O_WRONLY | O_CLOEXEC | O_TRUNC) | 451 | : (O_CREAT | O_WRONLY | O_CLOEXEC | O_TRUNC) |
| 448 | ); | 452 | ); |
| 453 | if (!O_CLOEXEC) | ||
| 454 | close_on_exec_on(output_fd); | ||
| 449 | } | 455 | } |
| 450 | 456 | ||
| 451 | run_command(argv, &res); | 457 | run_command(argv, &res); |
diff --git a/miscutils/ubi_tools.c b/miscutils/ubi_tools.c index 1ef8fd90e..a947abab5 100644 --- a/miscutils/ubi_tools.c +++ b/miscutils/ubi_tools.c | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | /* Ported to busybox from mtd-utils. | 1 | /* |
| 2 | * Ported to busybox from mtd-utils. | ||
| 2 | * | 3 | * |
| 3 | * Licensed under GPLv2, see file LICENSE in this source tree. | 4 | * Licensed under GPLv2, see file LICENSE in this source tree. |
| 4 | */ | 5 | */ |
diff --git a/networking/ifconfig.c b/networking/ifconfig.c index d1e9c58dc..61d91788a 100644 --- a/networking/ifconfig.c +++ b/networking/ifconfig.c | |||
| @@ -1,18 +1,17 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* ifconfig | 2 | /* |
| 3 | * ifconfig | ||
| 3 | * | 4 | * |
| 4 | * Similar to the standard Unix ifconfig, but with only the necessary | 5 | * Similar to the standard Unix ifconfig, but with only the necessary |
| 5 | * parts for AF_INET, and without any printing of if info (for now). | 6 | * parts for AF_INET, and without any printing of if info (for now). |
| 6 | * | 7 | * |
| 7 | * Bjorn Wesen, Axis Communications AB | 8 | * Bjorn Wesen, Axis Communications AB |
| 8 | * | 9 | * |
| 9 | * | ||
| 10 | * Authors of the original ifconfig was: | 10 | * Authors of the original ifconfig was: |
| 11 | * Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> | 11 | * Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> |
| 12 | * | 12 | * |
| 13 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 13 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 14 | */ | 14 | */ |
| 15 | |||
| 16 | /* | 15 | /* |
| 17 | * Heavily modified by Manuel Novoa III Mar 6, 2001 | 16 | * Heavily modified by Manuel Novoa III Mar 6, 2001 |
| 18 | * | 17 | * |
diff --git a/networking/ifupdown.c b/networking/ifupdown.c index 5521e8a5a..534c9f0c7 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c | |||
| @@ -1,18 +1,18 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* | 2 | /* |
| 3 | * ifup/ifdown for busybox | 3 | * ifup/ifdown for busybox |
| 4 | * Copyright (c) 2002 Glenn McGrath | 4 | * Copyright (c) 2002 Glenn McGrath |
| 5 | * Copyright (c) 2003-2004 Erik Andersen <andersen@codepoet.org> | 5 | * Copyright (c) 2003-2004 Erik Andersen <andersen@codepoet.org> |
| 6 | * | 6 | * |
| 7 | * Based on ifupdown v 0.6.4 by Anthony Towns | 7 | * Based on ifupdown v 0.6.4 by Anthony Towns |
| 8 | * Copyright (c) 1999 Anthony Towns <aj@azure.humbug.org.au> | 8 | * Copyright (c) 1999 Anthony Towns <aj@azure.humbug.org.au> |
| 9 | * | 9 | * |
| 10 | * Changes to upstream version | 10 | * Changes to upstream version |
| 11 | * Remove checks for kernel version, assume kernel version 2.2.0 or better. | 11 | * Remove checks for kernel version, assume kernel version 2.2.0 or better. |
| 12 | * Lines in the interfaces file cannot wrap. | 12 | * Lines in the interfaces file cannot wrap. |
| 13 | * To adhere to the FHS, the default state file is /var/run/ifstate | 13 | * To adhere to the FHS, the default state file is /var/run/ifstate |
| 14 | * (defined via CONFIG_IFUPDOWN_IFSTATE_PATH) and can be overridden by build | 14 | * (defined via CONFIG_IFUPDOWN_IFSTATE_PATH) and can be overridden by build |
| 15 | * configuration. | 15 | * configuration. |
| 16 | * | 16 | * |
| 17 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 17 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 18 | */ | 18 | */ |
diff --git a/networking/interface.c b/networking/interface.c index 119185881..89427f2f4 100644 --- a/networking/interface.c +++ b/networking/interface.c | |||
| @@ -30,7 +30,6 @@ | |||
| 30 | * 20001008 - Bernd Eckenfels, Patch from RH for setting mtu | 30 | * 20001008 - Bernd Eckenfels, Patch from RH for setting mtu |
| 31 | * (default AF was wrong) | 31 | * (default AF was wrong) |
| 32 | */ | 32 | */ |
| 33 | |||
| 34 | #include "libbb.h" | 33 | #include "libbb.h" |
| 35 | #include "inet_common.h" | 34 | #include "inet_common.h" |
| 36 | #include <net/if.h> | 35 | #include <net/if.h> |
diff --git a/networking/libiproute/ip_parse_common_args.c b/networking/libiproute/ip_parse_common_args.c index 1a298f738..d693c54fa 100644 --- a/networking/libiproute/ip_parse_common_args.c +++ b/networking/libiproute/ip_parse_common_args.c | |||
| @@ -11,7 +11,6 @@ | |||
| 11 | * | 11 | * |
| 12 | * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses | 12 | * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses |
| 13 | */ | 13 | */ |
| 14 | |||
| 15 | #include "ip_common.h" /* #include "libbb.h" is inside */ | 14 | #include "ip_common.h" /* #include "libbb.h" is inside */ |
| 16 | #include "utils.h" | 15 | #include "utils.h" |
| 17 | 16 | ||
diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c index 36d6b65c6..921ecf0d9 100644 --- a/networking/libiproute/ipaddress.c +++ b/networking/libiproute/ipaddress.c | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | * Changes: | 7 | * Changes: |
| 8 | * Laszlo Valko <valko@linux.karinthy.hu> 990223: address label must be zero terminated | 8 | * Laszlo Valko <valko@linux.karinthy.hu> 990223: address label must be zero terminated |
| 9 | */ | 9 | */ |
| 10 | |||
| 11 | #include <fnmatch.h> | 10 | #include <fnmatch.h> |
| 12 | #include <net/if.h> | 11 | #include <net/if.h> |
| 13 | #include <net/if_arp.h> | 12 | #include <net/if_arp.h> |
diff --git a/networking/libiproute/ipneigh.c b/networking/libiproute/ipneigh.c index 2a1c20e20..1cd90d707 100644 --- a/networking/libiproute/ipneigh.c +++ b/networking/libiproute/ipneigh.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Ported to Busybox by: Curt Brune <curt@cumulusnetworks.com> | 7 | * Ported to Busybox by: Curt Brune <curt@cumulusnetworks.com> |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "ip_common.h" /* #include "libbb.h" is inside */ | 9 | #include "ip_common.h" /* #include "libbb.h" is inside */ |
| 11 | #include "common_bufsiz.h" | 10 | #include "common_bufsiz.h" |
| 12 | #include "rt_names.h" | 11 | #include "rt_names.h" |
diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c index 6a41b8331..95dafe183 100644 --- a/networking/libiproute/iproute.c +++ b/networking/libiproute/iproute.c | |||
| @@ -9,12 +9,16 @@ | |||
| 9 | * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses | 9 | * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses |
| 10 | * Kunihiro Ishiguro <kunihiro@zebra.org> 001102: rtnh_ifindex was not initialized | 10 | * Kunihiro Ishiguro <kunihiro@zebra.org> 001102: rtnh_ifindex was not initialized |
| 11 | */ | 11 | */ |
| 12 | |||
| 13 | #include "ip_common.h" /* #include "libbb.h" is inside */ | 12 | #include "ip_common.h" /* #include "libbb.h" is inside */ |
| 14 | #include "common_bufsiz.h" | 13 | #include "common_bufsiz.h" |
| 15 | #include "rt_names.h" | 14 | #include "rt_names.h" |
| 16 | #include "utils.h" | 15 | #include "utils.h" |
| 17 | 16 | ||
| 17 | #include <linux/version.h> | ||
| 18 | /* RTA_TABLE is not a define, can't test with ifdef. */ | ||
| 19 | /* As a proxy, test which kernels toolchain expects: */ | ||
| 20 | #define HAVE_RTA_TABLE (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) | ||
| 21 | |||
| 18 | #ifndef RTAX_RTTVAR | 22 | #ifndef RTAX_RTTVAR |
| 19 | #define RTAX_RTTVAR RTAX_HOPS | 23 | #define RTAX_RTTVAR RTAX_HOPS |
| 20 | #endif | 24 | #endif |
| @@ -82,9 +86,11 @@ static int FAST_FUNC print_route(const struct sockaddr_nl *who UNUSED_PARAM, | |||
| 82 | memset(tb, 0, sizeof(tb)); | 86 | memset(tb, 0, sizeof(tb)); |
| 83 | parse_rtattr(tb, RTA_MAX, RTM_RTA(r), len); | 87 | parse_rtattr(tb, RTA_MAX, RTM_RTA(r), len); |
| 84 | 88 | ||
| 89 | #if HAVE_RTA_TABLE | ||
| 85 | if (tb[RTA_TABLE]) | 90 | if (tb[RTA_TABLE]) |
| 86 | tid = *(uint32_t *)RTA_DATA(tb[RTA_TABLE]); | 91 | tid = *(uint32_t *)RTA_DATA(tb[RTA_TABLE]); |
| 87 | else | 92 | else |
| 93 | #endif | ||
| 88 | tid = r->rtm_table; | 94 | tid = r->rtm_table; |
| 89 | 95 | ||
| 90 | if (r->rtm_family == AF_INET6) | 96 | if (r->rtm_family == AF_INET6) |
| @@ -460,12 +466,13 @@ IF_FEATURE_IP_RULE(ARG_table,) | |||
| 460 | NEXT_ARG(); | 466 | NEXT_ARG(); |
| 461 | if (rtnl_rttable_a2n(&tid, *argv)) | 467 | if (rtnl_rttable_a2n(&tid, *argv)) |
| 462 | invarg_1_to_2(*argv, keyword_table); | 468 | invarg_1_to_2(*argv, keyword_table); |
| 463 | if (tid < 256) | 469 | #if HAVE_RTA_TABLE |
| 464 | req.r.rtm_table = tid; | 470 | if (tid > 255) { |
| 465 | else { | ||
| 466 | req.r.rtm_table = RT_TABLE_UNSPEC; | 471 | req.r.rtm_table = RT_TABLE_UNSPEC; |
| 467 | addattr32(&req.n, sizeof(req), RTA_TABLE, tid); | 472 | addattr32(&req.n, sizeof(req), RTA_TABLE, tid); |
| 468 | } | 473 | } else |
| 474 | #endif | ||
| 475 | req.r.rtm_table = tid; | ||
| 469 | #endif | 476 | #endif |
| 470 | } else if (arg == ARG_dev || arg == ARG_oif) { | 477 | } else if (arg == ARG_dev || arg == ARG_oif) { |
| 471 | NEXT_ARG(); | 478 | NEXT_ARG(); |
diff --git a/networking/libiproute/iprule.c b/networking/libiproute/iprule.c index 1bb5e759e..53b11e16c 100644 --- a/networking/libiproute/iprule.c +++ b/networking/libiproute/iprule.c | |||
| @@ -12,7 +12,6 @@ | |||
| 12 | * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses | 12 | * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses |
| 13 | * initially integrated into busybox by Bernhard Reutner-Fischer | 13 | * initially integrated into busybox by Bernhard Reutner-Fischer |
| 14 | */ | 14 | */ |
| 15 | |||
| 16 | #include <netinet/in.h> | 15 | #include <netinet/in.h> |
| 17 | #include <netinet/ip.h> | 16 | #include <netinet/ip.h> |
| 18 | #include <arpa/inet.h> | 17 | #include <arpa/inet.h> |
| @@ -25,6 +24,11 @@ | |||
| 25 | #include "rt_names.h" | 24 | #include "rt_names.h" |
| 26 | #include "utils.h" | 25 | #include "utils.h" |
| 27 | 26 | ||
| 27 | #include <linux/version.h> | ||
| 28 | /* RTA_TABLE is not a define, can't test with ifdef. */ | ||
| 29 | /* As a proxy, test which kernels toolchain expects: */ | ||
| 30 | #define HAVE_RTA_TABLE (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) | ||
| 31 | |||
| 28 | /* If you add stuff here, update iprule_full_usage */ | 32 | /* If you add stuff here, update iprule_full_usage */ |
| 29 | static const char keywords[] ALIGN1 = | 33 | static const char keywords[] ALIGN1 = |
| 30 | "from\0""to\0""preference\0""order\0""priority\0" | 34 | "from\0""to\0""preference\0""order\0""priority\0" |
| @@ -121,9 +125,12 @@ static int FAST_FUNC print_rule(const struct sockaddr_nl *who UNUSED_PARAM, | |||
| 121 | printf("iif %s ", (char*)RTA_DATA(tb[RTA_IIF])); | 125 | printf("iif %s ", (char*)RTA_DATA(tb[RTA_IIF])); |
| 122 | } | 126 | } |
| 123 | 127 | ||
| 128 | #if HAVE_RTA_TABLE | ||
| 124 | if (tb[RTA_TABLE]) | 129 | if (tb[RTA_TABLE]) |
| 125 | printf("lookup %s ", rtnl_rttable_n2a(*(uint32_t*)RTA_DATA(tb[RTA_TABLE]))); | 130 | printf("lookup %s ", rtnl_rttable_n2a(*(uint32_t*)RTA_DATA(tb[RTA_TABLE]))); |
| 126 | else if (r->rtm_table) | 131 | else |
| 132 | #endif | ||
| 133 | if (r->rtm_table) | ||
| 127 | printf("lookup %s ", rtnl_rttable_n2a(r->rtm_table)); | 134 | printf("lookup %s ", rtnl_rttable_n2a(r->rtm_table)); |
| 128 | 135 | ||
| 129 | if (tb[FRA_SUPPRESS_PREFIXLEN]) { | 136 | if (tb[FRA_SUPPRESS_PREFIXLEN]) { |
| @@ -267,12 +274,15 @@ static int iprule_modify(int cmd, char **argv) | |||
| 267 | NEXT_ARG(); | 274 | NEXT_ARG(); |
| 268 | if (rtnl_rttable_a2n(&tid, *argv)) | 275 | if (rtnl_rttable_a2n(&tid, *argv)) |
| 269 | invarg_1_to_2(*argv, "table ID"); | 276 | invarg_1_to_2(*argv, "table ID"); |
| 270 | if (tid < 256) | 277 | |
| 271 | req.r.rtm_table = tid; | 278 | #if HAVE_RTA_TABLE |
| 272 | else { | 279 | if (tid > 255) { |
| 273 | req.r.rtm_table = RT_TABLE_UNSPEC; | 280 | req.r.rtm_table = RT_TABLE_UNSPEC; |
| 274 | addattr32(&req.n, sizeof(req), RTA_TABLE, tid); | 281 | addattr32(&req.n, sizeof(req), RTA_TABLE, tid); |
| 275 | } | 282 | } else |
| 283 | #endif | ||
| 284 | req.r.rtm_table = tid; | ||
| 285 | |||
| 276 | table_ok = 1; | 286 | table_ok = 1; |
| 277 | } else if (key == ARG_suppress_prefixlength) { | 287 | } else if (key == ARG_suppress_prefixlength) { |
| 278 | int prefix_length; | 288 | int prefix_length; |
diff --git a/networking/libiproute/iptunnel.c b/networking/libiproute/iptunnel.c index eb136e435..4002feb78 100644 --- a/networking/libiproute/iptunnel.c +++ b/networking/libiproute/iptunnel.c | |||
| @@ -10,7 +10,6 @@ | |||
| 10 | * Rani Assaf <rani@magic.metawire.com> 980930: do not allow key for ipip/sit | 10 | * Rani Assaf <rani@magic.metawire.com> 980930: do not allow key for ipip/sit |
| 11 | * Phil Karn <karn@ka9q.ampr.org> 990408: "pmtudisc" flag | 11 | * Phil Karn <karn@ka9q.ampr.org> 990408: "pmtudisc" flag |
| 12 | */ | 12 | */ |
| 13 | |||
| 14 | #include <netinet/ip.h> | 13 | #include <netinet/ip.h> |
| 15 | #include <net/if.h> | 14 | #include <net/if.h> |
| 16 | #include <net/if_arp.h> | 15 | #include <net/if_arp.h> |
diff --git a/networking/libiproute/libnetlink.c b/networking/libiproute/libnetlink.c index 7e0ff1b6c..3f0f70326 100644 --- a/networking/libiproute/libnetlink.c +++ b/networking/libiproute/libnetlink.c | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | * | 7 | * |
| 8 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | 8 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> |
| 9 | */ | 9 | */ |
| 10 | |||
| 11 | #include <sys/socket.h> | 10 | #include <sys/socket.h> |
| 12 | #include <sys/uio.h> | 11 | #include <sys/uio.h> |
| 13 | 12 | ||
diff --git a/networking/libiproute/ll_addr.c b/networking/libiproute/ll_addr.c index 33a54ea6c..afdd81ffb 100644 --- a/networking/libiproute/ll_addr.c +++ b/networking/libiproute/ll_addr.c | |||
| @@ -7,14 +7,12 @@ | |||
| 7 | * | 7 | * |
| 8 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | 8 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> |
| 9 | */ | 9 | */ |
| 10 | |||
| 11 | #include <net/if_arp.h> | 10 | #include <net/if_arp.h> |
| 12 | 11 | ||
| 13 | #include "libbb.h" | 12 | #include "libbb.h" |
| 14 | #include "rt_names.h" | 13 | #include "rt_names.h" |
| 15 | #include "utils.h" | 14 | #include "utils.h" |
| 16 | 15 | ||
| 17 | |||
| 18 | const char* FAST_FUNC ll_addr_n2a(unsigned char *addr, int alen, int type, char *buf, int blen) | 16 | const char* FAST_FUNC ll_addr_n2a(unsigned char *addr, int alen, int type, char *buf, int blen) |
| 19 | { | 17 | { |
| 20 | int i; | 18 | int i; |
diff --git a/networking/libiproute/ll_map.c b/networking/libiproute/ll_map.c index af9eb46f7..be88a04e8 100644 --- a/networking/libiproute/ll_map.c +++ b/networking/libiproute/ll_map.c | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | * | 7 | * |
| 8 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | 8 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> |
| 9 | */ | 9 | */ |
| 10 | |||
| 11 | #include <net/if.h> /* struct ifreq and co. */ | 10 | #include <net/if.h> /* struct ifreq and co. */ |
| 12 | 11 | ||
| 13 | #include "libbb.h" | 12 | #include "libbb.h" |
diff --git a/networking/libiproute/ll_proto.c b/networking/libiproute/ll_proto.c index 4c32ae574..7d46221ac 100644 --- a/networking/libiproute/ll_proto.c +++ b/networking/libiproute/ll_proto.c | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | * | 7 | * |
| 8 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | 8 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> |
| 9 | */ | 9 | */ |
| 10 | |||
| 11 | #include "libbb.h" | 10 | #include "libbb.h" |
| 12 | #include "rt_names.h" | 11 | #include "rt_names.h" |
| 13 | #include "utils.h" | 12 | #include "utils.h" |
diff --git a/networking/libiproute/rtm_map.c b/networking/libiproute/rtm_map.c index c763da049..e94c99ab6 100644 --- a/networking/libiproute/rtm_map.c +++ b/networking/libiproute/rtm_map.c | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | * | 7 | * |
| 8 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | 8 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> |
| 9 | */ | 9 | */ |
| 10 | |||
| 11 | #include "libbb.h" | 10 | #include "libbb.h" |
| 12 | #include "rt_names.h" | 11 | #include "rt_names.h" |
| 13 | #include "utils.h" | 12 | #include "utils.h" |
| @@ -44,7 +43,6 @@ const char* FAST_FUNC rtnl_rtntype_n2a(int id) | |||
| 44 | } | 43 | } |
| 45 | } | 44 | } |
| 46 | 45 | ||
| 47 | |||
| 48 | int FAST_FUNC rtnl_rtntype_a2n(int *id, char *arg) | 46 | int FAST_FUNC rtnl_rtntype_a2n(int *id, char *arg) |
| 49 | { | 47 | { |
| 50 | static const char keywords[] ALIGN1 = | 48 | static const char keywords[] ALIGN1 = |
diff --git a/networking/libiproute/utils.c b/networking/libiproute/utils.c index fca167ac6..bf053a54b 100644 --- a/networking/libiproute/utils.c +++ b/networking/libiproute/utils.c | |||
| @@ -8,7 +8,6 @@ | |||
| 8 | * | 8 | * |
| 9 | * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses | 9 | * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses |
| 10 | */ | 10 | */ |
| 11 | |||
| 12 | #include "libbb.h" | 11 | #include "libbb.h" |
| 13 | #include "utils.h" | 12 | #include "utils.h" |
| 14 | #include "inet_common.h" | 13 | #include "inet_common.h" |
diff --git a/networking/nc.c b/networking/nc.c index 4b8f9c13a..de02ccc9d 100644 --- a/networking/nc.c +++ b/networking/nc.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* nc: mini-netcat - built from the ground up for LRP | 2 | /* |
| 3 | * nc: mini-netcat - built from the ground up for LRP | ||
| 3 | * | 4 | * |
| 4 | * Copyright (C) 1998, 1999 Charles P. Wright | 5 | * Copyright (C) 1998, 1999 Charles P. Wright |
| 5 | * Copyright (C) 1998 Dave Cinege | 6 | * Copyright (C) 1998 Dave Cinege |
diff --git a/networking/ntpd.c b/networking/ntpd.c index 4f881eaf9..0b60d003b 100644 --- a/networking/ntpd.c +++ b/networking/ntpd.c | |||
| @@ -71,7 +71,7 @@ | |||
| 71 | //usage: "[-dnqNw"IF_FEATURE_NTPD_SERVER("l -I IFACE")"] [-S PROG] [-p PEER]..." | 71 | //usage: "[-dnqNw"IF_FEATURE_NTPD_SERVER("l -I IFACE")"] [-S PROG] [-p PEER]..." |
| 72 | //usage:#define ntpd_full_usage "\n\n" | 72 | //usage:#define ntpd_full_usage "\n\n" |
| 73 | //usage: "NTP client/server\n" | 73 | //usage: "NTP client/server\n" |
| 74 | //usage: "\n -d Verbose" | 74 | //usage: "\n -d Verbose (may be repeated)" |
| 75 | //usage: "\n -n Do not daemonize" | 75 | //usage: "\n -n Do not daemonize" |
| 76 | //usage: "\n -q Quit after clock is set" | 76 | //usage: "\n -q Quit after clock is set" |
| 77 | //usage: "\n -N Run at high priority" | 77 | //usage: "\n -N Run at high priority" |
| @@ -155,7 +155,8 @@ | |||
| 155 | #define RETRY_INTERVAL 32 /* on send/recv error, retry in N secs (need to be power of 2) */ | 155 | #define RETRY_INTERVAL 32 /* on send/recv error, retry in N secs (need to be power of 2) */ |
| 156 | #define NOREPLY_INTERVAL 512 /* sent, but got no reply: cap next query by this many seconds */ | 156 | #define NOREPLY_INTERVAL 512 /* sent, but got no reply: cap next query by this many seconds */ |
| 157 | #define RESPONSE_INTERVAL 16 /* wait for reply up to N secs */ | 157 | #define RESPONSE_INTERVAL 16 /* wait for reply up to N secs */ |
| 158 | #define HOSTNAME_INTERVAL 5 /* hostname lookup failed. Wait N secs for next try */ | 158 | #define HOSTNAME_INTERVAL 4 /* hostname lookup failed. Wait N * peer->dns_errors secs for next try */ |
| 159 | #define DNS_ERRORS_CAP 0x3f /* peer->dns_errors is in [0..63] */ | ||
| 159 | 160 | ||
| 160 | /* Step threshold (sec). std ntpd uses 0.128. | 161 | /* Step threshold (sec). std ntpd uses 0.128. |
| 161 | */ | 162 | */ |
| @@ -301,6 +302,7 @@ typedef struct { | |||
| 301 | uint8_t lastpkt_status; | 302 | uint8_t lastpkt_status; |
| 302 | uint8_t lastpkt_stratum; | 303 | uint8_t lastpkt_stratum; |
| 303 | uint8_t reachable_bits; | 304 | uint8_t reachable_bits; |
| 305 | uint8_t dns_errors; | ||
| 304 | /* when to send new query (if p_fd == -1) | 306 | /* when to send new query (if p_fd == -1) |
| 305 | * or when receive times out (if p_fd >= 0): */ | 307 | * or when receive times out (if p_fd >= 0): */ |
| 306 | double next_action_time; | 308 | double next_action_time; |
| @@ -802,10 +804,10 @@ resolve_peer_hostname(peer_t *p) | |||
| 802 | p->p_dotted = xmalloc_sockaddr2dotted_noport(&lsa->u.sa); | 804 | p->p_dotted = xmalloc_sockaddr2dotted_noport(&lsa->u.sa); |
| 803 | VERB1 if (strcmp(p->p_hostname, p->p_dotted) != 0) | 805 | VERB1 if (strcmp(p->p_hostname, p->p_dotted) != 0) |
| 804 | bb_error_msg("'%s' is %s", p->p_hostname, p->p_dotted); | 806 | bb_error_msg("'%s' is %s", p->p_hostname, p->p_dotted); |
| 805 | } else { | 807 | p->dns_errors = 0; |
| 806 | /* error message is emitted by host2sockaddr() */ | 808 | return lsa; |
| 807 | set_next(p, HOSTNAME_INTERVAL); | ||
| 808 | } | 809 | } |
| 810 | p->dns_errors = ((p->dns_errors << 1) | 1) & DNS_ERRORS_CAP; | ||
| 809 | return lsa; | 811 | return lsa; |
| 810 | } | 812 | } |
| 811 | 813 | ||
| @@ -866,10 +868,8 @@ do_sendto(int fd, | |||
| 866 | static void | 868 | static void |
| 867 | send_query_to_peer(peer_t *p) | 869 | send_query_to_peer(peer_t *p) |
| 868 | { | 870 | { |
| 869 | if (!p->p_lsa) { | 871 | if (!p->p_lsa) |
| 870 | if (!resolve_peer_hostname(p)) | 872 | return; |
| 871 | return; | ||
| 872 | } | ||
| 873 | 873 | ||
| 874 | /* Why do we need to bind()? | 874 | /* Why do we need to bind()? |
| 875 | * See what happens when we don't bind: | 875 | * See what happens when we don't bind: |
| @@ -2441,13 +2441,42 @@ int ntpd_main(int argc UNUSED_PARAM, char **argv) | |||
| 2441 | did_poll: | 2441 | did_poll: |
| 2442 | gettime1900d(); /* sets G.cur_time */ | 2442 | gettime1900d(); /* sets G.cur_time */ |
| 2443 | if (nfds <= 0) { | 2443 | if (nfds <= 0) { |
| 2444 | if (!bb_got_signal /* poll wasn't interrupted by a signal */ | 2444 | double ct; |
| 2445 | && G.cur_time - G.last_script_run > 11*60 | 2445 | int dns_error; |
| 2446 | ) { | 2446 | |
| 2447 | if (bb_got_signal) | ||
| 2448 | break; /* poll was interrupted by a signal */ | ||
| 2449 | |||
| 2450 | if (G.cur_time - G.last_script_run > 11*60) { | ||
| 2447 | /* Useful for updating battery-backed RTC and such */ | 2451 | /* Useful for updating battery-backed RTC and such */ |
| 2448 | run_script("periodic", G.last_update_offset); | 2452 | run_script("periodic", G.last_update_offset); |
| 2449 | gettime1900d(); /* sets G.cur_time */ | 2453 | gettime1900d(); /* sets G.cur_time */ |
| 2450 | } | 2454 | } |
| 2455 | |||
| 2456 | /* Resolve peer names to IPs, if not resolved yet. | ||
| 2457 | * We do it only when poll timed out: | ||
| 2458 | * this way, we almost never overlap DNS resolution with | ||
| 2459 | * "request-reply" packet round trip. | ||
| 2460 | */ | ||
| 2461 | dns_error = 0; | ||
| 2462 | ct = G.cur_time; | ||
| 2463 | for (item = G.ntp_peers; item != NULL; item = item->link) { | ||
| 2464 | peer_t *p = (peer_t *) item->data; | ||
| 2465 | if (p->next_action_time <= ct && !p->p_lsa) { | ||
| 2466 | /* This can take up to ~10 sec per each DNS query */ | ||
| 2467 | dns_error |= (!resolve_peer_hostname(p)); | ||
| 2468 | } | ||
| 2469 | } | ||
| 2470 | if (!dns_error) | ||
| 2471 | goto check_unsync; | ||
| 2472 | /* Set next time for those which are still not resolved */ | ||
| 2473 | gettime1900d(); /* sets G.cur_time (needed for set_next()) */ | ||
| 2474 | for (item = G.ntp_peers; item != NULL; item = item->link) { | ||
| 2475 | peer_t *p = (peer_t *) item->data; | ||
| 2476 | if (p->next_action_time <= ct && !p->p_lsa) { | ||
| 2477 | set_next(p, HOSTNAME_INTERVAL * p->dns_errors); | ||
| 2478 | } | ||
| 2479 | } | ||
| 2451 | goto check_unsync; | 2480 | goto check_unsync; |
| 2452 | } | 2481 | } |
| 2453 | 2482 | ||
diff --git a/networking/ping.c b/networking/ping.c index 774f8f3e0..d1d59d545 100644 --- a/networking/ping.c +++ b/networking/ping.c | |||
| @@ -135,6 +135,14 @@ | |||
| 135 | # define ICMP_ADDRESSREPLY 18 /* Address Mask Reply */ | 135 | # define ICMP_ADDRESSREPLY 18 /* Address Mask Reply */ |
| 136 | #endif | 136 | #endif |
| 137 | 137 | ||
| 138 | /* Some operating systems, like GNU/Hurd, don't define SOL_RAW, but do have | ||
| 139 | * IPPROTO_RAW. Since the IPPROTO definitions are also valid to use for | ||
| 140 | * setsockopt (and take the same value as their corresponding SOL definitions, | ||
| 141 | * if they exist), we can just fall back on IPPROTO_RAW. */ | ||
| 142 | #ifndef SOL_RAW | ||
| 143 | # define SOL_RAW IPPROTO_RAW | ||
| 144 | #endif | ||
| 145 | |||
| 138 | #if ENABLE_PING6 | 146 | #if ENABLE_PING6 |
| 139 | # include <netinet/icmp6.h> | 147 | # include <netinet/icmp6.h> |
| 140 | /* I see RENUMBERED constants in bits/in.h - !!? | 148 | /* I see RENUMBERED constants in bits/in.h - !!? |
diff --git a/networking/route.c b/networking/route.c index 32789eecc..6edc0f6d7 100644 --- a/networking/route.c +++ b/networking/route.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* route | 2 | /* |
| 3 | * route | ||
| 3 | * | 4 | * |
| 4 | * Similar to the standard Unix route, but with only the necessary | 5 | * Similar to the standard Unix route, but with only the necessary |
| 5 | * parts for AF_INET and AF_INET6 | 6 | * parts for AF_INET and AF_INET6 |
| @@ -18,7 +19,6 @@ | |||
| 18 | * | 19 | * |
| 19 | * IPV6 support added by Bart Visscher <magick@linux-fan.com> | 20 | * IPV6 support added by Bart Visscher <magick@linux-fan.com> |
| 20 | */ | 21 | */ |
| 21 | |||
| 22 | /* 2004/03/09 Manuel Novoa III <mjn3@codepoet.org> | 22 | /* 2004/03/09 Manuel Novoa III <mjn3@codepoet.org> |
| 23 | * | 23 | * |
| 24 | * Rewritten to fix several bugs, add additional error checking, and | 24 | * Rewritten to fix several bugs, add additional error checking, and |
diff --git a/networking/telnet.c b/networking/telnet.c index 1f8a44466..8b0df7f5c 100644 --- a/networking/telnet.c +++ b/networking/telnet.c | |||
| @@ -18,7 +18,6 @@ | |||
| 18 | * <jam@ltsp.org> | 18 | * <jam@ltsp.org> |
| 19 | * Modified 2004/02/11 to add ability to pass the USER variable to remote host | 19 | * Modified 2004/02/11 to add ability to pass the USER variable to remote host |
| 20 | * by Fernando Silveira <swrh@gmx.net> | 20 | * by Fernando Silveira <swrh@gmx.net> |
| 21 | * | ||
| 22 | */ | 21 | */ |
| 23 | //config:config TELNET | 22 | //config:config TELNET |
| 24 | //config: bool "telnet (8.7 kb)" | 23 | //config: bool "telnet (8.7 kb)" |
diff --git a/networking/traceroute.c b/networking/traceroute.c index 8b6247482..a027b928a 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c | |||
| @@ -311,6 +311,9 @@ | |||
| 311 | # ifndef SOL_IPV6 | 311 | # ifndef SOL_IPV6 |
| 312 | # define SOL_IPV6 IPPROTO_IPV6 | 312 | # define SOL_IPV6 IPPROTO_IPV6 |
| 313 | # endif | 313 | # endif |
| 314 | # if defined(IPV6_PKTINFO) && !defined(IPV6_RECVPKTINFO) | ||
| 315 | # define IPV6_RECVPKTINFO IPV6_PKTINFO | ||
| 316 | # endif | ||
| 314 | #endif | 317 | #endif |
| 315 | 318 | ||
| 316 | #include "libbb.h" | 319 | #include "libbb.h" |
| @@ -323,6 +326,14 @@ | |||
| 323 | # define IPPROTO_IP 0 | 326 | # define IPPROTO_IP 0 |
| 324 | #endif | 327 | #endif |
| 325 | 328 | ||
| 329 | /* Some operating systems, like GNU/Hurd, don't define SOL_RAW, but do have | ||
| 330 | * IPPROTO_RAW. Since the IPPROTO definitions are also valid to use for | ||
| 331 | * setsockopt (and take the same value as their corresponding SOL definitions, | ||
| 332 | * if they exist), we can just fall back on IPPROTO_RAW. */ | ||
| 333 | #ifndef SOL_RAW | ||
| 334 | # define SOL_RAW IPPROTO_RAW | ||
| 335 | #endif | ||
| 336 | |||
| 326 | 337 | ||
| 327 | #define OPT_STRING \ | 338 | #define OPT_STRING \ |
| 328 | "FIlnrdvxt:i:m:p:q:s:w:z:f:" \ | 339 | "FIlnrdvxt:i:m:p:q:s:w:z:f:" \ |
| @@ -698,6 +709,9 @@ packet_ok(int read_len, len_and_sockaddr *from_lsa, | |||
| 698 | 709 | ||
| 699 | # if ENABLE_FEATURE_TRACEROUTE_VERBOSE | 710 | # if ENABLE_FEATURE_TRACEROUTE_VERBOSE |
| 700 | if (verbose) { | 711 | if (verbose) { |
| 712 | # ifndef MAXHOSTNAMELEN | ||
| 713 | # define MAXHOSTNAMELEN 80 | ||
| 714 | # endif | ||
| 701 | unsigned char *p; | 715 | unsigned char *p; |
| 702 | char pa1[MAXHOSTNAMELEN]; | 716 | char pa1[MAXHOSTNAMELEN]; |
| 703 | char pa2[MAXHOSTNAMELEN]; | 717 | char pa2[MAXHOSTNAMELEN]; |
| @@ -903,12 +917,7 @@ common_traceroute_main(int op, char **argv) | |||
| 903 | #if ENABLE_TRACEROUTE6 | 917 | #if ENABLE_TRACEROUTE6 |
| 904 | if (af == AF_INET6) { | 918 | if (af == AF_INET6) { |
| 905 | xmove_fd(xsocket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6), rcvsock); | 919 | xmove_fd(xsocket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6), rcvsock); |
| 906 | # ifdef IPV6_RECVPKTINFO | ||
| 907 | setsockopt_1(rcvsock, SOL_IPV6, IPV6_RECVPKTINFO); | 920 | setsockopt_1(rcvsock, SOL_IPV6, IPV6_RECVPKTINFO); |
| 908 | setsockopt_1(rcvsock, SOL_IPV6, IPV6_2292PKTINFO); | ||
| 909 | # else | ||
| 910 | setsockopt_1(rcvsock, SOL_IPV6, IPV6_PKTINFO); | ||
| 911 | # endif | ||
| 912 | } else | 921 | } else |
| 913 | #endif | 922 | #endif |
| 914 | { | 923 | { |
diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h index a9c23a186..04939e707 100644 --- a/networking/udhcp/common.h +++ b/networking/udhcp/common.h | |||
| @@ -308,7 +308,9 @@ int udhcp_send_raw_packet(struct dhcp_packet *dhcp_pkt, | |||
| 308 | 308 | ||
| 309 | int udhcp_send_kernel_packet(struct dhcp_packet *dhcp_pkt, | 309 | int udhcp_send_kernel_packet(struct dhcp_packet *dhcp_pkt, |
| 310 | uint32_t source_nip, int source_port, | 310 | uint32_t source_nip, int source_port, |
| 311 | uint32_t dest_nip, int dest_port) FAST_FUNC; | 311 | uint32_t dest_nip, int dest_port, |
| 312 | int send_flags | ||
| 313 | ) FAST_FUNC; | ||
| 312 | 314 | ||
| 313 | void udhcp_sp_setup(void) FAST_FUNC; | 315 | void udhcp_sp_setup(void) FAST_FUNC; |
| 314 | void udhcp_sp_fd_set(struct pollfd *pfds, int extra_fd) FAST_FUNC; | 316 | void udhcp_sp_fd_set(struct pollfd *pfds, int extra_fd) FAST_FUNC; |
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c index 714555fa8..37ffd064d 100644 --- a/networking/udhcp/d6_dhcpc.c +++ b/networking/udhcp/d6_dhcpc.c | |||
| @@ -702,13 +702,15 @@ static NOINLINE int send_d6_renew(uint32_t xid, struct in6_addr *server_ipv6, st | |||
| 702 | opt_ptr = add_d6_client_options(opt_ptr); | 702 | opt_ptr = add_d6_client_options(opt_ptr); |
| 703 | 703 | ||
| 704 | bb_error_msg("sending %s", "renew"); | 704 | bb_error_msg("sending %s", "renew"); |
| 705 | if (server_ipv6) | 705 | if (server_ipv6) { |
| 706 | return d6_send_kernel_packet( | 706 | return d6_send_kernel_packet( |
| 707 | &packet, (opt_ptr - (uint8_t*) &packet), | 707 | &packet, (opt_ptr - (uint8_t*) &packet), |
| 708 | our_cur_ipv6, CLIENT_PORT6, | 708 | our_cur_ipv6, CLIENT_PORT6, |
| 709 | server_ipv6, SERVER_PORT6, | 709 | server_ipv6, SERVER_PORT6, |
| 710 | client_config.ifindex | 710 | client_config.ifindex |
| 711 | /* TODO? send_flags: MSG_DONTROUTE (see IPv4 code for reason why) */ | ||
| 711 | ); | 712 | ); |
| 713 | } | ||
| 712 | return d6_mcast_from_client_config_ifindex(&packet, opt_ptr); | 714 | return d6_mcast_from_client_config_ifindex(&packet, opt_ptr); |
| 713 | } | 715 | } |
| 714 | 716 | ||
| @@ -881,9 +883,14 @@ static int d6_raw_socket(int ifindex) | |||
| 881 | fd = xsocket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IPV6)); | 883 | fd = xsocket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IPV6)); |
| 882 | log2("got raw socket fd %d", fd); | 884 | log2("got raw socket fd %d", fd); |
| 883 | 885 | ||
| 886 | memset(&sock, 0, sizeof(sock)); /* let's be deterministic */ | ||
| 884 | sock.sll_family = AF_PACKET; | 887 | sock.sll_family = AF_PACKET; |
| 885 | sock.sll_protocol = htons(ETH_P_IPV6); | 888 | sock.sll_protocol = htons(ETH_P_IPV6); |
| 886 | sock.sll_ifindex = ifindex; | 889 | sock.sll_ifindex = ifindex; |
| 890 | /*sock.sll_hatype = ARPHRD_???;*/ | ||
| 891 | /*sock.sll_pkttype = PACKET_???;*/ | ||
| 892 | /*sock.sll_halen = ???;*/ | ||
| 893 | /*sock.sll_addr[8] = ???;*/ | ||
| 887 | xbind(fd, (struct sockaddr *) &sock, sizeof(sock)); | 894 | xbind(fd, (struct sockaddr *) &sock, sizeof(sock)); |
| 888 | 895 | ||
| 889 | #if 0 | 896 | #if 0 |
| @@ -1425,7 +1432,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
| 1425 | len = d6_recv_raw_packet(&srv6_buf, &packet, sockfd); | 1432 | len = d6_recv_raw_packet(&srv6_buf, &packet, sockfd); |
| 1426 | if (len == -1) { | 1433 | if (len == -1) { |
| 1427 | /* Error is severe, reopen socket */ | 1434 | /* Error is severe, reopen socket */ |
| 1428 | bb_error_msg("read error: %s, reopening socket", strerror(errno)); | 1435 | bb_error_msg("read error: "STRERROR_FMT", reopening socket" STRERROR_ERRNO); |
| 1429 | sleep(discover_timeout); /* 3 seconds by default */ | 1436 | sleep(discover_timeout); /* 3 seconds by default */ |
| 1430 | change_listen_mode(listen_mode); /* just close and reopen */ | 1437 | change_listen_mode(listen_mode); /* just close and reopen */ |
| 1431 | } | 1438 | } |
diff --git a/networking/udhcp/d6_packet.c b/networking/udhcp/d6_packet.c index 79a0ac8a8..493943d72 100644 --- a/networking/udhcp/d6_packet.c +++ b/networking/udhcp/d6_packet.c | |||
| @@ -18,7 +18,7 @@ void FAST_FUNC d6_dump_packet(struct d6_packet *packet) | |||
| 18 | return; | 18 | return; |
| 19 | 19 | ||
| 20 | bb_error_msg( | 20 | bb_error_msg( |
| 21 | "xid %x" | 21 | " xid %x" |
| 22 | , packet->d6_xid32 | 22 | , packet->d6_xid32 |
| 23 | ); | 23 | ); |
| 24 | //*bin2hex(buf, (void *) packet->chaddr, sizeof(packet->chaddr)) = '\0'; | 24 | //*bin2hex(buf, (void *) packet->chaddr, sizeof(packet->chaddr)) = '\0'; |
| @@ -75,6 +75,8 @@ int FAST_FUNC d6_send_raw_packet( | |||
| 75 | dest_sll.sll_family = AF_PACKET; | 75 | dest_sll.sll_family = AF_PACKET; |
| 76 | dest_sll.sll_protocol = htons(ETH_P_IPV6); | 76 | dest_sll.sll_protocol = htons(ETH_P_IPV6); |
| 77 | dest_sll.sll_ifindex = ifindex; | 77 | dest_sll.sll_ifindex = ifindex; |
| 78 | /*dest_sll.sll_hatype = ARPHRD_???;*/ | ||
| 79 | /*dest_sll.sll_pkttype = PACKET_???;*/ | ||
| 78 | dest_sll.sll_halen = 6; | 80 | dest_sll.sll_halen = 6; |
| 79 | memcpy(dest_sll.sll_addr, dest_arp, 6); | 81 | memcpy(dest_sll.sll_addr, dest_arp, 6); |
| 80 | 82 | ||
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index 99d91bf70..55f21c187 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* | 2 | /* |
| 3 | * udhcp client | 3 | * udhcp client |
| 4 | * | ||
| 5 | * Russ Dill <Russ.Dill@asu.edu> July 2001 | 4 | * Russ Dill <Russ.Dill@asu.edu> July 2001 |
| 6 | * | 5 | * |
| 7 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
| @@ -694,10 +693,16 @@ static int raw_bcast_from_client_config_ifindex(struct dhcp_packet *packet, uint | |||
| 694 | 693 | ||
| 695 | static int bcast_or_ucast(struct dhcp_packet *packet, uint32_t ciaddr, uint32_t server) | 694 | static int bcast_or_ucast(struct dhcp_packet *packet, uint32_t ciaddr, uint32_t server) |
| 696 | { | 695 | { |
| 697 | if (server) | 696 | if (server) { |
| 697 | /* Without MSG_DONTROUTE, the packet was seen routed over | ||
| 698 | * _other interface_ if server ID is bogus (example: 1.1.1.1). | ||
| 699 | */ | ||
| 698 | return udhcp_send_kernel_packet(packet, | 700 | return udhcp_send_kernel_packet(packet, |
| 699 | ciaddr, CLIENT_PORT, | 701 | ciaddr, CLIENT_PORT, |
| 700 | server, SERVER_PORT); | 702 | server, SERVER_PORT, |
| 703 | /*send_flags: "to hosts only on directly connected networks" */ MSG_DONTROUTE | ||
| 704 | ); | ||
| 705 | } | ||
| 701 | return raw_bcast_from_client_config_ifindex(packet, ciaddr); | 706 | return raw_bcast_from_client_config_ifindex(packet, ciaddr); |
| 702 | } | 707 | } |
| 703 | 708 | ||
| @@ -735,7 +740,7 @@ static NOINLINE int send_discover(uint32_t xid, uint32_t requested) | |||
| 735 | static NOINLINE int send_select(uint32_t xid, uint32_t server, uint32_t requested) | 740 | static NOINLINE int send_select(uint32_t xid, uint32_t server, uint32_t requested) |
| 736 | { | 741 | { |
| 737 | struct dhcp_packet packet; | 742 | struct dhcp_packet packet; |
| 738 | struct in_addr addr; | 743 | struct in_addr temp_addr; |
| 739 | 744 | ||
| 740 | /* | 745 | /* |
| 741 | * RFC 2131 4.3.2 DHCPREQUEST message | 746 | * RFC 2131 4.3.2 DHCPREQUEST message |
| @@ -766,8 +771,8 @@ static NOINLINE int send_select(uint32_t xid, uint32_t server, uint32_t requeste | |||
| 766 | */ | 771 | */ |
| 767 | add_client_options(&packet); | 772 | add_client_options(&packet); |
| 768 | 773 | ||
| 769 | addr.s_addr = requested; | 774 | temp_addr.s_addr = requested; |
| 770 | bb_error_msg("sending select for %s", inet_ntoa(addr)); | 775 | bb_error_msg("sending select for %s", inet_ntoa(temp_addr)); |
| 771 | return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY); | 776 | return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY); |
| 772 | } | 777 | } |
| 773 | 778 | ||
| @@ -776,6 +781,7 @@ static NOINLINE int send_select(uint32_t xid, uint32_t server, uint32_t requeste | |||
| 776 | static NOINLINE int send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr) | 781 | static NOINLINE int send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr) |
| 777 | { | 782 | { |
| 778 | struct dhcp_packet packet; | 783 | struct dhcp_packet packet; |
| 784 | struct in_addr temp_addr; | ||
| 779 | 785 | ||
| 780 | /* | 786 | /* |
| 781 | * RFC 2131 4.3.2 DHCPREQUEST message | 787 | * RFC 2131 4.3.2 DHCPREQUEST message |
| @@ -806,7 +812,8 @@ static NOINLINE int send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr) | |||
| 806 | */ | 812 | */ |
| 807 | add_client_options(&packet); | 813 | add_client_options(&packet); |
| 808 | 814 | ||
| 809 | bb_error_msg("sending %s", "renew"); | 815 | temp_addr.s_addr = server; |
| 816 | bb_error_msg("sending renew to %s", inet_ntoa(temp_addr)); | ||
| 810 | return bcast_or_ucast(&packet, ciaddr, server); | 817 | return bcast_or_ucast(&packet, ciaddr, server); |
| 811 | } | 818 | } |
| 812 | 819 | ||
| @@ -1010,9 +1017,14 @@ static int udhcp_raw_socket(int ifindex) | |||
| 1010 | */ | 1017 | */ |
| 1011 | log2("got raw socket fd"); | 1018 | log2("got raw socket fd"); |
| 1012 | 1019 | ||
| 1020 | memset(&sock, 0, sizeof(sock)); /* let's be deterministic */ | ||
| 1013 | sock.sll_family = AF_PACKET; | 1021 | sock.sll_family = AF_PACKET; |
| 1014 | sock.sll_protocol = htons(ETH_P_IP); | 1022 | sock.sll_protocol = htons(ETH_P_IP); |
| 1015 | sock.sll_ifindex = ifindex; | 1023 | sock.sll_ifindex = ifindex; |
| 1024 | /*sock.sll_hatype = ARPHRD_???;*/ | ||
| 1025 | /*sock.sll_pkttype = PACKET_???;*/ | ||
| 1026 | /*sock.sll_halen = ???;*/ | ||
| 1027 | /*sock.sll_addr[8] = ???;*/ | ||
| 1016 | xbind(fd, (struct sockaddr *) &sock, sizeof(sock)); | 1028 | xbind(fd, (struct sockaddr *) &sock, sizeof(sock)); |
| 1017 | 1029 | ||
| 1018 | #if 0 /* Several users reported breakage when BPF filter is used */ | 1030 | #if 0 /* Several users reported breakage when BPF filter is used */ |
| @@ -1519,11 +1531,24 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
| 1519 | * Anyway, it does recover by eventually failing through | 1531 | * Anyway, it does recover by eventually failing through |
| 1520 | * into INIT_SELECTING state. | 1532 | * into INIT_SELECTING state. |
| 1521 | */ | 1533 | */ |
| 1522 | send_renew(xid, server_addr, requested_ip); | 1534 | if (send_renew(xid, server_addr, requested_ip) >= 0) { |
| 1523 | timeout >>= 1; | 1535 | timeout >>= 1; |
| 1524 | continue; | 1536 | //TODO: the timeout to receive an answer for our renew should not be selected |
| 1537 | //with "timeout = lease_seconds / 2; ...; timeout = timeout / 2": it is often huge. | ||
| 1538 | //Waiting e.g. 4*3600 seconds for a reply does not make sense | ||
| 1539 | //(if reply isn't coming, we keep an open socket for hours), | ||
| 1540 | //it should be something like 10 seconds. | ||
| 1541 | //Also, it's probably best to try sending renew in kernel mode a few (3-5) times | ||
| 1542 | //and fall back to raw mode if it does not work. | ||
| 1543 | continue; | ||
| 1544 | } | ||
| 1545 | /* else: error sending. | ||
| 1546 | * example: ENETUNREACH seen with server | ||
| 1547 | * which gave us bogus server ID 1.1.1.1 | ||
| 1548 | * which wasn't reachable (and probably did not exist). | ||
| 1549 | */ | ||
| 1525 | } | 1550 | } |
| 1526 | /* Timed out, enter rebinding state */ | 1551 | /* Timed out or error, enter rebinding state */ |
| 1527 | log1("entering rebinding state"); | 1552 | log1("entering rebinding state"); |
| 1528 | state = REBINDING; | 1553 | state = REBINDING; |
| 1529 | /* fall right through */ | 1554 | /* fall right through */ |
| @@ -1605,7 +1630,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
| 1605 | len = udhcp_recv_raw_packet(&packet, sockfd); | 1630 | len = udhcp_recv_raw_packet(&packet, sockfd); |
| 1606 | if (len == -1) { | 1631 | if (len == -1) { |
| 1607 | /* Error is severe, reopen socket */ | 1632 | /* Error is severe, reopen socket */ |
| 1608 | bb_error_msg("read error: %s, reopening socket", strerror(errno)); | 1633 | bb_error_msg("read error: "STRERROR_FMT", reopening socket" STRERROR_ERRNO); |
| 1609 | sleep(discover_timeout); /* 3 seconds by default */ | 1634 | sleep(discover_timeout); /* 3 seconds by default */ |
| 1610 | change_listen_mode(listen_mode); /* just close and reopen */ | 1635 | change_listen_mode(listen_mode); /* just close and reopen */ |
| 1611 | } | 1636 | } |
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c index 05ddc8649..238542bb0 100644 --- a/networking/udhcp/dhcpd.c +++ b/networking/udhcp/dhcpd.c | |||
| @@ -588,7 +588,9 @@ static void send_packet_to_relay(struct dhcp_packet *dhcp_pkt) | |||
| 588 | 588 | ||
| 589 | udhcp_send_kernel_packet(dhcp_pkt, | 589 | udhcp_send_kernel_packet(dhcp_pkt, |
| 590 | server_config.server_nip, SERVER_PORT, | 590 | server_config.server_nip, SERVER_PORT, |
| 591 | dhcp_pkt->gateway_nip, SERVER_PORT); | 591 | dhcp_pkt->gateway_nip, SERVER_PORT, |
| 592 | /*send_flags:*/ 0 | ||
| 593 | ); | ||
| 592 | } | 594 | } |
| 593 | 595 | ||
| 594 | static void send_packet(struct dhcp_packet *dhcp_pkt, int force_broadcast) | 596 | static void send_packet(struct dhcp_packet *dhcp_pkt, int force_broadcast) |
| @@ -946,7 +948,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv) | |||
| 946 | if (bytes < 0) { | 948 | if (bytes < 0) { |
| 947 | /* bytes can also be -2 ("bad packet data") */ | 949 | /* bytes can also be -2 ("bad packet data") */ |
| 948 | if (bytes == -1 && errno != EINTR) { | 950 | if (bytes == -1 && errno != EINTR) { |
| 949 | log1("read error: %s, reopening socket", strerror(errno)); | 951 | log1("read error: "STRERROR_FMT", reopening socket" STRERROR_ERRNO); |
| 950 | close(server_socket); | 952 | close(server_socket); |
| 951 | server_socket = -1; | 953 | server_socket = -1; |
| 952 | } | 954 | } |
diff --git a/networking/udhcp/dhcprelay.c b/networking/udhcp/dhcprelay.c index ea84c0dd7..4d5644093 100644 --- a/networking/udhcp/dhcprelay.c +++ b/networking/udhcp/dhcprelay.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* Port to Busybox Copyright (C) 2006 Jesse Dutton <jessedutton@gmail.com> | 2 | /* |
| 3 | * Port to Busybox Copyright (C) 2006 Jesse Dutton <jessedutton@gmail.com> | ||
| 3 | * | 4 | * |
| 4 | * Licensed under GPLv2, see file LICENSE in this source tree. | 5 | * Licensed under GPLv2, see file LICENSE in this source tree. |
| 5 | * | 6 | * |
diff --git a/networking/udhcp/domain_codec.c b/networking/udhcp/domain_codec.c index 5a923cc2c..b7a3a5353 100644 --- a/networking/udhcp/domain_codec.c +++ b/networking/udhcp/domain_codec.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | 2 | /* | |
| 3 | /* RFC1035 domain compression routines (C) 2007 Gabriel Somlo <somlo at cmu.edu> | 3 | * RFC1035 domain compression routines (C) 2007 Gabriel Somlo <somlo at cmu.edu> |
| 4 | * | 4 | * |
| 5 | * Loosely based on the isc-dhcpd implementation by dhankins@isc.org | 5 | * Loosely based on the isc-dhcpd implementation by dhankins@isc.org |
| 6 | * | 6 | * |
diff --git a/networking/udhcp/packet.c b/networking/udhcp/packet.c index 9e1b46d2f..fc2bb5416 100644 --- a/networking/udhcp/packet.c +++ b/networking/udhcp/packet.c | |||
| @@ -41,7 +41,7 @@ void FAST_FUNC udhcp_dump_packet(struct dhcp_packet *packet) | |||
| 41 | return; | 41 | return; |
| 42 | 42 | ||
| 43 | bb_error_msg( | 43 | bb_error_msg( |
| 44 | //"op %x" | 44 | //" op %x" |
| 45 | //" htype %x" | 45 | //" htype %x" |
| 46 | " hlen %x" | 46 | " hlen %x" |
| 47 | //" hops %x" | 47 | //" hops %x" |
| @@ -52,7 +52,6 @@ void FAST_FUNC udhcp_dump_packet(struct dhcp_packet *packet) | |||
| 52 | " yiaddr %x" | 52 | " yiaddr %x" |
| 53 | " siaddr %x" | 53 | " siaddr %x" |
| 54 | " giaddr %x" | 54 | " giaddr %x" |
| 55 | //" chaddr %s" | ||
| 56 | //" sname %s" | 55 | //" sname %s" |
| 57 | //" file %s" | 56 | //" file %s" |
| 58 | //" cookie %x" | 57 | //" cookie %x" |
| @@ -68,14 +67,13 @@ void FAST_FUNC udhcp_dump_packet(struct dhcp_packet *packet) | |||
| 68 | , packet->yiaddr | 67 | , packet->yiaddr |
| 69 | , packet->siaddr_nip | 68 | , packet->siaddr_nip |
| 70 | , packet->gateway_nip | 69 | , packet->gateway_nip |
| 71 | //, packet->chaddr[16] | ||
| 72 | //, packet->sname[64] | 70 | //, packet->sname[64] |
| 73 | //, packet->file[128] | 71 | //, packet->file[128] |
| 74 | //, packet->cookie | 72 | //, packet->cookie |
| 75 | //, packet->options[] | 73 | //, packet->options[] |
| 76 | ); | 74 | ); |
| 77 | *bin2hex(buf, (void *) packet->chaddr, sizeof(packet->chaddr)) = '\0'; | 75 | *bin2hex(buf, (void *) packet->chaddr, sizeof(packet->chaddr)) = '\0'; |
| 78 | bb_error_msg("chaddr %s", buf); | 76 | bb_error_msg(" chaddr %s", buf); |
| 79 | } | 77 | } |
| 80 | #endif | 78 | #endif |
| 81 | 79 | ||
| @@ -129,6 +127,8 @@ int FAST_FUNC udhcp_send_raw_packet(struct dhcp_packet *dhcp_pkt, | |||
| 129 | dest_sll.sll_family = AF_PACKET; | 127 | dest_sll.sll_family = AF_PACKET; |
| 130 | dest_sll.sll_protocol = htons(ETH_P_IP); | 128 | dest_sll.sll_protocol = htons(ETH_P_IP); |
| 131 | dest_sll.sll_ifindex = ifindex; | 129 | dest_sll.sll_ifindex = ifindex; |
| 130 | /*dest_sll.sll_hatype = ARPHRD_???;*/ | ||
| 131 | /*dest_sll.sll_pkttype = PACKET_???;*/ | ||
| 132 | dest_sll.sll_halen = 6; | 132 | dest_sll.sll_halen = 6; |
| 133 | memcpy(dest_sll.sll_addr, dest_arp, 6); | 133 | memcpy(dest_sll.sll_addr, dest_arp, 6); |
| 134 | 134 | ||
| @@ -189,7 +189,8 @@ int FAST_FUNC udhcp_send_raw_packet(struct dhcp_packet *dhcp_pkt, | |||
| 189 | /* Let the kernel do all the work for packet generation */ | 189 | /* Let the kernel do all the work for packet generation */ |
| 190 | int FAST_FUNC udhcp_send_kernel_packet(struct dhcp_packet *dhcp_pkt, | 190 | int FAST_FUNC udhcp_send_kernel_packet(struct dhcp_packet *dhcp_pkt, |
| 191 | uint32_t source_nip, int source_port, | 191 | uint32_t source_nip, int source_port, |
| 192 | uint32_t dest_nip, int dest_port) | 192 | uint32_t dest_nip, int dest_port, |
| 193 | int send_flags) | ||
| 193 | { | 194 | { |
| 194 | struct sockaddr_in sa; | 195 | struct sockaddr_in sa; |
| 195 | unsigned padding; | 196 | unsigned padding; |
| @@ -226,8 +227,8 @@ int FAST_FUNC udhcp_send_kernel_packet(struct dhcp_packet *dhcp_pkt, | |||
| 226 | padding = DHCP_OPTIONS_BUFSIZE - 1 - udhcp_end_option(dhcp_pkt->options); | 227 | padding = DHCP_OPTIONS_BUFSIZE - 1 - udhcp_end_option(dhcp_pkt->options); |
| 227 | if (padding > DHCP_SIZE - 300) | 228 | if (padding > DHCP_SIZE - 300) |
| 228 | padding = DHCP_SIZE - 300; | 229 | padding = DHCP_SIZE - 300; |
| 229 | result = safe_write(fd, dhcp_pkt, DHCP_SIZE - padding); | 230 | result = send(fd, dhcp_pkt, DHCP_SIZE - padding, send_flags); |
| 230 | msg = "write"; | 231 | msg = "send"; |
| 231 | ret_close: | 232 | ret_close: |
| 232 | close(fd); | 233 | close(fd); |
| 233 | if (result < 0) { | 234 | if (result < 0) { |
diff --git a/networking/zcip.c b/networking/zcip.c index 55440285f..94e49adcb 100644 --- a/networking/zcip.c +++ b/networking/zcip.c | |||
| @@ -8,7 +8,6 @@ | |||
| 8 | * | 8 | * |
| 9 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 9 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 10 | */ | 10 | */ |
| 11 | |||
| 12 | /* | 11 | /* |
| 13 | * ZCIP just manages the 169.254.*.* addresses. That network is not | 12 | * ZCIP just manages the 169.254.*.* addresses. That network is not |
| 14 | * routed at the IP level, though various proxies or bridges can | 13 | * routed at the IP level, though various proxies or bridges can |
diff --git a/procps/free.c b/procps/free.c index b57e4a322..48139c4a3 100644 --- a/procps/free.c +++ b/procps/free.c | |||
| @@ -15,7 +15,7 @@ | |||
| 15 | //config: memory in the system, as well as the buffers used by the kernel. | 15 | //config: memory in the system, as well as the buffers used by the kernel. |
| 16 | //config: The shared memory column should be ignored; it is obsolete. | 16 | //config: The shared memory column should be ignored; it is obsolete. |
| 17 | 17 | ||
| 18 | //applet:IF_FREE(APPLET_NOEXEC(free, free, BB_DIR_USR_BIN, BB_SUID_DROP, free)) | 18 | //applet:IF_FREE(APPLET_NOFORK(free, free, BB_DIR_USR_BIN, BB_SUID_DROP, free)) |
| 19 | 19 | ||
| 20 | //kbuild:lib-$(CONFIG_FREE) += free.o | 20 | //kbuild:lib-$(CONFIG_FREE) += free.o |
| 21 | 21 | ||
| @@ -32,7 +32,6 @@ | |||
| 32 | //usage: "Total: 386144 257128 129016\n" | 32 | //usage: "Total: 386144 257128 129016\n" |
| 33 | 33 | ||
| 34 | #include "libbb.h" | 34 | #include "libbb.h" |
| 35 | #include "common_bufsiz.h" | ||
| 36 | #ifdef __linux__ | 35 | #ifdef __linux__ |
| 37 | # include <sys/sysinfo.h> | 36 | # include <sys/sysinfo.h> |
| 38 | #endif | 37 | #endif |
| @@ -40,25 +39,21 @@ | |||
| 40 | struct globals { | 39 | struct globals { |
| 41 | unsigned mem_unit; | 40 | unsigned mem_unit; |
| 42 | #if ENABLE_DESKTOP | 41 | #if ENABLE_DESKTOP |
| 43 | unsigned unit_steps; | 42 | uint8_t unit_steps; |
| 44 | # define G_unit_steps G.unit_steps | 43 | # define G_unit_steps g->unit_steps |
| 45 | #else | 44 | #else |
| 46 | # define G_unit_steps 10 | 45 | # define G_unit_steps 10 |
| 47 | #endif | 46 | #endif |
| 48 | } FIX_ALIASING; | 47 | }; |
| 49 | #define G (*(struct globals*)bb_common_bufsiz1) | 48 | /* Because of NOFORK, "globals" are not in global data */ |
| 50 | #define INIT_G() do { \ | ||
| 51 | setup_common_bufsiz(); \ | ||
| 52 | /* NB: noexec applet - globals not zeroed */ \ | ||
| 53 | } while (0) | ||
| 54 | 49 | ||
| 55 | 50 | static unsigned long long scale(struct globals *g, unsigned long d) | |
| 56 | static unsigned long long scale(unsigned long d) | ||
| 57 | { | 51 | { |
| 58 | return ((unsigned long long)d * G.mem_unit) >> G_unit_steps; | 52 | return ((unsigned long long)d * g->mem_unit) >> G_unit_steps; |
| 59 | } | 53 | } |
| 60 | 54 | ||
| 61 | static unsigned long parse_cached_kb(void) | 55 | /* NOINLINE reduces main() stack usage, which makes code smaller (on x86 at least) */ |
| 56 | static NOINLINE unsigned long parse_cached_kb(void) | ||
| 62 | { | 57 | { |
| 63 | char buf[60]; /* actual lines we expect are ~30 chars or less */ | 58 | char buf[60]; /* actual lines we expect are ~30 chars or less */ |
| 64 | FILE *fp; | 59 | FILE *fp; |
| @@ -69,8 +64,8 @@ static unsigned long parse_cached_kb(void) | |||
| 69 | if (sscanf(buf, "Cached: %lu %*s\n", &cached) == 1) | 64 | if (sscanf(buf, "Cached: %lu %*s\n", &cached) == 1) |
| 70 | break; | 65 | break; |
| 71 | } | 66 | } |
| 72 | if (ENABLE_FEATURE_CLEAN_UP) | 67 | /* Have to close because of NOFORK */ |
| 73 | fclose(fp); | 68 | fclose(fp); |
| 74 | 69 | ||
| 75 | return cached; | 70 | return cached; |
| 76 | } | 71 | } |
| @@ -78,11 +73,10 @@ static unsigned long parse_cached_kb(void) | |||
| 78 | int free_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 73 | int free_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
| 79 | int free_main(int argc UNUSED_PARAM, char **argv IF_NOT_DESKTOP(UNUSED_PARAM)) | 74 | int free_main(int argc UNUSED_PARAM, char **argv IF_NOT_DESKTOP(UNUSED_PARAM)) |
| 80 | { | 75 | { |
| 76 | struct globals G; | ||
| 81 | struct sysinfo info; | 77 | struct sysinfo info; |
| 82 | unsigned long long cached; | 78 | unsigned long long cached; |
| 83 | 79 | ||
| 84 | INIT_G(); | ||
| 85 | |||
| 86 | #if ENABLE_DESKTOP | 80 | #if ENABLE_DESKTOP |
| 87 | G.unit_steps = 10; | 81 | G.unit_steps = 10; |
| 88 | if (argv[1] && argv[1][0] == '-') { | 82 | if (argv[1] && argv[1][0] == '-') { |
| @@ -123,12 +117,12 @@ int free_main(int argc UNUSED_PARAM, char **argv IF_NOT_DESKTOP(UNUSED_PARAM)) | |||
| 123 | #define FIELDS_2 (FIELDS_6 + 4*6) | 117 | #define FIELDS_2 (FIELDS_6 + 4*6) |
| 124 | 118 | ||
| 125 | printf(FIELDS_6, | 119 | printf(FIELDS_6, |
| 126 | scale(info.totalram), //total | 120 | scale(&G, info.totalram), //total |
| 127 | scale(info.totalram - info.freeram), //used | 121 | scale(&G, info.totalram - info.freeram), //used |
| 128 | scale(info.freeram), //free | 122 | scale(&G, info.freeram), //free |
| 129 | scale(info.sharedram), //shared | 123 | scale(&G, info.sharedram), //shared |
| 130 | scale(info.bufferram), //buffers | 124 | scale(&G, info.bufferram), //buffers |
| 131 | scale(cached) //cached | 125 | scale(&G, cached) //cached |
| 132 | ); | 126 | ); |
| 133 | /* Show alternate, more meaningful busy/free numbers by counting | 127 | /* Show alternate, more meaningful busy/free numbers by counting |
| 134 | * buffer cache as free memory. */ | 128 | * buffer cache as free memory. */ |
| @@ -136,15 +130,15 @@ int free_main(int argc UNUSED_PARAM, char **argv IF_NOT_DESKTOP(UNUSED_PARAM)) | |||
| 136 | cached += info.freeram; | 130 | cached += info.freeram; |
| 137 | cached += info.bufferram; | 131 | cached += info.bufferram; |
| 138 | printf(FIELDS_2, | 132 | printf(FIELDS_2, |
| 139 | scale(info.totalram - cached), //used | 133 | scale(&G, info.totalram - cached), //used |
| 140 | scale(cached) //free | 134 | scale(&G, cached) //free |
| 141 | ); | 135 | ); |
| 142 | #if BB_MMU | 136 | #if BB_MMU |
| 143 | printf("Swap: "); | 137 | printf("Swap: "); |
| 144 | printf(FIELDS_3, | 138 | printf(FIELDS_3, |
| 145 | scale(info.totalswap), //total | 139 | scale(&G, info.totalswap), //total |
| 146 | scale(info.totalswap - info.freeswap), //used | 140 | scale(&G, info.totalswap - info.freeswap), //used |
| 147 | scale(info.freeswap) //free | 141 | scale(&G, info.freeswap) //free |
| 148 | ); | 142 | ); |
| 149 | #endif | 143 | #endif |
| 150 | return EXIT_SUCCESS; | 144 | return EXIT_SUCCESS; |
diff --git a/runit/sv.c b/runit/sv.c index 1d0809be8..dc5dcceb3 100644 --- a/runit/sv.c +++ b/runit/sv.c | |||
| @@ -224,7 +224,7 @@ static void out(const char *p, const char *m1) | |||
| 224 | { | 224 | { |
| 225 | printf("%s%s%s: %s", p, *service, islog ? "/log" : "", m1); | 225 | printf("%s%s%s: %s", p, *service, islog ? "/log" : "", m1); |
| 226 | if (errno) { | 226 | if (errno) { |
| 227 | printf(": %s", strerror(errno)); | 227 | printf(": "STRERROR_FMT STRERROR_ERRNO); |
| 228 | } | 228 | } |
| 229 | bb_putchar('\n'); /* will also flush the output */ | 229 | bb_putchar('\n'); /* will also flush the output */ |
| 230 | } | 230 | } |
diff --git a/selinux/matchpathcon.c b/selinux/matchpathcon.c index e57120d3b..6945a0295 100644 --- a/selinux/matchpathcon.c +++ b/selinux/matchpathcon.c | |||
| @@ -104,7 +104,7 @@ int matchpathcon_main(int argc UNUSED_PARAM, char **argv) | |||
| 104 | freecon(con); | 104 | freecon(con); |
| 105 | continue; | 105 | continue; |
| 106 | } | 106 | } |
| 107 | printf("actual context unknown: %s, should be ", strerror(errno)); | 107 | printf("actual context unknown: "STRERROR_FMT", should be " STRERROR_ERRNO); |
| 108 | error += print_matchpathcon(path, 1); | 108 | error += print_matchpathcon(path, 1); |
| 109 | } | 109 | } |
| 110 | matchpathcon_fini(); | 110 | matchpathcon_fini(); |
diff --git a/shell/ash.c b/shell/ash.c index 0d65a225b..81845dc60 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
| @@ -1399,16 +1399,9 @@ ash_msg_and_raise_error(const char *msg, ...) | |||
| 1399 | } | 1399 | } |
| 1400 | 1400 | ||
| 1401 | /* | 1401 | /* |
| 1402 | * Use '%m' to append error string on platforms that support it, '%s' and | ||
| 1403 | * strerror() on those that don't. | ||
| 1404 | * | ||
| 1405 | * 'fmt' must be a string literal. | 1402 | * 'fmt' must be a string literal. |
| 1406 | */ | 1403 | */ |
| 1407 | #ifdef HAVE_PRINTF_PERCENTM | 1404 | #define ash_msg_and_raise_perror(fmt, ...) ash_msg_and_raise_error(fmt ": "STRERROR_FMT, ##__VA_ARGS__ STRERROR_ERRNO) |
| 1408 | #define ash_msg_and_raise_perror(fmt, ...) ash_msg_and_raise_error(fmt ": %m", ##__VA_ARGS__) | ||
| 1409 | #else | ||
| 1410 | #define ash_msg_and_raise_perror(fmt, ...) ash_msg_and_raise_error(fmt ": %s", ##__VA_ARGS__, strerror(errno)) | ||
| 1411 | #endif | ||
| 1412 | 1405 | ||
| 1413 | static void raise_error_syntax(const char *) NORETURN; | 1406 | static void raise_error_syntax(const char *) NORETURN; |
| 1414 | static void | 1407 | static void |
| @@ -2474,8 +2467,11 @@ listsetvar(struct strlist *list_set_var, int flags) | |||
| 2474 | /* | 2467 | /* |
| 2475 | * Generate a list of variables satisfying the given conditions. | 2468 | * Generate a list of variables satisfying the given conditions. |
| 2476 | */ | 2469 | */ |
| 2470 | #if !ENABLE_FEATURE_SH_NOFORK | ||
| 2471 | # define listvars(on, off, lp, end) listvars(on, off, end) | ||
| 2472 | #endif | ||
| 2477 | static char ** | 2473 | static char ** |
| 2478 | listvars(int on, int off, char ***end) | 2474 | listvars(int on, int off, struct strlist *lp, char ***end) |
| 2479 | { | 2475 | { |
| 2480 | struct var **vpp; | 2476 | struct var **vpp; |
| 2481 | struct var *vp; | 2477 | struct var *vp; |
| @@ -2488,12 +2484,40 @@ listvars(int on, int off, char ***end) | |||
| 2488 | do { | 2484 | do { |
| 2489 | for (vp = *vpp; vp; vp = vp->next) { | 2485 | for (vp = *vpp; vp; vp = vp->next) { |
| 2490 | if ((vp->flags & mask) == on) { | 2486 | if ((vp->flags & mask) == on) { |
| 2487 | #if ENABLE_FEATURE_SH_NOFORK | ||
| 2488 | /* If variable with the same name is both | ||
| 2489 | * exported and temporarily set for a command: | ||
| 2490 | * export ZVAR=5 | ||
| 2491 | * ZVAR=6 printenv | ||
| 2492 | * then "ZVAR=6" will be both in vartab and | ||
| 2493 | * lp lists. Do not pass it twice to printenv. | ||
| 2494 | */ | ||
| 2495 | struct strlist *lp1 = lp; | ||
| 2496 | while (lp1) { | ||
| 2497 | if (strcmp(lp1->text, vp->var_text) == 0) | ||
| 2498 | goto skip; | ||
| 2499 | lp1 = lp1->next; | ||
| 2500 | } | ||
| 2501 | #endif | ||
| 2491 | if (ep == stackstrend()) | 2502 | if (ep == stackstrend()) |
| 2492 | ep = growstackstr(); | 2503 | ep = growstackstr(); |
| 2493 | *ep++ = (char*)vp->var_text; | 2504 | *ep++ = (char*)vp->var_text; |
| 2505 | #if ENABLE_FEATURE_SH_NOFORK | ||
| 2506 | skip: ; | ||
| 2507 | #endif | ||
| 2494 | } | 2508 | } |
| 2495 | } | 2509 | } |
| 2496 | } while (++vpp < vartab + VTABSIZE); | 2510 | } while (++vpp < vartab + VTABSIZE); |
| 2511 | |||
| 2512 | #if ENABLE_FEATURE_SH_NOFORK | ||
| 2513 | while (lp) { | ||
| 2514 | if (ep == stackstrend()) | ||
| 2515 | ep = growstackstr(); | ||
| 2516 | *ep++ = lp->text; | ||
| 2517 | lp = lp->next; | ||
| 2518 | } | ||
| 2519 | #endif | ||
| 2520 | |||
| 2497 | if (ep == stackstrend()) | 2521 | if (ep == stackstrend()) |
| 2498 | ep = growstackstr(); | 2522 | ep = growstackstr(); |
| 2499 | if (end) | 2523 | if (end) |
| @@ -8250,7 +8274,7 @@ static void shellexec(char *prog, char **argv, const char *path, int idx) | |||
| 8250 | int exerrno; | 8274 | int exerrno; |
| 8251 | int applet_no = -1; /* used only by FEATURE_SH_STANDALONE */ | 8275 | int applet_no = -1; /* used only by FEATURE_SH_STANDALONE */ |
| 8252 | 8276 | ||
| 8253 | envp = listvars(VEXPORT, VUNSET, /*end:*/ NULL); | 8277 | envp = listvars(VEXPORT, VUNSET, /*strlist:*/ NULL, /*end:*/ NULL); |
| 8254 | if ((strchr(prog, '/') || (ENABLE_PLATFORM_MINGW32 && strchr(prog, '\\'))) | 8278 | if ((strchr(prog, '/') || (ENABLE_PLATFORM_MINGW32 && strchr(prog, '\\'))) |
| 8255 | #if ENABLE_FEATURE_SH_STANDALONE | 8279 | #if ENABLE_FEATURE_SH_STANDALONE |
| 8256 | || (applet_no = find_applet_by_name(prog)) >= 0 | 8280 | || (applet_no = find_applet_by_name(prog)) >= 0 |
| @@ -10395,7 +10419,11 @@ evalcommand(union node *cmd, int flags) | |||
| 10395 | /* find_command() encodes applet_no as (-2 - applet_no) */ | 10419 | /* find_command() encodes applet_no as (-2 - applet_no) */ |
| 10396 | int applet_no = (- cmdentry.u.index - 2); | 10420 | int applet_no = (- cmdentry.u.index - 2); |
| 10397 | if (applet_no >= 0 && APPLET_IS_NOFORK(applet_no)) { | 10421 | if (applet_no >= 0 && APPLET_IS_NOFORK(applet_no)) { |
| 10398 | listsetvar(varlist.list, VEXPORT|VSTACK); | 10422 | char **sv_environ; |
| 10423 | |||
| 10424 | INT_OFF; | ||
| 10425 | sv_environ = environ; | ||
| 10426 | environ = listvars(VEXPORT, VUNSET, varlist.list, /*end:*/ NULL); | ||
| 10399 | /* | 10427 | /* |
| 10400 | * Run <applet>_main(). | 10428 | * Run <applet>_main(). |
| 10401 | * Signals (^C) can't interrupt here. | 10429 | * Signals (^C) can't interrupt here. |
| @@ -10404,8 +10432,8 @@ evalcommand(union node *cmd, int flags) | |||
| 10404 | * and/or wait for user input ineligible for NOFORK: | 10432 | * and/or wait for user input ineligible for NOFORK: |
| 10405 | * for example, "yes" or "rm" (rm -i waits for input). | 10433 | * for example, "yes" or "rm" (rm -i waits for input). |
| 10406 | */ | 10434 | */ |
| 10407 | INT_OFF; | ||
| 10408 | status = run_nofork_applet(applet_no, argv); | 10435 | status = run_nofork_applet(applet_no, argv); |
| 10436 | environ = sv_environ; | ||
| 10409 | /* | 10437 | /* |
| 10410 | * Try enabling NOFORK for "yes" applet. | 10438 | * Try enabling NOFORK for "yes" applet. |
| 10411 | * ^C _will_ stop it (write returns EINTR), | 10439 | * ^C _will_ stop it (write returns EINTR), |
| @@ -11344,7 +11372,7 @@ showvars(const char *sep_prefix, int on, int off) | |||
| 11344 | const char *sep; | 11372 | const char *sep; |
| 11345 | char **ep, **epend; | 11373 | char **ep, **epend; |
| 11346 | 11374 | ||
| 11347 | ep = listvars(on, off, &epend); | 11375 | ep = listvars(on, off, /*strlist:*/ NULL, &epend); |
| 11348 | qsort(ep, epend - ep, sizeof(char *), vpcmp); | 11376 | qsort(ep, epend - ep, sizeof(char *), vpcmp); |
| 11349 | 11377 | ||
| 11350 | sep = *sep_prefix ? " " : sep_prefix; | 11378 | sep = *sep_prefix ? " " : sep_prefix; |
| @@ -11353,9 +11381,17 @@ showvars(const char *sep_prefix, int on, int off) | |||
| 11353 | const char *p; | 11381 | const char *p; |
| 11354 | const char *q; | 11382 | const char *q; |
| 11355 | 11383 | ||
| 11356 | p = strchrnul(*ep, '='); | 11384 | p = endofname(*ep); |
| 11385 | /* Used to have simple "p = strchrnul(*ep, '=')" here instead, but this | ||
| 11386 | * makes "export -p" to have output not suitable for "eval": | ||
| 11387 | * import os | ||
| 11388 | * os.environ["test-test"]="test" | ||
| 11389 | * if os.fork() == 0: | ||
| 11390 | * os.execv("ash", [ 'ash', '-c', 'eval $(export -p); echo OK' ]) # fixes this | ||
| 11391 | * os.execv("ash", [ 'ash', '-c', 'env | grep test-test' ]) | ||
| 11392 | */ | ||
| 11357 | q = nullstr; | 11393 | q = nullstr; |
| 11358 | if (*p) | 11394 | if (*p == '=') |
| 11359 | q = single_quote(++p); | 11395 | q = single_quote(++p); |
| 11360 | out1fmt("%s%s%.*s%s\n", sep_prefix, sep, (int)(p - *ep), *ep, q); | 11396 | out1fmt("%s%s%.*s%s\n", sep_prefix, sep, (int)(p - *ep), *ep, q); |
| 11361 | } | 11397 | } |
| @@ -13146,7 +13182,24 @@ expandstr(const char *ps, int syntax_type) | |||
| 13146 | 13182 | ||
| 13147 | saveprompt = doprompt; | 13183 | saveprompt = doprompt; |
| 13148 | doprompt = 0; | 13184 | doprompt = 0; |
| 13149 | readtoken1(pgetc(), syntax_type, FAKEEOFMARK, 0); | 13185 | |
| 13186 | /* readtoken1() might die horribly. | ||
| 13187 | * Try a prompt with syntactically wrong command: | ||
| 13188 | * PS1='$(date "+%H:%M:%S) > ' | ||
| 13189 | */ | ||
| 13190 | { | ||
| 13191 | volatile int saveint; | ||
| 13192 | struct jmploc *volatile savehandler = exception_handler; | ||
| 13193 | struct jmploc jmploc; | ||
| 13194 | SAVE_INT(saveint); | ||
| 13195 | if (setjmp(jmploc.loc) == 0) { | ||
| 13196 | exception_handler = &jmploc; | ||
| 13197 | readtoken1(pgetc(), syntax_type, FAKEEOFMARK, 0); | ||
| 13198 | } | ||
| 13199 | exception_handler = savehandler; | ||
| 13200 | RESTORE_INT(saveint); | ||
| 13201 | } | ||
| 13202 | |||
| 13150 | doprompt = saveprompt; | 13203 | doprompt = saveprompt; |
| 13151 | 13204 | ||
| 13152 | popfile(); | 13205 | popfile(); |
| @@ -13215,7 +13268,7 @@ evalstring(char *s, int flags) | |||
| 13215 | 13268 | ||
| 13216 | exception_handler = savehandler; | 13269 | exception_handler = savehandler; |
| 13217 | if (ex) | 13270 | if (ex) |
| 13218 | longjmp(exception_handler->loc, ex); | 13271 | longjmp(exception_handler->loc, ex); |
| 13219 | 13272 | ||
| 13220 | return status; | 13273 | return status; |
| 13221 | } | 13274 | } |
| @@ -14069,8 +14122,8 @@ umaskcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
| 14069 | } | 14122 | } |
| 14070 | } else { | 14123 | } else { |
| 14071 | char *modestr = *argptr; | 14124 | char *modestr = *argptr; |
| 14072 | /* numeric umasks are taken as-is */ | 14125 | /* numeric umasks are taken as-is */ |
| 14073 | /* symbolic umasks are inverted: "umask a=rx" calls umask(222) */ | 14126 | /* symbolic umasks are inverted: "umask a=rx" calls umask(222) */ |
| 14074 | if (!isdigit(modestr[0])) | 14127 | if (!isdigit(modestr[0])) |
| 14075 | mask ^= 0777; | 14128 | mask ^= 0777; |
| 14076 | mask = bb_parse_mode(modestr, mask); | 14129 | mask = bb_parse_mode(modestr, mask); |
| @@ -14236,8 +14289,18 @@ init(void) | |||
| 14236 | } | 14289 | } |
| 14237 | #endif | 14290 | #endif |
| 14238 | for (envp = environ; envp && *envp; envp++) { | 14291 | for (envp = environ; envp && *envp; envp++) { |
| 14239 | p = endofname(*envp); | 14292 | /* Used to have |
| 14240 | if (p != *envp && *p == '=') { | 14293 | * p = endofname(*envp); |
| 14294 | * if (p != *envp && *p == '=') { | ||
| 14295 | * here to weed out badly-named variables, but this breaks | ||
| 14296 | * scenarios where people do want them passed to children: | ||
| 14297 | * import os | ||
| 14298 | * os.environ["test-test"]="test" | ||
| 14299 | * if os.fork() == 0: | ||
| 14300 | * os.execv("ash", [ 'ash', '-c', 'eval $(export -p); echo OK' ]) # fixes this | ||
| 14301 | * os.execv("ash", [ 'ash', '-c', 'env | grep test-test' ]) # breaks this | ||
| 14302 | */ | ||
| 14303 | if (strchr(*envp, '=')) { | ||
| 14241 | setvareq(*envp, VEXPORT|VTEXTFIXED); | 14304 | setvareq(*envp, VEXPORT|VTEXTFIXED); |
| 14242 | } | 14305 | } |
| 14243 | } | 14306 | } |
diff --git a/shell/ash_test/ash-parsing/comment2.right b/shell/ash_test/ash-parsing/comment2.right new file mode 100644 index 000000000..ee6e49a5a --- /dev/null +++ b/shell/ash_test/ash-parsing/comment2.right | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | Ok1 | ||
| 2 | Ok2 | ||
| 3 | Ok5 | ||
| 4 | Ok6 | ||
diff --git a/shell/ash_test/ash-parsing/comment2.tests b/shell/ash_test/ash-parsing/comment2.tests new file mode 100755 index 000000000..b7adad96a --- /dev/null +++ b/shell/ash_test/ash-parsing/comment2.tests | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | echo "`echo Ok1 #comment is ignored`" | ||
| 2 | echo `echo Ok2 #comment is ignored` | ||
| 3 | # | ||
| 4 | # Surprisingly, bash does not handle comments in $() | ||
| 5 | # the same way as in ``. "#" causes the rest of the line, _including_ )", | ||
| 6 | # to be ignored. These lines would cause an error: | ||
| 7 | #echo "$(echo Ok3 #comment is ignored)" | ||
| 8 | #echo $(echo Ok4 #comment is ignored) | ||
| 9 | # | ||
| 10 | echo "$(echo Ok5 #comment is ignored | ||
| 11 | )" | ||
| 12 | echo $(echo Ok6 #comment is ignored | ||
| 13 | ) | ||
diff --git a/shell/ash_test/ash-standalone/nofork_env.right b/shell/ash_test/ash-standalone/nofork_env.right new file mode 100644 index 000000000..3f16ff458 --- /dev/null +++ b/shell/ash_test/ash-standalone/nofork_env.right | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | ZVAR=1 | ||
| 2 | ZVAR=2 | ||
| 3 | ZVAR=3 | ||
| 4 | ZVAR=4 | ||
| 5 | ZVAR=5 | ||
| 6 | ZVAR=6 | ||
| 7 | ZVAR=7 | ||
| 8 | ZVAR=8 | ||
| 9 | Ok:0 | ||
diff --git a/shell/ash_test/ash-standalone/nofork_env.tests b/shell/ash_test/ash-standalone/nofork_env.tests new file mode 100755 index 000000000..111e564d2 --- /dev/null +++ b/shell/ash_test/ash-standalone/nofork_env.tests | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | # ash had a bug where NOFORKed applet (env/printenv) was not seeing new exported variables | ||
| 2 | |||
| 3 | (export ZVAR=1; printenv) | grep ^ZVAR= | ||
| 4 | (ZVAR=2 printenv) | grep ^ZVAR= | ||
| 5 | |||
| 6 | (export ZVAR=3; env) | grep ^ZVAR= | ||
| 7 | (ZVAR=4 env) | grep ^ZVAR= | ||
| 8 | |||
| 9 | export ZVAR=5; printenv | grep ^ZVAR= | ||
| 10 | ZVAR=6 printenv | grep ^ZVAR= | ||
| 11 | |||
| 12 | export ZVAR=7; env | grep ^ZVAR= | ||
| 13 | ZVAR=8 env | grep ^ZVAR= | ||
| 14 | |||
| 15 | echo Ok:$? | ||
diff --git a/shell/hush.c b/shell/hush.c index d27550ba0..708555ac4 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
| @@ -5140,14 +5140,23 @@ static struct pipe *parse_stream(char **pstring, | |||
| 5140 | case '#': | 5140 | case '#': |
| 5141 | if (dest.length == 0 && !dest.has_quoted_part) { | 5141 | if (dest.length == 0 && !dest.has_quoted_part) { |
| 5142 | /* skip "#comment" */ | 5142 | /* skip "#comment" */ |
| 5143 | /* note: we do not add it to &ctx.as_string */ | ||
| 5144 | /* TODO: in bash: | ||
| 5145 | * comment inside $() goes to the next \n, even inside quoted string (!): | ||
| 5146 | * cmd "$(cmd2 #comment)" - syntax error | ||
| 5147 | * cmd "`cmd2 #comment`" - ok | ||
| 5148 | * We accept both (comment ends where command subst ends, in both cases). | ||
| 5149 | */ | ||
| 5143 | while (1) { | 5150 | while (1) { |
| 5144 | ch = i_peek(input); | 5151 | ch = i_peek(input); |
| 5145 | if (ch == EOF || ch == '\n') | 5152 | if (ch == '\n') { |
| 5153 | nommu_addchr(&ctx.as_string, '\n'); | ||
| 5154 | break; | ||
| 5155 | } | ||
| 5156 | ch = i_getch(input); | ||
| 5157 | if (ch == EOF) | ||
| 5146 | break; | 5158 | break; |
| 5147 | i_getch(input); | ||
| 5148 | /* note: we do not add it to &ctx.as_string */ | ||
| 5149 | } | 5159 | } |
| 5150 | nommu_addchr(&ctx.as_string, '\n'); | ||
| 5151 | continue; /* back to top of while (1) */ | 5160 | continue; /* back to top of while (1) */ |
| 5152 | } | 5161 | } |
| 5153 | break; | 5162 | break; |
diff --git a/shell/hush_test/hush-parsing/comment2.right b/shell/hush_test/hush-parsing/comment2.right new file mode 100644 index 000000000..ee6e49a5a --- /dev/null +++ b/shell/hush_test/hush-parsing/comment2.right | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | Ok1 | ||
| 2 | Ok2 | ||
| 3 | Ok5 | ||
| 4 | Ok6 | ||
diff --git a/shell/hush_test/hush-parsing/comment2.tests b/shell/hush_test/hush-parsing/comment2.tests new file mode 100755 index 000000000..b7adad96a --- /dev/null +++ b/shell/hush_test/hush-parsing/comment2.tests | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | echo "`echo Ok1 #comment is ignored`" | ||
| 2 | echo `echo Ok2 #comment is ignored` | ||
| 3 | # | ||
| 4 | # Surprisingly, bash does not handle comments in $() | ||
| 5 | # the same way as in ``. "#" causes the rest of the line, _including_ )", | ||
| 6 | # to be ignored. These lines would cause an error: | ||
| 7 | #echo "$(echo Ok3 #comment is ignored)" | ||
| 8 | #echo $(echo Ok4 #comment is ignored) | ||
| 9 | # | ||
| 10 | echo "$(echo Ok5 #comment is ignored | ||
| 11 | )" | ||
| 12 | echo $(echo Ok6 #comment is ignored | ||
| 13 | ) | ||
diff --git a/shell/hush_test/hush-standalone/nofork_env.right b/shell/hush_test/hush-standalone/nofork_env.right new file mode 100644 index 000000000..3f16ff458 --- /dev/null +++ b/shell/hush_test/hush-standalone/nofork_env.right | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | ZVAR=1 | ||
| 2 | ZVAR=2 | ||
| 3 | ZVAR=3 | ||
| 4 | ZVAR=4 | ||
| 5 | ZVAR=5 | ||
| 6 | ZVAR=6 | ||
| 7 | ZVAR=7 | ||
| 8 | ZVAR=8 | ||
| 9 | Ok:0 | ||
diff --git a/shell/hush_test/hush-standalone/nofork_env.tests b/shell/hush_test/hush-standalone/nofork_env.tests new file mode 100755 index 000000000..111e564d2 --- /dev/null +++ b/shell/hush_test/hush-standalone/nofork_env.tests | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | # ash had a bug where NOFORKed applet (env/printenv) was not seeing new exported variables | ||
| 2 | |||
| 3 | (export ZVAR=1; printenv) | grep ^ZVAR= | ||
| 4 | (ZVAR=2 printenv) | grep ^ZVAR= | ||
| 5 | |||
| 6 | (export ZVAR=3; env) | grep ^ZVAR= | ||
| 7 | (ZVAR=4 env) | grep ^ZVAR= | ||
| 8 | |||
| 9 | export ZVAR=5; printenv | grep ^ZVAR= | ||
| 10 | ZVAR=6 printenv | grep ^ZVAR= | ||
| 11 | |||
| 12 | export ZVAR=7; env | grep ^ZVAR= | ||
| 13 | ZVAR=8 env | grep ^ZVAR= | ||
| 14 | |||
| 15 | echo Ok:$? | ||
diff --git a/sysklogd/syslogd_and_logger.c b/sysklogd/syslogd_and_logger.c index 6d06a718b..9bba195d4 100644 --- a/sysklogd/syslogd_and_logger.c +++ b/sysklogd/syslogd_and_logger.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
| 9 | |||
| 10 | #include "libbb.h" | 9 | #include "libbb.h" |
| 11 | #include "common_bufsiz.h" | 10 | #include "common_bufsiz.h" |
| 12 | #define SYSLOG_NAMES | 11 | #define SYSLOG_NAMES |
diff --git a/util-linux/blkdiscard.c b/util-linux/blkdiscard.c index 5863f0aab..e4902e5b5 100644 --- a/util-linux/blkdiscard.c +++ b/util-linux/blkdiscard.c | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | //config:config BLKDISCARD | 8 | //config:config BLKDISCARD |
| 9 | //config: bool "blkdiscard (5.3 kb)" | 9 | //config: bool "blkdiscard (5.3 kb)" |
| 10 | //config: default y | 10 | //config: default y |
| 11 | //config: select PLATFORM_LINUX | ||
| 11 | //config: help | 12 | //config: help |
| 12 | //config: blkdiscard discards sectors on a given device. | 13 | //config: blkdiscard discards sectors on a given device. |
| 13 | 14 | ||
diff --git a/util-linux/fdformat.c b/util-linux/fdformat.c index 855269c30..c72da8b89 100644 --- a/util-linux/fdformat.c +++ b/util-linux/fdformat.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* fdformat.c - Low-level formats a floppy disk - Werner Almesberger | 2 | /* |
| 3 | * fdformat.c - Low-level formats a floppy disk - Werner Almesberger | ||
| 3 | * 5 July 2003 -- modified for Busybox by Erik Andersen | 4 | * 5 July 2003 -- modified for Busybox by Erik Andersen |
| 4 | * | 5 | * |
| 5 | * Licensed under GPLv2, see file LICENSE in this source tree. | 6 | * Licensed under GPLv2, see file LICENSE in this source tree. |
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c index c4318b6c4..7275535e6 100644 --- a/util-linux/fdisk.c +++ b/util-linux/fdisk.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* fdisk.c -- Partition table manipulator for Linux. | 2 | /* |
| 3 | * fdisk.c -- Partition table manipulator for Linux. | ||
| 3 | * | 4 | * |
| 4 | * Copyright (C) 1992 A. V. Le Blanc (LeBlanc@mcc.ac.uk) | 5 | * Copyright (C) 1992 A. V. Le Blanc (LeBlanc@mcc.ac.uk) |
| 5 | * Copyright (C) 2001,2002 Vladimir Oleynik <dzo@simtreas.ru> (initial bb port) | 6 | * Copyright (C) 2001,2002 Vladimir Oleynik <dzo@simtreas.ru> (initial bb port) |
diff --git a/util-linux/fdisk_osf.c b/util-linux/fdisk_osf.c index 1141b7801..1328c1fcd 100644 --- a/util-linux/fdisk_osf.c +++ b/util-linux/fdisk_osf.c | |||
| @@ -709,6 +709,9 @@ sync_disks(void) | |||
| 709 | static void | 709 | static void |
| 710 | xbsd_write_bootstrap(void) | 710 | xbsd_write_bootstrap(void) |
| 711 | { | 711 | { |
| 712 | #ifndef MAXPATHLEN | ||
| 713 | # define MAXPATHLEN 1024 | ||
| 714 | #endif | ||
| 712 | char path[MAXPATHLEN]; | 715 | char path[MAXPATHLEN]; |
| 713 | const char *bootdir = BSD_LINUX_BOOTDIR; | 716 | const char *bootdir = BSD_LINUX_BOOTDIR; |
| 714 | const char *dkbasename; | 717 | const char *dkbasename; |
diff --git a/util-linux/getopt.c b/util-linux/getopt.c index a151b7e56..4431a7e74 100644 --- a/util-linux/getopt.c +++ b/util-linux/getopt.c | |||
| @@ -1,11 +1,10 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* | 2 | /* |
| 3 | * getopt.c - Enhanced implementation of BSD getopt(1) | 3 | * getopt.c - Enhanced implementation of BSD getopt(1) |
| 4 | * Copyright (c) 1997, 1998, 1999, 2000 Frodo Looijaard <frodol@dds.nl> | 4 | * Copyright (c) 1997, 1998, 1999, 2000 Frodo Looijaard <frodol@dds.nl> |
| 5 | * | 5 | * |
| 6 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 6 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 7 | */ | 7 | */ |
| 8 | |||
| 9 | /* | 8 | /* |
| 10 | * Version 1.0-b4: Tue Sep 23 1997. First public release. | 9 | * Version 1.0-b4: Tue Sep 23 1997. First public release. |
| 11 | * Version 1.0: Wed Nov 19 1997. | 10 | * Version 1.0: Wed Nov 19 1997. |
diff --git a/util-linux/mkswap.c b/util-linux/mkswap.c index 71449882d..2eb16bd84 100644 --- a/util-linux/mkswap.c +++ b/util-linux/mkswap.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* mkswap.c - format swap device (Linux v1 only) | 2 | /* |
| 3 | * mkswap.c - format swap device (Linux v1 only) | ||
| 3 | * | 4 | * |
| 4 | * Copyright 2006 Rob Landley <rob@landley.net> | 5 | * Copyright 2006 Rob Landley <rob@landley.net> |
| 5 | * | 6 | * |
diff --git a/util-linux/readprofile.c b/util-linux/readprofile.c index 394ece1dd..8fc33be3c 100644 --- a/util-linux/readprofile.c +++ b/util-linux/readprofile.c | |||
| @@ -1,8 +1,8 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* | 2 | /* |
| 3 | * readprofile.c - used to read /proc/profile | 3 | * readprofile.c - used to read /proc/profile |
| 4 | * | 4 | * |
| 5 | * Copyright (C) 1994,1996 Alessandro Rubini (rubini@ipvvis.unipv.it) | 5 | * Copyright (C) 1994,1996 Alessandro Rubini (rubini@ipvvis.unipv.it) |
| 6 | * | 6 | * |
| 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
| 8 | */ | 8 | */ |
diff --git a/util-linux/switch_root.c b/util-linux/switch_root.c index 080b05e45..2d1802b79 100644 --- a/util-linux/switch_root.c +++ b/util-linux/switch_root.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* Copyright 2005 Rob Landley <rob@landley.net> | 2 | /* |
| 3 | * Copyright 2005 Rob Landley <rob@landley.net> | ||
| 3 | * | 4 | * |
| 4 | * Switch from rootfs to another filesystem as the root of the mount tree. | 5 | * Switch from rootfs to another filesystem as the root of the mount tree. |
| 5 | * | 6 | * |
