diff options
author | Ron Yorston <rmy@pobox.com> | 2019-05-27 11:56:52 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2019-05-27 11:56:52 +0100 |
commit | a61949401890cbb33a9d6c4571b51c53460ad438 (patch) | |
tree | 64dedaddb89896d5b1670a421af123670ca2120b /libbb | |
parent | 03a7b173605a890e1db5177ecd5b8dd591081c41 (diff) | |
parent | bcb1fc3e6ca6fe902610f507eaf9b0b58a5c583a (diff) | |
download | busybox-w32-a61949401890cbb33a9d6c4571b51c53460ad438.tar.gz busybox-w32-a61949401890cbb33a9d6c4571b51c53460ad438.tar.bz2 busybox-w32-a61949401890cbb33a9d6c4571b51c53460ad438.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/find_mount_point.c | 15 | ||||
-rw-r--r-- | libbb/full_write.c | 3 | ||||
-rw-r--r-- | libbb/lineedit.c | 13 | ||||
-rw-r--r-- | libbb/read_printf.c | 12 | ||||
-rw-r--r-- | libbb/verror_msg.c | 22 | ||||
-rw-r--r-- | libbb/vfork_daemon_rexec.c | 17 |
6 files changed, 61 insertions, 21 deletions
diff --git a/libbb/find_mount_point.c b/libbb/find_mount_point.c index 341c30102..edf734614 100644 --- a/libbb/find_mount_point.c +++ b/libbb/find_mount_point.c | |||
@@ -70,11 +70,22 @@ struct mntent* FAST_FUNC find_mount_point(const char *name, int subdir_too) | |||
70 | continue; | 70 | continue; |
71 | 71 | ||
72 | /* Is device's dev_t == name's dev_t? */ | 72 | /* Is device's dev_t == name's dev_t? */ |
73 | if (stat(mountEntry->mnt_fsname, &s) == 0 && s.st_rdev == devno_of_name) | 73 | if (mountEntry->mnt_fsname[0] == '/' |
74 | /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
75 | * avoid stat'ing "sysfs", "proc", "none" and such, | ||
76 | * useless at best, can stat unrelated files at worst. | ||
77 | */ | ||
78 | && stat(mountEntry->mnt_fsname, &s) == 0 | ||
79 | && s.st_rdev == devno_of_name | ||
80 | ) { | ||
74 | break; | 81 | break; |
82 | } | ||
75 | /* Match the directory's mount point. */ | 83 | /* Match the directory's mount point. */ |
76 | if (stat(mountEntry->mnt_dir, &s) == 0 && s.st_dev == devno_of_name) | 84 | if (stat(mountEntry->mnt_dir, &s) == 0 |
85 | && s.st_dev == devno_of_name | ||
86 | ) { | ||
77 | break; | 87 | break; |
88 | } | ||
78 | } | 89 | } |
79 | endmntent(mtab_fp); | 90 | endmntent(mtab_fp); |
80 | #else | 91 | #else |
diff --git a/libbb/full_write.c b/libbb/full_write.c index 2b7983f4c..15766fc6c 100644 --- a/libbb/full_write.c +++ b/libbb/full_write.c | |||
@@ -11,7 +11,8 @@ | |||
11 | /* | 11 | /* |
12 | * Write all of the supplied buffer out to a file. | 12 | * Write all of the supplied buffer out to a file. |
13 | * This does multiple writes as necessary. | 13 | * This does multiple writes as necessary. |
14 | * Returns the amount written, or -1 on an error. | 14 | * Returns the amount written, or -1 if error was seen |
15 | * on the very first write. | ||
15 | */ | 16 | */ |
16 | ssize_t FAST_FUNC full_write(int fd, const void *buf, size_t len) | 17 | ssize_t FAST_FUNC full_write(int fd, const void *buf, size_t len) |
17 | { | 18 | { |
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 191bc0598..9781b4a08 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -70,13 +70,20 @@ | |||
70 | #if ENABLE_UNICODE_SUPPORT | 70 | #if ENABLE_UNICODE_SUPPORT |
71 | # define BB_NUL ((wchar_t)0) | 71 | # define BB_NUL ((wchar_t)0) |
72 | # define CHAR_T wchar_t | 72 | # define CHAR_T wchar_t |
73 | static bool BB_isspace(CHAR_T c) { return ((unsigned)c < 256 && isspace(c)); } | 73 | static bool BB_isspace(CHAR_T c) |
74 | { | ||
75 | return ((unsigned)c < 256 && isspace(c)); | ||
76 | } | ||
74 | # if ENABLE_FEATURE_EDITING_VI | 77 | # if ENABLE_FEATURE_EDITING_VI |
75 | static bool BB_isalnum_or_underscore(CHAR_T c) { | 78 | static bool BB_isalnum_or_underscore(CHAR_T c) |
79 | { | ||
76 | return ((unsigned)c < 256 && isalnum(c)) || c == '_'; | 80 | return ((unsigned)c < 256 && isalnum(c)) || c == '_'; |
77 | } | 81 | } |
78 | # endif | 82 | # endif |
79 | static bool BB_ispunct(CHAR_T c) { return ((unsigned)c < 256 && ispunct(c)); } | 83 | static bool BB_ispunct(CHAR_T c) |
84 | { | ||
85 | return ((unsigned)c < 256 && ispunct(c)); | ||
86 | } | ||
80 | # undef isspace | 87 | # undef isspace |
81 | # undef isalnum | 88 | # undef isalnum |
82 | # undef ispunct | 89 | # undef ispunct |
diff --git a/libbb/read_printf.c b/libbb/read_printf.c index e47ac7afe..1e67d6542 100644 --- a/libbb/read_printf.c +++ b/libbb/read_printf.c | |||
@@ -107,10 +107,9 @@ char* FAST_FUNC xmalloc_reads(int fd, size_t *maxsz_p) | |||
107 | 107 | ||
108 | // Read (potentially big) files in one go. File size is estimated | 108 | // Read (potentially big) files in one go. File size is estimated |
109 | // by stat. Extra '\0' byte is appended. | 109 | // by stat. Extra '\0' byte is appended. |
110 | void* FAST_FUNC xmalloc_read(int fd, size_t *maxsz_p) | 110 | void* FAST_FUNC xmalloc_read_with_initial_buf(int fd, size_t *maxsz_p, char *buf, size_t total) |
111 | { | 111 | { |
112 | char *buf; | 112 | size_t size, rd_size; |
113 | size_t size, rd_size, total; | ||
114 | size_t to_read; | 113 | size_t to_read; |
115 | struct stat st; | 114 | struct stat st; |
116 | 115 | ||
@@ -123,8 +122,6 @@ void* FAST_FUNC xmalloc_read(int fd, size_t *maxsz_p) | |||
123 | /* In order to make such files readable, we add small const */ | 122 | /* In order to make such files readable, we add small const */ |
124 | size = (st.st_size | 0x3ff) + 1; | 123 | size = (st.st_size | 0x3ff) + 1; |
125 | 124 | ||
126 | total = 0; | ||
127 | buf = NULL; | ||
128 | while (1) { | 125 | while (1) { |
129 | if (to_read < size) | 126 | if (to_read < size) |
130 | size = to_read; | 127 | size = to_read; |
@@ -153,6 +150,11 @@ void* FAST_FUNC xmalloc_read(int fd, size_t *maxsz_p) | |||
153 | return buf; | 150 | return buf; |
154 | } | 151 | } |
155 | 152 | ||
153 | void* FAST_FUNC xmalloc_read(int fd, size_t *maxsz_p) | ||
154 | { | ||
155 | return xmalloc_read_with_initial_buf(fd, maxsz_p, NULL, 0); | ||
156 | } | ||
157 | |||
156 | #ifdef USING_LSEEK_TO_GET_SIZE | 158 | #ifdef USING_LSEEK_TO_GET_SIZE |
157 | /* Alternatively, file size can be obtained by lseek to the end. | 159 | /* Alternatively, file size can be obtained by lseek to the end. |
158 | * The code is slightly bigger. Retained in case fstat approach | 160 | * The code is slightly bigger. Retained in case fstat approach |
diff --git a/libbb/verror_msg.c b/libbb/verror_msg.c index 22c30357b..6d3459905 100644 --- a/libbb/verror_msg.c +++ b/libbb/verror_msg.c | |||
@@ -12,7 +12,7 @@ | |||
12 | #endif | 12 | #endif |
13 | 13 | ||
14 | #if ENABLE_FEATURE_SYSLOG | 14 | #if ENABLE_FEATURE_SYSLOG |
15 | smallint syslog_level = LOG_ERR; | 15 | static smallint syslog_level = LOG_ERR; |
16 | #endif | 16 | #endif |
17 | smallint logmode = LOGMODE_STDIO; | 17 | smallint logmode = LOGMODE_STDIO; |
18 | const char *msg_eol = "\n"; | 18 | const char *msg_eol = "\n"; |
@@ -154,7 +154,7 @@ void FAST_FUNC bb_verror_msg(const char *s, va_list p, const char* strerr) | |||
154 | } | 154 | } |
155 | # if ENABLE_FEATURE_SYSLOG | 155 | # if ENABLE_FEATURE_SYSLOG |
156 | if (logmode & LOGMODE_SYSLOG) { | 156 | if (logmode & LOGMODE_SYSLOG) { |
157 | syslog(LOG_ERR, "%s", msgc); | 157 | syslog(syslog_level, "%s", msgc); |
158 | } | 158 | } |
159 | # endif | 159 | # endif |
160 | free(msgc); | 160 | free(msgc); |
@@ -180,3 +180,21 @@ void FAST_FUNC bb_error_msg(const char *s, ...) | |||
180 | bb_verror_msg(s, p, NULL); | 180 | bb_verror_msg(s, p, NULL); |
181 | va_end(p); | 181 | va_end(p); |
182 | } | 182 | } |
183 | |||
184 | #if ENABLE_FEATURE_SYSLOG_INFO | ||
185 | void FAST_FUNC bb_vinfo_msg(const char *s, va_list p) | ||
186 | { | ||
187 | syslog_level = LOG_INFO; | ||
188 | bb_verror_msg(s, p, NULL); | ||
189 | syslog_level = LOG_ERR; | ||
190 | } | ||
191 | |||
192 | void FAST_FUNC bb_info_msg(const char *s, ...) | ||
193 | { | ||
194 | va_list p; | ||
195 | |||
196 | va_start(p, s); | ||
197 | bb_vinfo_msg(s, p); | ||
198 | va_end(p); | ||
199 | } | ||
200 | #endif | ||
diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c index 2d497d754..26e1776a4 100644 --- a/libbb/vfork_daemon_rexec.c +++ b/libbb/vfork_daemon_rexec.c | |||
@@ -268,12 +268,6 @@ void FAST_FUNC bb_daemonize_or_rexec(int flags, char **argv) | |||
268 | if (flags & DAEMON_CHDIR_ROOT) | 268 | if (flags & DAEMON_CHDIR_ROOT) |
269 | xchdir("/"); | 269 | xchdir("/"); |
270 | 270 | ||
271 | if (flags & DAEMON_DEVNULL_STDIO) { | ||
272 | close(0); | ||
273 | close(1); | ||
274 | close(2); | ||
275 | } | ||
276 | |||
277 | fd = open(bb_dev_null, O_RDWR); | 271 | fd = open(bb_dev_null, O_RDWR); |
278 | if (fd < 0) { | 272 | if (fd < 0) { |
279 | /* NB: we can be called as bb_sanitize_stdio() from init | 273 | /* NB: we can be called as bb_sanitize_stdio() from init |
@@ -283,8 +277,15 @@ void FAST_FUNC bb_daemonize_or_rexec(int flags, char **argv) | |||
283 | fd = xopen("/", O_RDONLY); /* don't believe this can fail */ | 277 | fd = xopen("/", O_RDONLY); /* don't believe this can fail */ |
284 | } | 278 | } |
285 | 279 | ||
286 | while ((unsigned)fd < 2) | 280 | if (flags & DAEMON_DEVNULL_STDIO) { |
287 | fd = dup(fd); /* have 0,1,2 open at least to /dev/null */ | 281 | xdup2(fd, 0); |
282 | xdup2(fd, 1); | ||
283 | xdup2(fd, 2); | ||
284 | } else { | ||
285 | /* have 0,1,2 open at least to /dev/null */ | ||
286 | while ((unsigned)fd < 2) | ||
287 | fd = dup(fd); | ||
288 | } | ||
288 | 289 | ||
289 | if (!(flags & DAEMON_ONLY_SANITIZE)) { | 290 | if (!(flags & DAEMON_ONLY_SANITIZE)) { |
290 | 291 | ||