summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley2006-04-28 19:38:04 +0000
committerRob Landley2006-04-28 19:38:04 +0000
commita2d9a1752c4a59adc94307c584f949b24bd10338 (patch)
tree5e51df91f30752db400655b99f798969191b32bb
parent0e6a3e14e41f6ce7407f9d47eec9db257eb6b125 (diff)
downloadbusybox-a2d9a1752c4a59adc94307c584f949b24bd10338.zip
busybox-a2d9a1752c4a59adc94307c584f949b24bd10338.tar.gz
More usage.h cleanups, with collateral changes to httpd. Specifically,
most of our CONFIG entries switch stuff on instead of off when enabled, so fix the gratuitously reversed INETD thing.
-rw-r--r--include/usage.h86
-rw-r--r--networking/Config.in12
-rw-r--r--networking/httpd.c48
3 files changed, 44 insertions, 102 deletions
diff --git a/include/usage.h b/include/usage.h
index 052f6fc..65a7874 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -975,36 +975,6 @@ USE_FEATURE_DATE_ISOFMT( \
"\t-n\t\tno call to sync()\n" \
"\t-f\t\tforce halt (don't go through init)"
-#ifdef CONFIG_FEATURE_HDPARM_HDIO_SCAN_HWIF
-#define USAGE_SCAN_HWIF(a) a
-#else
-#define USAGE_SCAN_HWIF(a)
-#endif
-
-#ifdef CONFIG_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF
-#define USAGE_UNREGISTER_HWIF(a) a
-#else
-#define USAGE_UNREGISTER_HWIF(a)
-#endif
-
-#ifdef CONFIG_FEATURE_HDPARM_HDIO_DRIVE_RESET
-#define USAGE_DRIVE_RESET(a) a
-#else
-#define USAGE_DRIVE_RESET(a)
-#endif
-
-#ifdef CONFIG_FEATURE_HDPARM_HDIO_TRISTATE_HWIF
-#define USAGE_TRISTATE_HWIF(a) a
-#else
-#define USAGE_TRISTATE_HWIF(a)
-#endif
-
-#ifdef CONFIG_FEATURE_HDPARM_HDIO_GETSET_DMA
-#define USAGE_GETSET_DMA(a) a
-#else
-#define USAGE_GETSET_DMA(a)
-#endif
-
#define hdparm_trivial_usage \
"[options] [device] .."
#define hdparm_full_usage \
@@ -1015,7 +985,7 @@ USE_FEATURE_DATE_ISOFMT( \
"\t-B set Advanced Power Management setting (1-255)\n" \
"\t-c get/set IDE 32-bit IO setting\n" \
"\t-C check IDE power mode status\n" \
- USAGE_GETSET_DMA("\t-d get/set using_dma flag\n") \
+ USE_FEATURE_HDPARM_HDIO_GETSET_DMA("\t-d get/set using_dma flag\n") \
"\t-D enable/disable drive defect-mgmt\n" \
"\t-f flush buffer cache for device on exit\n" \
"\t-g display drive geometry\n" \
@@ -1033,29 +1003,23 @@ USE_FEATURE_DATE_ISOFMT( \
"\t-q change next setting quietly\n" \
"\t-Q get/set DMA tagged-queuing depth (if supported)\n" \
"\t-r get/set readonly flag (DANGEROUS to set)\n" \
- USAGE_SCAN_HWIF("\t-R register an IDE interface (DANGEROUS)\n") \
+ USE_FEATURE_HDPARM_HDIO_SCAN_HWIF("\t-R register an IDE interface (DANGEROUS)\n") \
"\t-S set standby (spindown) timeout\n" \
"\t-t perform device read timings\n" \
"\t-T perform cache read timings\n" \
"\t-u get/set unmaskirq flag (0/1)\n" \
- USAGE_UNREGISTER_HWIF("\t-U un-register an IDE interface (DANGEROUS)\n") \
+ USE_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF("\t-U un-register an IDE interface (DANGEROUS)\n") \
"\t-v defaults; same as -mcudkrag for IDE drives\n" \
"\t-V display program version and exit immediately\n" \
- USAGE_DRIVE_RESET("\t-w perform device reset (DANGEROUS)\n") \
+ USE_FEATURE_HDPARM_HDIO_DRIVE_RESET("\t-w perform device reset (DANGEROUS)\n") \
"\t-W set drive write-caching flag (0/1) (DANGEROUS)\n" \
- USAGE_TRISTATE_HWIF("\t-x tristate device for hotswap (0/1) (DANGEROUS)\n") \
+ USE_FEATURE_HDPARM_HDIO_TRISTATE_HWIF("\t-x tristate device for hotswap (0/1) (DANGEROUS)\n") \
"\t-X set IDE xfer mode (DANGEROUS)\n" \
"\t-y put IDE drive in standby mode\n" \
"\t-Y put IDE drive to sleep\n" \
"\t-Z disable Seagate auto-powersaving mode\n" \
"\t-z re-read partition table"
-#ifdef CONFIG_FEATURE_FANCY_HEAD
-#define USAGE_FANCY_HEAD(a) a
-#else
-#define USAGE_FANCY_HEAD(a)
-#endif
-
#define head_trivial_usage \
"[OPTION]... [FILE]..."
#define head_full_usage \
@@ -1064,7 +1028,7 @@ USE_FEATURE_DATE_ISOFMT( \
"file name. With no FILE, or when FILE is -, read standard input.\n\n" \
"Options:\n" \
"\t-n NUM\t\tPrint first NUM lines instead of first 10" \
- USAGE_FANCY_HEAD( \
+ USE_FEATURE_FANCY_HEAD( \
"\n\t-c NUM\t\toutput the first NUM bytes\n" \
"\t-q\t\tnever output headers giving file names\n" \
"\t-v\t\talways output headers giving file names" )
@@ -1111,44 +1075,22 @@ USE_FEATURE_DATE_ISOFMT( \
"$ hostname\n" \
"sage\n"
-#ifdef CONFIG_FEATURE_HTTPD_BASIC_AUTH
-# define USAGE_HTTPD_BASIC_AUTH(a) a
-# ifdef CONFIG_FEATURE_HTTPD_AUTH_MD5
-# define USAGE_HTTPD_AUTH_MD5(a) a
-# else
-# define USAGE_HTTPD_AUTH_MD5(a)
-# endif
-#else
-# define USAGE_HTTPD_BASIC_AUTH(a)
-# define USAGE_HTTPD_AUTH_MD5(a)
-#endif
-#ifdef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
-# define USAGE_HTTPD_STANDALONE(a)
-# define USAGE_HTTPD_SETUID(a)
-#else
-# define USAGE_HTTPD_STANDALONE(a) a
-# ifdef CONFIG_FEATURE_HTTPD_SETUID
-# define USAGE_HTTPD_SETUID(a) a
-# else
-# define USAGE_HTTPD_SETUID(a)
-# endif
-#endif
#define httpd_trivial_usage \
"[-c <conf file>]" \
- USAGE_HTTPD_STANDALONE(" [-p <port>]") \
- USAGE_HTTPD_SETUID(" [-u user]") \
- USAGE_HTTPD_BASIC_AUTH(" [-r <realm>]") \
- USAGE_HTTPD_AUTH_MD5(" [-m pass]") \
+ USE_FEATURE_HTTPD_WITHOUT_INETD(" [-p <port>]") \
+ USE_FEATURE_HTTPD_SETUID(" [-u user]") \
+ USE_FEATURE_HTTPD_BASIC_AUTH(" [-r <realm>]") \
+ USE_FEATURE_HTTPD_AUTH_MD5(" [-m pass]") \
" [-h home]" \
" [-d/-e <string>]"
#define httpd_full_usage \
"Listens for incoming http server requests.\n\n" \
"Options:\n" \
"\t-c FILE\t\tSpecifies configuration file. (default httpd.conf)\n" \
- USAGE_HTTPD_STANDALONE("\t-p PORT\tServer port (default 80)\n") \
- USAGE_HTTPD_SETUID("\t-u USER\tSet uid to USER after listening privileges port\n") \
- USAGE_HTTPD_BASIC_AUTH("\t-r REALM\tAuthentication Realm for Basic Authentication\n") \
- USAGE_HTTPD_AUTH_MD5("\t-m PASS\t\tCrypt PASS with md5 algorithm\n") \
+ USE_FEATURE_HTTPD_WITHOUT_INETD("\t-p PORT\tServer port (default 80)\n") \
+ USE_FEATURE_HTTPD_SETUID("\t-u USER\tSet uid to USER after listening privileges port\n") \
+ USE_FEATURE_HTTPD_BASIC_AUTH("\t-r REALM\tAuthentication Realm for Basic Authentication\n") \
+ USE_FEATURE_HTTPD_AUTH_MD5("\t-m PASS\t\tCrypt PASS with md5 algorithm\n") \
"\t-h HOME \tSpecifies http HOME directory (default ./)\n" \
"\t-e STRING\tHtml encode STRING\n" \
"\t-d STRING\tURL decode STRING"
diff --git a/networking/Config.in b/networking/Config.in
index 61d03aa..94e59ea 100644
--- a/networking/Config.in
+++ b/networking/Config.in
@@ -61,18 +61,18 @@ config CONFIG_HTTPD
help
Serve web pages via an HTTP server.
-config CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
- bool "Support using httpd only from inetd"
+config CONFIG_FEATURE_HTTPD_WITHOUT_INETD
+ bool "Support using httpd as a daemon (not from inetd)"
default n
depends on CONFIG_HTTPD
help
- This option disables uid and port options for the httpd applet
- but requires inetd server daemon.
+ This option enables uid and port options for the httpd applet,
+ and eliminates the need to be called from the inetd server daemon.
config CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP
bool "Support reloading the global config file using hup signal"
default n
- depends on CONFIG_HTTPD && !CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
+ depends on CONFIG_HTTPD && CONFIG_FEATURE_HTTPD_WITHOUT_INETD
help
This option enables processing of SIGHUP to reload cached
configuration settings.
@@ -80,7 +80,7 @@ config CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP
config CONFIG_FEATURE_HTTPD_SETUID
bool "Enable support -u <user> option"
default n
- depends on CONFIG_HTTPD && !CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
+ depends on CONFIG_HTTPD && CONFIG_FEATURE_HTTPD_WITHOUT_INETD
help
This option allows the server to run as a specific user
rather than defaulting to the user that starts the server.
diff --git a/networking/httpd.c b/networking/httpd.c
index 97bec6e..73a9461 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -183,7 +183,7 @@ typedef struct
Htaccess *mime_a; /* config mime types */
#endif
-#ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
+#ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD
int accepted_socket;
# define a_c_r config->accepted_socket
# define a_c_w config->accepted_socket
@@ -776,7 +776,7 @@ static void addEnv(const char *name_before_underline,
}
}
-#if defined(CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV) || !defined(CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY)
+#if defined(CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV) || defined(CONFIG_FEATURE_HTTPD_WITHOUT_INETD)
/* set environs SERVER_PORT and REMOTE_PORT */
static void addEnvPort(const char *port_name)
{
@@ -848,7 +848,7 @@ static void decodeBase64(char *Data)
#endif
-#ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
+#ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD
/****************************************************************************
*
> $Function: openServer()
@@ -885,7 +885,7 @@ static int openServer(void)
signal(SIGCHLD, SIG_IGN); /* prevent zombie (defunct) processes */
return fd;
}
-#endif /* CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY */
+#endif /* CONFIG_FEATURE_HTTPD_WITHOUT_INETD */
/****************************************************************************
*
@@ -1163,7 +1163,7 @@ static int sendCgi(const char *url,
}
}
}
-#ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
+#ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD
config->accepted_socket = 1; /* send to stdout */
#endif
sendHeaders(HTTP_NOT_FOUND);
@@ -1728,7 +1728,7 @@ FORBIDDEN: /* protect listing /cgi-bin */
config->last_mod = sb.st_mtime;
}
sendFile(test);
-#ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
+#ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD
/* unset if non inetd looped */
config->ContentLength = -1;
#endif
@@ -1741,7 +1741,7 @@ FORBIDDEN: /* protect listing /cgi-bin */
} while (0);
-#ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
+#ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD
/* from inetd don`t looping: freeing, closing automatic from exit always */
# if DEBUG
fprintf(stderr, "closing socket\n");
@@ -1754,7 +1754,7 @@ FORBIDDEN: /* protect listing /cgi-bin */
free(config->remoteuser);
#endif
# endif
-#endif /* CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY */
+#endif /* CONFIG_FEATURE_HTTPD_WITHOUT_INETD */
shutdown(a_c_w, SHUT_WR);
/* Properly wait for remote to closed */
@@ -1768,9 +1768,9 @@ FORBIDDEN: /* protect listing /cgi-bin */
} while (retval > 0 && (read (a_c_r, buf, sizeof (config->buf)) > 0));
shutdown(a_c_r, SHUT_RD);
-#ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
+#ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD
close(config->accepted_socket);
-#endif /* CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY */
+#endif /* CONFIG_FEATURE_HTTPD_WITHOUT_INETD */
}
/****************************************************************************
@@ -1788,7 +1788,7 @@ FORBIDDEN: /* protect listing /cgi-bin */
* $Return: (int) . . . . Always 0.
*
****************************************************************************/
-#ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
+#ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD
static int miniHttpd(int server)
{
fd_set readfd, portfd;
@@ -1874,7 +1874,7 @@ static int miniHttpd(void)
handleIncoming();
return 0;
}
-#endif /* CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY */
+#endif /* CONFIG_FEATURE_HTTPD_WITHOUT_INETD */
#ifdef CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP
static void sighup_handler(int sig)
@@ -1899,7 +1899,7 @@ enum httpd_opts_nums {
USE_FEATURE_HTTPD_BASIC_AUTH(r_opt_realm,)
USE_FEATURE_HTTPD_AUTH_MD5(m_opt_md5,)
USE_FEATURE_HTTPD_SETUID(u_opt_setuid,)
- SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(p_opt_port,)
+ USE_FEATURE_HTTPD_WITHOUT_INETD(p_opt_port,)
};
static const char httpd_opts[]="c:d:h:"
@@ -1907,7 +1907,7 @@ static const char httpd_opts[]="c:d:h:"
USE_FEATURE_HTTPD_BASIC_AUTH("r:")
USE_FEATURE_HTTPD_AUTH_MD5("m:")
USE_FEATURE_HTTPD_SETUID("u:")
- SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY("p:");
+ USE_FEATURE_HTTPD_WITHOUT_INETD("p:");
#define OPT_CONFIG_FILE (1<<c_opt_config_file)
#define OPT_DECODE_URL (1<<d_opt_decode_url)
@@ -1925,8 +1925,8 @@ static const char httpd_opts[]="c:d:h:"
#define OPT_SETUID USE_FEATURE_HTTPD_SETUID((1<<u_opt_setuid)) \
SKIP_FEATURE_HTTPD_SETUID(0)
-#define OPT_PORT SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY((1<<p_opt_port)) \
- USE_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(0)
+#define OPT_PORT USE_FEATURE_HTTPD_WITHOUT_INETD((1<<p_opt_port)) \
+ SKIP_FEATURE_HTTPD_WITHOUT_INETD(0)
int httpd_main(int argc, char *argv[])
@@ -1935,8 +1935,8 @@ int httpd_main(int argc, char *argv[])
const char *home_httpd = home;
char *url_for_decode;
USE_FEATURE_HTTPD_ENCODE_URL_STR(const char *url_for_encode;)
- SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(const char *s_port;)
- SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(int server;)
+ USE_FEATURE_HTTPD_WITHOUT_INETD(const char *s_port;)
+ USE_FEATURE_HTTPD_WITHOUT_INETD(int server;)
USE_FEATURE_HTTPD_SETUID(const char *s_uid;)
USE_FEATURE_HTTPD_SETUID(long uid = -1;)
@@ -1948,7 +1948,7 @@ int httpd_main(int argc, char *argv[])
config->realm = "Web Server Authentication";
#endif
-#ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
+#ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD
config->port = 80;
#endif
@@ -1960,7 +1960,7 @@ int httpd_main(int argc, char *argv[])
USE_FEATURE_HTTPD_BASIC_AUTH(, &(config->realm))
USE_FEATURE_HTTPD_AUTH_MD5(, &pass)
USE_FEATURE_HTTPD_SETUID(, &s_uid)
- SKIP_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY(, &s_port)
+ USE_FEATURE_HTTPD_WITHOUT_INETD(, &s_port)
);
if(opt & OPT_DECODE_URL) {
@@ -1979,7 +1979,7 @@ int httpd_main(int argc, char *argv[])
return 0;
}
#endif
-#ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
+#ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD
if(opt & OPT_PORT)
config->port = bb_xgetlarg(s_port, 10, 1, 0xffff);
#ifdef CONFIG_FEATURE_HTTPD_SETUID
@@ -1996,7 +1996,7 @@ int httpd_main(int argc, char *argv[])
#endif
bb_xchdir(home_httpd);
-#ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
+#ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD
server = openServer();
# ifdef CONFIG_FEATURE_HTTPD_SETUID
/* drop privileges */
@@ -2014,7 +2014,7 @@ int httpd_main(int argc, char *argv[])
clearenv();
if(p)
setenv("PATH", p, 1);
-# ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
+# ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD
addEnvPort("SERVER");
# endif
}
@@ -2026,7 +2026,7 @@ int httpd_main(int argc, char *argv[])
parse_conf(default_path_httpd_conf, FIRST_PARSE);
#endif
-#ifndef CONFIG_FEATURE_HTTPD_USAGE_FROM_INETD_ONLY
+#ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD
# if !DEBUG
bb_xdaemon(1, 0); /* don`t change curent directory */
# endif