aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-01-24 22:03:46 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-01-24 22:03:46 +0000
commite338dd95b45b39a1e3bc307adc98064173a0f9f3 (patch)
treeffbd0b893c8ba8088a2f034684b9745b49086dd8
parent8942c12782d20367c8816d3cc83c5274735e932a (diff)
downloadbusybox-w32-e338dd95b45b39a1e3bc307adc98064173a0f9f3.tar.gz
busybox-w32-e338dd95b45b39a1e3bc307adc98064173a0f9f3.tar.bz2
busybox-w32-e338dd95b45b39a1e3bc307adc98064173a0f9f3.zip
accumulated post-1.4.0 fixes
-rw-r--r--Makefile2
-rw-r--r--applets/applets.c24
-rw-r--r--archival/tar.c28
-rw-r--r--libbb/vdprintf.c4
-rw-r--r--libbb/xfuncs.c7
-rw-r--r--libbb/xreadlink.c2
-rw-r--r--networking/libiproute/libnetlink.h5
-rw-r--r--sysklogd/syslogd.c4
8 files changed, 40 insertions, 36 deletions
diff --git a/Makefile b/Makefile
index 8701dce3f..733987f60 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
1VERSION = 1 1VERSION = 1
2PATCHLEVEL = 4 2PATCHLEVEL = 4
3SUBLEVEL = 0 3SUBLEVEL = 1
4EXTRAVERSION = 4EXTRAVERSION =
5NAME = Unnamed 5NAME = Unnamed
6 6
diff --git a/applets/applets.c b/applets/applets.c
index ebd1ff313..a974743da 100644
--- a/applets/applets.c
+++ b/applets/applets.c
@@ -320,7 +320,7 @@ static void parse_config_file(void)
320} 320}
321 321
322#else 322#else
323#define parse_config_file() 323#define parse_config_file() ((void)0)
324#endif /* CONFIG_FEATURE_SUID_CONFIG */ 324#endif /* CONFIG_FEATURE_SUID_CONFIG */
325 325
326#ifdef CONFIG_FEATURE_SUID 326#ifdef CONFIG_FEATURE_SUID
@@ -340,20 +340,26 @@ static void check_suid(struct BB_applet *applet)
340 if (sct) { 340 if (sct) {
341 mode_t m = sct->m_mode; 341 mode_t m = sct->m_mode;
342 342
343 if (sct->m_uid == ruid) /* same uid */ 343 if (sct->m_uid == ruid)
344 /* same uid */
344 m >>= 6; 345 m >>= 6;
345 else if ((sct->m_gid == rgid) || ingroup(ruid, sct->m_gid)) /* same group / in group */ 346 else if ((sct->m_gid == rgid) || ingroup(ruid, sct->m_gid))
347 /* same group / in group */
346 m >>= 3; 348 m >>= 3;
347 349
348 if (!(m & S_IXOTH)) /* is x bit not set ? */ 350 if (!(m & S_IXOTH)) /* is x bit not set ? */
349 bb_error_msg_and_die("you have no permission to run this applet!"); 351 bb_error_msg_and_die("you have no permission to run this applet!");
350 352
351 if ((sct->m_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) { /* *both* have to be set for sgid */ 353 if (sct->m_gid != 0) {
352 xsetgid(sct->m_gid); 354 /* _both_ have to be set for sgid */
353 } else xsetgid(rgid); /* no sgid -> drop */ 355 if ((sct->m_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) {
354 356 xsetgid(sct->m_gid);
355 if (sct->m_mode & S_ISUID) xsetuid(sct->m_uid); 357 } else xsetgid(rgid); /* no sgid -> drop */
356 else xsetuid(ruid); /* no suid -> drop */ 358 }
359 if (sct->m_uid != 0) {
360 if (sct->m_mode & S_ISUID) xsetuid(sct->m_uid);
361 else xsetuid(ruid); /* no suid -> drop */
362 }
357 } else { 363 } else {
358 /* default: drop all privileges */ 364 /* default: drop all privileges */
359 xsetgid(rgid); 365 xsetgid(rgid);
diff --git a/archival/tar.c b/archival/tar.c
index 2ba51adf7..ca59643e5 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -23,10 +23,10 @@
23 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 23 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
24 */ 24 */
25 25
26#include "busybox.h"
27#include "unarchive.h"
28#include <fnmatch.h> 26#include <fnmatch.h>
29#include <getopt.h> 27#include <getopt.h>
28#include "busybox.h"
29#include "unarchive.h"
30 30
31#if ENABLE_FEATURE_TAR_CREATE 31#if ENABLE_FEATURE_TAR_CREATE
32 32
@@ -37,6 +37,7 @@
37/* POSIX tar Header Block, from POSIX 1003.1-1990 */ 37/* POSIX tar Header Block, from POSIX 1003.1-1990 */
38#define NAME_SIZE 100 38#define NAME_SIZE 100
39#define NAME_SIZE_STR "100" 39#define NAME_SIZE_STR "100"
40typedef struct TarHeader TarHeader;
40struct TarHeader { /* byte offset */ 41struct TarHeader { /* byte offset */
41 char name[NAME_SIZE]; /* 0-99 */ 42 char name[NAME_SIZE]; /* 0-99 */
42 char mode[8]; /* 100-107 */ 43 char mode[8]; /* 100-107 */
@@ -56,7 +57,6 @@ struct TarHeader { /* byte offset */
56 char prefix[155]; /* 345-499 */ 57 char prefix[155]; /* 345-499 */
57 char padding[12]; /* 500-512 (pad to exactly the TAR_BLOCK_SIZE) */ 58 char padding[12]; /* 500-512 (pad to exactly the TAR_BLOCK_SIZE) */
58}; 59};
59typedef struct TarHeader TarHeader;
60 60
61/* 61/*
62** writeTarFile(), writeFileToTarball(), and writeTarHeader() are 62** writeTarFile(), writeFileToTarball(), and writeTarHeader() are
@@ -73,6 +73,7 @@ struct HardLinkInfo {
73}; 73};
74 74
75/* Some info to be carried along when creating a new tarball */ 75/* Some info to be carried along when creating a new tarball */
76typedef struct TarBallInfo TarBallInfo;
76struct TarBallInfo { 77struct TarBallInfo {
77 int tarFd; /* Open-for-write file descriptor 78 int tarFd; /* Open-for-write file descriptor
78 for the tarball */ 79 for the tarball */
@@ -85,7 +86,6 @@ struct TarBallInfo {
85 HardLinkInfo *hlInfoHead; /* Hard Link Tracking Information */ 86 HardLinkInfo *hlInfoHead; /* Hard Link Tracking Information */
86 HardLinkInfo *hlInfo; /* Hard Link Info for the current file */ 87 HardLinkInfo *hlInfo; /* Hard Link Info for the current file */
87}; 88};
88typedef struct TarBallInfo TarBallInfo;
89 89
90/* A nice enum with all the possible tar file content types */ 90/* A nice enum with all the possible tar file content types */
91enum TarFileType { 91enum TarFileType {
@@ -348,7 +348,7 @@ static int writeTarHeader(struct TarBallInfo *tbInfo,
348 return TRUE; 348 return TRUE;
349} 349}
350 350
351# if ENABLE_FEATURE_TAR_FROM 351#if ENABLE_FEATURE_TAR_FROM
352static int exclude_file(const llist_t *excluded_files, const char *file) 352static int exclude_file(const llist_t *excluded_files, const char *file)
353{ 353{
354 while (excluded_files) { 354 while (excluded_files) {
@@ -371,12 +371,12 @@ static int exclude_file(const llist_t *excluded_files, const char *file)
371 371
372 return 0; 372 return 0;
373} 373}
374# else 374#else
375#define exclude_file(excluded_files, file) 0 375#define exclude_file(excluded_files, file) 0
376# endif 376#endif
377 377
378static int writeFileToTarball(const char *fileName, struct stat *statbuf, 378static int writeFileToTarball(const char *fileName, struct stat *statbuf,
379 void *userData, int depth) 379 void *userData, int depth ATTRIBUTE_UNUSED)
380{ 380{
381 struct TarBallInfo *tbInfo = (struct TarBallInfo *) userData; 381 struct TarBallInfo *tbInfo = (struct TarBallInfo *) userData;
382 const char *header_name; 382 const char *header_name;
@@ -509,14 +509,14 @@ static int writeTarFile(const int tar_fd, const int verboseFlag,
509 if (pipe(gzipDataPipe) < 0 || pipe(gzipStatusPipe) < 0) 509 if (pipe(gzipDataPipe) < 0 || pipe(gzipStatusPipe) < 0)
510 bb_perror_msg_and_die("pipe"); 510 bb_perror_msg_and_die("pipe");
511 511
512 signal(SIGPIPE, SIG_IGN); /* we only want EPIPE on errors */ 512 signal(SIGPIPE, SIG_IGN); /* we only want EPIPE on errors */
513 513
514# if __GNUC__ 514#if defined(__GNUC__) && __GNUC__
515 /* Avoid vfork clobbering */ 515 /* Avoid vfork clobbering */
516 (void) &include; 516 (void) &include;
517 (void) &errorFlag; 517 (void) &errorFlag;
518 (void) &zip_exec; 518 (void) &zip_exec;
519# endif 519#endif
520 520
521 gzipPid = vfork(); 521 gzipPid = vfork();
522 522
@@ -600,7 +600,7 @@ static int writeTarFile(const int tar_fd, const int verboseFlag,
600int writeTarFile(const int tar_fd, const int verboseFlag, 600int writeTarFile(const int tar_fd, const int verboseFlag,
601 const unsigned long dereferenceFlag, const llist_t *include, 601 const unsigned long dereferenceFlag, const llist_t *include,
602 const llist_t *exclude, const int gzip); 602 const llist_t *exclude, const int gzip);
603#endif /* tar_create */ 603#endif /* FEATURE_TAR_CREATE */
604 604
605#if ENABLE_FEATURE_TAR_FROM 605#if ENABLE_FEATURE_TAR_FROM
606static llist_t *append_file_list_to_list(llist_t *list) 606static llist_t *append_file_list_to_list(llist_t *list)
@@ -628,7 +628,7 @@ static llist_t *append_file_list_to_list(llist_t *list)
628 return newlist; 628 return newlist;
629} 629}
630#else 630#else
631#define append_file_list_to_list(x) 0 631#define append_file_list_to_list(x) 0
632#endif 632#endif
633 633
634#if ENABLE_FEATURE_TAR_COMPRESS 634#if ENABLE_FEATURE_TAR_COMPRESS
@@ -653,7 +653,7 @@ static char get_header_tar_Z(archive_handle_t *archive_handle)
653 return EXIT_FAILURE; 653 return EXIT_FAILURE;
654} 654}
655#else 655#else
656#define get_header_tar_Z 0 656#define get_header_tar_Z NULL
657#endif 657#endif
658 658
659#ifdef CHECK_FOR_CHILD_EXITCODE 659#ifdef CHECK_FOR_CHILD_EXITCODE
diff --git a/libbb/vdprintf.c b/libbb/vdprintf.c
index ea2a9d4bf..d16c51947 100644
--- a/libbb/vdprintf.c
+++ b/libbb/vdprintf.c
@@ -7,12 +7,8 @@
7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
8 */ 8 */
9 9
10#include <stdio.h>
11#include <unistd.h>
12#include "libbb.h" 10#include "libbb.h"
13 11
14
15
16#if defined(__GLIBC__) && __GLIBC__ < 2 12#if defined(__GLIBC__) && __GLIBC__ < 2
17int vdprintf(int d, const char *format, va_list ap) 13int vdprintf(int d, const char *format, va_list ap)
18{ 14{
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index dc160bf5c..c059e41e0 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -81,13 +81,14 @@ char * xstrndup(const char *s, int n)
81 t = (char*) s; 81 t = (char*) s;
82 while (m) { 82 while (m) {
83 if (!*t) break; 83 if (!*t) break;
84 m--; t++; 84 m--;
85 t++;
85 } 86 }
86 n = n - m; 87 n -= m;
87 t = xmalloc(n + 1); 88 t = xmalloc(n + 1);
88 t[n] = '\0'; 89 t[n] = '\0';
89 90
90 return memcpy(t,s,n); 91 return memcpy(t, s, n);
91} 92}
92 93
93// Die if we can't open a file and return a FILE * to it. 94// Die if we can't open a file and return a FILE * to it.
diff --git a/libbb/xreadlink.c b/libbb/xreadlink.c
index 76f52ca06..fb67cdef1 100644
--- a/libbb/xreadlink.c
+++ b/libbb/xreadlink.c
@@ -36,7 +36,7 @@ char *xreadlink(const char *path)
36 36
37char *xmalloc_realpath(const char *path) 37char *xmalloc_realpath(const char *path)
38{ 38{
39#ifdef __GLIBC__ 39#if defined(__GLIBC__) && !defined(__UCLIBC__)
40 /* glibc provides a non-standard extension */ 40 /* glibc provides a non-standard extension */
41 return realpath(path, NULL); 41 return realpath(path, NULL);
42#else 42#else
diff --git a/networking/libiproute/libnetlink.h b/networking/libiproute/libnetlink.h
index 6dd242d03..9a5a9d351 100644
--- a/networking/libiproute/libnetlink.h
+++ b/networking/libiproute/libnetlink.h
@@ -2,6 +2,9 @@
2#ifndef __LIBNETLINK_H__ 2#ifndef __LIBNETLINK_H__
3#define __LIBNETLINK_H__ 1 3#define __LIBNETLINK_H__ 1
4 4
5#include <linux/types.h>
6/* We need linux/types.h because older kernels use __u32 etc
7 * in linux/[rt]netlink.h. 2.6.19 seems to be ok, though */
5#include <linux/netlink.h> 8#include <linux/netlink.h>
6#include <linux/rtnetlink.h> 9#include <linux/rtnetlink.h>
7 10
@@ -37,6 +40,4 @@ extern int rta_addattr_l(struct rtattr *rta, int maxlen, int type, void *data, i
37 40
38extern int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len); 41extern int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len);
39 42
40
41#endif /* __LIBNETLINK_H__ */ 43#endif /* __LIBNETLINK_H__ */
42
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index 716e41f5f..dca488ec3 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -569,7 +569,7 @@ int syslogd_main(int argc, char **argv)
569 //if (option_mask32 & OPT_locallog) // -L 569 //if (option_mask32 & OPT_locallog) // -L
570#endif 570#endif
571#if ENABLE_FEATURE_IPC_SYSLOG 571#if ENABLE_FEATURE_IPC_SYSLOG
572 if ((option_mask32 & OPT_circularlog) && opt_C) // -C 572 if (opt_C) // -Cn
573 shm_size = xatoul_range(opt_C, 4, INT_MAX/1024) * 1024; 573 shm_size = xatoul_range(opt_C, 4, INT_MAX/1024) * 1024;
574#endif 574#endif
575 575
@@ -588,7 +588,7 @@ int syslogd_main(int argc, char **argv)
588#ifdef BB_NOMMU 588#ifdef BB_NOMMU
589 vfork_daemon_rexec(0, 1, argc, argv, "-n"); 589 vfork_daemon_rexec(0, 1, argc, argv, "-n");
590#else 590#else
591 xdaemon(0, 1); 591 bb_daemonize();
592#endif 592#endif
593 } 593 }
594 umask(0); 594 umask(0);