aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2014-01-21 09:40:50 +0000
committerRon Yorston <rmy@pobox.com>2014-01-21 09:40:50 +0000
commitbaac891244b03eec99cf14a724ebcdc5877bd4e7 (patch)
treea59e8b5156e8d8eb5ea01c518e80f9173c831033
parent61a0fc571381226c48728b262495c1c5eafc4fed (diff)
parent3b394781b5b9301fc489d9bfff6fbefb4db190f3 (diff)
downloadbusybox-w32-baac891244b03eec99cf14a724ebcdc5877bd4e7.tar.gz
busybox-w32-baac891244b03eec99cf14a724ebcdc5877bd4e7.tar.bz2
busybox-w32-baac891244b03eec99cf14a724ebcdc5877bd4e7.zip
Merge branch 'busybox' into merge
-rw-r--r--.gitignore6
-rw-r--r--coreutils/sort.c10
-rw-r--r--docs/keep_data_small.txt10
-rwxr-xr-xexamples/udhcp/sample.bound18
-rwxr-xr-xexamples/udhcp/sample.renew18
-rw-r--r--libbb/time.c16
-rw-r--r--loginutils/Config.src11
-rw-r--r--loginutils/addgroup.c13
-rw-r--r--loginutils/adduser.c24
-rw-r--r--networking/ntpd.c7
-rw-r--r--networking/ntpd_simple.c3
-rw-r--r--procps/top.c5
-rwxr-xr-xtestsuite/sort.tests3
13 files changed, 87 insertions, 57 deletions
diff --git a/.gitignore b/.gitignore
index 54369de10..cae1d53dd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -36,3 +36,9 @@ Config.in
36core 36core
37.gdb_history 37.gdb_history
38.gdbinit 38.gdbinit
39
40#
41# testing output
42#
43/busybox.links
44/runtest-tempdir-links
diff --git a/coreutils/sort.c b/coreutils/sort.c
index a1625fc9c..1cb4c3e3f 100644
--- a/coreutils/sort.c
+++ b/coreutils/sort.c
@@ -225,7 +225,7 @@ static int compare_keys(const void *xarg, const void *yarg)
225 y = *(char **)yarg; 225 y = *(char **)yarg;
226#endif 226#endif
227 /* Perform actual comparison */ 227 /* Perform actual comparison */
228 switch (flags & 7) { 228 switch (flags & (FLAG_n | FLAG_M | FLAG_g)) {
229 default: 229 default:
230 bb_error_msg_and_die("unknown sort type"); 230 bb_error_msg_and_die("unknown sort type");
231 break; 231 break;
@@ -302,10 +302,14 @@ static int compare_keys(const void *xarg, const void *yarg)
302 } /* for */ 302 } /* for */
303 303
304 /* Perform fallback sort if necessary */ 304 /* Perform fallback sort if necessary */
305 if (!retval && !(option_mask32 & FLAG_s)) 305 if (!retval && !(option_mask32 & FLAG_s)) {
306 retval = strcmp(*(char **)xarg, *(char **)yarg); 306 retval = strcmp(*(char **)xarg, *(char **)yarg);
307 flags = option_mask32;
308 }
309
310 if (flags & FLAG_r)
311 return -retval;
307 312
308 if (flags & FLAG_r) return -retval;
309 return retval; 313 return retval;
310} 314}
311 315
diff --git a/docs/keep_data_small.txt b/docs/keep_data_small.txt
index 9fc799646..3ced1a61d 100644
--- a/docs/keep_data_small.txt
+++ b/docs/keep_data_small.txt
@@ -103,7 +103,15 @@ smaller code. In order to assign it, use SET_PTR_TO_GLOBALS macro:
103 103
104 SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); 104 SET_PTR_TO_GLOBALS(xzalloc(sizeof(G)));
105 105
106Typically it is done in <applet>_main(). 106Typically it is done in <applet>_main(). Another variation is
107to use stack:
108
109int <applet>_main(...)
110{
111#undef G
112 struct globals G;
113 memset(&G, 0, sizeof(G));
114 SET_PTR_TO_GLOBALS(&G);
107 115
108Now you can reference "globals" by G.a, G.buf and so on, in any function. 116Now you can reference "globals" by G.a, G.buf and so on, in any function.
109 117
diff --git a/examples/udhcp/sample.bound b/examples/udhcp/sample.bound
index bd3569c77..7c9d857e0 100755
--- a/examples/udhcp/sample.bound
+++ b/examples/udhcp/sample.bound
@@ -22,10 +22,14 @@ then
22 done 22 done
23fi 23fi
24 24
25echo -n > $RESOLV_CONF 25# Only replace resolv.conf is we have at least one DNS server
26[ -n "$domain" ] && echo domain $domain >> $RESOLV_CONF 26if [ -n "$dns" ]
27for i in $dns 27then
28do 28 echo -n > $RESOLV_CONF
29 echo adding dns $i 29 [ -n "$domain" ] && echo domain $domain >> $RESOLV_CONF
30 echo nameserver $i >> $RESOLV_CONF 30 for i in $dns
31done 31 do
32 echo adding dns $i
33 echo nameserver $i >> $RESOLV_CONF
34 done
35fi
diff --git a/examples/udhcp/sample.renew b/examples/udhcp/sample.renew
index ea368fc9e..4dce8486a 100755
--- a/examples/udhcp/sample.renew
+++ b/examples/udhcp/sample.renew
@@ -22,10 +22,14 @@ then
22 done 22 done
23fi 23fi
24 24
25echo -n > $RESOLV_CONF 25# Only replace resolv.conf is we have at least one DNS server
26[ -n "$domain" ] && echo domain $domain >> $RESOLV_CONF 26if [ -n "$dns" ]
27for i in $dns 27then
28do 28 echo -n > $RESOLV_CONF
29 echo adding dns $i 29 [ -n "$domain" ] && echo domain $domain >> $RESOLV_CONF
30 echo nameserver $i >> $RESOLV_CONF 30 for i in $dns
31done 31 do
32 echo adding dns $i
33 echo nameserver $i >> $RESOLV_CONF
34 done
35fi
diff --git a/libbb/time.c b/libbb/time.c
index ea2f72e3b..aa19a47d4 100644
--- a/libbb/time.c
+++ b/libbb/time.c
@@ -68,15 +68,23 @@ void FAST_FUNC parse_datestr(const char *date_str, struct tm *ptm)
68 /* else end != NUL and we error out */ 68 /* else end != NUL and we error out */
69 } 69 }
70 } else 70 } else
71 /* yyyy-mm-dd HH */ 71 if (strchr(date_str, '-')
72 if (sscanf(date_str, "%u-%u-%u %u%c", &ptm->tm_year, 72 /* Why strchr('-') check?
73 * sscanf below will trash ptm->tm_year, this breaks
74 * if parse_str is "10101010" (iow, "MMddhhmm" form)
75 * because we destroy year. Do these sscanf
76 * only if we saw a dash in parse_str.
77 */
78 /* yyyy-mm-dd HH */
79 && (sscanf(date_str, "%u-%u-%u %u%c", &ptm->tm_year,
73 &ptm->tm_mon, &ptm->tm_mday, 80 &ptm->tm_mon, &ptm->tm_mday,
74 &ptm->tm_hour, 81 &ptm->tm_hour,
75 &end) >= 4 82 &end) >= 4
76 /* yyyy-mm-dd */ 83 /* yyyy-mm-dd */
77 || sscanf(date_str, "%u-%u-%u%c", &ptm->tm_year, 84 || sscanf(date_str, "%u-%u-%u%c", &ptm->tm_year,
78 &ptm->tm_mon, &ptm->tm_mday, 85 &ptm->tm_mon, &ptm->tm_mday,
79 &end) >= 3 86 &end) >= 3
87 )
80 ) { 88 ) {
81 ptm->tm_year -= 1900; /* Adjust years */ 89 ptm->tm_year -= 1900; /* Adjust years */
82 ptm->tm_mon -= 1; /* Adjust month from 1-12 to 0-11 */ 90 ptm->tm_mon -= 1; /* Adjust month from 1-12 to 0-11 */
diff --git a/loginutils/Config.src b/loginutils/Config.src
index 9bf79afee..b78d7c38e 100644
--- a/loginutils/Config.src
+++ b/loginutils/Config.src
@@ -118,10 +118,17 @@ config FEATURE_CHECK_NAMES
118 For compatibility with Samba machine accounts "$" is also supported 118 For compatibility with Samba machine accounts "$" is also supported
119 at the end of the user or group name. 119 at the end of the user or group name.
120 120
121config LAST_ID
122 int "Last valid uid or gid for adduser and addgroup"
123 depends on ADDUSER || ADDGROUP
124 default 60000
125 help
126 Last valid uid or gid for adduser and addgroup
127
121config FIRST_SYSTEM_ID 128config FIRST_SYSTEM_ID
122 int "First valid system uid or gid for adduser and addgroup" 129 int "First valid system uid or gid for adduser and addgroup"
123 depends on ADDUSER || ADDGROUP 130 depends on ADDUSER || ADDGROUP
124 range 0 64900 131 range 0 LAST_ID
125 default 100 132 default 100
126 help 133 help
127 First valid system uid or gid for adduser and addgroup 134 First valid system uid or gid for adduser and addgroup
@@ -129,7 +136,7 @@ config FIRST_SYSTEM_ID
129config LAST_SYSTEM_ID 136config LAST_SYSTEM_ID
130 int "Last valid system uid or gid for adduser and addgroup" 137 int "Last valid system uid or gid for adduser and addgroup"
131 depends on ADDUSER || ADDGROUP 138 depends on ADDUSER || ADDGROUP
132 range 0 64900 139 range FIRST_SYSTEM_ID LAST_ID
133 default 999 140 default 999
134 help 141 help
135 Last valid system uid or gid for adduser and addgroup 142 Last valid system uid or gid for adduser and addgroup
diff --git a/loginutils/addgroup.c b/loginutils/addgroup.c
index b37270ff0..22cd0e661 100644
--- a/loginutils/addgroup.c
+++ b/loginutils/addgroup.c
@@ -22,14 +22,16 @@
22#if CONFIG_LAST_SYSTEM_ID < CONFIG_FIRST_SYSTEM_ID 22#if CONFIG_LAST_SYSTEM_ID < CONFIG_FIRST_SYSTEM_ID
23#error Bad LAST_SYSTEM_ID or FIRST_SYSTEM_ID in .config 23#error Bad LAST_SYSTEM_ID or FIRST_SYSTEM_ID in .config
24#endif 24#endif
25#if CONFIG_LAST_ID < CONFIG_LAST_SYSTEM_ID
26#error Bad LAST_ID or LAST_SYSTEM_ID in .config
27#endif
25 28
26#define OPT_GID (1 << 0) 29#define OPT_GID (1 << 0)
27#define OPT_SYSTEM_ACCOUNT (1 << 1) 30#define OPT_SYSTEM_ACCOUNT (1 << 1)
28 31
29/* We assume GID_T_MAX == INT_MAX */
30static void xgroup_study(struct group *g) 32static void xgroup_study(struct group *g)
31{ 33{
32 unsigned max = INT_MAX; 34 unsigned max = CONFIG_LAST_ID;
33 35
34 /* Make sure gr_name is unused */ 36 /* Make sure gr_name is unused */
35 if (getgrnam(g->gr_name)) { 37 if (getgrnam(g->gr_name)) {
@@ -46,7 +48,6 @@ static void xgroup_study(struct group *g)
46 max = CONFIG_LAST_SYSTEM_ID; 48 max = CONFIG_LAST_SYSTEM_ID;
47 } else { 49 } else {
48 g->gr_gid = CONFIG_LAST_SYSTEM_ID + 1; 50 g->gr_gid = CONFIG_LAST_SYSTEM_ID + 1;
49 max = 64999;
50 } 51 }
51 } 52 }
52 /* Check if the desired gid is free 53 /* Check if the desired gid is free
@@ -125,7 +126,7 @@ int addgroup_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
125int addgroup_main(int argc UNUSED_PARAM, char **argv) 126int addgroup_main(int argc UNUSED_PARAM, char **argv)
126{ 127{
127 unsigned opts; 128 unsigned opts;
128 unsigned gid = 0; 129 const char *gid = "0";
129 130
130 /* need to be root */ 131 /* need to be root */
131 if (geteuid()) { 132 if (geteuid()) {
@@ -139,7 +140,7 @@ int addgroup_main(int argc UNUSED_PARAM, char **argv)
139 * addgroup -g num group 140 * addgroup -g num group
140 * addgroup user group 141 * addgroup user group
141 * Check for min, max and missing args */ 142 * Check for min, max and missing args */
142 opt_complementary = "-1:?2:g+"; 143 opt_complementary = "-1:?2";
143 opts = getopt32(argv, "g:S", &gid); 144 opts = getopt32(argv, "g:S", &gid);
144 /* move past the commandline options */ 145 /* move past the commandline options */
145 argv += optind; 146 argv += optind;
@@ -175,7 +176,7 @@ int addgroup_main(int argc UNUSED_PARAM, char **argv)
175#endif /* ENABLE_FEATURE_ADDUSER_TO_GROUP */ 176#endif /* ENABLE_FEATURE_ADDUSER_TO_GROUP */
176 { 177 {
177 die_if_bad_username(argv[0]); 178 die_if_bad_username(argv[0]);
178 new_group(argv[0], gid); 179 new_group(argv[0], xatou_range(gid, 0, CONFIG_LAST_ID));
179 } 180 }
180 /* Reached only on success */ 181 /* Reached only on success */
181 return EXIT_SUCCESS; 182 return EXIT_SUCCESS;
diff --git a/loginutils/adduser.c b/loginutils/adduser.c
index ef390adf8..568a3018e 100644
--- a/loginutils/adduser.c
+++ b/loginutils/adduser.c
@@ -26,6 +26,10 @@
26#if CONFIG_LAST_SYSTEM_ID < CONFIG_FIRST_SYSTEM_ID 26#if CONFIG_LAST_SYSTEM_ID < CONFIG_FIRST_SYSTEM_ID
27#error Bad LAST_SYSTEM_ID or FIRST_SYSTEM_ID in .config 27#error Bad LAST_SYSTEM_ID or FIRST_SYSTEM_ID in .config
28#endif 28#endif
29#if CONFIG_LAST_ID < CONFIG_LAST_SYSTEM_ID
30#error Bad LAST_ID or LAST_SYSTEM_ID in .config
31#endif
32
29 33
30/* #define OPT_HOME (1 << 0) */ /* unused */ 34/* #define OPT_HOME (1 << 0) */ /* unused */
31/* #define OPT_GECOS (1 << 1) */ /* unused */ 35/* #define OPT_GECOS (1 << 1) */ /* unused */
@@ -36,12 +40,11 @@
36#define OPT_DONT_MAKE_HOME (1 << 6) 40#define OPT_DONT_MAKE_HOME (1 << 6)
37#define OPT_UID (1 << 7) 41#define OPT_UID (1 << 7)
38 42
39/* We assume UID_T_MAX == INT_MAX */
40/* remix */ 43/* remix */
41/* recoded such that the uid may be passed in *p */ 44/* recoded such that the uid may be passed in *p */
42static void passwd_study(struct passwd *p) 45static void passwd_study(struct passwd *p)
43{ 46{
44 int max = UINT_MAX; 47 int max = CONFIG_LAST_ID;
45 48
46 if (getpwnam(p->pw_name)) { 49 if (getpwnam(p->pw_name)) {
47 bb_error_msg_and_die("%s '%s' in use", "user", p->pw_name); 50 bb_error_msg_and_die("%s '%s' in use", "user", p->pw_name);
@@ -54,7 +57,6 @@ static void passwd_study(struct passwd *p)
54 max = CONFIG_LAST_SYSTEM_ID; 57 max = CONFIG_LAST_SYSTEM_ID;
55 } else { 58 } else {
56 p->pw_uid = CONFIG_LAST_SYSTEM_ID + 1; 59 p->pw_uid = CONFIG_LAST_SYSTEM_ID + 1;
57 max = 64999;
58 } 60 }
59 } 61 }
60 /* check for a free uid (and maybe gid) */ 62 /* check for a free uid (and maybe gid) */
@@ -147,6 +149,7 @@ int adduser_main(int argc UNUSED_PARAM, char **argv)
147 const char *usegroup = NULL; 149 const char *usegroup = NULL;
148 char *p; 150 char *p;
149 unsigned opts; 151 unsigned opts;
152 char *uid;
150 153
151#if ENABLE_FEATURE_ADDUSER_LONG_OPTIONS 154#if ENABLE_FEATURE_ADDUSER_LONG_OPTIONS
152 applet_long_options = adduser_longopts; 155 applet_long_options = adduser_longopts;
@@ -164,16 +167,11 @@ int adduser_main(int argc UNUSED_PARAM, char **argv)
164 167
165 /* at least one and at most two non-option args */ 168 /* at least one and at most two non-option args */
166 /* disable interactive passwd for system accounts */ 169 /* disable interactive passwd for system accounts */
167 opt_complementary = "-1:?2:SD:u+"; 170 opt_complementary = "-1:?2:SD";
168 if (sizeof(pw.pw_uid) == sizeof(int)) { 171 opts = getopt32(argv, "h:g:s:G:DSHu:", &pw.pw_dir, &pw.pw_gecos, &pw.pw_shell, &usegroup, &uid);
169 opts = getopt32(argv, "h:g:s:G:DSHu:", &pw.pw_dir, &pw.pw_gecos, &pw.pw_shell, &usegroup, &pw.pw_uid); 172 if (opts & OPT_UID)
170 } else { 173 pw.pw_uid = xatou_range(uid, 0, CONFIG_LAST_ID);
171 unsigned uid; 174
172 opts = getopt32(argv, "h:g:s:G:DSHu:", &pw.pw_dir, &pw.pw_gecos, &pw.pw_shell, &usegroup, &uid);
173 if (opts & OPT_UID) {
174 pw.pw_uid = uid;
175 }
176 }
177 argv += optind; 175 argv += optind;
178 pw.pw_name = argv[0]; 176 pw.pw_name = argv[0];
179 177
diff --git a/networking/ntpd.c b/networking/ntpd.c
index c4b018778..03fe448ca 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -51,9 +51,6 @@
51#ifndef IPTOS_LOWDELAY 51#ifndef IPTOS_LOWDELAY
52# define IPTOS_LOWDELAY 0x10 52# define IPTOS_LOWDELAY 0x10
53#endif 53#endif
54#ifndef IP_PKTINFO
55# error "Sorry, your kernel has to support IP_PKTINFO"
56#endif
57 54
58 55
59/* Verbosity control (max level of -dddd options accepted). 56/* Verbosity control (max level of -dddd options accepted).
@@ -1328,7 +1325,9 @@ update_local_clock(peer_t *p)
1328#if !USING_KERNEL_PLL_LOOP 1325#if !USING_KERNEL_PLL_LOOP
1329 double freq_drift; 1326 double freq_drift;
1330#endif 1327#endif
1328#if !USING_KERNEL_PLL_LOOP || USING_INITIAL_FREQ_ESTIMATION
1331 double since_last_update; 1329 double since_last_update;
1330#endif
1332 double etemp, dtemp; 1331 double etemp, dtemp;
1333 1332
1334 abs_offset = fabs(offset); 1333 abs_offset = fabs(offset);
@@ -1356,7 +1355,9 @@ update_local_clock(peer_t *p)
1356 * action is and defines how the system reacts to large time 1355 * action is and defines how the system reacts to large time
1357 * and frequency errors. 1356 * and frequency errors.
1358 */ 1357 */
1358#if !USING_KERNEL_PLL_LOOP || USING_INITIAL_FREQ_ESTIMATION
1359 since_last_update = recv_time - G.reftime; 1359 since_last_update = recv_time - G.reftime;
1360#endif
1360#if !USING_KERNEL_PLL_LOOP 1361#if !USING_KERNEL_PLL_LOOP
1361 freq_drift = 0; 1362 freq_drift = 0;
1362#endif 1363#endif
diff --git a/networking/ntpd_simple.c b/networking/ntpd_simple.c
index 3e7fc4719..22e899cb6 100644
--- a/networking/ntpd_simple.c
+++ b/networking/ntpd_simple.c
@@ -11,9 +11,6 @@
11#ifndef IPTOS_LOWDELAY 11#ifndef IPTOS_LOWDELAY
12# define IPTOS_LOWDELAY 0x10 12# define IPTOS_LOWDELAY 0x10
13#endif 13#endif
14#ifndef IP_PKTINFO
15# error "Sorry, your kernel has to support IP_PKTINFO"
16#endif
17 14
18 15
19/* Sync to peers every N secs */ 16/* Sync to peers every N secs */
diff --git a/procps/top.c b/procps/top.c
index 51f1c1aed..530f45fa1 100644
--- a/procps/top.c
+++ b/procps/top.c
@@ -917,17 +917,12 @@ enum {
917#if ENABLE_FEATURE_USE_TERMIOS 917#if ENABLE_FEATURE_USE_TERMIOS
918static unsigned handle_input(unsigned scan_mask, unsigned interval) 918static unsigned handle_input(unsigned scan_mask, unsigned interval)
919{ 919{
920 struct pollfd pfd[1];
921
922 if (option_mask32 & OPT_EOF) { 920 if (option_mask32 & OPT_EOF) {
923 /* EOF on stdin ("top </dev/null") */ 921 /* EOF on stdin ("top </dev/null") */
924 sleep(interval); 922 sleep(interval);
925 return scan_mask; 923 return scan_mask;
926 } 924 }
927 925
928 pfd[0].fd = 0;
929 pfd[0].events = POLLIN;
930
931 while (1) { 926 while (1) {
932 int32_t c; 927 int32_t c;
933 928
diff --git a/testsuite/sort.tests b/testsuite/sort.tests
index 91b282ea0..68fa3e405 100755
--- a/testsuite/sort.tests
+++ b/testsuite/sort.tests
@@ -47,8 +47,6 @@ egg 1 2 papyrus
47999 3 0 algebra 47999 3 0 algebra
48" "$data" "" 48" "$data" ""
49 49
50test x"$SKIP_KNOWN_BUGS" = x"" && {
51# Busybox is definitely doing these wrong. FIXME
52testing "sort key range with numeric option and global reverse" \ 50testing "sort key range with numeric option and global reverse" \
53"sort -k2,3n -r input" \ 51"sort -k2,3n -r input" \
54"egg 1 2 papyrus 52"egg 1 2 papyrus
@@ -65,7 +63,6 @@ testing "sort key range with multiple options" "sort -k2,3rn input" \
6542 1 3 woot 6342 1 3 woot
66egg 1 2 papyrus 64egg 1 2 papyrus
67" "$data" "" 65" "$data" ""
68}
69 66
70testing "sort key range with two -k options" "sort -k 2,2n -k 1,1r input" "\ 67testing "sort key range with two -k options" "sort -k 2,2n -k 1,1r input" "\
71d 2 68d 2