libbb: reduce the overhead of single parameter bb_error_msg() calls
Back in 2007, commit 0c97c9d437
("'simple' error message functions by
Loic Grenie") introduced bb_simple_perror_msg() to allow for a lower
overhead call to bb_perror_msg() when only a string was being printed
with no parameters. This saves space for some CPU architectures because
it avoids the overhead of a call to a variadic function. However there
has never been a simple version of bb_error_msg(), and since 2007 many
new calls to bb_perror_msg() have been added that only take a single
parameter and so could have been using bb_simple_perror_message().
This changeset introduces 'simple' versions of bb_info_msg(),
bb_error_msg(), bb_error_msg_and_die(), bb_herror_msg() and
bb_herror_msg_and_die(), and replaces all calls that only take a
single parameter, or use something like ("%s", arg), with calls to the
corresponding 'simple' version.
Since it is likely that single parameter calls to the variadic functions
may be accidentally reintroduced in the future a new debugging config
option WARN_SIMPLE_MSG has been introduced. This uses some macro magic
which will cause any such calls to generate a warning, but this is
turned off by default to avoid use of the unpleasant macros in normal
circumstances.
This is a large changeset due to the number of calls that have been
replaced. The only files that contain changes other than simple
substitution of function calls are libbb.h, libbb/herror_msg.c,
libbb/verror_msg.c and libbb/xfuncs_printf.c. In miscutils/devfsd.c,
networking/udhcp/common.h and util-linux/mdev.c additonal macros have
been added for logging so that single parameter and multiple parameter
logging variants exist.
The amount of space saved varies considerably by architecture, and was
found to be as follows (for 'defconfig' using GCC 7.4):
Arm: -92 bytes
MIPS: -52 bytes
PPC: -1836 bytes
x86_64: -938 bytes
Note that for the MIPS architecture only an exception had to be made
disabling the 'simple' calls for 'udhcp' (in networking/udhcp/common.h)
because it made these files larger on MIPS.
Signed-off-by: James Byrne <james.byrne@origamienergy.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
caecfdc20d
commit
6937487be7
13
Config.in
13
Config.in
@ -661,6 +661,19 @@ config WERROR
|
|||||||
|
|
||||||
Most people should answer N.
|
Most people should answer N.
|
||||||
|
|
||||||
|
config WARN_SIMPLE_MSG
|
||||||
|
bool "Warn about single parameter bb_xx_msg calls"
|
||||||
|
default n
|
||||||
|
help
|
||||||
|
This will cause warnings to be shown for any instances of
|
||||||
|
bb_error_msg(), bb_error_msg_and_die(), bb_perror_msg(),
|
||||||
|
bb_perror_msg_and_die(), bb_herror_msg() or bb_herror_msg_and_die()
|
||||||
|
being called with a single parameter. In these cases the equivalent
|
||||||
|
bb_simple_xx_msg function should be used instead.
|
||||||
|
Note that use of STRERROR_FMT may give false positives.
|
||||||
|
|
||||||
|
If you aren't developing busybox, say N here.
|
||||||
|
|
||||||
choice
|
choice
|
||||||
prompt "Additional debugging library"
|
prompt "Additional debugging library"
|
||||||
default NO_DEBUG_LIB
|
default NO_DEBUG_LIB
|
||||||
|
@ -114,7 +114,7 @@ int FAST_FUNC bbunpack(char **argv,
|
|||||||
|
|
||||||
/* Check that the input is sane */
|
/* Check that the input is sane */
|
||||||
if (!(option_mask32 & BBUNPK_OPT_FORCE) && isatty(STDIN_FILENO)) {
|
if (!(option_mask32 & BBUNPK_OPT_FORCE) && isatty(STDIN_FILENO)) {
|
||||||
bb_error_msg_and_die("compressed data not read from terminal, "
|
bb_simple_error_msg_and_die("compressed data not read from terminal, "
|
||||||
"use -f to force it");
|
"use -f to force it");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ IF_DESKTOP(long long) int bz_write(bz_stream *strm, void* rbuf, ssize_t rlen, vo
|
|||||||
if (n2 != n) {
|
if (n2 != n) {
|
||||||
if (n2 >= 0)
|
if (n2 >= 0)
|
||||||
errno = 0; /* prevent bogus error message */
|
errno = 0; /* prevent bogus error message */
|
||||||
bb_perror_msg(n2 >= 0 ? "short write" : bb_msg_write_error);
|
bb_simple_perror_msg(n2 >= 0 ? "short write" : bb_msg_write_error);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -187,7 +187,7 @@ IF_DESKTOP(long long) int FAST_FUNC compressStream(transformer_state_t *xstate U
|
|||||||
while (1) {
|
while (1) {
|
||||||
count = full_read(STDIN_FILENO, rbuf, IOBUF_SIZE);
|
count = full_read(STDIN_FILENO, rbuf, IOBUF_SIZE);
|
||||||
if (count < 0) {
|
if (count < 0) {
|
||||||
bb_perror_msg(bb_msg_read_error);
|
bb_simple_perror_msg(bb_msg_read_error);
|
||||||
total = -1;
|
total = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -487,7 +487,7 @@ static void add_split_dependencies(common_node_t *parent_node, const char *whole
|
|||||||
} else if (strncmp(version, ">=", offset_ch) == 0) {
|
} else if (strncmp(version, ">=", offset_ch) == 0) {
|
||||||
edge->operator = VER_MORE_EQUAL;
|
edge->operator = VER_MORE_EQUAL;
|
||||||
} else {
|
} else {
|
||||||
bb_error_msg_and_die("illegal operator");
|
bb_simple_error_msg_and_die("illegal operator");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* skip to start of version numbers */
|
/* skip to start of version numbers */
|
||||||
@ -730,7 +730,7 @@ static void set_status(const unsigned status_node_num, const char *new_value, co
|
|||||||
status = new_value_num;
|
status = new_value_num;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
bb_error_msg_and_die("DEBUG ONLY: this shouldnt happen");
|
bb_simple_error_msg_and_die("DEBUG ONLY: this shouldnt happen");
|
||||||
}
|
}
|
||||||
|
|
||||||
new_status = xasprintf("%s %s %s", name_hashtable[want], name_hashtable[flag], name_hashtable[status]);
|
new_status = xasprintf("%s %s %s", name_hashtable[want], name_hashtable[flag], name_hashtable[status]);
|
||||||
@ -944,10 +944,10 @@ static void write_status_file(deb_file_t **deb_file)
|
|||||||
/* Create a separate backfile to dpkg */
|
/* Create a separate backfile to dpkg */
|
||||||
if (rename("/var/lib/dpkg/status", "/var/lib/dpkg/status.udeb.bak") == -1) {
|
if (rename("/var/lib/dpkg/status", "/var/lib/dpkg/status.udeb.bak") == -1) {
|
||||||
if (errno != ENOENT)
|
if (errno != ENOENT)
|
||||||
bb_error_msg_and_die("can't create backup status file");
|
bb_simple_error_msg_and_die("can't create backup status file");
|
||||||
/* Its ok if renaming the status file fails because status
|
/* Its ok if renaming the status file fails because status
|
||||||
* file doesn't exist, maybe we are starting from scratch */
|
* file doesn't exist, maybe we are starting from scratch */
|
||||||
bb_error_msg("no status file found, creating new one");
|
bb_simple_error_msg("no status file found, creating new one");
|
||||||
}
|
}
|
||||||
|
|
||||||
xrename("/var/lib/dpkg/status.udeb", "/var/lib/dpkg/status");
|
xrename("/var/lib/dpkg/status.udeb", "/var/lib/dpkg/status");
|
||||||
@ -1816,7 +1816,7 @@ int dpkg_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
init_archive_deb_control(archive_handle);
|
init_archive_deb_control(archive_handle);
|
||||||
deb_file[deb_count]->control_file = deb_extract_control_file_to_buffer(archive_handle, control_list);
|
deb_file[deb_count]->control_file = deb_extract_control_file_to_buffer(archive_handle, control_list);
|
||||||
if (deb_file[deb_count]->control_file == NULL) {
|
if (deb_file[deb_count]->control_file == NULL) {
|
||||||
bb_error_msg_and_die("can't extract control file");
|
bb_simple_error_msg_and_die("can't extract control file");
|
||||||
}
|
}
|
||||||
deb_file[deb_count]->filename = xstrdup(argv[0]);
|
deb_file[deb_count]->filename = xstrdup(argv[0]);
|
||||||
package_num = fill_package_struct(deb_file[deb_count]->control_file);
|
package_num = fill_package_struct(deb_file[deb_count]->control_file);
|
||||||
@ -1879,13 +1879,13 @@ int dpkg_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
argv++;
|
argv++;
|
||||||
}
|
}
|
||||||
if (!deb_count)
|
if (!deb_count)
|
||||||
bb_error_msg_and_die("no package files specified");
|
bb_simple_error_msg_and_die("no package files specified");
|
||||||
deb_file[deb_count] = NULL;
|
deb_file[deb_count] = NULL;
|
||||||
|
|
||||||
/* Check that the deb file arguments are installable */
|
/* Check that the deb file arguments are installable */
|
||||||
if (!(opt & OPT_force_ignore_depends)) {
|
if (!(opt & OPT_force_ignore_depends)) {
|
||||||
if (!check_deps(deb_file, 0 /*, deb_count*/)) {
|
if (!check_deps(deb_file, 0 /*, deb_count*/)) {
|
||||||
bb_error_msg_and_die("dependency check failed");
|
bb_simple_error_msg_and_die("dependency check failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ aa: 85.1% -- replaced with aa.gz
|
|||||||
/* Diagnostic functions */
|
/* Diagnostic functions */
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
static int verbose;
|
static int verbose;
|
||||||
# define Assert(cond,msg) { if (!(cond)) bb_error_msg(msg); }
|
# define Assert(cond,msg) { if (!(cond)) bb_simple_error_msg(msg); }
|
||||||
# define Trace(x) fprintf x
|
# define Trace(x) fprintf x
|
||||||
# define Tracev(x) {if (verbose) fprintf x; }
|
# define Tracev(x) {if (verbose) fprintf x; }
|
||||||
# define Tracevv(x) {if (verbose > 1) fprintf x; }
|
# define Tracevv(x) {if (verbose > 1) fprintf x; }
|
||||||
@ -787,7 +787,7 @@ static void check_match(IPos start, IPos match, int length)
|
|||||||
/* check that the match is indeed a match */
|
/* check that the match is indeed a match */
|
||||||
if (memcmp(G1.window + match, G1.window + start, length) != 0) {
|
if (memcmp(G1.window + match, G1.window + start, length) != 0) {
|
||||||
bb_error_msg(" start %d, match %d, length %d", start, match, length);
|
bb_error_msg(" start %d, match %d, length %d", start, match, length);
|
||||||
bb_error_msg("invalid match");
|
bb_simple_error_msg("invalid match");
|
||||||
}
|
}
|
||||||
if (verbose > 1) {
|
if (verbose > 1) {
|
||||||
bb_error_msg("\\[%d,%d]", start - match, length);
|
bb_error_msg("\\[%d,%d]", start - match, length);
|
||||||
|
@ -103,7 +103,7 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
|
|||||||
struct stat existing_sb;
|
struct stat existing_sb;
|
||||||
if (lstat(dst_name, &existing_sb) == -1) {
|
if (lstat(dst_name, &existing_sb) == -1) {
|
||||||
if (errno != ENOENT) {
|
if (errno != ENOENT) {
|
||||||
bb_perror_msg_and_die("can't stat old file");
|
bb_simple_perror_msg_and_die("can't stat old file");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (existing_sb.st_mtime >= file_header->mtime) {
|
else if (existing_sb.st_mtime >= file_header->mtime) {
|
||||||
@ -207,7 +207,7 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
bb_error_msg_and_die("unrecognized file type");
|
bb_simple_error_msg_and_die("unrecognized file type");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!S_ISLNK(file_header->mode)) {
|
if (!S_ISLNK(file_header->mode)) {
|
||||||
|
@ -817,7 +817,7 @@ unpack_bz2_stream(transformer_state_t *xstate)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (bd->headerCRC != bd->totalCRC) {
|
if (bd->headerCRC != bd->totalCRC) {
|
||||||
bb_error_msg("CRC error");
|
bb_simple_error_msg("CRC error");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1012,7 +1012,7 @@ inflate_unzip_internal(STATE_PARAM transformer_state_t *xstate)
|
|||||||
error_msg = "corrupted data";
|
error_msg = "corrupted data";
|
||||||
if (setjmp(error_jmp)) {
|
if (setjmp(error_jmp)) {
|
||||||
/* Error from deep inside zip machinery */
|
/* Error from deep inside zip machinery */
|
||||||
bb_error_msg(error_msg);
|
bb_simple_error_msg(error_msg);
|
||||||
n = -1;
|
n = -1;
|
||||||
goto ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
@ -1085,7 +1085,7 @@ static int top_up(STATE_PARAM unsigned n)
|
|||||||
bytebuffer_offset = 0;
|
bytebuffer_offset = 0;
|
||||||
bytebuffer_size = full_read(gunzip_src_fd, &bytebuffer[count], bytebuffer_max - count);
|
bytebuffer_size = full_read(gunzip_src_fd, &bytebuffer[count], bytebuffer_max - count);
|
||||||
if ((int)bytebuffer_size < 0) {
|
if ((int)bytebuffer_size < 0) {
|
||||||
bb_error_msg(bb_msg_read_error);
|
bb_simple_error_msg(bb_msg_read_error);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
bytebuffer_size += count;
|
bytebuffer_size += count;
|
||||||
@ -1211,7 +1211,7 @@ unpack_gz_stream(transformer_state_t *xstate)
|
|||||||
|
|
||||||
if (full_read(xstate->src_fd, &magic2, 2) != 2) {
|
if (full_read(xstate->src_fd, &magic2, 2) != 2) {
|
||||||
bad_magic:
|
bad_magic:
|
||||||
bb_error_msg("invalid magic");
|
bb_simple_error_msg("invalid magic");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (magic2 == COMPRESS_MAGIC) {
|
if (magic2 == COMPRESS_MAGIC) {
|
||||||
@ -1233,7 +1233,7 @@ unpack_gz_stream(transformer_state_t *xstate)
|
|||||||
|
|
||||||
again:
|
again:
|
||||||
if (!check_header_gzip(PASS_STATE xstate)) {
|
if (!check_header_gzip(PASS_STATE xstate)) {
|
||||||
bb_error_msg("corrupted data");
|
bb_simple_error_msg("corrupted data");
|
||||||
total = -1;
|
total = -1;
|
||||||
goto ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
@ -1246,7 +1246,7 @@ unpack_gz_stream(transformer_state_t *xstate)
|
|||||||
total += n;
|
total += n;
|
||||||
|
|
||||||
if (!top_up(PASS_STATE 8)) {
|
if (!top_up(PASS_STATE 8)) {
|
||||||
bb_error_msg("corrupted data");
|
bb_simple_error_msg("corrupted data");
|
||||||
total = -1;
|
total = -1;
|
||||||
goto ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
@ -1254,7 +1254,7 @@ unpack_gz_stream(transformer_state_t *xstate)
|
|||||||
/* Validate decompression - crc */
|
/* Validate decompression - crc */
|
||||||
v32 = buffer_read_le_u32(PASS_STATE_ONLY);
|
v32 = buffer_read_le_u32(PASS_STATE_ONLY);
|
||||||
if ((~gunzip_crc) != v32) {
|
if ((~gunzip_crc) != v32) {
|
||||||
bb_error_msg("crc error");
|
bb_simple_error_msg("crc error");
|
||||||
total = -1;
|
total = -1;
|
||||||
goto ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
@ -1262,7 +1262,7 @@ unpack_gz_stream(transformer_state_t *xstate)
|
|||||||
/* Validate decompression - size */
|
/* Validate decompression - size */
|
||||||
v32 = buffer_read_le_u32(PASS_STATE_ONLY);
|
v32 = buffer_read_le_u32(PASS_STATE_ONLY);
|
||||||
if ((uint32_t)gunzip_bytes_out != v32) {
|
if ((uint32_t)gunzip_bytes_out != v32) {
|
||||||
bb_error_msg("incorrect length");
|
bb_simple_error_msg("incorrect length");
|
||||||
total = -1;
|
total = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ unpack_Z_stream(transformer_state_t *xstate)
|
|||||||
/* xread isn't good here, we have to return - caller may want
|
/* xread isn't good here, we have to return - caller may want
|
||||||
* to do some cleanup (e.g. delete incomplete unpacked file etc) */
|
* to do some cleanup (e.g. delete incomplete unpacked file etc) */
|
||||||
if (full_read(xstate->src_fd, inbuf, 1) != 1) {
|
if (full_read(xstate->src_fd, inbuf, 1) != 1) {
|
||||||
bb_error_msg("short read");
|
bb_simple_error_msg("short read");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ unpack_Z_stream(transformer_state_t *xstate)
|
|||||||
if (insize < (int) (IBUFSIZ + 64) - IBUFSIZ) {
|
if (insize < (int) (IBUFSIZ + 64) - IBUFSIZ) {
|
||||||
rsize = safe_read(xstate->src_fd, inbuf + insize, IBUFSIZ);
|
rsize = safe_read(xstate->src_fd, inbuf + insize, IBUFSIZ);
|
||||||
if (rsize < 0)
|
if (rsize < 0)
|
||||||
bb_error_msg_and_die(bb_msg_read_error);
|
bb_simple_error_msg_and_die(bb_msg_read_error);
|
||||||
insize += rsize;
|
insize += rsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ unpack_Z_stream(transformer_state_t *xstate)
|
|||||||
|
|
||||||
if (oldcode == -1) {
|
if (oldcode == -1) {
|
||||||
if (code >= 256)
|
if (code >= 256)
|
||||||
bb_error_msg_and_die("corrupted data"); /* %ld", code); */
|
bb_simple_error_msg_and_die("corrupted data"); /* %ld", code); */
|
||||||
oldcode = code;
|
oldcode = code;
|
||||||
finchar = (int) oldcode;
|
finchar = (int) oldcode;
|
||||||
outbuf[outpos++] = (unsigned char) finchar;
|
outbuf[outpos++] = (unsigned char) finchar;
|
||||||
@ -236,7 +236,7 @@ unpack_Z_stream(transformer_state_t *xstate)
|
|||||||
insize, posbits, p[-1], p[0], p[1], p[2], p[3],
|
insize, posbits, p[-1], p[0], p[1], p[2], p[3],
|
||||||
(posbits & 07));
|
(posbits & 07));
|
||||||
*/
|
*/
|
||||||
bb_error_msg("corrupted data");
|
bb_simple_error_msg("corrupted data");
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,7 +247,7 @@ unpack_Z_stream(transformer_state_t *xstate)
|
|||||||
/* Generate output characters in reverse order */
|
/* Generate output characters in reverse order */
|
||||||
while (code >= 256) {
|
while (code >= 256) {
|
||||||
if (stackp <= &htabof(0))
|
if (stackp <= &htabof(0))
|
||||||
bb_error_msg_and_die("corrupted data");
|
bb_simple_error_msg_and_die("corrupted data");
|
||||||
*--stackp = tab_suffixof(code);
|
*--stackp = tab_suffixof(code);
|
||||||
code = tab_prefixof(code);
|
code = tab_prefixof(code);
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ static void rc_read(rc_t *rc)
|
|||||||
//TODO: return -1 instead
|
//TODO: return -1 instead
|
||||||
//This will make unlzma delete broken unpacked file on unpack errors
|
//This will make unlzma delete broken unpacked file on unpack errors
|
||||||
if (buffer_size <= 0)
|
if (buffer_size <= 0)
|
||||||
bb_error_msg_and_die("unexpected EOF");
|
bb_simple_error_msg_and_die("unexpected EOF");
|
||||||
rc->buffer_end = RC_BUFFER + buffer_size;
|
rc->buffer_end = RC_BUFFER + buffer_size;
|
||||||
rc->ptr = RC_BUFFER;
|
rc->ptr = RC_BUFFER;
|
||||||
}
|
}
|
||||||
@ -234,7 +234,7 @@ unpack_lzma_stream(transformer_state_t *xstate)
|
|||||||
if (full_read(xstate->src_fd, &header, sizeof(header)) != sizeof(header)
|
if (full_read(xstate->src_fd, &header, sizeof(header)) != sizeof(header)
|
||||||
|| header.pos >= (9 * 5 * 5)
|
|| header.pos >= (9 * 5 * 5)
|
||||||
) {
|
) {
|
||||||
bb_error_msg("bad lzma header");
|
bb_simple_error_msg("bad lzma header");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -513,7 +513,7 @@ unpack_lzma_stream(transformer_state_t *xstate)
|
|||||||
* potentially more detailed information).
|
* potentially more detailed information).
|
||||||
* Do not fail silently.
|
* Do not fail silently.
|
||||||
*/
|
*/
|
||||||
bb_error_msg("corrupted data");
|
bb_simple_error_msg("corrupted data");
|
||||||
total_written = -1; /* failure */
|
total_written = -1; /* failure */
|
||||||
}
|
}
|
||||||
rc_free(rc);
|
rc_free(rc);
|
||||||
|
@ -74,7 +74,7 @@ unpack_xz_stream(transformer_state_t *xstate)
|
|||||||
if (iobuf.in_pos == iobuf.in_size) {
|
if (iobuf.in_pos == iobuf.in_size) {
|
||||||
int rd = safe_read(xstate->src_fd, membuf, BUFSIZ);
|
int rd = safe_read(xstate->src_fd, membuf, BUFSIZ);
|
||||||
if (rd < 0) {
|
if (rd < 0) {
|
||||||
bb_error_msg(bb_msg_read_error);
|
bb_simple_error_msg(bb_msg_read_error);
|
||||||
total = -1;
|
total = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -123,7 +123,7 @@ unpack_xz_stream(transformer_state_t *xstate)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (xz_result != XZ_OK && xz_result != XZ_UNSUPPORTED_CHECK) {
|
if (xz_result != XZ_OK && xz_result != XZ_UNSUPPORTED_CHECK) {
|
||||||
bb_error_msg("corrupted data");
|
bb_simple_error_msg("corrupted data");
|
||||||
total = -1;
|
total = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ static unsigned read_num(char *str, int base, int len)
|
|||||||
* on misformatted numbers bb_strtou returns all-ones */
|
* on misformatted numbers bb_strtou returns all-ones */
|
||||||
err = bb_strtou(str, NULL, base);
|
err = bb_strtou(str, NULL, base);
|
||||||
if (err == -1)
|
if (err == -1)
|
||||||
bb_error_msg_and_die("invalid ar header");
|
bb_simple_error_msg_and_die("invalid ar header");
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ char FAST_FUNC get_header_ar(archive_handle_t *archive_handle)
|
|||||||
archive_handle->offset += 60;
|
archive_handle->offset += 60;
|
||||||
|
|
||||||
if (ar.formatted.magic[0] != '`' || ar.formatted.magic[1] != '\n')
|
if (ar.formatted.magic[0] != '`' || ar.formatted.magic[1] != '\n')
|
||||||
bb_error_msg_and_die("invalid ar header");
|
bb_simple_error_msg_and_die("invalid ar header");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note that the fields MUST be read in reverse order as
|
* Note that the fields MUST be read in reverse order as
|
||||||
@ -86,7 +86,7 @@ char FAST_FUNC get_header_ar(archive_handle_t *archive_handle)
|
|||||||
return get_header_ar(archive_handle);
|
return get_header_ar(archive_handle);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
bb_error_msg_and_die("long filenames not supported");
|
bb_simple_error_msg_and_die("long filenames not supported");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
/* Only size is always present, the rest may be missing in
|
/* Only size is always present, the rest may be missing in
|
||||||
@ -107,7 +107,7 @@ char FAST_FUNC get_header_ar(archive_handle_t *archive_handle)
|
|||||||
long_offset = read_num(&ar.formatted.name[1], 10,
|
long_offset = read_num(&ar.formatted.name[1], 10,
|
||||||
sizeof(ar.formatted.name) - 1);
|
sizeof(ar.formatted.name) - 1);
|
||||||
if (long_offset >= archive_handle->ar__long_name_size) {
|
if (long_offset >= archive_handle->ar__long_name_size) {
|
||||||
bb_error_msg_and_die("can't resolve long filename");
|
bb_simple_error_msg_and_die("can't resolve long filename");
|
||||||
}
|
}
|
||||||
typed->name = xstrdup(archive_handle->ar__long_names + long_offset);
|
typed->name = xstrdup(archive_handle->ar__long_names + long_offset);
|
||||||
} else
|
} else
|
||||||
|
@ -33,14 +33,14 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle)
|
|||||||
goto create_hardlinks;
|
goto create_hardlinks;
|
||||||
}
|
}
|
||||||
if (size != 110) {
|
if (size != 110) {
|
||||||
bb_error_msg_and_die("short read");
|
bb_simple_error_msg_and_die("short read");
|
||||||
}
|
}
|
||||||
archive_handle->offset += 110;
|
archive_handle->offset += 110;
|
||||||
|
|
||||||
if (!is_prefixed_with(&cpio_header[0], "07070")
|
if (!is_prefixed_with(&cpio_header[0], "07070")
|
||||||
|| (cpio_header[5] != '1' && cpio_header[5] != '2')
|
|| (cpio_header[5] != '1' && cpio_header[5] != '2')
|
||||||
) {
|
) {
|
||||||
bb_error_msg_and_die("unsupported cpio format, use newc or crc");
|
bb_simple_error_msg_and_die("unsupported cpio format, use newc or crc");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sscanf(cpio_header + 6,
|
if (sscanf(cpio_header + 6,
|
||||||
@ -50,7 +50,7 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle)
|
|||||||
&inode, &mode, &uid, &gid,
|
&inode, &mode, &uid, &gid,
|
||||||
&nlink, &mtime, &size,
|
&nlink, &mtime, &size,
|
||||||
&major, &minor, &namesize) != 10)
|
&major, &minor, &namesize) != 10)
|
||||||
bb_error_msg_and_die("damaged cpio file");
|
bb_simple_error_msg_and_die("damaged cpio file");
|
||||||
file_header->mode = mode;
|
file_header->mode = mode;
|
||||||
/* "cpio -R USER:GRP" support: */
|
/* "cpio -R USER:GRP" support: */
|
||||||
if (archive_handle->cpio__owner.uid != (uid_t)-1L)
|
if (archive_handle->cpio__owner.uid != (uid_t)-1L)
|
||||||
|
@ -32,7 +32,7 @@ static unsigned long long getOctal(char *str, int len)
|
|||||||
if (*end != '\0' && *end != ' ') {
|
if (*end != '\0' && *end != ' ') {
|
||||||
int8_t first = str[0];
|
int8_t first = str[0];
|
||||||
if (!(first & 0x80))
|
if (!(first & 0x80))
|
||||||
bb_error_msg_and_die("corrupted octal value in tar header");
|
bb_simple_error_msg_and_die("corrupted octal value in tar header");
|
||||||
/*
|
/*
|
||||||
* GNU tar uses "base-256 encoding" for very large numbers.
|
* GNU tar uses "base-256 encoding" for very large numbers.
|
||||||
* Encoding is binary, with highest bit always set as a marker
|
* Encoding is binary, with highest bit always set as a marker
|
||||||
@ -100,7 +100,7 @@ static void process_pax_hdr(archive_handle_t *archive_handle, unsigned sz, int g
|
|||||||
|| errno != EINVAL
|
|| errno != EINVAL
|
||||||
|| *end != ' '
|
|| *end != ' '
|
||||||
) {
|
) {
|
||||||
bb_error_msg("malformed extended header, skipped");
|
bb_simple_error_msg("malformed extended header, skipped");
|
||||||
// More verbose version:
|
// More verbose version:
|
||||||
//bb_error_msg("malformed extended header at %"OFF_FMT"d, skipped",
|
//bb_error_msg("malformed extended header at %"OFF_FMT"d, skipped",
|
||||||
// archive_handle->offset - (sz + len));
|
// archive_handle->offset - (sz + len));
|
||||||
@ -194,13 +194,13 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
|||||||
* the very first read fails. Grrr.
|
* the very first read fails. Grrr.
|
||||||
*/
|
*/
|
||||||
if (archive_handle->offset == 0)
|
if (archive_handle->offset == 0)
|
||||||
bb_error_msg("short read");
|
bb_simple_error_msg("short read");
|
||||||
/* this merely signals end of archive, not exit(1): */
|
/* this merely signals end of archive, not exit(1): */
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
if (i != 512) {
|
if (i != 512) {
|
||||||
IF_FEATURE_TAR_AUTODETECT(goto autodetect;)
|
IF_FEATURE_TAR_AUTODETECT(goto autodetect;)
|
||||||
bb_error_msg_and_die("short read");
|
bb_simple_error_msg_and_die("short read");
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@ -243,11 +243,11 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
|||||||
goto err;
|
goto err;
|
||||||
if (setup_unzip_on_fd(archive_handle->src_fd, /*fail_if_not_compressed:*/ 0) != 0)
|
if (setup_unzip_on_fd(archive_handle->src_fd, /*fail_if_not_compressed:*/ 0) != 0)
|
||||||
err:
|
err:
|
||||||
bb_error_msg_and_die("invalid tar magic");
|
bb_simple_error_msg_and_die("invalid tar magic");
|
||||||
archive_handle->offset = 0;
|
archive_handle->offset = 0;
|
||||||
goto again_after_align;
|
goto again_after_align;
|
||||||
#endif
|
#endif
|
||||||
bb_error_msg_and_die("invalid tar magic");
|
bb_simple_error_msg_and_die("invalid tar magic");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Do checksum on headers.
|
/* Do checksum on headers.
|
||||||
@ -282,7 +282,7 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
|||||||
if (sum_u != sum
|
if (sum_u != sum
|
||||||
IF_FEATURE_TAR_OLDSUN_COMPATIBILITY(&& sum_s != sum)
|
IF_FEATURE_TAR_OLDSUN_COMPATIBILITY(&& sum_s != sum)
|
||||||
) {
|
) {
|
||||||
bb_error_msg_and_die("invalid tar header checksum");
|
bb_simple_error_msg_and_die("invalid tar header checksum");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* GET_OCTAL trashes subsequent field, therefore we call it
|
/* GET_OCTAL trashes subsequent field, therefore we call it
|
||||||
|
@ -15,7 +15,7 @@ int FAST_FUNC check_signature16(transformer_state_t *xstate, unsigned magic16)
|
|||||||
if (!xstate->signature_skipped) {
|
if (!xstate->signature_skipped) {
|
||||||
uint16_t magic2;
|
uint16_t magic2;
|
||||||
if (full_read(xstate->src_fd, &magic2, 2) != 2 || magic2 != magic16) {
|
if (full_read(xstate->src_fd, &magic2, 2) != 2 || magic2 != magic16) {
|
||||||
bb_error_msg("invalid magic");
|
bb_simple_error_msg("invalid magic");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
xstate->signature_skipped = 2;
|
xstate->signature_skipped = 2;
|
||||||
@ -46,7 +46,7 @@ ssize_t FAST_FUNC transformer_write(transformer_state_t *xstate, const void *buf
|
|||||||
} else {
|
} else {
|
||||||
nwrote = full_write(xstate->dst_fd, buf, bufsize);
|
nwrote = full_write(xstate->dst_fd, buf, bufsize);
|
||||||
if (nwrote != (ssize_t)bufsize) {
|
if (nwrote != (ssize_t)bufsize) {
|
||||||
bb_perror_msg("write");
|
bb_simple_perror_msg("write");
|
||||||
nwrote = -1;
|
nwrote = -1;
|
||||||
goto ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
@ -205,7 +205,7 @@ static transformer_state_t *setup_transformer_on_fd(int fd, int fail_if_not_comp
|
|||||||
|
|
||||||
/* No known magic seen */
|
/* No known magic seen */
|
||||||
if (fail_if_not_compressed)
|
if (fail_if_not_compressed)
|
||||||
bb_error_msg_and_die("no gzip"
|
bb_simple_error_msg_and_die("no gzip"
|
||||||
IF_FEATURE_SEAMLESS_BZ2("/bzip2")
|
IF_FEATURE_SEAMLESS_BZ2("/bzip2")
|
||||||
IF_FEATURE_SEAMLESS_XZ("/xz")
|
IF_FEATURE_SEAMLESS_XZ("/xz")
|
||||||
" magic");
|
" magic");
|
||||||
|
@ -13,6 +13,6 @@ void FAST_FUNC seek_by_jump(int fd, off_t amount)
|
|||||||
if (errno == ESPIPE)
|
if (errno == ESPIPE)
|
||||||
seek_by_read(fd, amount);
|
seek_by_read(fd, amount);
|
||||||
else
|
else
|
||||||
bb_perror_msg_and_die("seek failure");
|
bb_simple_perror_msg_and_die("seek failure");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ void FAST_FUNC unpack_ar_archive(archive_handle_t *ar_archive)
|
|||||||
|
|
||||||
xread(ar_archive->src_fd, magic, AR_MAGIC_LEN);
|
xread(ar_archive->src_fd, magic, AR_MAGIC_LEN);
|
||||||
if (!is_prefixed_with(magic, AR_MAGIC)) {
|
if (!is_prefixed_with(magic, AR_MAGIC)) {
|
||||||
bb_error_msg_and_die("invalid ar magic");
|
bb_simple_error_msg_and_die("invalid ar magic");
|
||||||
}
|
}
|
||||||
ar_archive->offset += AR_MAGIC_LEN;
|
ar_archive->offset += AR_MAGIC_LEN;
|
||||||
|
|
||||||
|
@ -752,7 +752,7 @@ static FAST_FUNC void lzo_check(
|
|||||||
*/
|
*/
|
||||||
uint32_t c = fn(init, buf, len);
|
uint32_t c = fn(init, buf, len);
|
||||||
if (c != ref)
|
if (c != ref)
|
||||||
bb_error_msg_and_die("checksum error");
|
bb_simple_error_msg_and_die("checksum error");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
@ -785,15 +785,15 @@ static NOINLINE int lzo_decompress(uint32_t h_flags32)
|
|||||||
/* error if split file */
|
/* error if split file */
|
||||||
if (dst_len == 0xffffffffL)
|
if (dst_len == 0xffffffffL)
|
||||||
/* should not happen - not yet implemented */
|
/* should not happen - not yet implemented */
|
||||||
bb_error_msg_and_die("this file is a split lzop file");
|
bb_simple_error_msg_and_die("this file is a split lzop file");
|
||||||
|
|
||||||
if (dst_len > MAX_BLOCK_SIZE)
|
if (dst_len > MAX_BLOCK_SIZE)
|
||||||
bb_error_msg_and_die("corrupted data");
|
bb_simple_error_msg_and_die("corrupted data");
|
||||||
|
|
||||||
/* read compressed block size */
|
/* read compressed block size */
|
||||||
src_len = read32();
|
src_len = read32();
|
||||||
if (src_len <= 0 || src_len > dst_len)
|
if (src_len <= 0 || src_len > dst_len)
|
||||||
bb_error_msg_and_die("corrupted data");
|
bb_simple_error_msg_and_die("corrupted data");
|
||||||
|
|
||||||
if (dst_len > block_size) {
|
if (dst_len > block_size) {
|
||||||
if (b2) {
|
if (b2) {
|
||||||
@ -846,7 +846,7 @@ static NOINLINE int lzo_decompress(uint32_t h_flags32)
|
|||||||
r = lzo1x_decompress_safe(b1, src_len, b2, &d /*, NULL*/);
|
r = lzo1x_decompress_safe(b1, src_len, b2, &d /*, NULL*/);
|
||||||
|
|
||||||
if (r != 0 /*LZO_E_OK*/ || dst_len != d) {
|
if (r != 0 /*LZO_E_OK*/ || dst_len != d) {
|
||||||
bb_error_msg_and_die("corrupted data");
|
bb_simple_error_msg_and_die("corrupted data");
|
||||||
}
|
}
|
||||||
dst = b2;
|
dst = b2;
|
||||||
} else {
|
} else {
|
||||||
@ -913,7 +913,7 @@ static void check_magic(void)
|
|||||||
unsigned char magic[sizeof(lzop_magic)];
|
unsigned char magic[sizeof(lzop_magic)];
|
||||||
xread(0, magic, sizeof(magic));
|
xread(0, magic, sizeof(magic));
|
||||||
if (memcmp(magic, lzop_magic, sizeof(lzop_magic)) != 0)
|
if (memcmp(magic, lzop_magic, sizeof(lzop_magic)) != 0)
|
||||||
bb_error_msg_and_die("bad magic number");
|
bb_simple_error_msg_and_die("bad magic number");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
@ -1049,7 +1049,7 @@ static void lzo_set_method(header_t *h)
|
|||||||
else if (option_mask32 & OPT_8)
|
else if (option_mask32 & OPT_8)
|
||||||
level = 8;
|
level = 8;
|
||||||
#else
|
#else
|
||||||
bb_error_msg_and_die("high compression not compiled in");
|
bb_simple_error_msg_and_die("high compression not compiled in");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -543,7 +543,7 @@ int rpm2cpio_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bb_copyfd_eof(rpm_fd, STDOUT_FILENO) < 0)
|
if (bb_copyfd_eof(rpm_fd, STDOUT_FILENO) < 0)
|
||||||
bb_error_msg_and_die("error unpacking");
|
bb_simple_error_msg_and_die("error unpacking");
|
||||||
|
|
||||||
if (ENABLE_FEATURE_CLEAN_UP) {
|
if (ENABLE_FEATURE_CLEAN_UP) {
|
||||||
close(rpm_fd);
|
close(rpm_fd);
|
||||||
|
@ -369,7 +369,7 @@ static int writeTarHeader(struct TarBallInfo *tbInfo,
|
|||||||
/* If it is larger than 100 bytes, bail out */
|
/* If it is larger than 100 bytes, bail out */
|
||||||
if (header.linkname[sizeof(header.linkname)-1]) {
|
if (header.linkname[sizeof(header.linkname)-1]) {
|
||||||
free(lpath);
|
free(lpath);
|
||||||
bb_error_msg("names longer than "NAME_SIZE_STR" chars not supported");
|
bb_simple_error_msg("names longer than "NAME_SIZE_STR" chars not supported");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
@ -542,7 +542,7 @@ static int FAST_FUNC writeFileToTarball(const char *fileName, struct stat *statb
|
|||||||
|
|
||||||
# if !ENABLE_FEATURE_TAR_GNU_EXTENSIONS
|
# if !ENABLE_FEATURE_TAR_GNU_EXTENSIONS
|
||||||
if (strlen(header_name) >= NAME_SIZE) {
|
if (strlen(header_name) >= NAME_SIZE) {
|
||||||
bb_error_msg("names longer than "NAME_SIZE_STR" chars not supported");
|
bb_simple_error_msg("names longer than "NAME_SIZE_STR" chars not supported");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
@ -715,13 +715,13 @@ static NOINLINE int writeTarFile(
|
|||||||
freeHardLinkInfo(&tbInfo->hlInfoHead);
|
freeHardLinkInfo(&tbInfo->hlInfoHead);
|
||||||
|
|
||||||
if (errorFlag)
|
if (errorFlag)
|
||||||
bb_error_msg("error exit delayed from previous errors");
|
bb_simple_error_msg("error exit delayed from previous errors");
|
||||||
|
|
||||||
# if SEAMLESS_COMPRESSION
|
# if SEAMLESS_COMPRESSION
|
||||||
if (gzip) {
|
if (gzip) {
|
||||||
int status;
|
int status;
|
||||||
if (safe_waitpid(-1, &status, 0) == -1)
|
if (safe_waitpid(-1, &status, 0) == -1)
|
||||||
bb_perror_msg("waitpid");
|
bb_simple_perror_msg("waitpid");
|
||||||
else if (!WIFEXITED(status) || WEXITSTATUS(status))
|
else if (!WIFEXITED(status) || WEXITSTATUS(status))
|
||||||
/* gzip was killed or has exited with nonzero! */
|
/* gzip was killed or has exited with nonzero! */
|
||||||
errorFlag = TRUE;
|
errorFlag = TRUE;
|
||||||
@ -1150,7 +1150,7 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
if (opt & OPT_CREATE) {
|
if (opt & OPT_CREATE) {
|
||||||
/* Make sure there is at least one file to tar up */
|
/* Make sure there is at least one file to tar up */
|
||||||
if (tar_handle->accept == NULL)
|
if (tar_handle->accept == NULL)
|
||||||
bb_error_msg_and_die("empty archive");
|
bb_simple_error_msg_and_die("empty archive");
|
||||||
|
|
||||||
tar_fd = STDOUT_FILENO;
|
tar_fd = STDOUT_FILENO;
|
||||||
/* Mimicking GNU tar 1.15.1: */
|
/* Mimicking GNU tar 1.15.1: */
|
||||||
|
@ -322,7 +322,7 @@ static uint32_t read_next_cdf(uint32_t cdf_offset, cdf_header_t *cdf)
|
|||||||
static void die_if_bad_fnamesize(unsigned sz)
|
static void die_if_bad_fnamesize(unsigned sz)
|
||||||
{
|
{
|
||||||
if (sz > 0xfff) /* more than 4k?! no funny business please */
|
if (sz > 0xfff) /* more than 4k?! no funny business please */
|
||||||
bb_error_msg_and_die("bad archive");
|
bb_simple_error_msg_and_die("bad archive");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void unzip_skip(off_t skip)
|
static void unzip_skip(off_t skip)
|
||||||
@ -359,7 +359,7 @@ static void unzip_extract_symlink(llist_t **symlink_placeholders,
|
|||||||
xread(zip_fd, target, zip->fmt.ucmpsize);
|
xread(zip_fd, target, zip->fmt.ucmpsize);
|
||||||
} else {
|
} else {
|
||||||
#if 1
|
#if 1
|
||||||
bb_error_msg_and_die("compressed symlink is not supported");
|
bb_simple_error_msg_and_die("compressed symlink is not supported");
|
||||||
#else
|
#else
|
||||||
transformer_state_t xstate;
|
transformer_state_t xstate;
|
||||||
init_transformer_state(&xstate);
|
init_transformer_state(&xstate);
|
||||||
@ -399,10 +399,10 @@ static void unzip_extract(zip_header_t *zip, int dst_fd)
|
|||||||
if (zip->fmt.method == 8) {
|
if (zip->fmt.method == 8) {
|
||||||
/* Method 8 - inflate */
|
/* Method 8 - inflate */
|
||||||
if (inflate_unzip(&xstate) < 0)
|
if (inflate_unzip(&xstate) < 0)
|
||||||
bb_error_msg_and_die("inflate error");
|
bb_simple_error_msg_and_die("inflate error");
|
||||||
/* Validate decompression - crc */
|
/* Validate decompression - crc */
|
||||||
if (zip->fmt.crc32 != (xstate.crc32 ^ 0xffffffffL)) {
|
if (zip->fmt.crc32 != (xstate.crc32 ^ 0xffffffffL)) {
|
||||||
bb_error_msg_and_die("crc error");
|
bb_simple_error_msg_and_die("crc error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if ENABLE_FEATURE_UNZIP_BZIP2
|
#if ENABLE_FEATURE_UNZIP_BZIP2
|
||||||
@ -412,7 +412,7 @@ static void unzip_extract(zip_header_t *zip, int dst_fd)
|
|||||||
*/
|
*/
|
||||||
xstate.bytes_out = unpack_bz2_stream(&xstate);
|
xstate.bytes_out = unpack_bz2_stream(&xstate);
|
||||||
if (xstate.bytes_out < 0)
|
if (xstate.bytes_out < 0)
|
||||||
bb_error_msg_and_die("inflate error");
|
bb_simple_error_msg_and_die("inflate error");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if ENABLE_FEATURE_UNZIP_LZMA
|
#if ENABLE_FEATURE_UNZIP_LZMA
|
||||||
@ -420,7 +420,7 @@ static void unzip_extract(zip_header_t *zip, int dst_fd)
|
|||||||
/* Not tested yet */
|
/* Not tested yet */
|
||||||
xstate.bytes_out = unpack_lzma_stream(&xstate);
|
xstate.bytes_out = unpack_lzma_stream(&xstate);
|
||||||
if (xstate.bytes_out < 0)
|
if (xstate.bytes_out < 0)
|
||||||
bb_error_msg_and_die("inflate error");
|
bb_simple_error_msg_and_die("inflate error");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if ENABLE_FEATURE_UNZIP_XZ
|
#if ENABLE_FEATURE_UNZIP_XZ
|
||||||
@ -428,7 +428,7 @@ static void unzip_extract(zip_header_t *zip, int dst_fd)
|
|||||||
/* Not tested yet */
|
/* Not tested yet */
|
||||||
xstate.bytes_out = unpack_xz_stream(&xstate);
|
xstate.bytes_out = unpack_xz_stream(&xstate);
|
||||||
if (xstate.bytes_out < 0)
|
if (xstate.bytes_out < 0)
|
||||||
bb_error_msg_and_die("inflate error");
|
bb_simple_error_msg_and_die("inflate error");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else {
|
else {
|
||||||
@ -439,7 +439,7 @@ static void unzip_extract(zip_header_t *zip, int dst_fd)
|
|||||||
if (zip->fmt.ucmpsize != xstate.bytes_out) {
|
if (zip->fmt.ucmpsize != xstate.bytes_out) {
|
||||||
/* Don't die. Who knows, maybe len calculation
|
/* Don't die. Who knows, maybe len calculation
|
||||||
* was botched somewhere. After all, crc matched! */
|
* was botched somewhere. After all, crc matched! */
|
||||||
bb_error_msg("bad length");
|
bb_simple_error_msg("bad length");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,7 +447,7 @@ static void my_fgets80(char *buf80)
|
|||||||
{
|
{
|
||||||
fflush_all();
|
fflush_all();
|
||||||
if (!fgets(buf80, 80, stdin)) {
|
if (!fgets(buf80, 80, stdin)) {
|
||||||
bb_perror_msg_and_die("can't read standard input");
|
bb_simple_perror_msg_and_die("can't read standard input");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ static void do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize,
|
|||||||
if (unicode == PSF2_SEPARATOR) {
|
if (unicode == PSF2_SEPARATOR) {
|
||||||
break;
|
break;
|
||||||
} else if (unicode == PSF2_STARTSEQ) {
|
} else if (unicode == PSF2_STARTSEQ) {
|
||||||
bb_error_msg_and_die("unicode sequences not implemented");
|
bb_simple_error_msg_and_die("unicode sequences not implemented");
|
||||||
} else if (unicode >= 0xC0) {
|
} else if (unicode >= 0xC0) {
|
||||||
if (unicode >= 0xFC)
|
if (unicode >= 0xFC)
|
||||||
unicode &= 0x01, maxct = 5;
|
unicode &= 0x01, maxct = 5;
|
||||||
@ -239,12 +239,12 @@ static void do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize,
|
|||||||
unicode &= 0x1F, maxct = 1;
|
unicode &= 0x1F, maxct = 1;
|
||||||
do {
|
do {
|
||||||
if (tailsz <= 0 || *inbuf < 0x80 || *inbuf > 0xBF)
|
if (tailsz <= 0 || *inbuf < 0x80 || *inbuf > 0xBF)
|
||||||
bb_error_msg_and_die("illegal UTF-8 character");
|
bb_simple_error_msg_and_die("illegal UTF-8 character");
|
||||||
--tailsz;
|
--tailsz;
|
||||||
unicode = (unicode << 6) + (*inbuf++ & 0x3F);
|
unicode = (unicode << 6) + (*inbuf++ & 0x3F);
|
||||||
} while (--maxct > 0);
|
} while (--maxct > 0);
|
||||||
} else if (unicode >= 0x80) {
|
} else if (unicode >= 0x80) {
|
||||||
bb_error_msg_and_die("illegal UTF-8 character");
|
bb_simple_error_msg_and_die("illegal UTF-8 character");
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
return;
|
return;
|
||||||
@ -281,7 +281,7 @@ static void do_load(int fd, unsigned char *buffer, size_t len)
|
|||||||
|
|
||||||
if (len >= sizeof(struct psf1_header) && PSF1_MAGIC_OK(psf1h(buffer))) {
|
if (len >= sizeof(struct psf1_header) && PSF1_MAGIC_OK(psf1h(buffer))) {
|
||||||
if (psf1h(buffer)->mode > PSF1_MAXMODE)
|
if (psf1h(buffer)->mode > PSF1_MAXMODE)
|
||||||
bb_error_msg_and_die("unsupported psf file mode");
|
bb_simple_error_msg_and_die("unsupported psf file mode");
|
||||||
if (psf1h(buffer)->mode & PSF1_MODE512)
|
if (psf1h(buffer)->mode & PSF1_MODE512)
|
||||||
fontsize = 512;
|
fontsize = 512;
|
||||||
if (psf1h(buffer)->mode & PSF1_MODEHASTAB)
|
if (psf1h(buffer)->mode & PSF1_MODEHASTAB)
|
||||||
@ -292,7 +292,7 @@ static void do_load(int fd, unsigned char *buffer, size_t len)
|
|||||||
#if ENABLE_FEATURE_LOADFONT_PSF2
|
#if ENABLE_FEATURE_LOADFONT_PSF2
|
||||||
if (len >= sizeof(struct psf2_header) && PSF2_MAGIC_OK(psf2h(buffer))) {
|
if (len >= sizeof(struct psf2_header) && PSF2_MAGIC_OK(psf2h(buffer))) {
|
||||||
if (psf2h(buffer)->version > PSF2_MAXVERSION)
|
if (psf2h(buffer)->version > PSF2_MAXVERSION)
|
||||||
bb_error_msg_and_die("unsupported psf file version");
|
bb_simple_error_msg_and_die("unsupported psf file version");
|
||||||
fontsize = psf2h(buffer)->length;
|
fontsize = psf2h(buffer)->length;
|
||||||
if (psf2h(buffer)->flags & PSF2_HAS_UNICODE_TABLE)
|
if (psf2h(buffer)->flags & PSF2_HAS_UNICODE_TABLE)
|
||||||
has_table = 2;
|
has_table = 2;
|
||||||
@ -311,19 +311,19 @@ static void do_load(int fd, unsigned char *buffer, size_t len)
|
|||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
bb_error_msg_and_die("input file: bad length or unsupported font type");
|
bb_simple_error_msg_and_die("input file: bad length or unsupported font type");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(PIO_FONTX) || defined(__sparc__)
|
#if !defined(PIO_FONTX) || defined(__sparc__)
|
||||||
if (fontsize != 256)
|
if (fontsize != 256)
|
||||||
bb_error_msg_and_die("only fontsize 256 supported");
|
bb_simple_error_msg_and_die("only fontsize 256 supported");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
table = font + fontsize * charsize;
|
table = font + fontsize * charsize;
|
||||||
buffer += len;
|
buffer += len;
|
||||||
|
|
||||||
if (table > buffer || (!has_table && table != buffer))
|
if (table > buffer || (!has_table && table != buffer))
|
||||||
bb_error_msg_and_die("input file: bad length");
|
bb_simple_error_msg_and_die("input file: bad length");
|
||||||
|
|
||||||
do_loadfont(fd, font, height, width, charsize, fontsize);
|
do_loadfont(fd, font, height, width, charsize, fontsize);
|
||||||
|
|
||||||
@ -361,7 +361,7 @@ int loadfont_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
buffer = xmalloc_read(STDIN_FILENO, &len);
|
buffer = xmalloc_read(STDIN_FILENO, &len);
|
||||||
// xmalloc_open_zipped_read_close(filename, &len);
|
// xmalloc_open_zipped_read_close(filename, &len);
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
bb_perror_msg_and_die("error reading input font");
|
bb_simple_perror_msg_and_die("error reading input font");
|
||||||
do_load(get_console_fd_or_die(), buffer, len);
|
do_load(get_console_fd_or_die(), buffer, len);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
@ -502,7 +502,7 @@ int setfont_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
if (a < 0 || a >= E_TABSZ
|
if (a < 0 || a >= E_TABSZ
|
||||||
|| b < 0 || b > 65535
|
|| b < 0 || b > 65535
|
||||||
) {
|
) {
|
||||||
bb_error_msg_and_die("map format");
|
bb_simple_error_msg_and_die("map format");
|
||||||
}
|
}
|
||||||
// patch map
|
// patch map
|
||||||
unicodes[a] = b;
|
unicodes[a] = b;
|
||||||
|
@ -69,7 +69,7 @@ int loadkmap_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
|
|
||||||
xread(STDIN_FILENO, flags, 7);
|
xread(STDIN_FILENO, flags, 7);
|
||||||
if (!is_prefixed_with(flags, BINARY_KEYMAP_MAGIC))
|
if (!is_prefixed_with(flags, BINARY_KEYMAP_MAGIC))
|
||||||
bb_error_msg_and_die("not a valid binary keymap");
|
bb_simple_error_msg_and_die("not a valid binary keymap");
|
||||||
|
|
||||||
xread(STDIN_FILENO, flags, MAX_NR_KEYMAPS);
|
xread(STDIN_FILENO, flags, MAX_NR_KEYMAPS);
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ static int get_vt_fd(void)
|
|||||||
fd = open(DEV_CONSOLE, O_RDONLY | O_NONBLOCK);
|
fd = open(DEV_CONSOLE, O_RDONLY | O_NONBLOCK);
|
||||||
if (fd >= 0 && !not_vt_fd(fd))
|
if (fd >= 0 && !not_vt_fd(fd))
|
||||||
return fd;
|
return fd;
|
||||||
bb_error_msg_and_die("can't find open VT");
|
bb_simple_error_msg_and_die("can't find open VT");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int find_free_vtno(void)
|
static int find_free_vtno(void)
|
||||||
@ -98,7 +98,7 @@ static int find_free_vtno(void)
|
|||||||
errno = 0;
|
errno = 0;
|
||||||
/*xfunc_error_retval = 3; - do we need compat? */
|
/*xfunc_error_retval = 3; - do we need compat? */
|
||||||
if (ioctl(fd, VT_OPENQRY, &vtno) != 0 || vtno <= 0)
|
if (ioctl(fd, VT_OPENQRY, &vtno) != 0 || vtno <= 0)
|
||||||
bb_perror_msg_and_die("can't find open VT");
|
bb_simple_perror_msg_and_die("can't find open VT");
|
||||||
// Not really needed, grep for DAEMON_CLOSE_EXTRA_FDS
|
// Not really needed, grep for DAEMON_CLOSE_EXTRA_FDS
|
||||||
// if (fd > 2)
|
// if (fd > 2)
|
||||||
// close(fd);
|
// close(fd);
|
||||||
|
@ -56,7 +56,7 @@ static void xset1(struct termios *t)
|
|||||||
{
|
{
|
||||||
int ret = tcsetattr(STDIN_FILENO, TCSAFLUSH, t);
|
int ret = tcsetattr(STDIN_FILENO, TCSAFLUSH, t);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
bb_perror_msg("can't tcsetattr for stdin");
|
bb_simple_perror_msg("can't tcsetattr for stdin");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ int cp_main(int argc, char **argv)
|
|||||||
// flags, FILEUTILS_RMDEST, OPT_parents);
|
// flags, FILEUTILS_RMDEST, OPT_parents);
|
||||||
if (flags & OPT_parents) {
|
if (flags & OPT_parents) {
|
||||||
if (!(d_flags & 2)) {
|
if (!(d_flags & 2)) {
|
||||||
bb_error_msg_and_die("with --parents, the destination must be a directory");
|
bb_simple_error_msg_and_die("with --parents, the destination must be a directory");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (flags & FILEUTILS_RMDEST) {
|
if (flags & FILEUTILS_RMDEST) {
|
||||||
@ -236,7 +236,7 @@ int cp_main(int argc, char **argv)
|
|||||||
goto DO_COPY; /* NB: argc==2 -> *++argv==last */
|
goto DO_COPY; /* NB: argc==2 -> *++argv==last */
|
||||||
}
|
}
|
||||||
} else if (flags & FILEUTILS_NO_TARGET_DIR) {
|
} else if (flags & FILEUTILS_NO_TARGET_DIR) {
|
||||||
bb_error_msg_and_die("too many arguments");
|
bb_simple_error_msg_and_die("too many arguments");
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -209,11 +209,11 @@ int cut_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
// argc -= optind;
|
// argc -= optind;
|
||||||
argv += optind;
|
argv += optind;
|
||||||
if (!(opt & (CUT_OPT_BYTE_FLGS | CUT_OPT_CHAR_FLGS | CUT_OPT_FIELDS_FLGS)))
|
if (!(opt & (CUT_OPT_BYTE_FLGS | CUT_OPT_CHAR_FLGS | CUT_OPT_FIELDS_FLGS)))
|
||||||
bb_error_msg_and_die("expected a list of bytes, characters, or fields");
|
bb_simple_error_msg_and_die("expected a list of bytes, characters, or fields");
|
||||||
|
|
||||||
if (opt & CUT_OPT_DELIM_FLGS) {
|
if (opt & CUT_OPT_DELIM_FLGS) {
|
||||||
if (ltok[0] && ltok[1]) { /* more than 1 char? */
|
if (ltok[0] && ltok[1]) { /* more than 1 char? */
|
||||||
bb_error_msg_and_die("the delimiter must be a single character");
|
bb_simple_error_msg_and_die("the delimiter must be a single character");
|
||||||
}
|
}
|
||||||
delim = ltok[0];
|
delim = ltok[0];
|
||||||
}
|
}
|
||||||
@ -288,7 +288,7 @@ int cut_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
|
|
||||||
/* make sure we got some cut positions out of all that */
|
/* make sure we got some cut positions out of all that */
|
||||||
if (nlists == 0)
|
if (nlists == 0)
|
||||||
bb_error_msg_and_die("missing list of positions");
|
bb_simple_error_msg_and_die("missing list of positions");
|
||||||
|
|
||||||
/* now that the lists are parsed, we need to sort them to make life
|
/* now that the lists are parsed, we need to sort them to make life
|
||||||
* easier on us when it comes time to print the chars / fields / lines
|
* easier on us when it comes time to print the chars / fields / lines
|
||||||
|
@ -304,7 +304,7 @@ int date_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
|
|
||||||
/* if setting time, set it */
|
/* if setting time, set it */
|
||||||
if ((opt & OPT_SET) && stime(&ts.tv_sec) < 0) {
|
if ((opt & OPT_SET) && stime(&ts.tv_sec) < 0) {
|
||||||
bb_perror_msg("can't set date");
|
bb_simple_perror_msg("can't set date");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ int df_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
if (!argv[0]) {
|
if (!argv[0]) {
|
||||||
mount_table = setmntent(bb_path_mtab_file, "r");
|
mount_table = setmntent(bb_path_mtab_file, "r");
|
||||||
if (!mount_table)
|
if (!mount_table)
|
||||||
bb_perror_msg_and_die(bb_path_mtab_file);
|
bb_simple_perror_msg_and_die(bb_path_mtab_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -188,7 +188,7 @@ int echo_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
/*r =*/ full_write(STDOUT_FILENO, buffer, out - buffer);
|
/*r =*/ full_write(STDOUT_FILENO, buffer, out - buffer);
|
||||||
free(buffer);
|
free(buffer);
|
||||||
if (/*WRONG:r < 0*/ errno) {
|
if (/*WRONG:r < 0*/ errno) {
|
||||||
bb_perror_msg(bb_msg_write_error);
|
bb_simple_perror_msg(bb_msg_write_error);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -79,7 +79,7 @@ int env_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
|
|
||||||
while (*argv && (strchr(*argv, '=') != NULL)) {
|
while (*argv && (strchr(*argv, '=') != NULL)) {
|
||||||
if (putenv(*argv) < 0) {
|
if (putenv(*argv) < 0) {
|
||||||
bb_perror_msg_and_die("putenv");
|
bb_simple_perror_msg_and_die("putenv");
|
||||||
}
|
}
|
||||||
++argv;
|
++argv;
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ int expand_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
/* Now close stdin also */
|
/* Now close stdin also */
|
||||||
/* (if we didn't read from it, it's a no-op) */
|
/* (if we didn't read from it, it's a no-op) */
|
||||||
if (fclose(stdin))
|
if (fclose(stdin))
|
||||||
bb_perror_msg_and_die(bb_msg_standard_input);
|
bb_simple_perror_msg_and_die(bb_msg_standard_input);
|
||||||
|
|
||||||
fflush_stdout_and_exit(exit_status);
|
fflush_stdout_and_exit(exit_status);
|
||||||
}
|
}
|
||||||
|
@ -249,7 +249,7 @@ static arith_t arithmetic_common(VALUE *l, VALUE *r, int op)
|
|||||||
arith_t li, ri;
|
arith_t li, ri;
|
||||||
|
|
||||||
if (!toarith(l) || !toarith(r))
|
if (!toarith(l) || !toarith(r))
|
||||||
bb_error_msg_and_die("non-numeric argument");
|
bb_simple_error_msg_and_die("non-numeric argument");
|
||||||
li = l->u.i;
|
li = l->u.i;
|
||||||
ri = r->u.i;
|
ri = r->u.i;
|
||||||
if (op == '+')
|
if (op == '+')
|
||||||
@ -259,7 +259,7 @@ static arith_t arithmetic_common(VALUE *l, VALUE *r, int op)
|
|||||||
if (op == '*')
|
if (op == '*')
|
||||||
return li * ri;
|
return li * ri;
|
||||||
if (ri == 0)
|
if (ri == 0)
|
||||||
bb_error_msg_and_die("division by zero");
|
bb_simple_error_msg_and_die("division by zero");
|
||||||
if (op == '/')
|
if (op == '/')
|
||||||
return li / ri;
|
return li / ri;
|
||||||
return li % ri;
|
return li % ri;
|
||||||
@ -319,19 +319,19 @@ static VALUE *eval7(void)
|
|||||||
VALUE *v;
|
VALUE *v;
|
||||||
|
|
||||||
if (!*G.args)
|
if (!*G.args)
|
||||||
bb_error_msg_and_die("syntax error");
|
bb_simple_error_msg_and_die("syntax error");
|
||||||
|
|
||||||
if (nextarg("(")) {
|
if (nextarg("(")) {
|
||||||
G.args++;
|
G.args++;
|
||||||
v = eval();
|
v = eval();
|
||||||
if (!nextarg(")"))
|
if (!nextarg(")"))
|
||||||
bb_error_msg_and_die("syntax error");
|
bb_simple_error_msg_and_die("syntax error");
|
||||||
G.args++;
|
G.args++;
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextarg(")"))
|
if (nextarg(")"))
|
||||||
bb_error_msg_and_die("syntax error");
|
bb_simple_error_msg_and_die("syntax error");
|
||||||
|
|
||||||
return str_value(*G.args++);
|
return str_value(*G.args++);
|
||||||
}
|
}
|
||||||
@ -353,7 +353,7 @@ static VALUE *eval6(void)
|
|||||||
G.args++; /* We have a valid token, so get the next argument. */
|
G.args++; /* We have a valid token, so get the next argument. */
|
||||||
if (key == 1) { /* quote */
|
if (key == 1) { /* quote */
|
||||||
if (!*G.args)
|
if (!*G.args)
|
||||||
bb_error_msg_and_die("syntax error");
|
bb_simple_error_msg_and_die("syntax error");
|
||||||
return str_value(*G.args++);
|
return str_value(*G.args++);
|
||||||
}
|
}
|
||||||
if (key == 2) { /* length */
|
if (key == 2) { /* length */
|
||||||
@ -546,11 +546,11 @@ int expr_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
xfunc_error_retval = 2; /* coreutils compat */
|
xfunc_error_retval = 2; /* coreutils compat */
|
||||||
G.args = argv + 1;
|
G.args = argv + 1;
|
||||||
if (*G.args == NULL) {
|
if (*G.args == NULL) {
|
||||||
bb_error_msg_and_die("too few arguments");
|
bb_simple_error_msg_and_die("too few arguments");
|
||||||
}
|
}
|
||||||
v = eval();
|
v = eval();
|
||||||
if (*G.args)
|
if (*G.args)
|
||||||
bb_error_msg_and_die("syntax error");
|
bb_simple_error_msg_and_die("syntax error");
|
||||||
if (v->type == INTEGER)
|
if (v->type == INTEGER)
|
||||||
printf("%" PF_REZ "d\n", PF_REZ_TYPE v->u.i);
|
printf("%" PF_REZ "d\n", PF_REZ_TYPE v->u.i);
|
||||||
else
|
else
|
||||||
|
@ -231,7 +231,7 @@ int id_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
}
|
}
|
||||||
} else if (n < 0) { /* error in get_groups() */
|
} else if (n < 0) { /* error in get_groups() */
|
||||||
if (ENABLE_DESKTOP)
|
if (ENABLE_DESKTOP)
|
||||||
bb_error_msg_and_die("can't get groups");
|
bb_simple_error_msg_and_die("can't get groups");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
if (ENABLE_FEATURE_CLEAN_UP)
|
if (ENABLE_FEATURE_CLEAN_UP)
|
||||||
|
@ -238,7 +238,7 @@ int install_main(int argc, char **argv)
|
|||||||
args[2] = dest;
|
args[2] = dest;
|
||||||
args[3] = NULL;
|
args[3] = NULL;
|
||||||
if (spawn_and_wait(args)) {
|
if (spawn_and_wait(args)) {
|
||||||
bb_perror_msg("strip");
|
bb_simple_perror_msg("strip");
|
||||||
ret = EXIT_FAILURE;
|
ret = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ int ln_main(int argc, char **argv)
|
|||||||
argc -= optind;
|
argc -= optind;
|
||||||
|
|
||||||
if ((opts & LN_LINKFILE) && argc > 2) {
|
if ((opts & LN_LINKFILE) && argc > 2) {
|
||||||
bb_error_msg_and_die("-T accepts 2 args max");
|
bb_simple_error_msg_and_die("-T accepts 2 args max");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!argv[1]) {
|
if (!argv[1]) {
|
||||||
|
@ -56,5 +56,5 @@ int logname_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
|||||||
return fflush_all();
|
return fflush_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
bb_perror_msg_and_die("getlogin");
|
bb_simple_perror_msg_and_die("getlogin");
|
||||||
}
|
}
|
||||||
|
@ -300,7 +300,7 @@ int md5_sha1_sum_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
}
|
}
|
||||||
if (filename_ptr == NULL) {
|
if (filename_ptr == NULL) {
|
||||||
if (flags & FLAG_WARN) {
|
if (flags & FLAG_WARN) {
|
||||||
bb_error_msg("invalid format");
|
bb_simple_error_msg("invalid format");
|
||||||
}
|
}
|
||||||
count_failed++;
|
count_failed++;
|
||||||
return_value = EXIT_FAILURE;
|
return_value = EXIT_FAILURE;
|
||||||
|
@ -536,7 +536,7 @@ check_and_close(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ferror(stdout)) {
|
if (ferror(stdout)) {
|
||||||
bb_error_msg_and_die(bb_msg_write_error);
|
bb_simple_error_msg_and_die(bb_msg_write_error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -841,7 +841,7 @@ skip(off_t n_skip)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (n_skip)
|
if (n_skip)
|
||||||
bb_error_msg_and_die("can't skip past end of combined input");
|
bb_simple_error_msg_and_die("can't skip past end of combined input");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1308,10 +1308,10 @@ int od_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
pseudo_start = o2;
|
pseudo_start = o2;
|
||||||
argv[1] = NULL;
|
argv[1] = NULL;
|
||||||
} else {
|
} else {
|
||||||
bb_error_msg_and_die("the last two arguments must be offsets");
|
bb_simple_error_msg_and_die("the last two arguments must be offsets");
|
||||||
}
|
}
|
||||||
} else { /* >3 args */
|
} else { /* >3 args */
|
||||||
bb_error_msg_and_die("too many arguments");
|
bb_simple_error_msg_and_die("too many arguments");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pseudo_start >= 0) {
|
if (pseudo_start >= 0) {
|
||||||
@ -1332,7 +1332,7 @@ int od_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
if (option_mask32 & OPT_N) {
|
if (option_mask32 & OPT_N) {
|
||||||
end_offset = n_bytes_to_skip + max_bytes_to_format;
|
end_offset = n_bytes_to_skip + max_bytes_to_format;
|
||||||
if (end_offset < n_bytes_to_skip)
|
if (end_offset < n_bytes_to_skip)
|
||||||
bb_error_msg_and_die("SKIP + SIZE is too large");
|
bb_simple_error_msg_and_die("SKIP + SIZE is too large");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (G.n_specs == 0) {
|
if (G.n_specs == 0) {
|
||||||
@ -1389,7 +1389,7 @@ int od_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
dump(n_bytes_to_skip, end_offset);
|
dump(n_bytes_to_skip, end_offset);
|
||||||
|
|
||||||
if (fclose(stdin))
|
if (fclose(stdin))
|
||||||
bb_perror_msg_and_die(bb_msg_standard_input);
|
bb_simple_perror_msg_and_die(bb_msg_standard_input);
|
||||||
|
|
||||||
return G.exit_code;
|
return G.exit_code;
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ int paste_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
|
|
||||||
if (opt & PASTE_OPT_DELIMITERS) {
|
if (opt & PASTE_OPT_DELIMITERS) {
|
||||||
if (!delims[0])
|
if (!delims[0])
|
||||||
bb_error_msg_and_die("-d '' is not supported");
|
bb_simple_error_msg_and_die("-d '' is not supported");
|
||||||
/* unknown mappings are not changed: "\z" -> '\\' 'z' */
|
/* unknown mappings are not changed: "\z" -> '\\' 'z' */
|
||||||
/* trailing backslash, if any, is preserved */
|
/* trailing backslash, if any, is preserved */
|
||||||
del_cnt = strcpy_and_process_escape_sequences(delims, delims) - delims;
|
del_cnt = strcpy_and_process_escape_sequences(delims, delims) - delims;
|
||||||
|
@ -430,7 +430,7 @@ int printf_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
if (ENABLE_ASH_PRINTF
|
if (ENABLE_ASH_PRINTF
|
||||||
&& applet_name[0] != 'p'
|
&& applet_name[0] != 'p'
|
||||||
) {
|
) {
|
||||||
bb_error_msg("usage: printf FORMAT [ARGUMENT...]");
|
bb_simple_error_msg("usage: printf FORMAT [ARGUMENT...]");
|
||||||
return 2; /* bash compat */
|
return 2; /* bash compat */
|
||||||
}
|
}
|
||||||
bb_show_usage();
|
bb_show_usage();
|
||||||
|
@ -62,7 +62,7 @@ int rm_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
const char *base = bb_get_last_path_component_strip(*argv);
|
const char *base = bb_get_last_path_component_strip(*argv);
|
||||||
|
|
||||||
if (DOT_OR_DOTDOT(base)) {
|
if (DOT_OR_DOTDOT(base)) {
|
||||||
bb_error_msg("can't remove '.' or '..'");
|
bb_simple_error_msg("can't remove '.' or '..'");
|
||||||
} else if (remove_file(*argv, flags) >= 0) {
|
} else if (remove_file(*argv, flags) >= 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -277,7 +277,7 @@ static int compare_keys(const void *xarg, const void *yarg)
|
|||||||
/* Perform actual comparison */
|
/* Perform actual comparison */
|
||||||
switch (flags & (FLAG_n | FLAG_g | FLAG_M | FLAG_V)) {
|
switch (flags & (FLAG_n | FLAG_g | FLAG_M | FLAG_V)) {
|
||||||
default:
|
default:
|
||||||
bb_error_msg_and_die("unknown sort type");
|
bb_simple_error_msg_and_die("unknown sort type");
|
||||||
break;
|
break;
|
||||||
#if defined(HAVE_STRVERSCMP) && HAVE_STRVERSCMP == 1
|
#if defined(HAVE_STRVERSCMP) && HAVE_STRVERSCMP == 1
|
||||||
case FLAG_V:
|
case FLAG_V:
|
||||||
@ -398,10 +398,10 @@ static unsigned str2u(char **str)
|
|||||||
{
|
{
|
||||||
unsigned long lu;
|
unsigned long lu;
|
||||||
if (!isdigit((*str)[0]))
|
if (!isdigit((*str)[0]))
|
||||||
bb_error_msg_and_die("bad field specification");
|
bb_simple_error_msg_and_die("bad field specification");
|
||||||
lu = strtoul(*str, str, 10);
|
lu = strtoul(*str, str, 10);
|
||||||
if ((sizeof(long) > sizeof(int) && lu > INT_MAX) || !lu)
|
if ((sizeof(long) > sizeof(int) && lu > INT_MAX) || !lu)
|
||||||
bb_error_msg_and_die("bad field specification");
|
bb_simple_error_msg_and_die("bad field specification");
|
||||||
return lu;
|
return lu;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -461,7 +461,7 @@ int sort_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
#if ENABLE_FEATURE_SORT_BIG
|
#if ENABLE_FEATURE_SORT_BIG
|
||||||
if (opts & FLAG_t) {
|
if (opts & FLAG_t) {
|
||||||
if (!str_t[0] || str_t[1])
|
if (!str_t[0] || str_t[1])
|
||||||
bb_error_msg_and_die("bad -t parameter");
|
bb_simple_error_msg_and_die("bad -t parameter");
|
||||||
key_separator = str_t[0];
|
key_separator = str_t[0];
|
||||||
}
|
}
|
||||||
/* note: below this point we use option_mask32, not opts,
|
/* note: below this point we use option_mask32, not opts,
|
||||||
@ -504,10 +504,10 @@ int sort_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
because comma isn't in OPT_STR */
|
because comma isn't in OPT_STR */
|
||||||
idx = strchr(OPT_STR, *str_k);
|
idx = strchr(OPT_STR, *str_k);
|
||||||
if (!idx)
|
if (!idx)
|
||||||
bb_error_msg_and_die("unknown key option");
|
bb_simple_error_msg_and_die("unknown key option");
|
||||||
flag = 1 << (idx - OPT_STR);
|
flag = 1 << (idx - OPT_STR);
|
||||||
if (flag & ~FLAG_allowed_for_k)
|
if (flag & ~FLAG_allowed_for_k)
|
||||||
bb_error_msg_and_die("unknown sort type");
|
bb_simple_error_msg_and_die("unknown sort type");
|
||||||
/* b after ',' means strip _trailing_ space */
|
/* b after ',' means strip _trailing_ space */
|
||||||
if (i && flag == FLAG_b)
|
if (i && flag == FLAG_b)
|
||||||
flag = FLAG_bb;
|
flag = FLAG_bb;
|
||||||
|
@ -127,7 +127,7 @@ int split_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (NAME_MAX < strlen(sfx) + suffix_len)
|
if (NAME_MAX < strlen(sfx) + suffix_len)
|
||||||
bb_error_msg_and_die("suffix too long");
|
bb_simple_error_msg_and_die("suffix too long");
|
||||||
|
|
||||||
{
|
{
|
||||||
char *char_p = xzalloc(suffix_len + 1);
|
char *char_p = xzalloc(suffix_len + 1);
|
||||||
@ -147,7 +147,7 @@ int split_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
do {
|
do {
|
||||||
if (!remaining) {
|
if (!remaining) {
|
||||||
if (!pfx)
|
if (!pfx)
|
||||||
bb_error_msg_and_die("suffixes exhausted");
|
bb_simple_error_msg_and_die("suffixes exhausted");
|
||||||
xmove_fd(xopen(pfx, O_WRONLY | O_CREAT | O_TRUNC), 1);
|
xmove_fd(xopen(pfx, O_WRONLY | O_CREAT | O_TRUNC), 1);
|
||||||
pfx = next_file(pfx, suffix_len);
|
pfx = next_file(pfx, suffix_len);
|
||||||
remaining = cnt;
|
remaining = cnt;
|
||||||
|
@ -1320,7 +1320,7 @@ int stty_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
break;
|
break;
|
||||||
case 'F':
|
case 'F':
|
||||||
if (file_name)
|
if (file_name)
|
||||||
bb_error_msg_and_die("only one device may be specified");
|
bb_simple_error_msg_and_die("only one device may be specified");
|
||||||
file_name = &arg[i+1]; /* "-Fdevice" ? */
|
file_name = &arg[i+1]; /* "-Fdevice" ? */
|
||||||
if (!file_name[0]) { /* nope, "-F device" */
|
if (!file_name[0]) { /* nope, "-F device" */
|
||||||
int p = k+1; /* argv[p] is argnext */
|
int p = k+1; /* argv[p] is argnext */
|
||||||
@ -1405,13 +1405,13 @@ int stty_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
if ((stty_state & (STTY_verbose_output | STTY_recoverable_output)) ==
|
if ((stty_state & (STTY_verbose_output | STTY_recoverable_output)) ==
|
||||||
(STTY_verbose_output | STTY_recoverable_output)
|
(STTY_verbose_output | STTY_recoverable_output)
|
||||||
) {
|
) {
|
||||||
bb_error_msg_and_die("-a and -g are mutually exclusive");
|
bb_simple_error_msg_and_die("-a and -g are mutually exclusive");
|
||||||
}
|
}
|
||||||
/* Specifying -a or -g with non-options is an error */
|
/* Specifying -a or -g with non-options is an error */
|
||||||
if ((stty_state & (STTY_verbose_output | STTY_recoverable_output))
|
if ((stty_state & (STTY_verbose_output | STTY_recoverable_output))
|
||||||
&& !(stty_state & STTY_noargs)
|
&& !(stty_state & STTY_noargs)
|
||||||
) {
|
) {
|
||||||
bb_error_msg_and_die("modes may not be set when -a or -g is used");
|
bb_simple_error_msg_and_die("modes may not be set when -a or -g is used");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now it is safe to start doing things */
|
/* Now it is safe to start doing things */
|
||||||
|
@ -89,7 +89,7 @@ static ssize_t tail_read(int fd, char *buf, size_t count)
|
|||||||
|
|
||||||
r = full_read(fd, buf, count);
|
r = full_read(fd, buf, count);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
bb_perror_msg(bb_msg_read_error);
|
bb_simple_perror_msg(bb_msg_read_error);
|
||||||
G.exitcode = EXIT_FAILURE;
|
G.exitcode = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ int tail_main(int argc, char **argv)
|
|||||||
} while (++i < argc);
|
} while (++i < argc);
|
||||||
|
|
||||||
if (!nfiles)
|
if (!nfiles)
|
||||||
bb_error_msg_and_die("no files");
|
bb_simple_error_msg_and_die("no files");
|
||||||
|
|
||||||
/* prepare the buffer */
|
/* prepare the buffer */
|
||||||
tailbufsize = BUFSIZ;
|
tailbufsize = BUFSIZ;
|
||||||
|
@ -832,12 +832,12 @@ int test_main(int argc, char **argv)
|
|||||||
--argc;
|
--argc;
|
||||||
if (!arg0[1]) { /* "[" ? */
|
if (!arg0[1]) { /* "[" ? */
|
||||||
if (NOT_LONE_CHAR(argv[argc], ']')) {
|
if (NOT_LONE_CHAR(argv[argc], ']')) {
|
||||||
bb_error_msg("missing ]");
|
bb_simple_error_msg("missing ]");
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
} else { /* assuming "[[" */
|
} else { /* assuming "[[" */
|
||||||
if (strcmp(argv[argc], "]]") != 0) {
|
if (strcmp(argv[argc], "]]") != 0) {
|
||||||
bb_error_msg("missing ]]");
|
bb_simple_error_msg("missing ]]");
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -308,7 +308,7 @@ int tr_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
str1_length = complement(str1, str1_length);
|
str1_length = complement(str1, str1_length);
|
||||||
if (*argv) {
|
if (*argv) {
|
||||||
if (argv[0][0] == '\0')
|
if (argv[0][0] == '\0')
|
||||||
bb_error_msg_and_die("STRING2 cannot be empty");
|
bb_simple_error_msg_and_die("STRING2 cannot be empty");
|
||||||
str2_length = expand(*argv, &str2);
|
str2_length = expand(*argv, &str2);
|
||||||
map(vector, str1, str1_length,
|
map(vector, str1, str1_length,
|
||||||
str2, str2_length);
|
str2, str2_length);
|
||||||
@ -333,7 +333,7 @@ int tr_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
read_chars = safe_read(STDIN_FILENO, str1, TR_BUFSIZ);
|
read_chars = safe_read(STDIN_FILENO, str1, TR_BUFSIZ);
|
||||||
if (read_chars <= 0) {
|
if (read_chars <= 0) {
|
||||||
if (read_chars < 0)
|
if (read_chars < 0)
|
||||||
bb_perror_msg_and_die(bb_msg_read_error);
|
bb_simple_perror_msg_and_die(bb_msg_read_error);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
in_index = 0;
|
in_index = 0;
|
||||||
|
@ -82,7 +82,7 @@ static void FAST_FUNC read_stduu(FILE *src_stream, FILE *dst_stream, int flags U
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (encoded_len > 60) {
|
if (encoded_len > 60) {
|
||||||
bb_error_msg_and_die("line too long");
|
bb_simple_error_msg_and_die("line too long");
|
||||||
}
|
}
|
||||||
|
|
||||||
dst = line;
|
dst = line;
|
||||||
@ -108,7 +108,7 @@ static void FAST_FUNC read_stduu(FILE *src_stream, FILE *dst_stream, int flags U
|
|||||||
fwrite(line, 1, dst - line, dst_stream);
|
fwrite(line, 1, dst - line, dst_stream);
|
||||||
free(line);
|
free(line);
|
||||||
}
|
}
|
||||||
bb_error_msg_and_die("short file");
|
bb_simple_error_msg_and_die("short file");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ int uudecode_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
/* fclose_if_not_stdin(src_stream); - redundant */
|
/* fclose_if_not_stdin(src_stream); - redundant */
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
bb_error_msg_and_die("no 'begin' line");
|
bb_simple_error_msg_and_die("no 'begin' line");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -216,7 +216,7 @@ int base64_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
if (!size)
|
if (!size)
|
||||||
break;
|
break;
|
||||||
if ((ssize_t)size < 0)
|
if ((ssize_t)size < 0)
|
||||||
bb_perror_msg_and_die(bb_msg_read_error);
|
bb_simple_perror_msg_and_die(bb_msg_read_error);
|
||||||
/* Encode the buffer we just read in */
|
/* Encode the buffer we just read in */
|
||||||
bb_uuencode(dst_buf, src_buf, size, bb_uuenc_tbl_base64);
|
bb_uuencode(dst_buf, src_buf, size, bb_uuenc_tbl_base64);
|
||||||
xwrite(STDOUT_FILENO, dst_buf, 4 * ((size + 2) / 3));
|
xwrite(STDOUT_FILENO, dst_buf, 4 * ((size + 2) / 3));
|
||||||
|
@ -66,7 +66,7 @@ int uuencode_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
if (!size)
|
if (!size)
|
||||||
break;
|
break;
|
||||||
if ((ssize_t)size < 0)
|
if ((ssize_t)size < 0)
|
||||||
bb_perror_msg_and_die(bb_msg_read_error);
|
bb_simple_perror_msg_and_die(bb_msg_read_error);
|
||||||
/* Encode the buffer we just read in */
|
/* Encode the buffer we just read in */
|
||||||
bb_uuencode(dst_buf, src_buf, size, tbl);
|
bb_uuencode(dst_buf, src_buf, size, tbl);
|
||||||
bb_putchar('\n');
|
bb_putchar('\n');
|
||||||
|
@ -317,7 +317,7 @@ static void do_procinit(void)
|
|||||||
}
|
}
|
||||||
closedir(procdir);
|
closedir(procdir);
|
||||||
if (!pid)
|
if (!pid)
|
||||||
bb_error_msg_and_die("nothing in /proc - not mounted?");
|
bb_simple_error_msg_and_die("nothing in /proc - not mounted?");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_stop(void)
|
static int do_stop(void)
|
||||||
@ -337,7 +337,7 @@ static int do_stop(void)
|
|||||||
} else if (userspec) {
|
} else if (userspec) {
|
||||||
what = xasprintf("process(es) owned by '%s'", userspec);
|
what = xasprintf("process(es) owned by '%s'", userspec);
|
||||||
} else {
|
} else {
|
||||||
bb_error_msg_and_die("internal error, please report");
|
bb_simple_error_msg_and_die("internal error, please report");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!G.found_procs) {
|
if (!G.found_procs) {
|
||||||
|
@ -196,11 +196,11 @@ int chattr_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
|
|
||||||
/* run sanity checks on all the arguments given us */
|
/* run sanity checks on all the arguments given us */
|
||||||
if ((g.flags & OPT_SET) && (g.flags & (OPT_ADD|OPT_REM)))
|
if ((g.flags & OPT_SET) && (g.flags & (OPT_ADD|OPT_REM)))
|
||||||
bb_error_msg_and_die("= is incompatible with - and +");
|
bb_simple_error_msg_and_die("= is incompatible with - and +");
|
||||||
if (g.rf & g.af)
|
if (g.rf & g.af)
|
||||||
bb_error_msg_and_die("can't set and unset a flag");
|
bb_simple_error_msg_and_die("can't set and unset a flag");
|
||||||
if (!g.flags)
|
if (!g.flags)
|
||||||
bb_error_msg_and_die("must use '-v', =, - or +");
|
bb_simple_error_msg_and_die("must use '-v', =, - or +");
|
||||||
|
|
||||||
/* now run chattr on all the files passed to us */
|
/* now run chattr on all the files passed to us */
|
||||||
do change_attributes(*argv, &g); while (*++argv);
|
do change_attributes(*argv, &g); while (*++argv);
|
||||||
|
@ -431,10 +431,10 @@ static int wait_one(int flags)
|
|||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
continue;
|
continue;
|
||||||
if (errno == ECHILD) { /* paranoia */
|
if (errno == ECHILD) { /* paranoia */
|
||||||
bb_error_msg("wait: no more children");
|
bb_simple_error_msg("wait: no more children");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
bb_perror_msg("wait");
|
bb_simple_perror_msg("wait");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
prev = NULL;
|
prev = NULL;
|
||||||
@ -919,7 +919,7 @@ static void compile_fs_type(char *fs_type)
|
|||||||
if (G.fs_type_negated == -1)
|
if (G.fs_type_negated == -1)
|
||||||
G.fs_type_negated = negate;
|
G.fs_type_negated = negate;
|
||||||
if (G.fs_type_negated != negate)
|
if (G.fs_type_negated != negate)
|
||||||
bb_error_msg_and_die(
|
bb_simple_error_msg_and_die(
|
||||||
"either all or none of the filesystem types passed to -t must be prefixed "
|
"either all or none of the filesystem types passed to -t must be prefixed "
|
||||||
"with 'no' or '!'");
|
"with 'no' or '!'");
|
||||||
}
|
}
|
||||||
|
@ -2633,7 +2633,7 @@ static var *evaluate(node *op, var *res)
|
|||||||
if (opn == '|') {
|
if (opn == '|') {
|
||||||
rsm->F = popen(R.s, "w");
|
rsm->F = popen(R.s, "w");
|
||||||
if (rsm->F == NULL)
|
if (rsm->F == NULL)
|
||||||
bb_perror_msg_and_die("popen");
|
bb_simple_perror_msg_and_die("popen");
|
||||||
rsm->is_pipe = 1;
|
rsm->is_pipe = 1;
|
||||||
} else {
|
} else {
|
||||||
rsm->F = xfopen(R.s, opn=='w' ? "w" : "a");
|
rsm->F = xfopen(R.s, opn=='w' ? "w" : "a");
|
||||||
@ -3246,7 +3246,7 @@ int awk_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
argv += optind;
|
argv += optind;
|
||||||
//argc -= optind;
|
//argc -= optind;
|
||||||
if (opt & OPT_W)
|
if (opt & OPT_W)
|
||||||
bb_error_msg("warning: option -W is ignored");
|
bb_simple_error_msg("warning: option -W is ignored");
|
||||||
if (opt & OPT_F) {
|
if (opt & OPT_F) {
|
||||||
unescape_string_in_place(opt_F);
|
unescape_string_in_place(opt_F);
|
||||||
setvar_s(intvar[FS], opt_F);
|
setvar_s(intvar[FS], opt_F);
|
||||||
|
@ -1006,7 +1006,7 @@ int diff_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
xfunc_error_retval = 1;
|
xfunc_error_retval = 1;
|
||||||
|
|
||||||
if (gotstdin && (S_ISDIR(stb[0].st_mode) || S_ISDIR(stb[1].st_mode)))
|
if (gotstdin && (S_ISDIR(stb[0].st_mode) || S_ISDIR(stb[1].st_mode)))
|
||||||
bb_error_msg_and_die("can't compare stdin to a directory");
|
bb_simple_error_msg_and_die("can't compare stdin to a directory");
|
||||||
|
|
||||||
/* Compare metadata to check if the files are the same physical file.
|
/* Compare metadata to check if the files are the same physical file.
|
||||||
*
|
*
|
||||||
@ -1037,7 +1037,7 @@ int diff_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
#if ENABLE_FEATURE_DIFF_DIR
|
#if ENABLE_FEATURE_DIFF_DIR
|
||||||
diffdir(file, s_start);
|
diffdir(file, s_start);
|
||||||
#else
|
#else
|
||||||
bb_error_msg_and_die("no support for directory comparison");
|
bb_simple_error_msg_and_die("no support for directory comparison");
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
bool dirfile = S_ISDIR(stb[0].st_mode) || S_ISDIR(stb[1].st_mode);
|
bool dirfile = S_ISDIR(stb[0].st_mode) || S_ISDIR(stb[1].st_mode);
|
||||||
|
34
editors/ed.c
34
editors/ed.c
@ -165,7 +165,7 @@ static NOINLINE int searchLines(const char *str, int num1, int num2)
|
|||||||
|
|
||||||
if (*str == '\0') {
|
if (*str == '\0') {
|
||||||
if (searchString[0] == '\0') {
|
if (searchString[0] == '\0') {
|
||||||
bb_error_msg("no previous search string");
|
bb_simple_error_msg("no previous search string");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
str = searchString;
|
str = searchString;
|
||||||
@ -228,7 +228,7 @@ static const char* getNum(const char *cp, smallint *retHaveNum, int *retNum)
|
|||||||
case '\'':
|
case '\'':
|
||||||
cp++;
|
cp++;
|
||||||
if ((unsigned)(*cp - 'a') >= 26) {
|
if ((unsigned)(*cp - 'a') >= 26) {
|
||||||
bb_error_msg("bad mark name");
|
bb_simple_error_msg("bad mark name");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
haveNum = TRUE;
|
haveNum = TRUE;
|
||||||
@ -314,7 +314,7 @@ static int insertLine(int num, const char *data, int len)
|
|||||||
LINE *newLp, *lp;
|
LINE *newLp, *lp;
|
||||||
|
|
||||||
if ((num < 1) || (num > lastNum + 1)) {
|
if ((num < 1) || (num > lastNum + 1)) {
|
||||||
bb_error_msg("inserting at bad line number");
|
bb_simple_error_msg("inserting at bad line number");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -384,7 +384,7 @@ static int readLines(const char *file, int num)
|
|||||||
char *cp;
|
char *cp;
|
||||||
|
|
||||||
if ((num < 1) || (num > lastNum + 1)) {
|
if ((num < 1) || (num > lastNum + 1)) {
|
||||||
bb_error_msg("bad line for read");
|
bb_simple_error_msg("bad line for read");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -629,7 +629,7 @@ static void subCommand(const char *cmd, int num1, int num2)
|
|||||||
cp = buf;
|
cp = buf;
|
||||||
|
|
||||||
if (isblank(*cp) || (*cp == '\0')) {
|
if (isblank(*cp) || (*cp == '\0')) {
|
||||||
bb_error_msg("bad delimiter for substitute");
|
bb_simple_error_msg("bad delimiter for substitute");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -638,7 +638,7 @@ static void subCommand(const char *cmd, int num1, int num2)
|
|||||||
|
|
||||||
cp = strchr(cp, delim);
|
cp = strchr(cp, delim);
|
||||||
if (cp == NULL) {
|
if (cp == NULL) {
|
||||||
bb_error_msg("missing 2nd delimiter for substitute");
|
bb_simple_error_msg("missing 2nd delimiter for substitute");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -660,13 +660,13 @@ static void subCommand(const char *cmd, int num1, int num2)
|
|||||||
printFlag = TRUE;
|
printFlag = TRUE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
bb_error_msg("unknown option for substitute");
|
bb_simple_error_msg("unknown option for substitute");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*oldStr == '\0') {
|
if (*oldStr == '\0') {
|
||||||
if (searchString[0] == '\0') {
|
if (searchString[0] == '\0') {
|
||||||
bb_error_msg("no previous search string");
|
bb_simple_error_msg("no previous search string");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
oldStr = searchString;
|
oldStr = searchString;
|
||||||
@ -846,7 +846,7 @@ static void doCommands(void)
|
|||||||
|
|
||||||
case 'f':
|
case 'f':
|
||||||
if (*cp != '\0' && *cp != ' ') {
|
if (*cp != '\0' && *cp != ' ') {
|
||||||
bb_error_msg("bad file command");
|
bb_simple_error_msg("bad file command");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cp = skip_whitespace(cp);
|
cp = skip_whitespace(cp);
|
||||||
@ -870,7 +870,7 @@ static void doCommands(void)
|
|||||||
case 'k':
|
case 'k':
|
||||||
cp = skip_whitespace(cp);
|
cp = skip_whitespace(cp);
|
||||||
if ((unsigned)(*cp - 'a') >= 26 || cp[1]) {
|
if ((unsigned)(*cp - 'a') >= 26 || cp[1]) {
|
||||||
bb_error_msg("bad mark name");
|
bb_simple_error_msg("bad mark name");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
marks[(unsigned)(*cp - 'a')] = num2;
|
marks[(unsigned)(*cp - 'a')] = num2;
|
||||||
@ -887,7 +887,7 @@ static void doCommands(void)
|
|||||||
case 'q':
|
case 'q':
|
||||||
cp = skip_whitespace(cp);
|
cp = skip_whitespace(cp);
|
||||||
if (have1 || *cp) {
|
if (have1 || *cp) {
|
||||||
bb_error_msg("bad quit command");
|
bb_simple_error_msg("bad quit command");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!dirty)
|
if (!dirty)
|
||||||
@ -903,12 +903,12 @@ static void doCommands(void)
|
|||||||
|
|
||||||
case 'r':
|
case 'r':
|
||||||
if (*cp != '\0' && *cp != ' ') {
|
if (*cp != '\0' && *cp != ' ') {
|
||||||
bb_error_msg("bad read command");
|
bb_simple_error_msg("bad read command");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cp = skip_whitespace(cp);
|
cp = skip_whitespace(cp);
|
||||||
if (*cp == '\0') {
|
if (*cp == '\0') {
|
||||||
bb_error_msg("no file name");
|
bb_simple_error_msg("no file name");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!have1)
|
if (!have1)
|
||||||
@ -925,14 +925,14 @@ static void doCommands(void)
|
|||||||
|
|
||||||
case 'w':
|
case 'w':
|
||||||
if (*cp != '\0' && *cp != ' ') {
|
if (*cp != '\0' && *cp != ' ') {
|
||||||
bb_error_msg("bad write command");
|
bb_simple_error_msg("bad write command");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cp = skip_whitespace(cp);
|
cp = skip_whitespace(cp);
|
||||||
if (*cp == '\0') {
|
if (*cp == '\0') {
|
||||||
cp = fileName;
|
cp = fileName;
|
||||||
if (!cp) {
|
if (!cp) {
|
||||||
bb_error_msg("no file name specified");
|
bb_simple_error_msg("no file name specified");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -960,7 +960,7 @@ static void doCommands(void)
|
|||||||
|
|
||||||
case '.':
|
case '.':
|
||||||
if (have1) {
|
if (have1) {
|
||||||
bb_error_msg("no arguments allowed");
|
bb_simple_error_msg("no arguments allowed");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
printLines(curNum, curNum, FALSE);
|
printLines(curNum, curNum, FALSE);
|
||||||
@ -984,7 +984,7 @@ static void doCommands(void)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
bb_error_msg("unimplemented command");
|
bb_simple_error_msg("unimplemented command");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ static unsigned copy_lines(FILE *src_stream, FILE *dst_stream, unsigned lines_co
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (fputs(line, dst_stream) == EOF) {
|
if (fputs(line, dst_stream) == EOF) {
|
||||||
bb_perror_msg_and_die("error writing to new file");
|
bb_simple_perror_msg_and_die("error writing to new file");
|
||||||
}
|
}
|
||||||
free(line);
|
free(line);
|
||||||
lines_count--;
|
lines_count--;
|
||||||
@ -148,7 +148,7 @@ int patch_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
|
|
||||||
new_filename = extract_filename(patch_line, patch_level, "+++ ");
|
new_filename = extract_filename(patch_line, patch_level, "+++ ");
|
||||||
if (!new_filename) {
|
if (!new_filename) {
|
||||||
bb_error_msg_and_die("invalid patch");
|
bb_simple_error_msg_and_die("invalid patch");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get access rights from the file to be patched */
|
/* Get access rights from the file to be patched */
|
||||||
@ -209,7 +209,7 @@ int patch_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
/* src_beg_line will be 0 if it's a new file */
|
/* src_beg_line will be 0 if it's a new file */
|
||||||
count = src_beg_line - src_cur_line;
|
count = src_beg_line - src_cur_line;
|
||||||
if (copy_lines(src_stream, dst_stream, count)) {
|
if (copy_lines(src_stream, dst_stream, count)) {
|
||||||
bb_error_msg_and_die("bad src file");
|
bb_simple_error_msg_and_die("bad src file");
|
||||||
}
|
}
|
||||||
src_cur_line += count;
|
src_cur_line += count;
|
||||||
dst_cur_line += count;
|
dst_cur_line += count;
|
||||||
|
@ -200,7 +200,7 @@ int copy_tempfile(int fdin, char *name, char **tempname)
|
|||||||
|
|
||||||
*tempname = xasprintf("%sXXXXXX", name);
|
*tempname = xasprintf("%sXXXXXX", name);
|
||||||
fd = mkstemp(*tempname);
|
fd = mkstemp(*tempname);
|
||||||
if(-1 == fd) bb_perror_msg_and_die("no temp file");
|
if(-1 == fd) bb_simple_perror_msg_and_die("no temp file");
|
||||||
|
|
||||||
// Set permissions of output file
|
// Set permissions of output file
|
||||||
fstat(fdin, &statbuf);
|
fstat(fdin, &statbuf);
|
||||||
|
@ -315,7 +315,7 @@ static int parse_regex_delim(const char *cmdstr, char **match, char **replace)
|
|||||||
/* verify that the 's' or 'y' is followed by something. That something
|
/* verify that the 's' or 'y' is followed by something. That something
|
||||||
* (typically a 'slash') is now our regexp delimiter... */
|
* (typically a 'slash') is now our regexp delimiter... */
|
||||||
if (*cmdstr == '\0')
|
if (*cmdstr == '\0')
|
||||||
bb_error_msg_and_die("bad format in substitution expression");
|
bb_simple_error_msg_and_die("bad format in substitution expression");
|
||||||
delimiter = *cmdstr_ptr++;
|
delimiter = *cmdstr_ptr++;
|
||||||
|
|
||||||
/* save the match string */
|
/* save the match string */
|
||||||
@ -360,7 +360,7 @@ static int get_address(const char *my_str, int *linenum, regex_t ** regex)
|
|||||||
} else {
|
} else {
|
||||||
*regex = G.previous_regex_ptr;
|
*regex = G.previous_regex_ptr;
|
||||||
if (!G.previous_regex_ptr)
|
if (!G.previous_regex_ptr)
|
||||||
bb_error_msg_and_die("no previous regexp");
|
bb_simple_error_msg_and_die("no previous regexp");
|
||||||
}
|
}
|
||||||
/* Move position to next character after last delimiter */
|
/* Move position to next character after last delimiter */
|
||||||
pos += (next+1);
|
pos += (next+1);
|
||||||
@ -378,7 +378,7 @@ static int parse_file_cmd(/*sed_cmd_t *sed_cmd,*/ const char *filecmdstr, char *
|
|||||||
start = skip_whitespace(filecmdstr);
|
start = skip_whitespace(filecmdstr);
|
||||||
eol = strchrnul(start, '\n');
|
eol = strchrnul(start, '\n');
|
||||||
if (eol == start)
|
if (eol == start)
|
||||||
bb_error_msg_and_die("empty filename");
|
bb_simple_error_msg_and_die("empty filename");
|
||||||
|
|
||||||
if (*eol) {
|
if (*eol) {
|
||||||
/* If lines glued together, put backslash back. */
|
/* If lines glued together, put backslash back. */
|
||||||
@ -468,7 +468,7 @@ static int parse_subst_cmd(sed_cmd_t *sed_cmd, const char *substr)
|
|||||||
goto out;
|
goto out;
|
||||||
default:
|
default:
|
||||||
dbg("s bad flags:'%s'", substr + idx);
|
dbg("s bad flags:'%s'", substr + idx);
|
||||||
bb_error_msg_and_die("bad option in substitution expression");
|
bb_simple_error_msg_and_die("bad option in substitution expression");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
@ -688,7 +688,7 @@ static void add_cmd(const char *cmdstr)
|
|||||||
idx--; /* if 0, trigger error check below */
|
idx--; /* if 0, trigger error check below */
|
||||||
}
|
}
|
||||||
if (idx < 0)
|
if (idx < 0)
|
||||||
bb_error_msg_and_die("no address after comma");
|
bb_simple_error_msg_and_die("no address after comma");
|
||||||
sed_cmd->end_line_orig = sed_cmd->end_line;
|
sed_cmd->end_line_orig = sed_cmd->end_line;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -706,7 +706,7 @@ static void add_cmd(const char *cmdstr)
|
|||||||
|
|
||||||
/* last part (mandatory) will be a command */
|
/* last part (mandatory) will be a command */
|
||||||
if (!*cmdstr)
|
if (!*cmdstr)
|
||||||
bb_error_msg_and_die("missing command");
|
bb_simple_error_msg_and_die("missing command");
|
||||||
sed_cmd->cmd = *cmdstr++;
|
sed_cmd->cmd = *cmdstr++;
|
||||||
cmdstr = parse_cmd_args(sed_cmd, cmdstr);
|
cmdstr = parse_cmd_args(sed_cmd, cmdstr);
|
||||||
|
|
||||||
@ -791,7 +791,7 @@ static int do_subst_command(sed_cmd_t *sed_cmd, char **line_p)
|
|||||||
if (!current_regex) {
|
if (!current_regex) {
|
||||||
current_regex = G.previous_regex_ptr;
|
current_regex = G.previous_regex_ptr;
|
||||||
if (!current_regex)
|
if (!current_regex)
|
||||||
bb_error_msg_and_die("no previous regexp");
|
bb_simple_error_msg_and_die("no previous regexp");
|
||||||
}
|
}
|
||||||
G.previous_regex_ptr = current_regex;
|
G.previous_regex_ptr = current_regex;
|
||||||
|
|
||||||
@ -962,7 +962,7 @@ static void puts_maybe_newline(char *s, FILE *file, char *last_puts_char, char l
|
|||||||
|
|
||||||
if (ferror(file)) {
|
if (ferror(file)) {
|
||||||
xfunc_error_retval = 4; /* It's what gnu sed exits with... */
|
xfunc_error_retval = 4; /* It's what gnu sed exits with... */
|
||||||
bb_error_msg_and_die(bb_msg_write_error);
|
bb_simple_error_msg_and_die(bb_msg_write_error);
|
||||||
}
|
}
|
||||||
*last_puts_char = lpc;
|
*last_puts_char = lpc;
|
||||||
}
|
}
|
||||||
@ -1192,7 +1192,7 @@ static void process_files(void)
|
|||||||
}
|
}
|
||||||
sed_cmd = sed_cmd->next;
|
sed_cmd = sed_cmd->next;
|
||||||
if (!sed_cmd)
|
if (!sed_cmd)
|
||||||
bb_error_msg_and_die("unterminated {");
|
bb_simple_error_msg_and_die("unterminated {");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -1042,7 +1042,7 @@ static int readit(void) // read (maybe cursor) key from stdin
|
|||||||
goto again;
|
goto again;
|
||||||
go_bottom_and_clear_to_eol();
|
go_bottom_and_clear_to_eol();
|
||||||
cookmode(); // terminal to "cooked"
|
cookmode(); // terminal to "cooked"
|
||||||
bb_error_msg_and_die("can't read user input");
|
bb_simple_error_msg_and_die("can't read user input");
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
@ -1245,7 +1245,7 @@ static action*** parse_params(char **argv)
|
|||||||
* coreutils expects {} to appear only once in "-exec +"
|
* coreutils expects {} to appear only once in "-exec +"
|
||||||
*/
|
*/
|
||||||
if (all_subst != 1 && ap->filelist)
|
if (all_subst != 1 && ap->filelist)
|
||||||
bb_error_msg_and_die("only one '{}' allowed for -exec +");
|
bb_simple_error_msg_and_die("only one '{}' allowed for -exec +");
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1259,7 +1259,7 @@ static action*** parse_params(char **argv)
|
|||||||
endarg = argv;
|
endarg = argv;
|
||||||
while (1) {
|
while (1) {
|
||||||
if (!*++endarg)
|
if (!*++endarg)
|
||||||
bb_error_msg_and_die("unpaired '('");
|
bb_simple_error_msg_and_die("unpaired '('");
|
||||||
if (LONE_CHAR(*endarg, '('))
|
if (LONE_CHAR(*endarg, '('))
|
||||||
nested++;
|
nested++;
|
||||||
else if (LONE_CHAR(*endarg, ')') && !--nested) {
|
else if (LONE_CHAR(*endarg, ')') && !--nested) {
|
||||||
|
@ -665,7 +665,7 @@ int xargs_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
}
|
}
|
||||||
/* Sanity check */
|
/* Sanity check */
|
||||||
if (n_max_chars <= 0) {
|
if (n_max_chars <= 0) {
|
||||||
bb_error_msg_and_die("can't fit single argument within argument list size limit");
|
bb_simple_error_msg_and_die("can't fit single argument within argument list size limit");
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = xzalloc(n_max_chars + 1);
|
buf = xzalloc(n_max_chars + 1);
|
||||||
@ -716,7 +716,7 @@ int xargs_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
|
|
||||||
if (!G.args[initial_idx]) { /* not even one ARG was added? */
|
if (!G.args[initial_idx]) { /* not even one ARG was added? */
|
||||||
if (*rem != '\0')
|
if (*rem != '\0')
|
||||||
bb_error_msg_and_die("argument line too long");
|
bb_simple_error_msg_and_die("argument line too long");
|
||||||
if (opt & OPT_NO_EMPTY)
|
if (opt & OPT_NO_EMPTY)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1137,7 +1137,7 @@ void exec_prog_or_SHELL(char **argv) NORETURN FAST_FUNC;
|
|||||||
({ \
|
({ \
|
||||||
pid_t bb__xvfork_pid = vfork(); \
|
pid_t bb__xvfork_pid = vfork(); \
|
||||||
if (bb__xvfork_pid < 0) \
|
if (bb__xvfork_pid < 0) \
|
||||||
bb_perror_msg_and_die("vfork"); \
|
bb_simple_perror_msg_and_die("vfork"); \
|
||||||
bb__xvfork_pid; \
|
bb__xvfork_pid; \
|
||||||
})
|
})
|
||||||
#if BB_MMU
|
#if BB_MMU
|
||||||
@ -1324,13 +1324,17 @@ extern void (*die_func)(void);
|
|||||||
void xfunc_die(void) NORETURN FAST_FUNC;
|
void xfunc_die(void) NORETURN FAST_FUNC;
|
||||||
void bb_show_usage(void) NORETURN FAST_FUNC;
|
void bb_show_usage(void) NORETURN FAST_FUNC;
|
||||||
void bb_error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))) FAST_FUNC;
|
void bb_error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))) FAST_FUNC;
|
||||||
|
void bb_simple_error_msg(const char *s) FAST_FUNC;
|
||||||
void bb_error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))) FAST_FUNC;
|
void bb_error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))) FAST_FUNC;
|
||||||
|
void bb_simple_error_msg_and_die(const char *s) NORETURN FAST_FUNC;
|
||||||
void bb_perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))) FAST_FUNC;
|
void bb_perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))) FAST_FUNC;
|
||||||
void bb_simple_perror_msg(const char *s) FAST_FUNC;
|
void bb_simple_perror_msg(const char *s) FAST_FUNC;
|
||||||
void bb_perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))) FAST_FUNC;
|
void bb_perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))) FAST_FUNC;
|
||||||
void bb_simple_perror_msg_and_die(const char *s) NORETURN FAST_FUNC;
|
void bb_simple_perror_msg_and_die(const char *s) NORETURN FAST_FUNC;
|
||||||
void bb_herror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))) FAST_FUNC;
|
void bb_herror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))) FAST_FUNC;
|
||||||
|
void bb_simple_herror_msg(const char *s) FAST_FUNC;
|
||||||
void bb_herror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))) FAST_FUNC;
|
void bb_herror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))) FAST_FUNC;
|
||||||
|
void bb_simple_herror_msg_and_die(const char *s) NORETURN FAST_FUNC;
|
||||||
void bb_perror_nomsg_and_die(void) NORETURN FAST_FUNC;
|
void bb_perror_nomsg_and_die(void) NORETURN FAST_FUNC;
|
||||||
void bb_perror_nomsg(void) FAST_FUNC;
|
void bb_perror_nomsg(void) FAST_FUNC;
|
||||||
void bb_verror_msg(const char *s, va_list p, const char *strerr) FAST_FUNC;
|
void bb_verror_msg(const char *s, va_list p, const char *strerr) FAST_FUNC;
|
||||||
@ -1339,12 +1343,51 @@ void bb_logenv_override(void) FAST_FUNC;
|
|||||||
|
|
||||||
#if ENABLE_FEATURE_SYSLOG_INFO
|
#if ENABLE_FEATURE_SYSLOG_INFO
|
||||||
void bb_info_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))) FAST_FUNC;
|
void bb_info_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))) FAST_FUNC;
|
||||||
|
void bb_simple_info_msg(const char *s) FAST_FUNC;
|
||||||
void bb_vinfo_msg(const char *s, va_list p) FAST_FUNC;
|
void bb_vinfo_msg(const char *s, va_list p) FAST_FUNC;
|
||||||
#else
|
#else
|
||||||
#define bb_info_msg bb_error_msg
|
#define bb_info_msg bb_error_msg
|
||||||
|
#define bb_simple_info_msg bb_simple_error_msg
|
||||||
#define bb_vinfo_msg(s,p) bb_verror_msg(s,p,NULL)
|
#define bb_vinfo_msg(s,p) bb_verror_msg(s,p,NULL)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ENABLE_WARN_SIMPLE_MSG
|
||||||
|
/* If enabled, cause calls to bb_error_msg() et al that only take a single
|
||||||
|
* parameter to generate a warning.
|
||||||
|
*/
|
||||||
|
static inline void __attribute__ ((deprecated("use bb_simple_error_msg instead")))
|
||||||
|
bb_not_simple_error_msg(const char *s) { bb_simple_error_msg(s); }
|
||||||
|
static inline void __attribute__ ((deprecated("use bb_simple_error_msg_and_die instead"))) NORETURN
|
||||||
|
bb_not_simple_error_msg_and_die(const char *s) { bb_simple_error_msg_and_die(s); }
|
||||||
|
static inline void __attribute__ ((deprecated("use bb_simple_perror_msg instead")))
|
||||||
|
bb_not_simple_perror_msg(const char *s) { bb_simple_perror_msg(s); }
|
||||||
|
static inline void __attribute__ ((deprecated("use bb_simple_perror_msg_and_die instead"))) NORETURN
|
||||||
|
bb_not_simple_perror_msg_and_die(const char *s) { bb_simple_perror_msg_and_die(s); }
|
||||||
|
static inline void __attribute__ ((deprecated("use bb_simple_herror_msg instead")))
|
||||||
|
bb_not_simple_herror_msg(const char *s) { bb_simple_herror_msg(s); }
|
||||||
|
static inline void __attribute__ ((deprecated("use bb_simple_herror_msg_and_die instead"))) NORETURN
|
||||||
|
bb_not_simple_herror_msg_and_die(const char *s) { bb_simple_herror_msg_and_die(s); }
|
||||||
|
static inline void __attribute__ ((deprecated("use bb_simple_info_msg instead")))
|
||||||
|
bb_not_simple_info_msg(const char *s) { bb_simple_info_msg(s); }
|
||||||
|
/* Override bb_error_msg() and related functions with macros that will
|
||||||
|
* substitute them for the equivalent bb_not_simple_error_msg() function when
|
||||||
|
* they are used with only a single parameter. Macro approach inspired by
|
||||||
|
* https://gustedt.wordpress.com/2010/06/08/detect-empty-macro-arguments and
|
||||||
|
* https://gustedt.wordpress.com/2010/06/03/default-arguments-for-c99
|
||||||
|
*/
|
||||||
|
#define _ARG18(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, ...) _17
|
||||||
|
#define BB_MSG_KIND(...) _ARG18(__VA_ARGS__, , , , , , , , , , , , , , , , , _not_simple)
|
||||||
|
#define _BB_MSG(name, kind, ...) bb##kind##name(__VA_ARGS__)
|
||||||
|
#define BB_MSG(name, kind, ...) _BB_MSG(name, kind, __VA_ARGS__)
|
||||||
|
#define bb_error_msg(...) BB_MSG(_error_msg, BB_MSG_KIND(__VA_ARGS__), __VA_ARGS__)
|
||||||
|
#define bb_error_msg_and_die(...) BB_MSG(_error_msg_and_die, BB_MSG_KIND(__VA_ARGS__), __VA_ARGS__)
|
||||||
|
#define bb_perror_msg(...) BB_MSG(_perror_msg, BB_MSG_KIND(__VA_ARGS__), __VA_ARGS__)
|
||||||
|
#define bb_perror_msg_and_die(...) BB_MSG(_perror_msg_and_die, BB_MSG_KIND(__VA_ARGS__), __VA_ARGS__)
|
||||||
|
#define bb_herror_msg(...) BB_MSG(_herror_msg, BB_MSG_KIND(__VA_ARGS__), __VA_ARGS__)
|
||||||
|
#define bb_herror_msg_and_die(...) BB_MSG(_herror_msg_and_die, BB_MSG_KIND(__VA_ARGS__), __VA_ARGS__)
|
||||||
|
#define bb_info_msg(...) BB_MSG(_info_msg, BB_MSG_KIND(__VA_ARGS__), __VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* We need to export XXX_main from libbusybox
|
/* We need to export XXX_main from libbusybox
|
||||||
* only if we build "individual" binaries
|
* only if we build "individual" binaries
|
||||||
*/
|
*/
|
||||||
|
@ -208,7 +208,7 @@ static char *make_tempdir(void)
|
|||||||
bb_perror_msg_and_die("can't %smount tmpfs", "un");
|
bb_perror_msg_and_die("can't %smount tmpfs", "un");
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
bb_perror_msg_and_die("can't create temporary directory");
|
bb_simple_perror_msg_and_die("can't create temporary directory");
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
xchdir(tempdir);
|
xchdir(tempdir);
|
||||||
|
@ -1086,7 +1086,7 @@ int init_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
if (getpid() != 1
|
if (getpid() != 1
|
||||||
&& (!ENABLE_LINUXRC || applet_name[0] != 'l') /* not linuxrc? */
|
&& (!ENABLE_LINUXRC || applet_name[0] != 'l') /* not linuxrc? */
|
||||||
) {
|
) {
|
||||||
bb_error_msg_and_die("must be run as PID 1");
|
bb_simple_error_msg_and_die("must be run as PID 1");
|
||||||
}
|
}
|
||||||
#ifdef RB_DISABLE_CAD
|
#ifdef RB_DISABLE_CAD
|
||||||
/* Turn off rebooting via CTL-ALT-DEL - we get a
|
/* Turn off rebooting via CTL-ALT-DEL - we get a
|
||||||
|
@ -631,7 +631,7 @@ static void check_suid(int applet_no)
|
|||||||
/* same group / in group */
|
/* same group / in group */
|
||||||
m >>= 3;
|
m >>= 3;
|
||||||
if (!(m & S_IXOTH)) /* is x bit not set? */
|
if (!(m & S_IXOTH)) /* is x bit not set? */
|
||||||
bb_error_msg_and_die("you have no permission to run this applet");
|
bb_simple_error_msg_and_die("you have no permission to run this applet");
|
||||||
|
|
||||||
/* We set effective AND saved ids. If saved-id is not set
|
/* We set effective AND saved ids. If saved-id is not set
|
||||||
* like we do below, seteuid(0) can still later succeed! */
|
* like we do below, seteuid(0) can still later succeed! */
|
||||||
@ -643,7 +643,7 @@ static void check_suid(int applet_no)
|
|||||||
rgid = sct->m_ugid.gid;
|
rgid = sct->m_ugid.gid;
|
||||||
/* else: we will set egid = rgid, thus dropping sgid effect */
|
/* else: we will set egid = rgid, thus dropping sgid effect */
|
||||||
if (setresgid(-1, rgid, rgid))
|
if (setresgid(-1, rgid, rgid))
|
||||||
bb_perror_msg_and_die("setresgid");
|
bb_simple_perror_msg_and_die("setresgid");
|
||||||
|
|
||||||
/* Are we directed to change uid
|
/* Are we directed to change uid
|
||||||
* (APPLET = s** USER.GROUP or APPLET = S** USER.GROUP)?
|
* (APPLET = s** USER.GROUP or APPLET = S** USER.GROUP)?
|
||||||
@ -653,7 +653,7 @@ static void check_suid(int applet_no)
|
|||||||
uid = sct->m_ugid.uid;
|
uid = sct->m_ugid.uid;
|
||||||
/* else: we will set euid = ruid, thus dropping suid effect */
|
/* else: we will set euid = ruid, thus dropping suid effect */
|
||||||
if (setresuid(-1, uid, uid))
|
if (setresuid(-1, uid, uid))
|
||||||
bb_perror_msg_and_die("setresuid");
|
bb_simple_perror_msg_and_die("setresuid");
|
||||||
|
|
||||||
goto ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
@ -663,7 +663,7 @@ static void check_suid(int applet_no)
|
|||||||
|
|
||||||
if (!onetime) {
|
if (!onetime) {
|
||||||
onetime = 1;
|
onetime = 1;
|
||||||
bb_error_msg("using fallback suid method");
|
bb_simple_error_msg("using fallback suid method");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
@ -673,7 +673,7 @@ static void check_suid(int applet_no)
|
|||||||
/* Real uid is not 0. If euid isn't 0 too, suid bit
|
/* Real uid is not 0. If euid isn't 0 too, suid bit
|
||||||
* is most probably not set on our executable */
|
* is most probably not set on our executable */
|
||||||
if (geteuid())
|
if (geteuid())
|
||||||
bb_error_msg_and_die("must be suid to work properly");
|
bb_simple_error_msg_and_die("must be suid to work properly");
|
||||||
} else if (APPLET_SUID(applet_no) == BB_SUID_DROP) {
|
} else if (APPLET_SUID(applet_no) == BB_SUID_DROP) {
|
||||||
/*
|
/*
|
||||||
* Drop all privileges.
|
* Drop all privileges.
|
||||||
|
@ -38,7 +38,7 @@ gid_t* FAST_FUNC bb_getgroups(int *ngroups, gid_t *group_array)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* Some other error (should never happen on Linux) */
|
/* Some other error (should never happen on Linux) */
|
||||||
bb_perror_msg_and_die("getgroups");
|
bb_simple_perror_msg_and_die("getgroups");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ngroups)
|
if (ngroups)
|
||||||
|
@ -60,6 +60,6 @@ int unit_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bb_error_msg("All tests passed");
|
bb_simple_error_msg("All tests passed");
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ void FAST_FUNC getcaps(void *arg)
|
|||||||
caps->u32s = _LINUX_CAPABILITY_U32S_3;
|
caps->u32s = _LINUX_CAPABILITY_U32S_3;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
bb_error_msg_and_die("unsupported capability version");
|
bb_simple_error_msg_and_die("unsupported capability version");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (capget(&caps->header, caps->data) != 0)
|
if (capget(&caps->header, caps->data) != 0)
|
||||||
|
@ -51,7 +51,7 @@ void FAST_FUNC change_identity(const struct passwd *pw)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bb_perror_msg_and_die("can't set groups");
|
bb_simple_perror_msg_and_die("can't set groups");
|
||||||
}
|
}
|
||||||
|
|
||||||
xsetgid(pw->pw_gid);
|
xsetgid(pw->pw_gid);
|
||||||
|
@ -327,7 +327,7 @@ int FAST_FUNC copy_file(const char *source, const char *dest, int flags)
|
|||||||
) {
|
) {
|
||||||
security_context_t con;
|
security_context_t con;
|
||||||
if (getfscreatecon(&con) == -1) {
|
if (getfscreatecon(&con) == -1) {
|
||||||
bb_perror_msg("getfscreatecon");
|
bb_simple_perror_msg("getfscreatecon");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (con) {
|
if (con) {
|
||||||
|
@ -87,7 +87,7 @@ static off_t bb_full_fd_action(int src_fd, int dst_fd, off_t size)
|
|||||||
rd = safe_read(src_fd, buffer,
|
rd = safe_read(src_fd, buffer,
|
||||||
size > buffer_size ? buffer_size : size);
|
size > buffer_size ? buffer_size : size);
|
||||||
if (rd < 0) {
|
if (rd < 0) {
|
||||||
bb_perror_msg(bb_msg_read_error);
|
bb_simple_perror_msg(bb_msg_read_error);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
read_ok:
|
read_ok:
|
||||||
@ -100,7 +100,7 @@ static off_t bb_full_fd_action(int src_fd, int dst_fd, off_t size)
|
|||||||
ssize_t wr = full_write(dst_fd, buffer, rd);
|
ssize_t wr = full_write(dst_fd, buffer, rd);
|
||||||
if (wr < rd) {
|
if (wr < rd) {
|
||||||
if (!continue_on_write_error) {
|
if (!continue_on_write_error) {
|
||||||
bb_perror_msg(bb_msg_write_error);
|
bb_simple_perror_msg(bb_msg_write_error);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
dst_fd = -1;
|
dst_fd = -1;
|
||||||
@ -151,7 +151,7 @@ void FAST_FUNC bb_copyfd_exact_size(int fd1, int fd2, off_t size)
|
|||||||
if (sz == (size >= 0 ? size : -size))
|
if (sz == (size >= 0 ? size : -size))
|
||||||
return;
|
return;
|
||||||
if (sz != -1)
|
if (sz != -1)
|
||||||
bb_error_msg_and_die("short read");
|
bb_simple_error_msg_and_die("short read");
|
||||||
/* if sz == -1, bb_copyfd_XX already complained */
|
/* if sz == -1, bb_copyfd_XX already complained */
|
||||||
xfunc_die();
|
xfunc_die();
|
||||||
}
|
}
|
||||||
|
@ -57,5 +57,5 @@ void FAST_FUNC die_if_bad_username(const char *name)
|
|||||||
* including the terminating null byte.
|
* including the terminating null byte.
|
||||||
*/
|
*/
|
||||||
if (name - start >= LOGIN_NAME_MAX)
|
if (name - start >= LOGIN_NAME_MAX)
|
||||||
bb_error_msg_and_die("name is too long");
|
bb_simple_error_msg_and_die("name is too long");
|
||||||
}
|
}
|
||||||
|
@ -199,7 +199,7 @@ static NOINLINE void rewrite(priv_dumper_t *dumper, FS *fs)
|
|||||||
pr->bcnt = fu->bcnt;
|
pr->bcnt = fu->bcnt;
|
||||||
if (fu->bcnt == 0) {
|
if (fu->bcnt == 0) {
|
||||||
if (!prec)
|
if (!prec)
|
||||||
bb_error_msg_and_die("%%s needs precision or byte count");
|
bb_simple_error_msg_and_die("%%s needs precision or byte count");
|
||||||
pr->bcnt = atoi(prec);
|
pr->bcnt = atoi(prec);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@ -266,7 +266,7 @@ static NOINLINE void rewrite(priv_dumper_t *dumper, FS *fs)
|
|||||||
|
|
||||||
/* only one conversion character if byte count */
|
/* only one conversion character if byte count */
|
||||||
if (!(pr->flags & F_ADDRESS) && fu->bcnt && nconv++) {
|
if (!(pr->flags & F_ADDRESS) && fu->bcnt && nconv++) {
|
||||||
bb_error_msg_and_die("byte count with multiple conversion characters");
|
bb_simple_error_msg_and_die("byte count with multiple conversion characters");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -15,7 +15,7 @@ void FAST_FUNC fflush_stdout_and_exit(int retval)
|
|||||||
{
|
{
|
||||||
xfunc_error_retval = retval;
|
xfunc_error_retval = retval;
|
||||||
if (fflush(stdout))
|
if (fflush(stdout))
|
||||||
bb_perror_msg_and_die(bb_msg_standard_output);
|
bb_simple_perror_msg_and_die(bb_msg_standard_output);
|
||||||
/* In case we are in NOFORK applet. Do not exit() directly,
|
/* In case we are in NOFORK applet. Do not exit() directly,
|
||||||
* but use xfunc_die() */
|
* but use xfunc_die() */
|
||||||
xfunc_die();
|
xfunc_die();
|
||||||
|
@ -62,7 +62,7 @@ int FAST_FUNC get_console_fd_or_die(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bb_error_msg_and_die("can't open console");
|
bb_simple_error_msg_and_die("can't open console");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* From <linux/vt.h> */
|
/* From <linux/vt.h> */
|
||||||
|
@ -18,7 +18,7 @@ uoff_t FAST_FUNC get_volume_size_in_bytes(int fd,
|
|||||||
if (override) {
|
if (override) {
|
||||||
result = XATOOFF(override);
|
result = XATOOFF(override);
|
||||||
if (result >= (uoff_t)(MAXINT(off_t)) / override_units)
|
if (result >= (uoff_t)(MAXINT(off_t)) / override_units)
|
||||||
bb_error_msg_and_die("image size is too big");
|
bb_simple_error_msg_and_die("image size is too big");
|
||||||
result *= override_units;
|
result *= override_units;
|
||||||
/* seek past end fails on block devices but works on files */
|
/* seek past end fails on block devices but works on files */
|
||||||
if (lseek(fd, result - 1, SEEK_SET) != (off_t)-1) {
|
if (lseek(fd, result - 1, SEEK_SET) != (off_t)-1) {
|
||||||
@ -42,7 +42,7 @@ uoff_t FAST_FUNC get_volume_size_in_bytes(int fd,
|
|||||||
*
|
*
|
||||||
* Picked 16k arbitrarily: */
|
* Picked 16k arbitrarily: */
|
||||||
if (result < 16*1024)
|
if (result < 16*1024)
|
||||||
bb_error_msg_and_die("image is too small");
|
bb_simple_error_msg_and_die("image is too small");
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -23,14 +23,14 @@ int FAST_FUNC xgetpty(char *line)
|
|||||||
const char *name;
|
const char *name;
|
||||||
name = ptsname(p); /* find out the name of slave pty */
|
name = ptsname(p); /* find out the name of slave pty */
|
||||||
if (!name) {
|
if (!name) {
|
||||||
bb_perror_msg_and_die("ptsname error (is /dev/pts mounted?)");
|
bb_simple_perror_msg_and_die("ptsname error (is /dev/pts mounted?)");
|
||||||
}
|
}
|
||||||
safe_strncpy(line, name, GETPTY_BUFSIZE);
|
safe_strncpy(line, name, GETPTY_BUFSIZE);
|
||||||
}
|
}
|
||||||
# else
|
# else
|
||||||
/* find out the name of slave pty */
|
/* find out the name of slave pty */
|
||||||
if (ptsname_r(p, line, GETPTY_BUFSIZE-1) != 0) {
|
if (ptsname_r(p, line, GETPTY_BUFSIZE-1) != 0) {
|
||||||
bb_perror_msg_and_die("ptsname error (is /dev/pts mounted?)");
|
bb_simple_perror_msg_and_die("ptsname error (is /dev/pts mounted?)");
|
||||||
}
|
}
|
||||||
line[GETPTY_BUFSIZE-1] = '\0';
|
line[GETPTY_BUFSIZE-1] = '\0';
|
||||||
# endif
|
# endif
|
||||||
@ -61,5 +61,5 @@ int FAST_FUNC xgetpty(char *line)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* FEATURE_DEVPTS */
|
#endif /* FEATURE_DEVPTS */
|
||||||
bb_error_msg_and_die("can't find free pty");
|
bb_simple_error_msg_and_die("can't find free pty");
|
||||||
}
|
}
|
||||||
|
@ -26,3 +26,13 @@ void FAST_FUNC bb_herror_msg_and_die(const char *s, ...)
|
|||||||
va_end(p);
|
va_end(p);
|
||||||
xfunc_die();
|
xfunc_die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FAST_FUNC bb_simple_herror_msg(const char *s)
|
||||||
|
{
|
||||||
|
bb_herror_msg("%s", s);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FAST_FUNC bb_simple_herror_msg_and_die(const char *s)
|
||||||
|
{
|
||||||
|
bb_herror_msg_and_die("%s", s);
|
||||||
|
}
|
||||||
|
@ -21,7 +21,7 @@ void FAST_FUNC erase_mtab(const char *name)
|
|||||||
/* Bummer. Fall back on trying the /proc filesystem */
|
/* Bummer. Fall back on trying the /proc filesystem */
|
||||||
if (!mountTable) mountTable = setmntent("/proc/mounts", "r");
|
if (!mountTable) mountTable = setmntent("/proc/mounts", "r");
|
||||||
if (!mountTable) {
|
if (!mountTable) {
|
||||||
bb_perror_msg(bb_path_mtab_file);
|
bb_simple_perror_msg(bb_path_mtab_file);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,6 +49,6 @@ void FAST_FUNC erase_mtab(const char *name)
|
|||||||
}
|
}
|
||||||
endmntent(mountTable);
|
endmntent(mountTable);
|
||||||
} else if (errno != EROFS)
|
} else if (errno != EROFS)
|
||||||
bb_perror_msg(bb_path_mtab_file);
|
bb_simple_perror_msg(bb_path_mtab_file);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -12,11 +12,11 @@
|
|||||||
* instead of including libbb.h */
|
* instead of including libbb.h */
|
||||||
//#include "libbb.h"
|
//#include "libbb.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
extern void bb_perror_msg(const char *s, ...) FAST_FUNC;
|
extern void bb_simple_perror_msg(const char *s) FAST_FUNC;
|
||||||
|
|
||||||
/* suppress gcc "no previous prototype" warning */
|
/* suppress gcc "no previous prototype" warning */
|
||||||
void FAST_FUNC bb_perror_nomsg(void);
|
void FAST_FUNC bb_perror_nomsg(void);
|
||||||
void FAST_FUNC bb_perror_nomsg(void)
|
void FAST_FUNC bb_perror_nomsg(void)
|
||||||
{
|
{
|
||||||
bb_perror_msg(0);
|
bb_simple_perror_msg(0);
|
||||||
}
|
}
|
||||||
|
@ -12,11 +12,11 @@
|
|||||||
* instead of including libbb.h */
|
* instead of including libbb.h */
|
||||||
//#include "libbb.h"
|
//#include "libbb.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
extern void bb_perror_msg_and_die(const char *s, ...) FAST_FUNC;
|
extern void bb_simple_perror_msg_and_die(const char *s) FAST_FUNC;
|
||||||
|
|
||||||
/* suppress gcc "no previous prototype" warning */
|
/* suppress gcc "no previous prototype" warning */
|
||||||
void FAST_FUNC bb_perror_nomsg_and_die(void);
|
void FAST_FUNC bb_perror_nomsg_and_die(void);
|
||||||
void FAST_FUNC bb_perror_nomsg_and_die(void)
|
void FAST_FUNC bb_perror_nomsg_and_die(void)
|
||||||
{
|
{
|
||||||
bb_perror_msg_and_die(0);
|
bb_simple_perror_msg_and_die(0);
|
||||||
}
|
}
|
||||||
|
@ -217,7 +217,7 @@ void FAST_FUNC xread(int fd, void *buf, size_t count)
|
|||||||
if (count) {
|
if (count) {
|
||||||
ssize_t size = full_read(fd, buf, count);
|
ssize_t size = full_read(fd, buf, count);
|
||||||
if ((size_t)size != count)
|
if ((size_t)size != count)
|
||||||
bb_error_msg_and_die("short read");
|
bb_simple_error_msg_and_die("short read");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ int FAST_FUNC safe_poll(struct pollfd *ufds, nfds_t nfds, int timeout)
|
|||||||
/* I doubt many callers would handle this correctly! */
|
/* I doubt many callers would handle this correctly! */
|
||||||
if (errno == ENOMEM)
|
if (errno == ENOMEM)
|
||||||
continue;
|
continue;
|
||||||
bb_perror_msg("poll");
|
bb_simple_perror_msg("poll");
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ void FAST_FUNC selinux_preserve_fcontext(int fdesc)
|
|||||||
if (fgetfilecon(fdesc, &context) < 0) {
|
if (fgetfilecon(fdesc, &context) < 0) {
|
||||||
if (errno == ENODATA || errno == ENOTSUP)
|
if (errno == ENODATA || errno == ENOTSUP)
|
||||||
return;
|
return;
|
||||||
bb_perror_msg_and_die("fgetfilecon failed");
|
bb_simple_perror_msg_and_die("fgetfilecon failed");
|
||||||
}
|
}
|
||||||
setfscreatecon_or_die(context);
|
setfscreatecon_or_die(context);
|
||||||
freecon(context);
|
freecon(context);
|
||||||
|
@ -258,7 +258,7 @@ char* FAST_FUNC strftime_YYYYMMDDHHMMSS(char *buf, unsigned len, time_t *tp)
|
|||||||
static void get_mono(struct timespec *ts)
|
static void get_mono(struct timespec *ts)
|
||||||
{
|
{
|
||||||
if (syscall(__NR_clock_gettime, CLOCK_MONOTONIC, ts))
|
if (syscall(__NR_clock_gettime, CLOCK_MONOTONIC, ts))
|
||||||
bb_error_msg_and_die("clock_gettime(MONOTONIC) failed");
|
bb_simple_error_msg_and_die("clock_gettime(MONOTONIC) failed");
|
||||||
}
|
}
|
||||||
unsigned long long FAST_FUNC monotonic_ns(void)
|
unsigned long long FAST_FUNC monotonic_ns(void)
|
||||||
{
|
{
|
||||||
|
@ -25,7 +25,7 @@ static void check_selinux_update_passwd(const char *username)
|
|||||||
return; /* No need to check */
|
return; /* No need to check */
|
||||||
|
|
||||||
if (getprevcon_raw(&context) < 0)
|
if (getprevcon_raw(&context) < 0)
|
||||||
bb_perror_msg_and_die("getprevcon failed");
|
bb_simple_perror_msg_and_die("getprevcon failed");
|
||||||
seuser = strtok(context, ":");
|
seuser = strtok(context, ":");
|
||||||
if (!seuser)
|
if (!seuser)
|
||||||
bb_error_msg_and_die("invalid context '%s'", context);
|
bb_error_msg_and_die("invalid context '%s'", context);
|
||||||
@ -42,7 +42,7 @@ static void check_selinux_update_passwd(const char *username)
|
|||||||
|
|
||||||
if (selinux_check_passwd_access(av) != 0)
|
if (selinux_check_passwd_access(av) != 0)
|
||||||
die:
|
die:
|
||||||
bb_error_msg_and_die("SELinux: access denied");
|
bb_simple_error_msg_and_die("SELinux: access denied");
|
||||||
}
|
}
|
||||||
if (ENABLE_FEATURE_CLEAN_UP)
|
if (ENABLE_FEATURE_CLEAN_UP)
|
||||||
freecon(context);
|
freecon(context);
|
||||||
|
@ -213,7 +213,7 @@ void FAST_FUNC read_base64(FILE *src_stream, FILE *dst_stream, int flags)
|
|||||||
if (*in_tail == '\0')
|
if (*in_tail == '\0')
|
||||||
return;
|
return;
|
||||||
/* No */
|
/* No */
|
||||||
bb_error_msg_and_die("truncated base64 input");
|
bb_simple_error_msg_and_die("truncated base64 input");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* It was partial decode */
|
/* It was partial decode */
|
||||||
|
@ -197,4 +197,19 @@ void FAST_FUNC bb_info_msg(const char *s, ...)
|
|||||||
bb_vinfo_msg(s, p);
|
bb_vinfo_msg(s, p);
|
||||||
va_end(p);
|
va_end(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FAST_FUNC bb_simple_info_msg(const char *s)
|
||||||
|
{
|
||||||
|
bb_info_msg("%s", s);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void FAST_FUNC bb_simple_error_msg(const char *s)
|
||||||
|
{
|
||||||
|
bb_error_msg("%s", s);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FAST_FUNC bb_simple_error_msg_and_die(const char *s)
|
||||||
|
{
|
||||||
|
bb_error_msg_and_die("%s", s);
|
||||||
|
}
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
void FAST_FUNC bb_warn_ignoring_args(char *arg)
|
void FAST_FUNC bb_warn_ignoring_args(char *arg)
|
||||||
{
|
{
|
||||||
if (arg) {
|
if (arg) {
|
||||||
bb_error_msg("ignoring all arguments");
|
bb_simple_error_msg("ignoring all arguments");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -66,7 +66,7 @@ int FAST_FUNC setsockopt_bindtodevice(int fd, const char *iface)
|
|||||||
int FAST_FUNC setsockopt_bindtodevice(int fd UNUSED_PARAM,
|
int FAST_FUNC setsockopt_bindtodevice(int fd UNUSED_PARAM,
|
||||||
const char *iface UNUSED_PARAM)
|
const char *iface UNUSED_PARAM)
|
||||||
{
|
{
|
||||||
bb_error_msg("SO_BINDTODEVICE is not supported on this system");
|
bb_simple_error_msg("SO_BINDTODEVICE is not supported on this system");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -109,7 +109,7 @@ void FAST_FUNC xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen)
|
|||||||
bb_perror_msg_and_die("%s (%s)",
|
bb_perror_msg_and_die("%s (%s)",
|
||||||
"can't connect to remote host",
|
"can't connect to remote host",
|
||||||
inet_ntoa(((struct sockaddr_in *)s_addr)->sin_addr));
|
inet_ntoa(((struct sockaddr_in *)s_addr)->sin_addr));
|
||||||
bb_perror_msg_and_die("can't connect to remote host");
|
bb_simple_perror_msg_and_die("can't connect to remote host");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,6 +426,6 @@ int FAST_FUNC wait_for_exitstatus(pid_t pid)
|
|||||||
|
|
||||||
n = safe_waitpid(pid, &exit_status, 0);
|
n = safe_waitpid(pid, &exit_status, 0);
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
bb_perror_msg_and_die("waitpid");
|
bb_simple_perror_msg_and_die("waitpid");
|
||||||
return exit_status;
|
return exit_status;
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
void FAST_FUNC bb_die_memory_exhausted(void)
|
void FAST_FUNC bb_die_memory_exhausted(void)
|
||||||
{
|
{
|
||||||
bb_error_msg_and_die(bb_msg_memory_exhausted);
|
bb_simple_error_msg_and_die(bb_msg_memory_exhausted);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef DMALLOC
|
#ifndef DMALLOC
|
||||||
@ -40,7 +40,7 @@ void* FAST_FUNC malloc_or_warn(size_t size)
|
|||||||
{
|
{
|
||||||
void *ptr = malloc(size);
|
void *ptr = malloc(size);
|
||||||
if (ptr == NULL && size != 0)
|
if (ptr == NULL && size != 0)
|
||||||
bb_error_msg(bb_msg_memory_exhausted);
|
bb_simple_error_msg(bb_msg_memory_exhausted);
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ char* FAST_FUNC xstrndup(const char *s, int n)
|
|||||||
char *t;
|
char *t;
|
||||||
|
|
||||||
if (ENABLE_DEBUG && s == NULL)
|
if (ENABLE_DEBUG && s == NULL)
|
||||||
bb_error_msg_and_die("xstrndup bug");
|
bb_simple_error_msg_and_die("xstrndup bug");
|
||||||
|
|
||||||
/* We can just xmalloc(n+1) and strncpy into it, */
|
/* We can just xmalloc(n+1) and strncpy into it, */
|
||||||
/* but think about xstrndup("abc", 10000) wastage! */
|
/* but think about xstrndup("abc", 10000) wastage! */
|
||||||
@ -215,13 +215,13 @@ int FAST_FUNC rename_or_warn(const char *oldpath, const char *newpath)
|
|||||||
void FAST_FUNC xpipe(int filedes[2])
|
void FAST_FUNC xpipe(int filedes[2])
|
||||||
{
|
{
|
||||||
if (pipe(filedes))
|
if (pipe(filedes))
|
||||||
bb_perror_msg_and_die("can't create pipe");
|
bb_simple_perror_msg_and_die("can't create pipe");
|
||||||
}
|
}
|
||||||
|
|
||||||
void FAST_FUNC xdup2(int from, int to)
|
void FAST_FUNC xdup2(int from, int to)
|
||||||
{
|
{
|
||||||
if (dup2(from, to) != to)
|
if (dup2(from, to) != to)
|
||||||
bb_perror_msg_and_die("can't duplicate file descriptor");
|
bb_simple_perror_msg_and_die("can't duplicate file descriptor");
|
||||||
// " %d to %d", from, to);
|
// " %d to %d", from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,7 +245,7 @@ void FAST_FUNC xwrite(int fd, const void *buf, size_t count)
|
|||||||
* or some writes succeeded, then we hit an error.
|
* or some writes succeeded, then we hit an error.
|
||||||
* In either case, errno is set.
|
* In either case, errno is set.
|
||||||
*/
|
*/
|
||||||
bb_perror_msg_and_die(
|
bb_simple_perror_msg_and_die(
|
||||||
size >= 0 ? "short write" : "write error"
|
size >= 0 ? "short write" : "write error"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -259,7 +259,7 @@ void FAST_FUNC xwrite_str(int fd, const char *str)
|
|||||||
void FAST_FUNC xclose(int fd)
|
void FAST_FUNC xclose(int fd)
|
||||||
{
|
{
|
||||||
if (close(fd))
|
if (close(fd))
|
||||||
bb_perror_msg_and_die("close failed");
|
bb_simple_perror_msg_and_die("close failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Die with an error message if we can't lseek to the right spot.
|
// Die with an error message if we can't lseek to the right spot.
|
||||||
@ -267,9 +267,7 @@ off_t FAST_FUNC xlseek(int fd, off_t offset, int whence)
|
|||||||
{
|
{
|
||||||
off_t off = lseek(fd, offset, whence);
|
off_t off = lseek(fd, offset, whence);
|
||||||
if (off == (off_t)-1) {
|
if (off == (off_t)-1) {
|
||||||
if (whence == SEEK_SET)
|
bb_perror_msg_and_die("lseek(%"OFF_FMT"u, %d)", offset, whence);
|
||||||
bb_perror_msg_and_die("lseek(%"OFF_FMT"u)", offset);
|
|
||||||
bb_perror_msg_and_die("lseek");
|
|
||||||
}
|
}
|
||||||
return off;
|
return off;
|
||||||
}
|
}
|
||||||
@ -384,23 +382,23 @@ void FAST_FUNC bb_unsetenv_and_free(char *var)
|
|||||||
// setgid() will fail and we'll _still_be_root_, which is bad.)
|
// setgid() will fail and we'll _still_be_root_, which is bad.)
|
||||||
void FAST_FUNC xsetgid(gid_t gid)
|
void FAST_FUNC xsetgid(gid_t gid)
|
||||||
{
|
{
|
||||||
if (setgid(gid)) bb_perror_msg_and_die("setgid");
|
if (setgid(gid)) bb_simple_perror_msg_and_die("setgid");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Die with an error message if we can't set uid. (See xsetgid() for why.)
|
// Die with an error message if we can't set uid. (See xsetgid() for why.)
|
||||||
void FAST_FUNC xsetuid(uid_t uid)
|
void FAST_FUNC xsetuid(uid_t uid)
|
||||||
{
|
{
|
||||||
if (setuid(uid)) bb_perror_msg_and_die("setuid");
|
if (setuid(uid)) bb_simple_perror_msg_and_die("setuid");
|
||||||
}
|
}
|
||||||
|
|
||||||
void FAST_FUNC xsetegid(gid_t egid)
|
void FAST_FUNC xsetegid(gid_t egid)
|
||||||
{
|
{
|
||||||
if (setegid(egid)) bb_perror_msg_and_die("setegid");
|
if (setegid(egid)) bb_simple_perror_msg_and_die("setegid");
|
||||||
}
|
}
|
||||||
|
|
||||||
void FAST_FUNC xseteuid(uid_t euid)
|
void FAST_FUNC xseteuid(uid_t euid)
|
||||||
{
|
{
|
||||||
if (seteuid(euid)) bb_perror_msg_and_die("seteuid");
|
if (seteuid(euid)) bb_simple_perror_msg_and_die("seteuid");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Die if we can't chdir to a new path.
|
// Die if we can't chdir to a new path.
|
||||||
@ -413,7 +411,7 @@ void FAST_FUNC xchdir(const char *path)
|
|||||||
void FAST_FUNC xfchdir(int fd)
|
void FAST_FUNC xfchdir(int fd)
|
||||||
{
|
{
|
||||||
if (fchdir(fd))
|
if (fchdir(fd))
|
||||||
bb_perror_msg_and_die("fchdir");
|
bb_simple_perror_msg_and_die("fchdir");
|
||||||
}
|
}
|
||||||
|
|
||||||
void FAST_FUNC xchroot(const char *path)
|
void FAST_FUNC xchroot(const char *path)
|
||||||
@ -463,7 +461,7 @@ int FAST_FUNC xsocket(int domain, int type, int protocol)
|
|||||||
IF_FEATURE_IPV6(if (domain == AF_INET6) s = "INET6";)
|
IF_FEATURE_IPV6(if (domain == AF_INET6) s = "INET6";)
|
||||||
bb_perror_msg_and_die("socket(AF_%s,%d,%d)", s, type, protocol);
|
bb_perror_msg_and_die("socket(AF_%s,%d,%d)", s, type, protocol);
|
||||||
#else
|
#else
|
||||||
bb_perror_msg_and_die("socket");
|
bb_simple_perror_msg_and_die("socket");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -473,13 +471,13 @@ IF_FEATURE_IPV6(if (domain == AF_INET6) s = "INET6";)
|
|||||||
// Die with an error message if we can't bind a socket to an address.
|
// Die with an error message if we can't bind a socket to an address.
|
||||||
void FAST_FUNC xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen)
|
void FAST_FUNC xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen)
|
||||||
{
|
{
|
||||||
if (bind(sockfd, my_addr, addrlen)) bb_perror_msg_and_die("bind");
|
if (bind(sockfd, my_addr, addrlen)) bb_simple_perror_msg_and_die("bind");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Die with an error message if we can't listen for connections on a socket.
|
// Die with an error message if we can't listen for connections on a socket.
|
||||||
void FAST_FUNC xlisten(int s, int backlog)
|
void FAST_FUNC xlisten(int s, int backlog)
|
||||||
{
|
{
|
||||||
if (listen(s, backlog)) bb_perror_msg_and_die("listen");
|
if (listen(s, backlog)) bb_simple_perror_msg_and_die("listen");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Die with an error message if sendto failed.
|
/* Die with an error message if sendto failed.
|
||||||
@ -491,7 +489,7 @@ ssize_t FAST_FUNC xsendto(int s, const void *buf, size_t len, const struct socka
|
|||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
if (ENABLE_FEATURE_CLEAN_UP)
|
if (ENABLE_FEATURE_CLEAN_UP)
|
||||||
close(s);
|
close(s);
|
||||||
bb_perror_msg_and_die("sendto");
|
bb_simple_perror_msg_and_die("sendto");
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -519,12 +517,12 @@ void FAST_FUNC selinux_or_die(void)
|
|||||||
#if ENABLE_SELINUX
|
#if ENABLE_SELINUX
|
||||||
int rc = is_selinux_enabled();
|
int rc = is_selinux_enabled();
|
||||||
if (rc == 0) {
|
if (rc == 0) {
|
||||||
bb_error_msg_and_die("SELinux is disabled");
|
bb_simple_error_msg_and_die("SELinux is disabled");
|
||||||
} else if (rc < 0) {
|
} else if (rc < 0) {
|
||||||
bb_error_msg_and_die("is_selinux_enabled() failed");
|
bb_simple_error_msg_and_die("is_selinux_enabled() failed");
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
bb_error_msg_and_die("SELinux support is disabled");
|
bb_simple_error_msg_and_die("SELinux support is disabled");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -675,7 +673,7 @@ pid_t FAST_FUNC xfork(void)
|
|||||||
pid_t pid;
|
pid_t pid;
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if (pid < 0) /* wtf? */
|
if (pid < 0) /* wtf? */
|
||||||
bb_perror_msg_and_die("vfork"+1);
|
bb_simple_perror_msg_and_die("vfork"+1);
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -33,7 +33,7 @@ xrealloc_getcwd_or_warn(char *cwd)
|
|||||||
if (errno == ERANGE)
|
if (errno == ERANGE)
|
||||||
continue;
|
continue;
|
||||||
free(cwd);
|
free(cwd);
|
||||||
bb_perror_msg("getcwd");
|
bb_simple_perror_msg("getcwd");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
cwd = xrealloc(cwd, strlen(cwd) + 1);
|
cwd = xrealloc(cwd, strlen(cwd) + 1);
|
||||||
|
@ -12,6 +12,6 @@ struct hostent* FAST_FUNC xgethostbyname(const char *name)
|
|||||||
{
|
{
|
||||||
struct hostent *retval = gethostbyname(name);
|
struct hostent *retval = gethostbyname(name);
|
||||||
if (!retval)
|
if (!retval)
|
||||||
bb_herror_msg_and_die("%s", name);
|
bb_simple_herror_msg_and_die(name);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ int addgroup_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
|
|
||||||
/* need to be root */
|
/* need to be root */
|
||||||
if (geteuid()) {
|
if (geteuid()) {
|
||||||
bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
|
bb_simple_error_msg_and_die(bb_msg_perm_denied_are_you_root);
|
||||||
}
|
}
|
||||||
/* Syntax:
|
/* Syntax:
|
||||||
* addgroup group
|
* addgroup group
|
||||||
|
@ -159,7 +159,7 @@ static void passwd_wrapper(const char *login_name) NORETURN;
|
|||||||
static void passwd_wrapper(const char *login_name)
|
static void passwd_wrapper(const char *login_name)
|
||||||
{
|
{
|
||||||
BB_EXECLP("passwd", "passwd", "--", login_name, NULL);
|
BB_EXECLP("passwd", "passwd", "--", login_name, NULL);
|
||||||
bb_error_msg_and_die("can't execute passwd, you must set password manually");
|
bb_simple_error_msg_and_die("can't execute passwd, you must set password manually");
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME: upstream adduser has no short options! NOT COMPATIBLE!
|
//FIXME: upstream adduser has no short options! NOT COMPATIBLE!
|
||||||
@ -193,7 +193,7 @@ int adduser_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
|
|
||||||
/* got root? */
|
/* got root? */
|
||||||
if (geteuid()) {
|
if (geteuid()) {
|
||||||
bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
|
bb_simple_error_msg_and_die(bb_msg_perm_denied_are_you_root);
|
||||||
}
|
}
|
||||||
|
|
||||||
pw.pw_gecos = (char *)"Linux User,,,";
|
pw.pw_gecos = (char *)"Linux User,,,";
|
||||||
|
@ -63,7 +63,7 @@ int chpasswd_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
int opt;
|
int opt;
|
||||||
|
|
||||||
if (getuid() != 0)
|
if (getuid() != 0)
|
||||||
bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
|
bb_simple_error_msg_and_die(bb_msg_perm_denied_are_you_root);
|
||||||
|
|
||||||
opt = getopt32long(argv, "^" "emc:R:" "\0" "m--ec:e--mc:c--em",
|
opt = getopt32long(argv, "^" "emc:R:" "\0" "m--ec:e--mc:c--em",
|
||||||
chpasswd_longopts,
|
chpasswd_longopts,
|
||||||
@ -81,7 +81,7 @@ int chpasswd_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
|
|
||||||
pass = strchr(name, ':');
|
pass = strchr(name, ':');
|
||||||
if (!pass)
|
if (!pass)
|
||||||
bb_error_msg_and_die("missing new password");
|
bb_simple_error_msg_and_die("missing new password");
|
||||||
*pass++ = '\0';
|
*pass++ = '\0';
|
||||||
|
|
||||||
xuname2uid(name); /* dies if there is no such user */
|
xuname2uid(name); /* dies if there is no such user */
|
||||||
|
@ -76,7 +76,7 @@ int deluser_main(int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (geteuid() != 0)
|
if (geteuid() != 0)
|
||||||
bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
|
bb_simple_error_msg_and_die(bb_msg_perm_denied_are_you_root);
|
||||||
|
|
||||||
name = argv[1];
|
name = argv[1];
|
||||||
member = NULL;
|
member = NULL;
|
||||||
|
@ -168,7 +168,7 @@ static void parse_speeds(char *arg)
|
|||||||
/* note: arg "0" turns into speed B0 */
|
/* note: arg "0" turns into speed B0 */
|
||||||
G.numspeed++;
|
G.numspeed++;
|
||||||
if (G.numspeed > MAX_SPEED)
|
if (G.numspeed > MAX_SPEED)
|
||||||
bb_error_msg_and_die("too many alternate speeds");
|
bb_simple_error_msg_and_die("too many alternate speeds");
|
||||||
}
|
}
|
||||||
debug("exiting parse_speeds\n");
|
debug("exiting parse_speeds\n");
|
||||||
}
|
}
|
||||||
@ -230,7 +230,7 @@ static void open_tty(void)
|
|||||||
* Make sure it is open for read/write.
|
* Make sure it is open for read/write.
|
||||||
*/
|
*/
|
||||||
if ((fcntl(0, F_GETFL) & (O_RDWR|O_RDONLY|O_WRONLY)) != O_RDWR)
|
if ((fcntl(0, F_GETFL) & (O_RDWR|O_RDONLY|O_WRONLY)) != O_RDWR)
|
||||||
bb_error_msg_and_die("stdin is not open for read/write");
|
bb_simple_error_msg_and_die("stdin is not open for read/write");
|
||||||
|
|
||||||
/* Try to get real tty name instead of "-" */
|
/* Try to get real tty name instead of "-" */
|
||||||
n = xmalloc_ttyname(0);
|
n = xmalloc_ttyname(0);
|
||||||
@ -243,7 +243,7 @@ static void open_tty(void)
|
|||||||
static void set_tty_attrs(void)
|
static void set_tty_attrs(void)
|
||||||
{
|
{
|
||||||
if (tcsetattr_stdin_TCSANOW(&G.tty_attrs) < 0)
|
if (tcsetattr_stdin_TCSANOW(&G.tty_attrs) < 0)
|
||||||
bb_perror_msg_and_die("tcsetattr");
|
bb_simple_perror_msg_and_die("tcsetattr");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We manipulate tty_attrs this way:
|
/* We manipulate tty_attrs this way:
|
||||||
@ -485,7 +485,7 @@ static char *get_logname(void)
|
|||||||
finalize_tty_attrs();
|
finalize_tty_attrs();
|
||||||
if (errno == EINTR || errno == EIO)
|
if (errno == EINTR || errno == EIO)
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
bb_perror_msg_and_die(bb_msg_read_error);
|
bb_simple_perror_msg_and_die(bb_msg_read_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
@ -582,7 +582,7 @@ int getty_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
// " sid %d pgid %d",
|
// " sid %d pgid %d",
|
||||||
// pid, getppid(),
|
// pid, getppid(),
|
||||||
// getsid(0), getpgid(0));
|
// getsid(0), getpgid(0));
|
||||||
bb_perror_msg_and_die("setsid");
|
bb_simple_perror_msg_and_die("setsid");
|
||||||
/*
|
/*
|
||||||
* When we can end up here?
|
* When we can end up here?
|
||||||
* Example: setsid() fails when run alone in interactive shell:
|
* Example: setsid() fails when run alone in interactive shell:
|
||||||
@ -651,13 +651,13 @@ int getty_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
tsid = tcgetsid(STDIN_FILENO);
|
tsid = tcgetsid(STDIN_FILENO);
|
||||||
if (tsid < 0 || pid != tsid) {
|
if (tsid < 0 || pid != tsid) {
|
||||||
if (ioctl(STDIN_FILENO, TIOCSCTTY, /*force:*/ (long)1) < 0)
|
if (ioctl(STDIN_FILENO, TIOCSCTTY, /*force:*/ (long)1) < 0)
|
||||||
bb_perror_msg_and_die("TIOCSCTTY");
|
bb_simple_perror_msg_and_die("TIOCSCTTY");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
/* Make ourself a foreground process group within our session */
|
/* Make ourself a foreground process group within our session */
|
||||||
if (tcsetpgrp(STDIN_FILENO, pid) < 0)
|
if (tcsetpgrp(STDIN_FILENO, pid) < 0)
|
||||||
bb_perror_msg_and_die("tcsetpgrp");
|
bb_simple_perror_msg_and_die("tcsetpgrp");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -669,7 +669,7 @@ int getty_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
* 5 seconds seems to be a good value.
|
* 5 seconds seems to be a good value.
|
||||||
*/
|
*/
|
||||||
if (tcgetattr(STDIN_FILENO, &G.tty_attrs) < 0)
|
if (tcgetattr(STDIN_FILENO, &G.tty_attrs) < 0)
|
||||||
bb_perror_msg_and_die("tcgetattr");
|
bb_simple_perror_msg_and_die("tcgetattr");
|
||||||
|
|
||||||
/* Update the utmp file. This tty is ours now! */
|
/* Update the utmp file. This tty is ours now! */
|
||||||
update_utmp(pid, LOGIN_PROCESS, G.tty_name, "LOGIN", G.fakehost);
|
update_utmp(pid, LOGIN_PROCESS, G.tty_name, "LOGIN", G.fakehost);
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user