Compare commits
6
Commits
master
...
1_7_stable
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de15bb931a | ||
|
|
cf24d29529 | ||
|
|
fa3f806cd0 | ||
|
|
43f0a0bb3a | ||
|
|
e755e827f7 | ||
|
|
ed6ac53104 |
No files matched your search
@@ -1,7 +1,7 @@
|
||||
VERSION = 1
|
||||
PATCHLEVEL = 7
|
||||
SUBLEVEL = 0
|
||||
EXTRAVERSION = .svn
|
||||
SUBLEVEL = 5
|
||||
EXTRAVERSION =
|
||||
NAME = Unnamed
|
||||
|
||||
# *DOCUMENTATION*
|
||||
|
||||
+3
-4
@@ -546,7 +546,7 @@ static int busybox_main(char **argv)
|
||||
help:
|
||||
output_width = 80;
|
||||
if (ENABLE_FEATURE_AUTOWIDTH) {
|
||||
/* Obtain the terminal width. */
|
||||
/* Obtain the terminal width */
|
||||
get_terminal_width_height(0, &output_width, NULL);
|
||||
}
|
||||
/* leading tab and room to wrap */
|
||||
@@ -580,12 +580,11 @@ static int busybox_main(char **argv)
|
||||
|
||||
if (ENABLE_FEATURE_INSTALLER && strcmp(argv[1], "--install") == 0) {
|
||||
const char *busybox;
|
||||
busybox = xmalloc_readlink_or_warn(bb_busybox_exec_path);
|
||||
busybox = xmalloc_readlink(bb_busybox_exec_path);
|
||||
if (!busybox)
|
||||
busybox = bb_busybox_exec_path;
|
||||
/* -s makes symlinks */
|
||||
install_links(busybox,
|
||||
argv[2] && strcmp(argv[2], "-s") == 0);
|
||||
install_links(busybox, argv[2] && strcmp(argv[2], "-s") == 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -298,7 +298,7 @@ USE_DESKTOP(long long) int unpack_unlzma(void)
|
||||
int unlzma_main(int argc, char **argv);
|
||||
int unlzma_main(int argc, char **argv)
|
||||
{
|
||||
getopt32(argv, "c");
|
||||
getopt32(argv, "cf");
|
||||
argv += optind;
|
||||
/* lzmacat? */
|
||||
if (applet_name[4] == 'c')
|
||||
|
||||
@@ -35,36 +35,34 @@ DPKG_FILES:= \
|
||||
get_header_tar.o \
|
||||
filter_accept_list_reassign.o
|
||||
|
||||
# open_transformer uses fork(). Compile it only if absolutely necessary
|
||||
lib-$(CONFIG_RPM) += open_transformer.o
|
||||
lib-$(CONFIG_FEATURE_TAR_BZIP2) += open_transformer.o
|
||||
lib-$(CONFIG_FEATURE_TAR_LZMA) += open_transformer.o
|
||||
lib-$(CONFIG_FEATURE_TAR_GZIP) += open_transformer.o
|
||||
lib-$(CONFIG_FEATURE_TAR_COMPRESS) += open_transformer.o
|
||||
lib-$(CONFIG_FEATURE_DEB_TAR_GZ) += open_transformer.o
|
||||
lib-$(CONFIG_FEATURE_DEB_TAR_BZ2) += open_transformer.o
|
||||
lib-$(CONFIG_FEATURE_DEB_TAR_LZMA) += open_transformer.o
|
||||
|
||||
lib-$(CONFIG_AR) += get_header_ar.o unpack_ar_archive.o
|
||||
lib-$(CONFIG_BUNZIP2) += decompress_bunzip2.o
|
||||
lib-$(CONFIG_UNLZMA) += decompress_unlzma.o
|
||||
lib-$(CONFIG_CPIO) += get_header_cpio.o
|
||||
lib-$(CONFIG_DPKG) += $(DPKG_FILES)
|
||||
lib-$(CONFIG_DPKG_DEB) += $(DPKG_FILES)
|
||||
lib-$(CONFIG_FEATURE_DEB_TAR_GZ) += $(GUNZIP_FILES) get_header_tar_gz.o
|
||||
lib-$(CONFIG_FEATURE_DEB_TAR_BZ2) += decompress_bunzip2.o get_header_tar_bz2.o
|
||||
lib-$(CONFIG_FEATURE_DEB_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
|
||||
lib-$(CONFIG_GUNZIP) += $(GUNZIP_FILES)
|
||||
lib-$(CONFIG_FEATURE_GUNZIP_UNCOMPRESS) += decompress_uncompress.o
|
||||
lib-$(CONFIG_RPM2CPIO) += $(GUNZIP_FILES) get_header_cpio.o
|
||||
lib-$(CONFIG_RPM) += $(GUNZIP_FILES) get_header_cpio.o
|
||||
lib-$(CONFIG_FEATURE_RPM_BZ2) += decompress_bunzip2.o
|
||||
lib-$(CONFIG_TAR) += get_header_tar.o
|
||||
lib-$(CONFIG_FEATURE_TAR_BZIP2) += decompress_bunzip2.o get_header_tar_bz2.o
|
||||
lib-$(CONFIG_FEATURE_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
|
||||
lib-$(CONFIG_FEATURE_TAR_GZIP) += $(GUNZIP_FILES) get_header_tar_gz.o
|
||||
lib-$(CONFIG_FEATURE_TAR_COMPRESS) += decompress_uncompress.o
|
||||
lib-$(CONFIG_UNCOMPRESS) += decompress_uncompress.o
|
||||
lib-$(CONFIG_UNZIP) += $(GUNZIP_FILES)
|
||||
lib-$(CONFIG_FEATURE_COMPRESS_USAGE) += decompress_bunzip2.o
|
||||
lib-$(CONFIG_FEATURE_TAR_BZIP2) += open_transformer.o
|
||||
lib-$(CONFIG_FEATURE_TAR_LZMA) += open_transformer.o
|
||||
lib-$(CONFIG_FEATURE_TAR_GZIP) += open_transformer.o
|
||||
lib-$(CONFIG_FEATURE_TAR_COMPRESS) += open_transformer.o
|
||||
lib-$(CONFIG_FEATURE_DEB_TAR_GZ) += open_transformer.o
|
||||
lib-$(CONFIG_FEATURE_DEB_TAR_BZ2) += open_transformer.o
|
||||
lib-$(CONFIG_FEATURE_DEB_TAR_LZMA) += open_transformer.o
|
||||
|
||||
lib-$(CONFIG_AR) += get_header_ar.o unpack_ar_archive.o
|
||||
lib-$(CONFIG_BUNZIP2) += decompress_bunzip2.o
|
||||
lib-$(CONFIG_UNLZMA) += decompress_unlzma.o
|
||||
lib-$(CONFIG_CPIO) += get_header_cpio.o
|
||||
lib-$(CONFIG_DPKG) += $(DPKG_FILES)
|
||||
lib-$(CONFIG_DPKG_DEB) += $(DPKG_FILES)
|
||||
lib-$(CONFIG_FEATURE_DEB_TAR_GZ) += $(GUNZIP_FILES) get_header_tar_gz.o
|
||||
lib-$(CONFIG_FEATURE_DEB_TAR_BZ2) += decompress_bunzip2.o get_header_tar_bz2.o
|
||||
lib-$(CONFIG_FEATURE_DEB_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
|
||||
lib-$(CONFIG_GUNZIP) += $(GUNZIP_FILES)
|
||||
lib-$(CONFIG_FEATURE_GUNZIP_UNCOMPRESS) += decompress_uncompress.o
|
||||
lib-$(CONFIG_RPM2CPIO) += $(GUNZIP_FILES) get_header_cpio.o
|
||||
lib-$(CONFIG_RPM) += $(GUNZIP_FILES) get_header_cpio.o
|
||||
lib-$(CONFIG_FEATURE_RPM_BZ2) += decompress_bunzip2.o
|
||||
lib-$(CONFIG_TAR) += get_header_tar.o
|
||||
lib-$(CONFIG_FEATURE_TAR_BZIP2) += decompress_bunzip2.o get_header_tar_bz2.o
|
||||
lib-$(CONFIG_FEATURE_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
|
||||
lib-$(CONFIG_FEATURE_TAR_GZIP) += $(GUNZIP_FILES) get_header_tar_gz.o
|
||||
lib-$(CONFIG_FEATURE_TAR_COMPRESS) += decompress_uncompress.o
|
||||
lib-$(CONFIG_UNCOMPRESS) += decompress_uncompress.o
|
||||
lib-$(CONFIG_UNZIP) += $(GUNZIP_FILES)
|
||||
lib-$(CONFIG_FEATURE_COMPRESS_USAGE) += decompress_bunzip2.o
|
||||
@@ -11,7 +11,7 @@ char get_header_tar_bz2(archive_handle_t *archive_handle)
|
||||
/* Can't lseek over pipes */
|
||||
archive_handle->seek = seek_by_read;
|
||||
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_bz2_stream);
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_bz2_stream, "bunzip2", "bunzip2", "-cf", "-", NULL);
|
||||
archive_handle->offset = 0;
|
||||
while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/;
|
||||
|
||||
|
||||
@@ -8,19 +8,26 @@
|
||||
|
||||
char get_header_tar_gz(archive_handle_t *archive_handle)
|
||||
{
|
||||
#if BB_MMU
|
||||
unsigned char magic[2];
|
||||
#endif
|
||||
|
||||
/* Can't lseek over pipes */
|
||||
archive_handle->seek = seek_by_read;
|
||||
|
||||
/* Check gzip magic only if open_transformer will invoke unpack_gz_stream (MMU case).
|
||||
* Otherwise, it will invoke an external helper "gunzip -cf" (NOMMU case) which will
|
||||
* need the header. */
|
||||
#if BB_MMU
|
||||
xread(archive_handle->src_fd, &magic, 2);
|
||||
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
|
||||
bb_error_msg_and_die("invalid gzip magic");
|
||||
}
|
||||
|
||||
check_header_gzip_or_die(archive_handle->src_fd);
|
||||
#endif
|
||||
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_gz_stream);
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_gz_stream, "gunzip", "gunzip", "-cf", "-", NULL);
|
||||
archive_handle->offset = 0;
|
||||
while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ char get_header_tar_lzma(archive_handle_t * archive_handle)
|
||||
/* Can't lseek over pipes */
|
||||
archive_handle->seek = seek_by_read;
|
||||
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_lzma_stream);
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_lzma_stream, "unlzma", "unlzma", "-cf", "-", NULL);
|
||||
archive_handle->offset = 0;
|
||||
while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/;
|
||||
|
||||
|
||||
@@ -7,27 +7,48 @@
|
||||
#include "unarchive.h"
|
||||
|
||||
/* transformer(), more than meets the eye */
|
||||
/*
|
||||
* On MMU machine, the transform_prog and ... are stripped
|
||||
* by a macro in include/unarchive.h. On NOMMU, transformer is stripped.
|
||||
*/
|
||||
int open_transformer(int src_fd,
|
||||
USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd))
|
||||
USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd),
|
||||
const char *transform_prog, ...)
|
||||
{
|
||||
int fd_pipe[2];
|
||||
int pid;
|
||||
|
||||
xpipe(fd_pipe);
|
||||
|
||||
#if BB_MMU
|
||||
pid = fork();
|
||||
if (pid == -1) {
|
||||
#else
|
||||
pid = vfork();
|
||||
#endif
|
||||
if (pid == -1)
|
||||
bb_perror_msg_and_die("fork failed");
|
||||
}
|
||||
|
||||
if (pid == 0) {
|
||||
#if !BB_MMU
|
||||
va_list ap;
|
||||
#endif
|
||||
/* child process */
|
||||
close(fd_pipe[0]); /* We don't wan't to read from the parent */
|
||||
// FIXME: error check?
|
||||
#if BB_MMU
|
||||
transformer(src_fd, fd_pipe[1]);
|
||||
close(fd_pipe[1]); /* Send EOF */
|
||||
close(src_fd);
|
||||
if (ENABLE_FEATURE_CLEAN_UP) {
|
||||
close(fd_pipe[1]); /* Send EOF */
|
||||
close(src_fd);
|
||||
}
|
||||
exit(0);
|
||||
#else
|
||||
xmove_fd(src_fd, 0);
|
||||
xmove_fd(fd_pipe[1], 1);
|
||||
va_start(ap, transform_prog);
|
||||
BB_EXECVP(transform_prog, ap);
|
||||
bb_perror_and_die("exec failed");
|
||||
#endif
|
||||
/* notreached */
|
||||
}
|
||||
|
||||
|
||||
+23
-3
@@ -187,9 +187,15 @@ int rpm_main(int argc, char **argv)
|
||||
|
||||
static void extract_cpio_gz(int fd)
|
||||
{
|
||||
USE_DESKTOP(long long) int (*xformer)(int src_fd, int dst_fd);
|
||||
archive_handle_t *archive_handle;
|
||||
unsigned char magic[2];
|
||||
#if BB_MMU
|
||||
USE_DESKTOP(long long) int (*xformer)(int src_fd, int dst_fd);
|
||||
enum { xformer_prog = 0 };
|
||||
#else
|
||||
enum { xformer = 0 };
|
||||
const char *xformer_prog;
|
||||
#endif
|
||||
|
||||
/* Initialize */
|
||||
archive_handle = init_handle();
|
||||
@@ -202,11 +208,19 @@ static void extract_cpio_gz(int fd)
|
||||
archive_handle->offset = 0;
|
||||
|
||||
xread(archive_handle->src_fd, &magic, 2);
|
||||
#if BB_MMU
|
||||
xformer = unpack_gz_stream;
|
||||
#else
|
||||
xformer_prog = "gunzip";
|
||||
#endif
|
||||
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
|
||||
if (ENABLE_FEATURE_RPM_BZ2
|
||||
&& (magic[0] == 0x42) && (magic[1] == 0x5a)) {
|
||||
#if BB_MMU
|
||||
xformer = unpack_bz2_stream;
|
||||
#else
|
||||
xformer_prog = "bunzip2";
|
||||
#endif
|
||||
/* We can do better, need modifying unpack_bz2_stream to not require
|
||||
* first 2 bytes. Not very hard to do... I mean, TODO :) */
|
||||
xlseek(archive_handle->src_fd, -2, SEEK_CUR);
|
||||
@@ -214,11 +228,17 @@ static void extract_cpio_gz(int fd)
|
||||
bb_error_msg_and_die("no gzip"
|
||||
USE_FEATURE_RPM_BZ2("/bzip")
|
||||
" magic");
|
||||
} else
|
||||
} else {
|
||||
check_header_gzip_or_die(archive_handle->src_fd);
|
||||
#if !BB_MMU
|
||||
/* NOMMU version of open_transformer execs an external unzipper that should
|
||||
* have the file position at the start of the file */
|
||||
xlseek(archive_handle->src_fd, 0, SEEK_SET);
|
||||
#endif
|
||||
}
|
||||
|
||||
xchdir("/"); /* Install RPM's to root */
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, xformer);
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, xformer, xformer_prog, xformer_prog, "-cf", "-", NULL);
|
||||
archive_handle->offset = 0;
|
||||
while (get_header_cpio(archive_handle) == EXIT_SUCCESS)
|
||||
continue;
|
||||
|
||||
+1
-1
@@ -648,7 +648,7 @@ static char get_header_tar_Z(archive_handle_t *archive_handle)
|
||||
bb_error_msg_and_die("invalid magic");
|
||||
}
|
||||
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, uncompress);
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, uncompress, "uncompress", "uncompress", "-cf", "-", NULL);
|
||||
archive_handle->offset = 0;
|
||||
while (get_header_tar(archive_handle) == EXIT_SUCCESS)
|
||||
/* nothing */;
|
||||
|
||||
+69
-53
@@ -1,6 +1,6 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Copyright (C) 2003 by Glenn McGrath <bug1@iinet.net.au>
|
||||
* Copyright (C) 2003 by Glenn McGrath
|
||||
* SELinux support: by Yuichi Nakamura <ynakam@hitachisoft.jp>
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
@@ -23,6 +23,8 @@ static const char install_longopts[] ALIGN1 =
|
||||
"group\0" No_argument "g"
|
||||
"mode\0" No_argument "m"
|
||||
"owner\0" No_argument "o"
|
||||
/* autofs build insists of using -b --suffix=.orig */
|
||||
/* TODO? (short option for --suffix is -S) */
|
||||
#if ENABLE_SELINUX
|
||||
"context\0" Required_argument "Z"
|
||||
"preserve_context\0" No_argument "\xff"
|
||||
@@ -33,8 +35,6 @@ static const char install_longopts[] ALIGN1 =
|
||||
|
||||
|
||||
#if ENABLE_SELINUX
|
||||
static bool use_default_selinux_context = 1;
|
||||
|
||||
static void setdefaultfilecon(const char *path)
|
||||
{
|
||||
struct stat s;
|
||||
@@ -73,25 +73,31 @@ int install_main(int argc, char **argv)
|
||||
mode_t mode;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
char *arg, *last;
|
||||
const char *gid_str;
|
||||
const char *uid_str;
|
||||
const char *mode_str;
|
||||
int copy_flags = FILEUTILS_DEREFERENCE | FILEUTILS_FORCE;
|
||||
int ret = EXIT_SUCCESS, flags, i, isdir;
|
||||
int flags;
|
||||
int ret = EXIT_SUCCESS;
|
||||
int isdir;
|
||||
#if ENABLE_SELINUX
|
||||
security_context_t scontext;
|
||||
bool use_default_selinux_context = 1;
|
||||
#endif
|
||||
enum {
|
||||
OPT_CMD = 0x1,
|
||||
OPT_DIRECTORY = 0x2,
|
||||
OPT_PRESERVE_TIME = 0x4,
|
||||
OPT_STRIP = 0x8,
|
||||
OPT_GROUP = 0x10,
|
||||
OPT_MODE = 0x20,
|
||||
OPT_OWNER = 0x40,
|
||||
OPT_c = 1 << 0,
|
||||
OPT_v = 1 << 1,
|
||||
OPT_b = 1 << 2,
|
||||
OPT_DIRECTORY = 1 << 3,
|
||||
OPT_PRESERVE_TIME = 1 << 4,
|
||||
OPT_STRIP = 1 << 5,
|
||||
OPT_GROUP = 1 << 6,
|
||||
OPT_MODE = 1 << 7,
|
||||
OPT_OWNER = 1 << 8,
|
||||
#if ENABLE_SELINUX
|
||||
OPT_SET_SECURITY_CONTEXT = 0x80,
|
||||
OPT_PRESERVE_SECURITY_CONTEXT = 0x100,
|
||||
OPT_SET_SECURITY_CONTEXT = 1 << 9,
|
||||
OPT_PRESERVE_SECURITY_CONTEXT = 1 << 10,
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -100,21 +106,24 @@ int install_main(int argc, char **argv)
|
||||
#endif
|
||||
opt_complementary = "s--d:d--s" USE_SELINUX(":Z--\xff:\xff--Z");
|
||||
/* -c exists for backwards compatibility, it's needed */
|
||||
|
||||
flags = getopt32(argv, "cdpsg:m:o:" USE_SELINUX("Z:"),
|
||||
/* -v is ignored ("print name of each created directory") */
|
||||
/* -b is ignored ("make a backup of each existing destination file") */
|
||||
flags = getopt32(argv, "cvb" "dpsg:m:o:" USE_SELINUX("Z:"),
|
||||
&gid_str, &mode_str, &uid_str USE_SELINUX(, &scontext));
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
#if ENABLE_SELINUX
|
||||
if (flags & OPT_PRESERVE_SECURITY_CONTEXT) {
|
||||
use_default_selinux_context = 0;
|
||||
copy_flags |= FILEUTILS_PRESERVE_SECURITY_CONTEXT;
|
||||
if (flags & (OPT_PRESERVE_SECURITY_CONTEXT|OPT_SET_SECURITY_CONTEXT)) {
|
||||
selinux_or_die();
|
||||
}
|
||||
if (flags & OPT_SET_SECURITY_CONTEXT) {
|
||||
selinux_or_die();
|
||||
setfscreatecon_or_die(scontext);
|
||||
use_default_selinux_context = 0;
|
||||
copy_flags |= FILEUTILS_SET_SECURITY_CONTEXT;
|
||||
if (flags & OPT_PRESERVE_SECURITY_CONTEXT) {
|
||||
copy_flags |= FILEUTILS_PRESERVE_SECURITY_CONTEXT;
|
||||
}
|
||||
if (flags & OPT_SET_SECURITY_CONTEXT) {
|
||||
setfscreatecon_or_die(scontext);
|
||||
copy_flags |= FILEUTILS_SET_SECURITY_CONTEXT;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -123,58 +132,63 @@ int install_main(int argc, char **argv)
|
||||
copy_flags |= FILEUTILS_PRESERVE_STATUS;
|
||||
}
|
||||
mode = 0666;
|
||||
if (flags & OPT_MODE) bb_parse_mode(mode_str, &mode);
|
||||
if (flags & OPT_MODE)
|
||||
bb_parse_mode(mode_str, &mode);
|
||||
uid = (flags & OPT_OWNER) ? get_ug_id(uid_str, xuname2uid) : getuid();
|
||||
gid = (flags & OPT_GROUP) ? get_ug_id(gid_str, xgroup2gid) : getgid();
|
||||
if (flags & (OPT_OWNER|OPT_GROUP)) umask(0);
|
||||
if (flags & (OPT_OWNER|OPT_GROUP))
|
||||
umask(0);
|
||||
|
||||
/* Create directories
|
||||
* don't use bb_make_directory() as it can't change uid or gid
|
||||
* perhaps bb_make_directory() should be improved.
|
||||
*/
|
||||
if (flags & OPT_DIRECTORY) {
|
||||
for (argv += optind; *argv; argv++) {
|
||||
char *old_argv_ptr = *argv + 1;
|
||||
char *argv_ptr;
|
||||
do {
|
||||
argv_ptr = strchr(old_argv_ptr, '/');
|
||||
old_argv_ptr = argv_ptr;
|
||||
if (argv_ptr) {
|
||||
*argv_ptr = '\0';
|
||||
old_argv_ptr++;
|
||||
}
|
||||
if (mkdir(*argv, mode | 0111) == -1) {
|
||||
while ((arg = *argv++) != NULL) {
|
||||
char *slash = arg;
|
||||
while (1) {
|
||||
slash = strchr(slash + 1, '/');
|
||||
if (slash)
|
||||
*slash = '\0';
|
||||
if (mkdir(arg, mode | 0111) == -1) {
|
||||
if (errno != EEXIST) {
|
||||
bb_perror_msg("cannot create %s", *argv);
|
||||
bb_perror_msg("cannot create %s", arg);
|
||||
ret = EXIT_FAILURE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((flags & (OPT_OWNER|OPT_GROUP))
|
||||
&& lchown(*argv, uid, gid) == -1
|
||||
} /* dir was created, chown? */
|
||||
else if ((flags & (OPT_OWNER|OPT_GROUP))
|
||||
&& lchown(arg, uid, gid) == -1
|
||||
) {
|
||||
bb_perror_msg("cannot change ownership of %s", *argv);
|
||||
bb_perror_msg("cannot change ownership of %s", arg);
|
||||
ret = EXIT_FAILURE;
|
||||
break;
|
||||
}
|
||||
if (argv_ptr) {
|
||||
*argv_ptr = '/';
|
||||
}
|
||||
} while (old_argv_ptr);
|
||||
if (!slash)
|
||||
break;
|
||||
*slash = '/';
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (argc < 2)
|
||||
bb_show_usage();
|
||||
|
||||
last = argv[argc - 1];
|
||||
argv[argc - 1] = NULL;
|
||||
/* coreutils install resolves link in this case, don't use lstat */
|
||||
isdir = stat(argv[argc - 1], &statbuf) < 0 ? 0 : S_ISDIR(statbuf.st_mode);
|
||||
isdir = stat(last, &statbuf) < 0 ? 0 : S_ISDIR(statbuf.st_mode);
|
||||
|
||||
for (i = optind; i < argc - 1; i++) {
|
||||
char *dest;
|
||||
|
||||
dest = argv[argc - 1];
|
||||
while ((arg = *argv++) != NULL) {
|
||||
char *dest = last;
|
||||
if (isdir)
|
||||
dest = concat_path_file(argv[argc - 1], basename(argv[i]));
|
||||
ret |= copy_file(argv[i], dest, copy_flags);
|
||||
dest = concat_path_file(last, basename(arg));
|
||||
if (copy_file(arg, dest, copy_flags)) {
|
||||
/* copy is not made */
|
||||
ret = EXIT_FAILURE;
|
||||
goto next;
|
||||
}
|
||||
|
||||
/* Set the file mode */
|
||||
if ((flags & OPT_MODE) && chmod(dest, mode) == -1) {
|
||||
@@ -202,7 +216,9 @@ int install_main(int argc, char **argv)
|
||||
ret = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
if (ENABLE_FEATURE_CLEAN_UP && isdir) free(dest);
|
||||
next:
|
||||
if (ENABLE_FEATURE_CLEAN_UP && isdir)
|
||||
free(dest);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
+14
-7
@@ -47,13 +47,16 @@ static void tail_xprint_header(const char *fmt, const char *filename)
|
||||
static ssize_t tail_read(int fd, char *buf, size_t count)
|
||||
{
|
||||
ssize_t r;
|
||||
off_t current, end;
|
||||
off_t current;
|
||||
struct stat sbuf;
|
||||
|
||||
end = current = lseek(fd, 0, SEEK_CUR);
|
||||
if (!fstat(fd, &sbuf))
|
||||
end = sbuf.st_size;
|
||||
lseek(fd, end < current ? 0 : current, SEEK_SET);
|
||||
/* (A good comment is missing here) */
|
||||
current = lseek(fd, 0, SEEK_CUR);
|
||||
/* /proc files report zero st_size, don't lseek them. */
|
||||
if (fstat(fd, &sbuf) == 0 && sbuf.st_size)
|
||||
if (sbuf.st_size < current)
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
|
||||
r = safe_read(fd, buf, count);
|
||||
if (r < 0) {
|
||||
bb_perror_msg(bb_msg_read_error);
|
||||
@@ -67,8 +70,12 @@ static const char header_fmt[] ALIGN1 = "\n==> %s <==\n";
|
||||
|
||||
static unsigned eat_num(const char *p)
|
||||
{
|
||||
if (*p == '-') p++;
|
||||
else if (*p == '+') { p++; G.status = EXIT_FAILURE; }
|
||||
if (*p == '-')
|
||||
p++;
|
||||
else if (*p == '+') {
|
||||
p++;
|
||||
G.status = EXIT_FAILURE;
|
||||
}
|
||||
return xatou_sfx(p, tail_suffixes);
|
||||
}
|
||||
|
||||
|
||||
+4
-2
@@ -383,9 +383,11 @@ static int fileAction(const char *fileName, struct stat *statbuf, void *userData
|
||||
#if ENABLE_FEATURE_FIND_XDEV
|
||||
if (S_ISDIR(statbuf->st_mode) && xdev_count) {
|
||||
for (i = 0; i < xdev_count; i++) {
|
||||
if (xdev_dev[i] != statbuf->st_dev)
|
||||
return SKIP;
|
||||
if (xdev_dev[i] == statbuf->st_dev)
|
||||
break;
|
||||
}
|
||||
if (i == xdev_count)
|
||||
return SKIP;
|
||||
}
|
||||
#endif
|
||||
i = exec_actions(actions, fileName, statbuf);
|
||||
|
||||
+11
-4
@@ -154,14 +154,14 @@ static int grep_file(FILE *file)
|
||||
|
||||
while ((line = xmalloc_getline(file)) != NULL) {
|
||||
llist_t *pattern_ptr = pattern_head;
|
||||
grep_list_data_t * gl;
|
||||
grep_list_data_t *gl = gl; /* for gcc */
|
||||
|
||||
linenum++;
|
||||
ret = 0;
|
||||
while (pattern_ptr) {
|
||||
gl = (grep_list_data_t *)pattern_ptr->data;
|
||||
if (FGREP_FLAG) {
|
||||
ret = strstr(line, gl->pattern) != NULL;
|
||||
ret |= (strstr(line, gl->pattern) != NULL);
|
||||
} else {
|
||||
/*
|
||||
* test for a postitive-assertion match (regexec returns success (0)
|
||||
@@ -255,8 +255,15 @@ static int grep_file(FILE *file)
|
||||
print_n_lines_after = lines_after;
|
||||
#endif
|
||||
if (option_mask32 & OPT_o) {
|
||||
line[regmatch.rm_eo] = '\0';
|
||||
print_line(line + regmatch.rm_so, linenum, ':');
|
||||
if (FGREP_FLAG) {
|
||||
/* -Fo just prints the pattern
|
||||
* (unless -v: -Fov doesnt print anything at all) */
|
||||
if (ret)
|
||||
print_line(gl->pattern, linenum, ':');
|
||||
} else {
|
||||
line[regmatch.rm_eo] = '\0';
|
||||
print_line(line + regmatch.rm_so, linenum, ':');
|
||||
}
|
||||
} else {
|
||||
print_line(line, linenum, ':');
|
||||
}
|
||||
|
||||
+6
-5
@@ -248,9 +248,10 @@ void xmove_fd(int, int);
|
||||
DIR *xopendir(const char *path);
|
||||
DIR *warn_opendir(const char *path);
|
||||
|
||||
char *xrealloc_getcwd_or_warn(char *cwd);
|
||||
/* UNUSED: char *xmalloc_realpath(const char *path); */
|
||||
char *xmalloc_readlink(const char *path);
|
||||
char *xmalloc_readlink_or_warn(const char *path);
|
||||
char *xmalloc_realpath(const char *path);
|
||||
char *xrealloc_getcwd_or_warn(char *cwd);
|
||||
|
||||
|
||||
//TODO: signal(sid, f) is the same? then why?
|
||||
@@ -316,8 +317,8 @@ enum {
|
||||
};
|
||||
/* Create stream socket, and allocate suitable lsa.
|
||||
* (lsa of correct size and lsa->sa.sa_family (AF_INET/AF_INET6))
|
||||
* af == AF_UNSPEC will result in trying to create IPv6, and
|
||||
* if kernel doesn't support it, IPv4.
|
||||
* af == AF_UNSPEC will result in trying to create IPv6 socket,
|
||||
* and if kernel doesn't support it, IPv4.
|
||||
*/
|
||||
int xsocket_type(len_and_sockaddr **lsap, USE_FEATURE_IPV6(int af,) int sock_type);
|
||||
int xsocket_stream(len_and_sockaddr **lsap);
|
||||
@@ -775,7 +776,7 @@ char *bb_simplify_path(const char *path);
|
||||
extern void bb_do_delay(int seconds);
|
||||
extern void change_identity(const struct passwd *pw);
|
||||
extern const char *change_identity_e2str(const struct passwd *pw);
|
||||
extern void run_shell(const char *shell, int loginshell, const char *command, const char **additional_args);
|
||||
extern void run_shell(const char *shell, int loginshell, const char *command, const char **additional_args) ATTRIBUTE_NORETURN;
|
||||
#if ENABLE_SELINUX
|
||||
extern void renew_current_security_context(void);
|
||||
extern void set_current_security_context(security_context_t sid);
|
||||
|
||||
@@ -115,7 +115,13 @@ extern USE_DESKTOP(long long) int inflate_unzip(inflate_unzip_result *res, unsig
|
||||
extern USE_DESKTOP(long long) int unpack_gz_stream(int src_fd, int dst_fd);
|
||||
extern USE_DESKTOP(long long) int unpack_lzma_stream(int src_fd, int dst_fd);
|
||||
|
||||
#if BB_MMU
|
||||
extern int open_transformer(int src_fd,
|
||||
USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd));
|
||||
#define open_transformer(src_fd, transformer, transform_prog, ...) open_transformer(src_fd, transformer)
|
||||
#else
|
||||
extern int open_transformer(int src_fd, const char *transform_prog, ...);
|
||||
#define open_transformer(src_fd, transformer, transform_prog, ...) open_transformer(src_fd, transform_prog, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+111
-84
@@ -19,28 +19,31 @@
|
||||
// (or fail, if it points to dir/nonexistent location/etc).
|
||||
// This is strange, but POSIX-correct.
|
||||
// coreutils cp has --remove-destination to override this...
|
||||
//
|
||||
// NB: we have special code which still allows for "cp file /dev/node"
|
||||
// to work POSIX-ly (the only realistic case where it makes sense)
|
||||
|
||||
#define DO_POSIX_CP 0 /* 1 - POSIX behavior, 0 - safe behavior */
|
||||
|
||||
|
||||
// errno must be set to relevant value ("why we cannot create dest?")
|
||||
// for POSIX mode to give reasonable error message
|
||||
static int ask_and_unlink(const char *dest, int flags)
|
||||
{
|
||||
// If !DO_POSIX_CP, act as if -f is always in effect - we don't want
|
||||
// "'file' exists" msg, we want unlink to be done (silently unless -i
|
||||
// is also in effect).
|
||||
// This prevents safe way from asking more questions than POSIX does.
|
||||
#if DO_POSIX_CP
|
||||
if (!(flags & (FILEUTILS_FORCE|FILEUTILS_INTERACTIVE))) {
|
||||
fprintf(stderr, "'%s' exists\n", dest);
|
||||
// Either it exists, or the *path* doesnt exist
|
||||
bb_perror_msg("cannot create '%s'", dest);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
// If !DO_POSIX_CP, act as if -f is always in effect - we don't want
|
||||
// "cannot create" msg, we want unlink to be done (silently unless -i).
|
||||
|
||||
// TODO: maybe we should do it only if ctty is present?
|
||||
if (flags & FILEUTILS_INTERACTIVE) {
|
||||
// We would not do POSIX insanity. -i asks,
|
||||
// then _unlinks_ the offender. Presto.
|
||||
// (No opening without O_EXCL, no unlinks only if -f)
|
||||
// (No "opening without O_EXCL", no "unlink only if -f")
|
||||
// Or else we will end up having 3 open()s!
|
||||
fprintf(stderr, "%s: overwrite '%s'? ", applet_name, dest);
|
||||
if (!bb_ask_confirmation())
|
||||
@@ -60,9 +63,11 @@ static int ask_and_unlink(const char *dest, int flags)
|
||||
*/
|
||||
int copy_file(const char *source, const char *dest, int flags)
|
||||
{
|
||||
/* This is a recursive function, try to minimize stack usage */
|
||||
/* NB: each struct stat is ~100 bytes */
|
||||
struct stat source_stat;
|
||||
struct stat dest_stat;
|
||||
int status = 0;
|
||||
signed char retval = 0;
|
||||
signed char dest_exists = 0;
|
||||
signed char ovr;
|
||||
|
||||
@@ -112,6 +117,7 @@ int copy_file(const char *source, const char *dest, int flags)
|
||||
|
||||
if (S_ISDIR(source_stat.st_mode)) {
|
||||
DIR *dp;
|
||||
const char *tp;
|
||||
struct dirent *d;
|
||||
mode_t saved_umask = 0;
|
||||
|
||||
@@ -120,12 +126,23 @@ int copy_file(const char *source, const char *dest, int flags)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Create DEST. */
|
||||
/* Did we ever create source ourself before? */
|
||||
tp = is_in_ino_dev_hashtable(&source_stat);
|
||||
if (tp) {
|
||||
/* We did! it's a recursion! man the lifeboats... */
|
||||
bb_error_msg("recursion detected, omitting directory '%s'",
|
||||
source);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Create DEST */
|
||||
if (dest_exists) {
|
||||
if (!S_ISDIR(dest_stat.st_mode)) {
|
||||
bb_error_msg("target '%s' is not a directory", dest);
|
||||
return -1;
|
||||
}
|
||||
/* race here: user can substitute a symlink between
|
||||
* this check and actual creation of files inside dest */
|
||||
} else {
|
||||
mode_t mode;
|
||||
saved_umask = umask(0);
|
||||
@@ -133,22 +150,29 @@ int copy_file(const char *source, const char *dest, int flags)
|
||||
mode = source_stat.st_mode;
|
||||
if (!(flags & FILEUTILS_PRESERVE_STATUS))
|
||||
mode = source_stat.st_mode & ~saved_umask;
|
||||
/* Allow owner to access new dir (at least for now) */
|
||||
mode |= S_IRWXU;
|
||||
|
||||
if (mkdir(dest, mode) < 0) {
|
||||
umask(saved_umask);
|
||||
bb_perror_msg("cannot create directory '%s'", dest);
|
||||
return -1;
|
||||
}
|
||||
|
||||
umask(saved_umask);
|
||||
/* need stat info for add_to_ino_dev_hashtable */
|
||||
if (lstat(dest, &dest_stat) < 0) {
|
||||
bb_perror_msg("cannot stat '%s'", dest);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
/* remember (dev,inode) of each created dir.
|
||||
* NULL: name is not remembered */
|
||||
add_to_ino_dev_hashtable(&dest_stat, NULL);
|
||||
|
||||
/* Recursively copy files in SOURCE. */
|
||||
/* Recursively copy files in SOURCE */
|
||||
dp = opendir(source);
|
||||
if (dp == NULL) {
|
||||
status = -1;
|
||||
goto preserve_status;
|
||||
retval = -1;
|
||||
goto preserve_mode_ugid_time;
|
||||
}
|
||||
|
||||
while ((d = readdir(dp)) != NULL) {
|
||||
@@ -159,7 +183,7 @@ int copy_file(const char *source, const char *dest, int flags)
|
||||
continue;
|
||||
new_dest = concat_path_file(dest, d->d_name);
|
||||
if (copy_file(new_source, new_dest, flags) < 0)
|
||||
status = -1;
|
||||
retval = -1;
|
||||
free(new_source);
|
||||
free(new_dest);
|
||||
}
|
||||
@@ -168,11 +192,13 @@ int copy_file(const char *source, const char *dest, int flags)
|
||||
if (!dest_exists
|
||||
&& chmod(dest, source_stat.st_mode & ~saved_umask) < 0
|
||||
) {
|
||||
bb_perror_msg("cannot change permissions of '%s'", dest);
|
||||
status = -1;
|
||||
bb_perror_msg("cannot preserve %s of '%s'", "permissions", dest);
|
||||
/* retval = -1; - WRONG! copy *WAS* made */
|
||||
}
|
||||
goto preserve_mode_ugid_time;
|
||||
}
|
||||
|
||||
} else if (flags & (FILEUTILS_MAKE_SOFTLINK|FILEUTILS_MAKE_HARDLINK)) {
|
||||
if (flags & (FILEUTILS_MAKE_SOFTLINK|FILEUTILS_MAKE_HARDLINK)) {
|
||||
int (*lf)(const char *oldpath, const char *newpath);
|
||||
make_links:
|
||||
// Hmm... maybe
|
||||
@@ -188,47 +214,52 @@ int copy_file(const char *source, const char *dest, int flags)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
/* _Not_ jumping to preserve_mode_ugid_time:
|
||||
* hard/softlinks don't have those */
|
||||
return 0;
|
||||
}
|
||||
|
||||
} else if (S_ISREG(source_stat.st_mode)
|
||||
/* Huh? DEREF uses stat, which never returns links! */
|
||||
if (S_ISREG(source_stat.st_mode)
|
||||
/* DEREF uses stat, which never returns S_ISLNK() == true. */
|
||||
/* || (FLAGS_DEREF && S_ISLNK(source_stat.st_mode)) */
|
||||
) {
|
||||
int src_fd;
|
||||
int dst_fd;
|
||||
if (ENABLE_FEATURE_PRESERVE_HARDLINKS) {
|
||||
char *link_target;
|
||||
|
||||
if (!FLAGS_DEREF) {
|
||||
link_target = is_in_ino_dev_hashtable(&source_stat);
|
||||
if (link_target) {
|
||||
if (ENABLE_FEATURE_PRESERVE_HARDLINKS && !FLAGS_DEREF) {
|
||||
const char *link_target;
|
||||
link_target = is_in_ino_dev_hashtable(&source_stat);
|
||||
if (link_target) {
|
||||
if (link(link_target, dest) < 0) {
|
||||
ovr = ask_and_unlink(dest, flags);
|
||||
if (ovr <= 0)
|
||||
return ovr;
|
||||
if (link(link_target, dest) < 0) {
|
||||
ovr = ask_and_unlink(dest, flags);
|
||||
if (ovr <= 0)
|
||||
return ovr;
|
||||
if (link(link_target, dest) < 0) {
|
||||
bb_perror_msg("cannot create link '%s'", dest);
|
||||
return -1;
|
||||
}
|
||||
bb_perror_msg("cannot create link '%s'", dest);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
add_to_ino_dev_hashtable(&source_stat, dest);
|
||||
}
|
||||
|
||||
src_fd = open_or_warn(source, O_RDONLY);
|
||||
if (src_fd < 0) {
|
||||
if (src_fd < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if DO_POSIX_CP /* POSIX way (a security problem versus symlink attacks!): */
|
||||
dst_fd = open(dest, (flags & FILEUTILS_INTERACTIVE)
|
||||
? O_WRONLY|O_CREAT|O_EXCL
|
||||
: O_WRONLY|O_CREAT|O_TRUNC, source_stat.st_mode);
|
||||
#else /* safe way: */
|
||||
dst_fd = open(dest, O_WRONLY|O_CREAT|O_EXCL, source_stat.st_mode);
|
||||
#endif
|
||||
/* POSIX way is a security problem versus symlink attacks,
|
||||
* we do it only for non-symlinks, and only for non-recursive,
|
||||
* non-interactive cp. NB: it is still racy
|
||||
* for "cp file /home/bad_user/file" case
|
||||
* (user can rm file and create a link to /etc/passwd) */
|
||||
if (DO_POSIX_CP
|
||||
|| (dest_exists && !(flags & (FILEUTILS_RECUR|FILEUTILS_INTERACTIVE))
|
||||
&& !S_ISLNK(dest_stat.st_mode))
|
||||
) {
|
||||
dst_fd = open(dest, O_WRONLY|O_CREAT|O_TRUNC, source_stat.st_mode);
|
||||
} else /* safe way: */
|
||||
dst_fd = open(dest, O_WRONLY|O_CREAT|O_EXCL, source_stat.st_mode);
|
||||
if (dst_fd == -1) {
|
||||
ovr = ask_and_unlink(dest, flags);
|
||||
if (ovr <= 0) {
|
||||
@@ -264,60 +295,55 @@ int copy_file(const char *source, const char *dest, int flags)
|
||||
}
|
||||
#endif
|
||||
if (bb_copyfd_eof(src_fd, dst_fd) == -1)
|
||||
status = -1;
|
||||
retval = -1;
|
||||
/* Ok, writing side I can understand... */
|
||||
if (close(dst_fd) < 0) {
|
||||
bb_perror_msg("cannot close '%s'", dest);
|
||||
status = -1;
|
||||
}
|
||||
if (close(src_fd) < 0) {
|
||||
bb_perror_msg("cannot close '%s'", source);
|
||||
status = -1;
|
||||
retval = -1;
|
||||
}
|
||||
/* ...but read size is already checked by bb_copyfd_eof */
|
||||
close(src_fd);
|
||||
goto preserve_mode_ugid_time;
|
||||
}
|
||||
|
||||
} else if (S_ISBLK(source_stat.st_mode) || S_ISCHR(source_stat.st_mode)
|
||||
|| S_ISSOCK(source_stat.st_mode) || S_ISFIFO(source_stat.st_mode)
|
||||
|| S_ISLNK(source_stat.st_mode)
|
||||
) {
|
||||
// We are lazy here, a bit lax with races...
|
||||
if (dest_exists) {
|
||||
ovr = ask_and_unlink(dest, flags);
|
||||
if (ovr <= 0)
|
||||
return ovr;
|
||||
}
|
||||
if (S_ISFIFO(source_stat.st_mode)) {
|
||||
if (mkfifo(dest, source_stat.st_mode) < 0) {
|
||||
bb_perror_msg("cannot create fifo '%s'", dest);
|
||||
return -1;
|
||||
}
|
||||
} else if (S_ISLNK(source_stat.st_mode)) {
|
||||
char *lpath;
|
||||
|
||||
lpath = xmalloc_readlink_or_warn(source);
|
||||
if (lpath && symlink(lpath, dest) < 0) {
|
||||
bb_perror_msg("cannot create symlink '%s'", dest);
|
||||
free(lpath);
|
||||
return -1;
|
||||
}
|
||||
/* Source is a symlink or a special file */
|
||||
/* We are lazy here, a bit lax with races... */
|
||||
if (dest_exists) {
|
||||
errno = EEXIST;
|
||||
ovr = ask_and_unlink(dest, flags);
|
||||
if (ovr <= 0)
|
||||
return ovr;
|
||||
}
|
||||
if (S_ISLNK(source_stat.st_mode)) {
|
||||
char *lpath = xmalloc_readlink_or_warn(source);
|
||||
if (lpath) {
|
||||
int r = symlink(lpath, dest);
|
||||
free(lpath);
|
||||
|
||||
if (r < 0) {
|
||||
bb_perror_msg("cannot create symlink '%s'", dest);
|
||||
return -1;
|
||||
}
|
||||
if (flags & FILEUTILS_PRESERVE_STATUS)
|
||||
if (lchown(dest, source_stat.st_uid, source_stat.st_gid) < 0)
|
||||
bb_perror_msg("cannot preserve %s of '%s'", "ownership", dest);
|
||||
|
||||
return 0;
|
||||
|
||||
} else {
|
||||
if (mknod(dest, source_stat.st_mode, source_stat.st_rdev) < 0) {
|
||||
bb_perror_msg("cannot create '%s'", dest);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
/* _Not_ jumping to preserve_mode_ugid_time:
|
||||
* symlinks don't have those */
|
||||
return 0;
|
||||
}
|
||||
if (S_ISBLK(source_stat.st_mode) || S_ISCHR(source_stat.st_mode)
|
||||
|| S_ISSOCK(source_stat.st_mode) || S_ISFIFO(source_stat.st_mode)
|
||||
) {
|
||||
if (mknod(dest, source_stat.st_mode, source_stat.st_rdev) < 0) {
|
||||
bb_perror_msg("cannot create '%s'", dest);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
bb_error_msg("internal error: unrecognized file type");
|
||||
bb_error_msg("unrecognized file '%s' with mode %x", source, source_stat.st_mode);
|
||||
return -1;
|
||||
}
|
||||
|
||||
preserve_status:
|
||||
preserve_mode_ugid_time:
|
||||
|
||||
if (flags & FILEUTILS_PRESERVE_STATUS
|
||||
/* Cannot happen: */
|
||||
@@ -327,6 +353,7 @@ int copy_file(const char *source, const char *dest, int flags)
|
||||
|
||||
times.actime = source_stat.st_atime;
|
||||
times.modtime = source_stat.st_mtime;
|
||||
/* BTW, utimes sets usec-precision time - just FYI */
|
||||
if (utime(dest, ×) < 0)
|
||||
bb_perror_msg("cannot preserve %s of '%s'", "times", dest);
|
||||
if (chown(dest, source_stat.st_uid, source_stat.st_gid) < 0) {
|
||||
@@ -337,5 +364,5 @@ int copy_file(const char *source, const char *dest, int flags)
|
||||
bb_perror_msg("cannot preserve %s of '%s'", "permissions", dest);
|
||||
}
|
||||
|
||||
return status;
|
||||
return retval;
|
||||
}
|
||||
+17
-5
@@ -81,8 +81,9 @@ static int num_ok_lines = 1;
|
||||
#endif
|
||||
|
||||
#if ENABLE_FEATURE_GETUSERNAME_AND_HOMEDIR
|
||||
static char *user_buf = (char*)"";
|
||||
static char *home_pwd_buf = (char*)"";
|
||||
static const char null_str[] = "";
|
||||
static char *user_buf;
|
||||
static char *home_pwd_buf = (char*)null_str;
|
||||
#endif
|
||||
|
||||
/* Put 'command_ps[cursor]', cursor++.
|
||||
@@ -311,7 +312,7 @@ static void username_tab_completion(char *ud, char *with_shash_flg)
|
||||
|
||||
if (with_shash_flg) { /* "~/..." or "~user/..." */
|
||||
char *sav_ud = ud - 1;
|
||||
char *home = 0;
|
||||
char *home = NULL;
|
||||
char *temp;
|
||||
|
||||
if (*ud == '/') { /* "~/..." */
|
||||
@@ -1119,7 +1120,7 @@ static void parse_prompt(const char *prmt_ptr)
|
||||
switch (c) {
|
||||
#if ENABLE_FEATURE_GETUSERNAME_AND_HOMEDIR
|
||||
case 'u':
|
||||
pbuf = user_buf;
|
||||
pbuf = user_buf ? user_buf : (char*)"";
|
||||
break;
|
||||
#endif
|
||||
case 'h':
|
||||
@@ -1143,7 +1144,7 @@ static void parse_prompt(const char *prmt_ptr)
|
||||
case 'w':
|
||||
pbuf = pwd_buf;
|
||||
l = strlen(home_pwd_buf);
|
||||
if (home_pwd_buf[0] != 0
|
||||
if (l != 0
|
||||
&& strncmp(home_pwd_buf, pbuf, l) == 0
|
||||
&& (pbuf[l]=='/' || pbuf[l]=='\0')
|
||||
&& strlen(pwd_buf+l)<PATH_MAX
|
||||
@@ -1253,6 +1254,11 @@ static void win_changed(int nsig)
|
||||
#undef CTRL
|
||||
#define CTRL(a) ((a) & ~0x40)
|
||||
|
||||
/* Returns:
|
||||
* -1 on read errors or EOF, or on bare Ctrl-D.
|
||||
* 0 on ctrl-C,
|
||||
* >0 length of input string, including terminating '\n'
|
||||
*/
|
||||
int read_line_input(const char* prompt, char* command, int maxsize, line_input_t *st)
|
||||
{
|
||||
int lastWasTab = FALSE;
|
||||
@@ -1305,8 +1311,14 @@ int read_line_input(const char* prompt, char* command, int maxsize, line_input_t
|
||||
|
||||
entry = getpwuid(geteuid());
|
||||
if (entry) {
|
||||
/* If we enter read_line_input for the Nth time,
|
||||
* they may be already allocated! Need to free. */
|
||||
free(user_buf);
|
||||
if (home_pwd_buf != null_str)
|
||||
free(home_pwd_buf);
|
||||
user_buf = xstrdup(entry->pw_name);
|
||||
home_pwd_buf = xstrdup(entry->pw_dir);
|
||||
/* They are not freed on exit (too small to bother) */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
+16
-6
@@ -10,8 +10,7 @@
|
||||
* NOTE: This function returns a malloced char* that you will have to free
|
||||
* yourself. You have been warned.
|
||||
*/
|
||||
|
||||
char *xmalloc_readlink_or_warn(const char *path)
|
||||
char *xmalloc_readlink(const char *path)
|
||||
{
|
||||
enum { GROWBY = 80 }; /* how large we will grow strings by */
|
||||
|
||||
@@ -20,20 +19,30 @@ char *xmalloc_readlink_or_warn(const char *path)
|
||||
|
||||
do {
|
||||
buf = xrealloc(buf, bufsize += GROWBY);
|
||||
readsize = readlink(path, buf, bufsize); /* 1st try */
|
||||
readsize = readlink(path, buf, bufsize);
|
||||
if (readsize == -1) {
|
||||
bb_perror_msg("%s", path);
|
||||
free(buf);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
while (bufsize < readsize + 1);
|
||||
} while (bufsize < readsize + 1);
|
||||
|
||||
buf[readsize] = '\0';
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
char *xmalloc_readlink_or_warn(const char *path)
|
||||
{
|
||||
char *buf = xmalloc_readlink(path);
|
||||
if (!buf) {
|
||||
/* EINVAL => "file: Invalid argument" => puzzled user */
|
||||
bb_error_msg("%s: cannot read link (not a symlink?)", path);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* UNUSED */
|
||||
#if 0
|
||||
char *xmalloc_realpath(const char *path)
|
||||
{
|
||||
#if defined(__GLIBC__) && !defined(__UCLIBC__)
|
||||
@@ -46,3 +55,4 @@ char *xmalloc_realpath(const char *path)
|
||||
return xstrdup(realpath(path, buf));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
+26
-14
@@ -307,18 +307,26 @@ int login_main(int argc, char **argv)
|
||||
goto pam_auth_failed;
|
||||
}
|
||||
pamret = pam_authenticate(pamh, 0);
|
||||
if (pamret == PAM_SUCCESS) {
|
||||
char *pamuser;
|
||||
/* check that the account is healthy. */
|
||||
pamret = pam_acct_mgmt(pamh, 0);
|
||||
if (pamret != PAM_SUCCESS) {
|
||||
failed_msg = "account setup";
|
||||
goto pam_auth_failed;
|
||||
}
|
||||
/* read user back */
|
||||
if (pamret != PAM_SUCCESS) {
|
||||
failed_msg = "pam_authenticate";
|
||||
goto pam_auth_failed;
|
||||
/* TODO: or just "goto auth_failed"
|
||||
* since user seems to enter wrong password
|
||||
* (in this case pamret == 7)
|
||||
*/
|
||||
}
|
||||
/* check that the account is healthy */
|
||||
pamret = pam_acct_mgmt(pamh, 0);
|
||||
if (pamret != PAM_SUCCESS) {
|
||||
failed_msg = "account setup";
|
||||
goto pam_auth_failed;
|
||||
}
|
||||
/* read user back */
|
||||
{
|
||||
const char *pamuser;
|
||||
/* gcc: "dereferencing type-punned pointer breaks aliasing rules..."
|
||||
* thus we use double cast */
|
||||
if (pam_get_item(pamh, PAM_USER, (const void **)(void*)&pamuser) != PAM_SUCCESS) {
|
||||
* thus we cast to (void*) */
|
||||
if (pam_get_item(pamh, PAM_USER, (void*)&pamuser) != PAM_SUCCESS) {
|
||||
failed_msg = "pam_get_item(USER)";
|
||||
goto pam_auth_failed;
|
||||
}
|
||||
@@ -331,7 +339,7 @@ int login_main(int argc, char **argv)
|
||||
break;
|
||||
goto auth_failed;
|
||||
pam_auth_failed:
|
||||
bb_error_msg("%s failed: %s", failed_msg, pam_strerror(pamh, pamret));
|
||||
bb_error_msg("%s failed: %s (%d)", failed_msg, pam_strerror(pamh, pamret), pamret);
|
||||
safe_strncpy(username, "UNKNOWN", sizeof(username));
|
||||
#else /* not PAM */
|
||||
pw = getpwnam(username);
|
||||
@@ -360,6 +368,7 @@ int login_main(int argc, char **argv)
|
||||
auth_failed:
|
||||
opt &= ~LOGIN_OPT_f;
|
||||
bb_do_delay(FAIL_DELAY);
|
||||
/* TODO: doesn't sound like correct English phrase to me */
|
||||
puts("Login incorrect");
|
||||
if (++count == 3) {
|
||||
syslog(LOG_WARNING, "invalid password for '%s'%s",
|
||||
@@ -423,7 +432,9 @@ int login_main(int argc, char **argv)
|
||||
tmp = pw->pw_shell;
|
||||
if (!tmp || !*tmp)
|
||||
tmp = DEFAULT_SHELL;
|
||||
/* setup_environment params: shell, loginshell, changeenv, pw */
|
||||
setup_environment(tmp, 1, !(opt & LOGIN_OPT_p), pw);
|
||||
/* FIXME: login shell = 1 -> 3rd parameter is ignored! */
|
||||
|
||||
motd();
|
||||
|
||||
@@ -454,7 +465,8 @@ int login_main(int argc, char **argv)
|
||||
* should it leave SIGINT etc enabled or disabled? */
|
||||
signal(SIGINT, SIG_DFL);
|
||||
|
||||
run_shell(tmp, 1, 0, 0); /* exec the shell finally */
|
||||
/* Exec login shell with no additional parameters */
|
||||
run_shell(tmp, 1, NULL, NULL);
|
||||
|
||||
return EXIT_FAILURE;
|
||||
/* return EXIT_FAILURE; - not reached */
|
||||
}
|
||||
+11
-1
@@ -598,7 +598,7 @@ static void parse_conf(const char *path, int flag)
|
||||
++p; /* so keep last character */
|
||||
}
|
||||
*p = '\0';
|
||||
sprintf(p0, "%s:%s", p0, c);
|
||||
sprintf(p0 + strlen(p0), ":%s", c);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1186,6 +1186,9 @@ static void send_cgi_and_exit(
|
||||
* and send it to the peer. So please no SIGPIPEs! */
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
||||
/* Accound for POSTDATA already in hdr_buf */
|
||||
bodyLen -= hdr_cnt;
|
||||
|
||||
/* This loop still looks messy. What is an exit criteria?
|
||||
* "CGI's output closed"? Or "CGI has exited"?
|
||||
* What to do if CGI has closed both input and output, but
|
||||
@@ -1602,6 +1605,13 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
|
||||
if (fromAddr->sa.sa_family == AF_INET) {
|
||||
rmt_ip = ntohl(fromAddr->sin.sin_addr.s_addr);
|
||||
}
|
||||
#if ENABLE_FEATURE_IPV6
|
||||
if (fromAddr->sa.sa_family == AF_INET6
|
||||
&& fromAddr->sin6.sin6_addr.s6_addr32[0] == 0
|
||||
&& fromAddr->sin6.sin6_addr.s6_addr32[1] == 0
|
||||
&& ntohl(fromAddr->sin6.sin6_addr.s6_addr32[2]) == 0xffff)
|
||||
rmt_ip = ntohl(fromAddr->sin6.sin6_addr.s6_addr32[3]);
|
||||
#endif
|
||||
if (ENABLE_FEATURE_HTTPD_CGI || DEBUG || verbose) {
|
||||
rmt_ip_str = xmalloc_sockaddr2dotted(&fromAddr->sa);
|
||||
}
|
||||
|
||||
+2
-1
@@ -734,7 +734,8 @@ static servtab_t *getconfigent(void)
|
||||
/* if ((arg = skip(&cp, 1)) == NULL) */
|
||||
/* goto more; */
|
||||
|
||||
sep->se_server = xxstrdup(skip(&cp));
|
||||
arg = skip(&cp);
|
||||
sep->se_server = xxstrdup(arg);
|
||||
if (strcmp(sep->se_server, "internal") == 0) {
|
||||
#ifdef INETD_FEATURE_ENABLED
|
||||
const struct builtin *bi;
|
||||
|
||||
+2
-16
@@ -21,20 +21,6 @@
|
||||
|
||||
/* Helpers */
|
||||
|
||||
/* Even if _POSIX_MONOTONIC_CLOCK is defined, this
|
||||
* may require librt */
|
||||
#if 0 /*def _POSIX_MONOTONIC_CLOCK*/
|
||||
static time_t monotonic_time(void)
|
||||
{
|
||||
struct timespec ts;
|
||||
if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0)
|
||||
time(&ts.tv_sec);
|
||||
return ts.tv_sec;
|
||||
}
|
||||
#else
|
||||
#define monotonic_time() (time(NULL))
|
||||
#endif
|
||||
|
||||
/* Opaque structure */
|
||||
|
||||
struct isrv_state_t {
|
||||
@@ -258,7 +244,7 @@ static void handle_fd_set(isrv_state_t *state, fd_set *fds, int (*h)(int, void *
|
||||
/* this peer is gone */
|
||||
remove_peer(state, peer);
|
||||
} else if (TIMEOUT) {
|
||||
TIMEO_TBL[peer] = monotonic_time();
|
||||
TIMEO_TBL[peer] = monotonic_sec();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -335,7 +321,7 @@ void isrv_run(
|
||||
break;
|
||||
|
||||
if (timeout) {
|
||||
time_t t = monotonic_time();
|
||||
time_t t = monotonic_sec();
|
||||
if (t != CURTIME) {
|
||||
CURTIME = t;
|
||||
handle_timeout(state, do_timeout);
|
||||
|
||||
@@ -241,12 +241,12 @@ static void parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p)
|
||||
} else if (key == ARG_remote) {
|
||||
NEXT_ARG();
|
||||
key = index_in_strings(keywords, *argv);
|
||||
if (key == ARG_any)
|
||||
if (key != ARG_any)
|
||||
p->iph.daddr = get_addr32(*argv);
|
||||
} else if (key == ARG_local) {
|
||||
NEXT_ARG();
|
||||
key = index_in_strings(keywords, *argv);
|
||||
if (key == ARG_any)
|
||||
if (key != ARG_any)
|
||||
p->iph.saddr = get_addr32(*argv);
|
||||
} else if (key == ARG_dev) {
|
||||
NEXT_ARG();
|
||||
|
||||
+28
-8
@@ -33,6 +33,34 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "libbb.h"
|
||||
#include "runit_lib.h"
|
||||
|
||||
#if ENABLE_MONOTONIC_SYSCALL
|
||||
#include <sys/syscall.h>
|
||||
|
||||
/* libc has incredibly messy way of doing this,
|
||||
* typically requiring -lrt. We just skip all this mess */
|
||||
static void gettimeofday_ns(struct timespec *ts)
|
||||
{
|
||||
syscall(__NR_clock_gettime, CLOCK_REALTIME, ts);
|
||||
}
|
||||
#else
|
||||
static void gettimeofday_ns(struct timespec *ts)
|
||||
{
|
||||
if (sizeof(struct timeval) == sizeof(struct timespec)
|
||||
&& sizeof(((struct timeval*)ts)->tv_usec) == sizeof(ts->tv_nsec)
|
||||
) {
|
||||
/* Cheat */
|
||||
gettimeofday((void*)ts, NULL);
|
||||
ts->tv_nsec *= 1000;
|
||||
} else {
|
||||
extern void BUG_need_to_implement_gettimeofday_ns(void);
|
||||
BUG_need_to_implement_gettimeofday_ns();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Compare possibly overflowing unsigned counters */
|
||||
#define LESS(a,b) ((int)((unsigned)(b) - (unsigned)(a)) > 0)
|
||||
|
||||
static int selfpipe[2];
|
||||
|
||||
/* state */
|
||||
@@ -126,14 +154,6 @@ static int rename_or_warn(const char *old, const char *new)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define LESS(a,b) ((int)((unsigned)(b) - (unsigned)(a)) > 0)
|
||||
|
||||
#include <sys/syscall.h>
|
||||
static void gettimeofday_ns(struct timespec *ts)
|
||||
{
|
||||
syscall(__NR_clock_gettime, CLOCK_REALTIME, ts);
|
||||
}
|
||||
|
||||
static void update_status(struct svdir *s)
|
||||
{
|
||||
ssize_t sz;
|
||||
|
||||
+1
-1
@@ -300,10 +300,10 @@ int runsvdir_main(int argc, char **argv)
|
||||
stamplog = now + 900;
|
||||
}
|
||||
}
|
||||
deadline = now + (check ? 1 : 5);
|
||||
|
||||
pfd[0].revents = 0;
|
||||
sig_block(SIGCHLD);
|
||||
deadline = (check ? 1 : 5);
|
||||
if (rplog)
|
||||
poll(pfd, 1, deadline*1000);
|
||||
else
|
||||
|
||||
+23
-35
@@ -14,37 +14,30 @@ try() {
|
||||
BBOX_LIB_LIST=`echo "$BBOX_LIB_LIST" | xargs -n1 | sort | uniq | xargs`
|
||||
|
||||
# First link with all libs. If it fails, bail out
|
||||
l_list=`echo "$BBOX_LIB_LIST" | sed -e 's/ / -l/g' -e 's/^/-l/'`
|
||||
echo "Trying libraries: $BBOX_LIB_LIST"
|
||||
try "-Wl,--start-group $l_list -Wl,--end-group" "$@" \
|
||||
l_list=`echo "$BBOX_LIB_LIST" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'`
|
||||
test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group"
|
||||
try "$l_list" "$@" \
|
||||
|| {
|
||||
echo "Failed: $* -Wl,--start-group $l_list -Wl,--end-group"
|
||||
cat busybox_ld.err
|
||||
exit 1
|
||||
}
|
||||
|
||||
#### Hack disabled: conflicts with ld --verbose flag in last link phase
|
||||
|
||||
##### Hack: we are not supposed to know executable name,
|
||||
##### but this hack cuts down link time
|
||||
####mv busybox_unstripped busybox_unstripped.tmp
|
||||
####mv busybox.map busybox.map.tmp
|
||||
|
||||
# Now try to remove each lib and build without it.
|
||||
# Stop when no lib can be removed.
|
||||
####ever_discarded=false
|
||||
while test "$BBOX_LIB_LIST"; do
|
||||
$debug && echo "Trying libraries: $BBOX_LIB_LIST"
|
||||
all_needed=true
|
||||
for one in $BBOX_LIB_LIST; do
|
||||
without_one=`echo " $BBOX_LIB_LIST " | sed "s/ $one / /g" | xargs`
|
||||
l_list=`echo "$without_one" | sed -e 's/ / -l/g' -e 's/^/-l/'`
|
||||
$debug && echo "Trying -l options: $l_list"
|
||||
if try "-Wl,--start-group $l_list -Wl,--end-group" "$@"; then
|
||||
l_list=`echo "$without_one" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'`
|
||||
test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group"
|
||||
$debug && echo "Trying -l options: '$l_list'"
|
||||
if try "$l_list" "$@"; then
|
||||
echo "Library $one is not needed"
|
||||
BBOX_LIB_LIST="$without_one"
|
||||
all_needed=false
|
||||
#### ever_discarded=true
|
||||
else
|
||||
echo "Library $one is needed"
|
||||
fi
|
||||
@@ -57,24 +50,19 @@ while test "$BBOX_LIB_LIST"; do
|
||||
#{ echo "$BBOX_LIB_LIST" | grep -q ' '; } || break
|
||||
done
|
||||
|
||||
####mv busybox_unstripped.tmp busybox_unstripped
|
||||
####mv busybox.map.tmp busybox.map
|
||||
####$ever_discarded && {
|
||||
# Make the binary with final, minimal list of libs
|
||||
echo "Final link with: $BBOX_LIB_LIST"
|
||||
l_list=`echo "$BBOX_LIB_LIST" | sed -e 's/ / -l/g' -e 's/^/-l/'`
|
||||
# --verbose gives us gobs of info to stdout (e.g. linker script used)
|
||||
if ! test -f busybox_ldscript; then
|
||||
try "-Wl,--start-group $l_list -Wl,--end-group -Wl,--verbose" "$@" >busybox_ld.out ####|| exit 1
|
||||
else
|
||||
echo "Custom linker script 'busybox_ldscript' found, using it"
|
||||
# Add SORT_BY_ALIGNMENT to linker script (found in busybox_ld.out):
|
||||
# .rodata : { *(.rodata SORT_BY_ALIGNMENT(.rodata.*) .gnu.linkonce.r.*) }
|
||||
# *(.data SORT_BY_ALIGNMENT(.data.*) .gnu.linkonce.d.*)
|
||||
# *(.bss SORT_BY_ALIGNMENT(.bss.*) .gnu.linkonce.b.*)
|
||||
# This will eliminate most of the data padding (~3kb).
|
||||
try "-Wl,--start-group $l_list -Wl,--end-group -Wl,--verbose -Wl,-T -Wl,busybox_ldscript" "$@" >busybox_ld.out
|
||||
fi
|
||||
####}
|
||||
####rm busybox_ld.err
|
||||
####exit 0 # Ensure "success" exit code
|
||||
# Make the binary with final, minimal list of libs
|
||||
echo "Final link with: $BBOX_LIB_LIST"
|
||||
l_list=`echo "$BBOX_LIB_LIST" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'`
|
||||
test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group -Wl,--verbose"
|
||||
# --verbose gives us gobs of info to stdout (e.g. linker script used)
|
||||
if ! test -f busybox_ldscript; then
|
||||
try "$l_list -Wl,--verbose" "$@" >busybox_ld.out
|
||||
else
|
||||
echo "Custom linker script 'busybox_ldscript' found, using it"
|
||||
# Add SORT_BY_ALIGNMENT to linker script (found in busybox_ld.out):
|
||||
# .rodata : { *(.rodata SORT_BY_ALIGNMENT(.rodata.*) .gnu.linkonce.r.*) }
|
||||
# *(.data SORT_BY_ALIGNMENT(.data.*) .gnu.linkonce.d.*)
|
||||
# *(.bss SORT_BY_ALIGNMENT(.bss.*) .gnu.linkonce.b.*)
|
||||
# This will eliminate most of the data padding (~3kb).
|
||||
try "$l_list -Wl,--verbose -Wl,-T -Wl,busybox_ldscript" "$@" >busybox_ld.out
|
||||
fi
|
||||
+1
-1
@@ -136,7 +136,7 @@ int chcon_main(int argc, char **argv)
|
||||
":\xff--urtl:u--\xff:r--\xff:t--\xff:l--\xff"
|
||||
#endif
|
||||
":f--v:v--f"; /* 'verbose' and 'quiet' are exclusive */
|
||||
getopt32(argv, "Rchf:u:r:t:l:v",
|
||||
getopt32(argv, "Rchfu:r:t:l:v",
|
||||
&user, &role, &type, &range, &reference_file);
|
||||
argv += optind;
|
||||
|
||||
|
||||
+1
-1
@@ -189,7 +189,7 @@ static int match(const char *name, struct stat *sb, char **con)
|
||||
file_sep = strrchr(tmp_path, '/');
|
||||
if (file_sep == tmp_path) {
|
||||
file_sep++;
|
||||
p[0] = '\0';
|
||||
path[0] = '\0';
|
||||
p = path;
|
||||
} else if (file_sep) {
|
||||
*file_sep++ = '\0';
|
||||
|
||||
+1
-7
@@ -4379,6 +4379,7 @@ clear_traps(void)
|
||||
|
||||
/* Lives far away from here, needed for forkchild */
|
||||
static void closescript(void);
|
||||
|
||||
/* Called after fork(), in child */
|
||||
static void
|
||||
forkchild(struct job *jp, union node *n, int mode)
|
||||
@@ -4423,15 +4424,8 @@ forkchild(struct job *jp, union node *n, int mode)
|
||||
setsignal(SIGQUIT);
|
||||
setsignal(SIGTERM);
|
||||
}
|
||||
#if JOBS
|
||||
/* For "jobs | cat" to work like in bash, we must retain list of jobs
|
||||
* in child, but we do need to remove ourself */
|
||||
if (jp)
|
||||
freejob(jp);
|
||||
#else
|
||||
for (jp = curjob; jp; jp = jp->prev_job)
|
||||
freejob(jp);
|
||||
#endif
|
||||
jobless = 0;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -107,7 +107,7 @@ int logger_main(int argc, char **argv)
|
||||
argv += optind;
|
||||
if (!argc) {
|
||||
#define strbuf bb_common_bufsiz1
|
||||
while (fgets(strbuf, BUFSIZ, stdin)) {
|
||||
while (fgets(strbuf, COMMON_BUFSIZE, stdin)) {
|
||||
if (strbuf[0]
|
||||
&& NOT_LONE_CHAR(strbuf, '\n')
|
||||
) {
|
||||
@@ -117,11 +117,11 @@ int logger_main(int argc, char **argv)
|
||||
}
|
||||
} else {
|
||||
char *message = NULL;
|
||||
int len = 1; /* for NUL */
|
||||
int len = 0;
|
||||
int pos = 0;
|
||||
do {
|
||||
len += strlen(*argv) + 1;
|
||||
message = xrealloc(message, len);
|
||||
message = xrealloc(message, len + 1);
|
||||
sprintf(message + pos, " %s", *argv),
|
||||
pos = len;
|
||||
} while (*++argv);
|
||||
|
||||
@@ -638,8 +638,16 @@ static void
|
||||
seek_sector(ullong secno)
|
||||
{
|
||||
secno *= sector_size;
|
||||
#if ENABLE_FDISK_SUPPORT_LARGE_DISKS
|
||||
if (lseek64(fd, (off64_t)secno, SEEK_SET) == (off64_t) -1)
|
||||
fdisk_fatal(unable_to_seek);
|
||||
#else
|
||||
if (secno > MAXINT(off_t)
|
||||
|| lseek(fd, (off_t)secno, SEEK_SET) == (off_t) -1
|
||||
) {
|
||||
fdisk_fatal(unable_to_seek);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ENABLE_FEATURE_FDISK_WRITABLE
|
||||
|
||||
Reference in new issue
Block a user