aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277>2003-05-26 14:07:50 +0000
committerbug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277>2003-05-26 14:07:50 +0000
commit76f4ab68a56e14747c25e6da830cf73b38bbe1cd (patch)
treed2e94dac0f1f5da5cb3ecb927b78c4c2a02f4ea6
parent37e0338781ea28f57bed354fe745effb020d16fc (diff)
downloadbusybox-w32-76f4ab68a56e14747c25e6da830cf73b38bbe1cd.tar.gz
busybox-w32-76f4ab68a56e14747c25e6da830cf73b38bbe1cd.tar.bz2
busybox-w32-76f4ab68a56e14747c25e6da830cf73b38bbe1cd.zip
Vodz, last_patch_86
git-svn-id: svn://busybox.net/trunk/busybox@6853 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--coreutils/du.c5
-rw-r--r--include/libbb.h1
-rw-r--r--libbb/Makefile.in2
-rw-r--r--libbb/concat_subpath_file.c36
-rw-r--r--libbb/copy_file.c6
-rw-r--r--libbb/find_root_device.c7
-rw-r--r--libbb/isdirectory.c12
-rw-r--r--libbb/login.c50
-rw-r--r--libbb/pw_encrypt.c5
-rw-r--r--libbb/recursive_action.c6
-rw-r--r--libbb/remove_file.c6
-rw-r--r--libbb/run_shell.c4
-rw-r--r--libbb/setup_environment.c4
-rw-r--r--libbb/xgetcwd.c2
-rw-r--r--networking/Config.in18
-rw-r--r--networking/httpd.c68
-rw-r--r--networking/ifconfig.c4
17 files changed, 121 insertions, 115 deletions
diff --git a/coreutils/du.c b/coreutils/du.c
index 702a9aa14..1c16cfbd4 100644
--- a/coreutils/du.c
+++ b/coreutils/du.c
@@ -144,10 +144,9 @@ static long du(char *filename)
144 while ((entry = readdir(dir))) { 144 while ((entry = readdir(dir))) {
145 char *name = entry->d_name; 145 char *name = entry->d_name;
146 146
147 if ((name[0] == '.') && (!name[1] || (name[1] == '.' && !name[2]))) { 147 newfile = concat_subpath_file(filename, name);
148 if(newfile == NULL)
148 continue; 149 continue;
149 }
150 newfile = concat_path_file(filename, name);
151 ++du_depth; 150 ++du_depth;
152 sum += du(newfile); 151 sum += du(newfile);
153 --du_depth; 152 --du_depth;
diff --git a/include/libbb.h b/include/libbb.h
index f79def321..a54ab4d5c 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -272,6 +272,7 @@ int klogctl(int type, char * b, int len);
272char *xgetcwd(char *cwd); 272char *xgetcwd(char *cwd);
273char *xreadlink(const char *path); 273char *xreadlink(const char *path);
274char *concat_path_file(const char *path, const char *filename); 274char *concat_path_file(const char *path, const char *filename);
275char *concat_subpath_file(const char *path, const char *filename);
275char *last_char_is(const char *s, int c); 276char *last_char_is(const char *s, int c);
276 277
277extern long arith (const char *startbuf, int *errcode); 278extern long arith (const char *startbuf, int *errcode);
diff --git a/libbb/Makefile.in b/libbb/Makefile.in
index 06daf232c..98b0c66e2 100644
--- a/libbb/Makefile.in
+++ b/libbb/Makefile.in
@@ -48,7 +48,7 @@ LIBBB_SRC:= \
48 fclose_nonstdin.c fflush_stdout_and_exit.c getopt_ulflags.c \ 48 fclose_nonstdin.c fflush_stdout_and_exit.c getopt_ulflags.c \
49 default_error_retval.c wfopen_input.c speed_table.c \ 49 default_error_retval.c wfopen_input.c speed_table.c \
50 perror_nomsg_and_die.c perror_nomsg.c skip_whitespace.c \ 50 perror_nomsg_and_die.c perror_nomsg.c skip_whitespace.c \
51 warn_ignoring_args.c 51 warn_ignoring_args.c concat_subpath_file.c
52 52
53LIBBB_OBJS=$(patsubst %.c,$(LIBBB_DIR)%.o, $(LIBBB_SRC)) 53LIBBB_OBJS=$(patsubst %.c,$(LIBBB_DIR)%.o, $(LIBBB_SRC))
54 54
diff --git a/libbb/concat_subpath_file.c b/libbb/concat_subpath_file.c
new file mode 100644
index 000000000..6d86f5e8c
--- /dev/null
+++ b/libbb/concat_subpath_file.c
@@ -0,0 +1,36 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * Utility routines.
4 *
5 * Copyright (C) (C) 2003 Vladimir Oleynik <dzo@simtreas.ru>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * USA
21 */
22
23/*
24 This function make special for recursive actions with usage
25 concat_path_file(path, filename)
26 and skiping "." and ".." directory entries
27*/
28
29#include "libbb.h"
30
31extern char *concat_subpath_file(const char *path, const char *f)
32{
33 if(f && *f == '.' && (!f[1] || (f[1] == '.' && !f[2])))
34 return NULL;
35 return concat_path_file(path, f);
36}
diff --git a/libbb/copy_file.c b/libbb/copy_file.c
index 81c547479..5808ca48c 100644
--- a/libbb/copy_file.c
+++ b/libbb/copy_file.c
@@ -105,11 +105,9 @@ int copy_file(const char *source, const char *dest, int flags)
105 while ((d = readdir(dp)) != NULL) { 105 while ((d = readdir(dp)) != NULL) {
106 char *new_source, *new_dest; 106 char *new_source, *new_dest;
107 107
108 if (strcmp(d->d_name, ".") == 0 || 108 new_source = concat_subpath_file(source, d->d_name);
109 strcmp(d->d_name, "..") == 0) 109 if(new_source == NULL)
110 continue; 110 continue;
111
112 new_source = concat_path_file(source, d->d_name);
113 new_dest = concat_path_file(dest, d->d_name); 111 new_dest = concat_path_file(dest, d->d_name);
114 if (copy_file(new_source, new_dest, flags) < 0) 112 if (copy_file(new_source, new_dest, flags) < 0)
115 status = -1; 113 status = -1;
diff --git a/libbb/find_root_device.c b/libbb/find_root_device.c
index 763ac7519..b12d392a2 100644
--- a/libbb/find_root_device.c
+++ b/libbb/find_root_device.c
@@ -49,13 +49,10 @@ extern char *find_real_root_device_name(const char* name)
49 else { 49 else {
50 while((entry = readdir(dir)) != NULL) { 50 while((entry = readdir(dir)) != NULL) {
51 51
52 /* Must skip ".." since that is "/", and so we 52 fileName = concat_subpath_file("/dev", entry->d_name);
53 * would get a false positive on ".." */ 53 if(fileName == NULL)
54 if (strcmp(entry->d_name, "..") == 0)
55 continue; 54 continue;
56 55
57 fileName = concat_path_file("/dev", entry->d_name);
58
59 /* Some char devices have the same dev_t as block 56 /* Some char devices have the same dev_t as block
60 * devices, so make sure this is a block device */ 57 * devices, so make sure this is a block device */
61 if (stat(fileName, &statBuf) == 0 && 58 if (stat(fileName, &statBuf) == 0 &&
diff --git a/libbb/isdirectory.c b/libbb/isdirectory.c
index e8ef2df14..e9b106aa3 100644
--- a/libbb/isdirectory.c
+++ b/libbb/isdirectory.c
@@ -20,8 +20,6 @@
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */ 21 */
22 22
23#include <stdio.h>
24#include <stdlib.h>
25#include <sys/stat.h> 23#include <sys/stat.h>
26#include "libbb.h" 24#include "libbb.h"
27 25
@@ -32,11 +30,11 @@
32int is_directory(const char *fileName, const int followLinks, struct stat *statBuf) 30int is_directory(const char *fileName, const int followLinks, struct stat *statBuf)
33{ 31{
34 int status; 32 int status;
35 int didMalloc = 0; 33 struct stat astatBuf;
36 34
37 if (statBuf == NULL) { 35 if (statBuf == NULL) {
38 statBuf = (struct stat *)xmalloc(sizeof(struct stat)); 36 /* set from auto stack buffer */
39 ++didMalloc; 37 statBuf = &astatBuf;
40 } 38 }
41 39
42 if (followLinks) 40 if (followLinks)
@@ -49,10 +47,6 @@ int is_directory(const char *fileName, const int followLinks, struct stat *statB
49 } 47 }
50 else status = TRUE; 48 else status = TRUE;
51 49
52 if (didMalloc) {
53 free(statBuf);
54 statBuf = NULL;
55 }
56 return status; 50 return status;
57} 51}
58 52
diff --git a/libbb/login.c b/libbb/login.c
index bd8035f41..67636e6b5 100644
--- a/libbb/login.c
+++ b/libbb/login.c
@@ -17,26 +17,28 @@
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 * 19 *
20 * $Id: login.c,v 1.3 2003/05/13 13:28:25 bug1 Exp $ 20 * Optimize and correcting OCRNL by Vladimir Oleynik <dzo@simtreas.ru>
21 */ 21 */
22 22
23#include <sys/param.h> /* MAXHOSTNAMELEN */
23#include <stdio.h> 24#include <stdio.h>
24#include <unistd.h> 25#include <unistd.h>
25#include "busybox.h" 26#include "libbb.h"
26 27
27#include <sys/utsname.h> 28#include <sys/utsname.h>
28#include <time.h> 29#include <time.h>
29 30
30#define LOGIN " login: " 31#define LOGIN " login: "
31 32
32static char fmtstr_d[] = { "%A, %d %B %Y" }; 33static const char fmtstr_d[] = "%A, %d %B %Y";
33static char fmtstr_t[] = { "%H:%M:%S" }; 34static const char fmtstr_t[] = "%H:%M:%S";
34 35
35void print_login_issue(const char *issue_file, const char *tty) 36void print_login_issue(const char *issue_file, const char *tty)
36{ 37{
37 FILE *fd; 38 FILE *fd;
38 int c; 39 int c;
39 char buf[256]; 40 char buf[256];
41 const char *outbuf;
40 time_t t; 42 time_t t;
41 struct utsname uts; 43 struct utsname uts;
42 44
@@ -47,73 +49,75 @@ void print_login_issue(const char *issue_file, const char *tty)
47 49
48 if ((fd = fopen(issue_file, "r"))) { 50 if ((fd = fopen(issue_file, "r"))) {
49 while ((c = fgetc(fd)) != EOF) { 51 while ((c = fgetc(fd)) != EOF) {
52 outbuf = buf;
53 buf[0] = c;
54 if(c == '\n') {
55 buf[1] = '\r';
56 buf[2] = 0;
57 } else {
58 buf[1] = 0;
59 }
50 if (c == '\\' || c == '%') { 60 if (c == '\\' || c == '%') {
51 c = fgetc(fd); 61 c = fgetc(fd);
52
53 switch (c) { 62 switch (c) {
54 case 's': 63 case 's':
55 fputs(uts.sysname, stdout); 64 outbuf = uts.sysname;
56 break; 65 break;
57 66
58 case 'n': 67 case 'n':
59 fputs(uts.nodename, stdout); 68 outbuf = uts.nodename;
60 break; 69 break;
61 70
62 case 'r': 71 case 'r':
63 fputs(uts.release, stdout); 72 outbuf = uts.release;
64 break; 73 break;
65 74
66 case 'v': 75 case 'v':
67 fputs(uts.version, stdout); 76 outbuf = uts.version;
68 break; 77 break;
69 78
70 case 'm': 79 case 'm':
71 fputs(uts.machine, stdout); 80 outbuf = uts.machine;
72 break; 81 break;
73 82
74 case 'D': 83 case 'D':
75 case 'o': 84 case 'o':
76 getdomainname(buf, sizeof(buf)); 85 getdomainname(buf, sizeof(buf));
77 buf[sizeof(buf) - 1] = '\0'; 86 buf[sizeof(buf) - 1] = '\0';
78 fputs(buf, stdout);
79 break; 87 break;
80 88
81 case 'd': 89 case 'd':
82 strftime(buf, sizeof(buf), fmtstr_d, localtime(&t)); 90 strftime(buf, sizeof(buf), fmtstr_d, localtime(&t));
83 fputs(buf, stdout);
84 break; 91 break;
85 92
86 case 't': 93 case 't':
87 strftime(buf, sizeof(buf), fmtstr_t, localtime(&t)); 94 strftime(buf, sizeof(buf), fmtstr_t, localtime(&t));
88 fputs(buf, stdout);
89 break; 95 break;
90 96
91 case 'h': 97 case 'h':
92 gethostname(buf, sizeof(buf)); 98 gethostname(buf, sizeof(buf) - 1);
93 fputs(buf, stdout);
94 break; 99 break;
95 100
96 case 'l': 101 case 'l':
97 printf("%s", tty); 102 outbuf = tty;
98 break; 103 break;
99 104
100 default: 105 default:
101 putchar(c); 106 buf[0] = c;
102 } 107 }
103 } else
104 putchar(c);
105 } 108 }
106 109 fputs(outbuf, stdout);
107 puts(""); /* start a new line */ 110 }
108 fflush(stdout);
109 111
110 fclose(fd); 112 fclose(fd);
113
114 fflush(stdout);
111 } 115 }
112} 116}
113 117
114void print_login_prompt(void) 118void print_login_prompt(void)
115{ 119{
116 char buf[MAXHOSTNAMELEN]; 120 char buf[MAXHOSTNAMELEN+1];
117 121
118 gethostname(buf, MAXHOSTNAMELEN); 122 gethostname(buf, MAXHOSTNAMELEN);
119 fputs(buf, stdout); 123 fputs(buf, stdout);
diff --git a/libbb/pw_encrypt.c b/libbb/pw_encrypt.c
index 0e4eb9f8a..ac79f839f 100644
--- a/libbb/pw_encrypt.c
+++ b/libbb/pw_encrypt.c
@@ -39,10 +39,7 @@ extern char *pw_encrypt(const char *clear, const char *salt)
39 /* if crypt (a nonstandard crypt) returns a string too large, 39 /* if crypt (a nonstandard crypt) returns a string too large,
40 truncate it so we don't overrun buffers and hope there is 40 truncate it so we don't overrun buffers and hope there is
41 enough security in what's left */ 41 enough security in what's left */
42 if (strlen(cp) > sizeof(cipher)-1) { 42 safe_strncpy(cipher, cp, sizeof(cipher));
43 cp[sizeof(cipher)-1] = 0;
44 }
45 strcpy(cipher, cp);
46 return cipher; 43 return cipher;
47} 44}
48 45
diff --git a/libbb/recursive_action.c b/libbb/recursive_action.c
index a4a4a7be3..3ea107ca9 100644
--- a/libbb/recursive_action.c
+++ b/libbb/recursive_action.c
@@ -103,11 +103,9 @@ int recursive_action(const char *fileName,
103 while ((next = readdir(dir)) != NULL) { 103 while ((next = readdir(dir)) != NULL) {
104 char *nextFile; 104 char *nextFile;
105 105
106 if ((strcmp(next->d_name, "..") == 0) 106 nextFile = concat_subpath_file(fileName, next->d_name);
107 || (strcmp(next->d_name, ".") == 0)) { 107 if(nextFile == NULL)
108 continue; 108 continue;
109 }
110 nextFile = concat_path_file(fileName, next->d_name);
111 if (! recursive_action(nextFile, TRUE, followLinks, depthFirst, 109 if (! recursive_action(nextFile, TRUE, followLinks, depthFirst,
112 fileAction, dirAction, userData)) { 110 fileAction, dirAction, userData)) {
113 status = FALSE; 111 status = FALSE;
diff --git a/libbb/remove_file.c b/libbb/remove_file.c
index 65708a252..8b45c58b8 100644
--- a/libbb/remove_file.c
+++ b/libbb/remove_file.c
@@ -79,11 +79,9 @@ extern int remove_file(const char *path, int flags)
79 while ((d = readdir(dp)) != NULL) { 79 while ((d = readdir(dp)) != NULL) {
80 char *new_path; 80 char *new_path;
81 81
82 if (strcmp(d->d_name, ".") == 0 || 82 new_path = concat_subpath_file(path, d->d_name);
83 strcmp(d->d_name, "..") == 0) 83 if(new_path == NULL)
84 continue; 84 continue;
85
86 new_path = concat_path_file(path, d->d_name);
87 if (remove_file(new_path, flags) < 0) 85 if (remove_file(new_path, flags) < 0)
88 status = -1; 86 status = -1;
89 free(new_path); 87 free(new_path);
diff --git a/libbb/run_shell.c b/libbb/run_shell.c
index d154b9852..49e8a76c2 100644
--- a/libbb/run_shell.c
+++ b/libbb/run_shell.c
@@ -52,10 +52,7 @@ void run_shell ( const char *shell, int loginshell, const char *command, const c
52 for ( args = additional_args; args && *args; args++ ) 52 for ( args = additional_args; args && *args; args++ )
53 additional_args_cnt++; 53 additional_args_cnt++;
54 54
55 if ( additional_args )
56 args = (const char **) xmalloc (sizeof (char *) * ( 4 + additional_args_cnt )); 55 args = (const char **) xmalloc (sizeof (char *) * ( 4 + additional_args_cnt ));
57 else
58 args = (const char **) xmalloc (sizeof (char *) * 4 );
59 56
60 args [0] = bb_get_last_path_component ( bb_xstrdup ( shell )); 57 args [0] = bb_get_last_path_component ( bb_xstrdup ( shell ));
61 58
@@ -77,4 +74,3 @@ void run_shell ( const char *shell, int loginshell, const char *command, const c
77 execv ( shell, (char **) args ); 74 execv ( shell, (char **) args );
78 bb_perror_msg_and_die ( "cannot run %s", shell ); 75 bb_perror_msg_and_die ( "cannot run %s", shell );
79} 76}
80
diff --git a/libbb/setup_environment.c b/libbb/setup_environment.c
index 30d317cea..b18f8967e 100644
--- a/libbb/setup_environment.c
+++ b/libbb/setup_environment.c
@@ -45,13 +45,13 @@
45static void xsetenv ( const char *key, const char *value ) 45static void xsetenv ( const char *key, const char *value )
46{ 46{
47 if ( setenv ( key, value, 1 )) 47 if ( setenv ( key, value, 1 ))
48 bb_error_msg_and_die ( "out of memory" ); 48 bb_error_msg_and_die (bb_msg_memory_exhausted);
49} 49}
50 50
51void setup_environment ( const char *shell, int loginshell, int changeenv, const struct passwd *pw ) 51void setup_environment ( const char *shell, int loginshell, int changeenv, const struct passwd *pw )
52{ 52{
53 if ( loginshell ) { 53 if ( loginshell ) {
54 char *term; 54 const char *term;
55 55
56 /* Change the current working directory to be the home directory 56 /* Change the current working directory to be the home directory
57 * of the user. It is a fatal error for this process to be unable 57 * of the user. It is a fatal error for this process to be unable
diff --git a/libbb/xgetcwd.c b/libbb/xgetcwd.c
index 85a5c4125..1fcdba198 100644
--- a/libbb/xgetcwd.c
+++ b/libbb/xgetcwd.c
@@ -3,7 +3,7 @@
3 * Copyright (C) 1992, 1996 Free Software Foundation, Inc. 3 * Copyright (C) 1992, 1996 Free Software Foundation, Inc.
4 * Written by David MacKenzie <djm@gnu.ai.mit.edu>. 4 * Written by David MacKenzie <djm@gnu.ai.mit.edu>.
5 * 5 *
6 * Special function for busybox written by Vladimir Oleynik <vodz@usa.net> 6 * Special function for busybox written by Vladimir Oleynik <dzo@simtreas.ru>
7*/ 7*/
8 8
9#include <stdlib.h> 9#include <stdlib.h>
diff --git a/networking/Config.in b/networking/Config.in
index 3a0d3e9d9..2b2de28ec 100644
--- a/networking/Config.in
+++ b/networking/Config.in
@@ -58,6 +58,7 @@ config CONFIG_FEATURE_HTTPD_BASIC_AUTH
58 authentication on a per url basis. 58 authentication on a per url basis.
59 59
60 60
61if !CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
61config CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP 62config CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP
62 bool " Enable support reload global config file after hup signaled" 63 bool " Enable support reload global config file after hup signaled"
63 default n 64 default n
@@ -75,6 +76,7 @@ config CONFIG_FEATURE_HTTPD_SETUID
75 rather than defaulting to the user that starts the server. 76 rather than defaulting to the user that starts the server.
76 Use of this option requires special privilegies to change to a 77 Use of this option requires special privilegies to change to a
77 different user. 78 different user.
79endif
78 80
79config CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES 81config CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES
80 bool " Enable support load from config file mime types" 82 bool " Enable support load from config file mime types"
@@ -91,6 +93,7 @@ config CONFIG_FEATURE_HTTPD_CGI
91 help 93 help
92 This option allows scripts and executables to be invoked 94 This option allows scripts and executables to be invoked
93 when specific urls are requested. 95 when specific urls are requested.
96
94config CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV 97config CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV
95 bool " Enable support set eviroment REMOTE_PORT variable for CGI" 98 bool " Enable support set eviroment REMOTE_PORT variable for CGI"
96 default n 99 default n
@@ -111,15 +114,6 @@ config CONFIG_FEATURE_HTTPD_SET_CGI_VARS_TO_ENV
111 to 'bar'. In addition, this option sets a variable that 114 to 'bar'. In addition, this option sets a variable that
112 lists all the argument names. e.g. CGI_VARNAMES_="name1 name2". 115 lists all the argument names. e.g. CGI_VARNAMES_="name1 name2".
113 116
114config CONFIG_FEATURE_HTTPD_DECODE_URL_STR
115 bool " Enable the -d option for shell script CGI simplification"
116 default y
117 depends on CONFIG_HTTPD
118 help
119 After set, this option enables support for decoding of
120 url-encoded form arguments via the -d option. Output goes to
121 stdout. For example, httpd -d "Hello%20World" produces "Hello World".
122
123config CONFIG_FEATURE_HTTPD_ENCODE_URL_STR 117config CONFIG_FEATURE_HTTPD_ENCODE_URL_STR
124 bool " Enable the -e option for shell script CGI simplification." 118 bool " Enable the -e option for shell script CGI simplification."
125 default y 119 default y
@@ -474,7 +468,7 @@ config CONFIG_FEATURE_TFTP_BLOCKSIZE
474 468
475config CONFIG_FEATURE_TFTP_DEBUG 469config CONFIG_FEATURE_TFTP_DEBUG
476 bool " Enable debug" 470 bool " Enable debug"
477 default y 471 default n
478 depends on CONFIG_TFTP 472 depends on CONFIG_TFTP
479 help 473 help
480 Please submit a patch to add help text for this item. 474 Please submit a patch to add help text for this item.
@@ -487,14 +481,14 @@ config CONFIG_TRACEROUTE
487 481
488config CONFIG_FEATURE_TRACEROUTE_VERBOSE 482config CONFIG_FEATURE_TRACEROUTE_VERBOSE
489 bool " Enable verbose output" 483 bool " Enable verbose output"
490 default y 484 default n
491 depends on CONFIG_TRACEROUTE 485 depends on CONFIG_TRACEROUTE
492 help 486 help
493 Please submit a patch to add help text for this item. 487 Please submit a patch to add help text for this item.
494 488
495config CONFIG_FEATURE_TRACEROUTE_SO_DEBUG 489config CONFIG_FEATURE_TRACEROUTE_SO_DEBUG
496 bool " Enable SO_DEBUG option" 490 bool " Enable SO_DEBUG option"
497 default y 491 default n
498 depends on CONFIG_TRACEROUTE 492 depends on CONFIG_TRACEROUTE
499 help 493 help
500 Please submit a patch to add help text for this item. 494 Please submit a patch to add help text for this item.
diff --git a/networking/httpd.c b/networking/httpd.c
index e9f4c15bc..ef8263b99 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -60,8 +60,7 @@
60 * .au:audio/basic # additional mime type for audio.au files 60 * .au:audio/basic # additional mime type for audio.au files
61 * 61 *
62 * A/D may be as a/d or allow/deny - first char case unsensitive 62 * A/D may be as a/d or allow/deny - first char case unsensitive
63 * Deny IP rules take precedence over allow rules. Any IP rules after D:* are 63 * Deny IP rules take precedence over allow rules.
64 * ignored.
65 * 64 *
66 * 65 *
67 * The Deny/Allow IP logic: 66 * The Deny/Allow IP logic:
@@ -123,7 +122,7 @@
123#include "busybox.h" 122#include "busybox.h"
124 123
125 124
126static const char httpdVersion[] = "busybox httpd/1.26 18-May-2003"; 125static const char httpdVersion[] = "busybox httpd/1.27 25-May-2003";
127static const char default_path_httpd_conf[] = "/etc"; 126static const char default_path_httpd_conf[] = "/etc";
128static const char httpd_conf[] = "httpd.conf"; 127static const char httpd_conf[] = "httpd.conf";
129static const char home[] = "./"; 128static const char home[] = "./";
@@ -234,6 +233,7 @@ typedef struct
234 time_t last_mod; 233 time_t last_mod;
235 234
236 Htaccess *ip_a_d; /* config allow/deny lines */ 235 Htaccess *ip_a_d; /* config allow/deny lines */
236 int flg_deny_all;
237#ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH 237#ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH
238 Htaccess *auth; /* config user:password lines */ 238 Htaccess *auth; /* config user:password lines */
239#endif 239#endif
@@ -452,16 +452,21 @@ static void parse_conf(const char *path, int flag)
452 /* test for empty or strange line */ 452 /* test for empty or strange line */
453 if (c == NULL || *c == 0) 453 if (c == NULL || *c == 0)
454 continue; 454 continue;
455 if(*c == '*')
456 *c = 0; /* Allow all */
457 p0 = buf; 455 p0 = buf;
458 if((*p0 == 'i') || (*p0 == 'I'))
459 *p0 = 'A'; // version 1.1/1.2 compatibility for ip:
460 if(*p0 == 'a')
461 *p0 = 'A';
462 if(*p0 == 'd') 456 if(*p0 == 'd')
463 *p0 = 'D'; 457 *p0 = 'D';
464 if(*p0 != 'A' && *p0 != 'D' 458 if(*c == '*') {
459 if(*p0 == 'D') {
460 /* memorize deny all */
461 config->flg_deny_all++;
462 }
463 /* skip default other "word:*" config lines */
464 continue;
465 }
466
467 if(*p0 == 'a')
468 *p0 = 'A';
469 else if(*p0 != 'D'
465#ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH 470#ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH
466 && *p0 != '/' 471 && *p0 != '/'
467#endif 472#endif
@@ -471,17 +476,8 @@ static void parse_conf(const char *path, int flag)
471 ) 476 )
472 continue; 477 continue;
473 478
474 if(*p0 == 'A' && *c == 0) {
475 /* skip default A:* */
476 continue;
477 }
478 p0 = buf;
479#ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH 479#ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH
480 if(*p0 == '/') { 480 if(*p0 == '/') {
481 if(*c == 0) {
482 /* skip /path:* */
483 continue;
484 }
485 /* make full path from httpd root / curent_path / config_line_path */ 481 /* make full path from httpd root / curent_path / config_line_path */
486 cf = flag == SUBDIR_PARSE ? path : ""; 482 cf = flag == SUBDIR_PARSE ? path : "";
487 p0 = malloc(strlen(cf) + (c - buf) + 2 + strlen(c)); 483 p0 = malloc(strlen(cf) + (c - buf) + 2 + strlen(c));
@@ -532,12 +528,12 @@ static void parse_conf(const char *path, int flag)
532 free(p0); 528 free(p0);
533#endif 529#endif
534 if(*cf == 'A' || *cf == 'D') { 530 if(*cf == 'A' || *cf == 'D') {
535 if(*cf == 'D' && *c) { 531 if(*cf == 'D') {
536 /* Deny:form_IP move top */ 532 /* Deny:form_IP move top */
537 cur->next = config->ip_a_d; 533 cur->next = config->ip_a_d;
538 config->ip_a_d = cur; 534 config->ip_a_d = cur;
539 } else { 535 } else {
540 /* add to bottom current IP config line */ 536 /* add to bottom A:form_IP config line */
541 Htaccess *prev_IP = config->ip_a_d; 537 Htaccess *prev_IP = config->ip_a_d;
542 538
543 if(prev_IP == NULL) { 539 if(prev_IP == NULL) {
@@ -573,12 +569,11 @@ static void parse_conf(const char *path, int flag)
573 cur->next = hti; 569 cur->next = hti;
574 if(prev_hti != hti) { 570 if(prev_hti != hti) {
575 prev_hti->next = cur; 571 prev_hti->next = cur;
576 break;
577 } else { 572 } else {
578 /* insert as top */ 573 /* insert as top */
579 config->auth = cur; 574 config->auth = cur;
580 break;
581 } 575 }
576 break;
582 } 577 }
583 if(prev_hti != hti) 578 if(prev_hti != hti)
584 prev_hti = prev_hti->next; 579 prev_hti = prev_hti->next;
@@ -695,18 +690,16 @@ static void addEnv(const char *name_before_underline,
695 const char *name_after_underline, const char *value) 690 const char *name_after_underline, const char *value)
696{ 691{
697 char *s; 692 char *s;
693 const char *underline;
698 694
699 if (config->envCount >= ENVSIZE) 695 if (config->envCount >= ENVSIZE)
700 return; 696 return;
701 if (!value) 697 if (!value)
702 value = ""; 698 value = "";
703 s = malloc(strlen(name_before_underline) + strlen(name_after_underline) + 699 underline = *name_after_underline ? "_" : "";
704 strlen(value) + 3); 700 asprintf(&s, "%s%s%s=%s", name_before_underline, underline,
705 if (s) {
706 const char *underline = *name_after_underline ? "_" : "";
707
708 sprintf(s,"%s%s%s=%s", name_before_underline, underline,
709 name_after_underline, value); 701 name_after_underline, value);
702 if(s) {
710 config->envp[config->envCount++] = s; 703 config->envp[config->envCount++] = s;
711 config->envp[config->envCount] = 0; 704 config->envp[config->envCount] = 0;
712 } 705 }
@@ -764,11 +757,11 @@ static void addEnvCgi(const char *pargs)
764 *args++ = 0; 757 *args++ = 0;
765 addEnv("CGI", name, decodeString(value, 1)); 758 addEnv("CGI", name, decodeString(value, 1));
766 if (*namelist) strcat(namelist, " "); 759 if (*namelist) strcat(namelist, " ");
767 strcat(namelist,name); 760 strcat(namelist, name);
768 } 761 }
769 free(memargs); 762 free(memargs);
770 if (namelist) { 763 if (namelist) {
771 addEnv("CGI","ARGLIST_",namelist); 764 addEnv("CGI", "ARGLIST_", namelist);
772 free(namelist); 765 free(namelist);
773 } 766 }
774} 767}
@@ -1337,6 +1330,8 @@ static int checkPerm(const char *path, const char *request)
1337 } 1330 }
1338 } /* for */ 1331 } /* for */
1339 1332
1333 if(ipaddr)
1334 return config->flg_deny_all;
1340 return prev == NULL; 1335 return prev == NULL;
1341} 1336}
1342 1337
@@ -1359,7 +1354,7 @@ static int checkPermIP(const char *request)
1359 } 1354 }
1360 1355
1361 /* if uncofigured, return 1 - access from all */ 1356 /* if uncofigured, return 1 - access from all */
1362 return 1; 1357 return config->flg_deny_all;
1363} 1358}
1364#define checkPerm(null, request) checkPermIP(request) 1359#define checkPerm(null, request) checkPermIP(request)
1365#endif /* CONFIG_FEATURE_HTTPD_BASIC_AUTH */ 1360#endif /* CONFIG_FEATURE_HTTPD_BASIC_AUTH */
@@ -1788,9 +1783,7 @@ int httpd_main(int argc, char *argv[])
1788 config->debugHttpd = 1; 1783 config->debugHttpd = 1;
1789 break; 1784 break;
1790 case 'p': 1785 case 'p':
1791 config->port = atoi(optarg); 1786 config->port = bb_xgetlarg(optarg, 10, 1, 0xffff);
1792 if(config->port <= 0 || config->port > 0xffff)
1793 bb_error_msg_and_die("invalid %s for -p", optarg);
1794 break; 1787 break;
1795#endif 1788#endif
1796 case 'd': 1789 case 'd':
@@ -1854,10 +1847,11 @@ int httpd_main(int argc, char *argv[])
1854#ifdef TEST 1847#ifdef TEST
1855 if (numTestArgs) 1848 if (numTestArgs)
1856 { 1849 {
1857 if (strcmp(testArgs[0],"ip") == 0) testArgs[0] = 0; 1850 int result;
1851 if (strcmp(testArgs[0], "ip") == 0) testArgs[0] = 0;
1858 if (numTestArgs > 2) 1852 if (numTestArgs > 2)
1859 parse_conf(testArgs[2], SUBDIR_PARSE); 1853 parse_conf(testArgs[2], SUBDIR_PARSE);
1860 int result = printf("%d\n",checkPerm(testArgs[0],testArgs[1])); 1854 result = printf("%d\n", checkPerm(testArgs[0], testArgs[1]));
1861 return result; 1855 return result;
1862 } 1856 }
1863#endif 1857#endif
diff --git a/networking/ifconfig.c b/networking/ifconfig.c
index c09c48c58..37cba235a 100644
--- a/networking/ifconfig.c
+++ b/networking/ifconfig.c
@@ -15,7 +15,7 @@
15 * Foundation; either version 2 of the License, or (at 15 * Foundation; either version 2 of the License, or (at
16 * your option) any later version. 16 * your option) any later version.
17 * 17 *
18 * $Id: ifconfig.c,v 1.23 2003/03/19 09:12:38 mjn3 Exp $ 18 * $Id: ifconfig.c,v 1.24 2003/05/26 14:06:01 bug1 Exp $
19 * 19 *
20 */ 20 */
21 21
@@ -296,7 +296,7 @@ int ifconfig_main(int argc, char **argv)
296#ifdef CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS 296#ifdef CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS
297 unsigned int mask; 297 unsigned int mask;
298 unsigned int did_flags; 298 unsigned int did_flags;
299 in_addr_t sai_hostname, sai_netmask; 299 unsigned int sai_hostname, sai_netmask;
300#else 300#else
301 unsigned char mask; 301 unsigned char mask;
302 unsigned char did_flags; 302 unsigned char did_flags;