[kernel] pci_set_mwi depends upon CONFIG_HAVE_PCI_SET_MWI
[openwrt.git] / package / uhttpd / src / uhttpd.c
index be13b53..2f77a32 100644 (file)
@@ -71,8 +71,8 @@ static void uh_config_parse(const char *path)
                                if( !uh_auth_add(line, user, pass) )
                                {
                                        fprintf(stderr,
-                                               "Can not manage more than %i basic auth realms, "
-                                               "will skip the rest\n", UH_LIMIT_AUTHREALMS
+                                               "Notice: No password set for user %s, ignoring "
+                                               "authentication on %s\n", user, line
                                        );
 
                                        break;
@@ -416,19 +416,23 @@ int main (int argc, char **argv)
        /* maximum file descriptor number */
        int new_fd, cur_fd, max_fd = 0;
 
+#ifdef HAVE_TLS
        int tls = 0;
        int keys = 0;
+#endif
+
        int bound = 0;
        int nofork = 0;
 
        /* args */
-       char opt;
+       int opt;
        char bind[128];
        char *port = NULL;
 
-       /* library handles */
-       void *tls_lib;
-       void *lua_lib;
+#if defined(HAVE_TLS) || defined(HAVE_LUA)
+       /* library handle */
+       void *lib;
+#endif
 
        /* clear the master and temp sets */
        FD_ZERO(&used_fds);
@@ -466,7 +470,7 @@ int main (int argc, char **argv)
 
 #ifdef HAVE_TLS
        /* load TLS plugin */
-       if( ! (tls_lib = dlopen("uhttpd_tls.so", RTLD_LAZY | RTLD_GLOBAL)) )
+       if( ! (lib = dlopen("uhttpd_tls.so", RTLD_LAZY | RTLD_GLOBAL)) )
        {
                fprintf(stderr,
                        "Notice: Unable to load TLS plugin - disabling SSL support! "
@@ -476,14 +480,14 @@ int main (int argc, char **argv)
        else
        {
                /* resolve functions */
-               if( !(conf.tls_init   = dlsym(tls_lib, "uh_tls_ctx_init"))      ||
-                   !(conf.tls_cert   = dlsym(tls_lib, "uh_tls_ctx_cert"))      ||
-                   !(conf.tls_key    = dlsym(tls_lib, "uh_tls_ctx_key"))       ||
-                   !(conf.tls_free   = dlsym(tls_lib, "uh_tls_ctx_free"))      ||
-                       !(conf.tls_accept = dlsym(tls_lib, "uh_tls_client_accept")) ||
-                       !(conf.tls_close  = dlsym(tls_lib, "uh_tls_client_close"))  ||
-                       !(conf.tls_recv   = dlsym(tls_lib, "uh_tls_client_recv"))   ||
-                       !(conf.tls_send   = dlsym(tls_lib, "uh_tls_client_send"))
+               if( !(conf.tls_init   = dlsym(lib, "uh_tls_ctx_init"))      ||
+                   !(conf.tls_cert   = dlsym(lib, "uh_tls_ctx_cert"))      ||
+                   !(conf.tls_key    = dlsym(lib, "uh_tls_ctx_key"))       ||
+                   !(conf.tls_free   = dlsym(lib, "uh_tls_ctx_free"))      ||
+                       !(conf.tls_accept = dlsym(lib, "uh_tls_client_accept")) ||
+                       !(conf.tls_close  = dlsym(lib, "uh_tls_client_close"))  ||
+                       !(conf.tls_recv   = dlsym(lib, "uh_tls_client_recv"))   ||
+                       !(conf.tls_send   = dlsym(lib, "uh_tls_client_send"))
                ) {
                        fprintf(stderr,
                                "Error: Failed to lookup required symbols "
@@ -501,7 +505,7 @@ int main (int argc, char **argv)
        }
 #endif
 
-       while( (opt = getopt(argc, argv, "fC:K:p:s:h:c:l:L:d:r:m:x:t:")) > 0 )
+       while( (opt = getopt(argc, argv, "fSC:K:p:s:h:c:l:L:d:r:m:x:t:T:")) > 0 )
        {
                switch(opt)
                {
@@ -524,6 +528,7 @@ int main (int argc, char **argv)
                                        port = optarg;
                                }
 
+#ifdef HAVE_TLS
                                if( opt == 's' )
                                {
                                        if( !conf.tls )
@@ -537,6 +542,7 @@ int main (int argc, char **argv)
 
                                        tls = 1;
                                }
+#endif
 
                                /* bind sockets */
                                bound += uh_socket_bind(
@@ -544,6 +550,7 @@ int main (int argc, char **argv)
                                        &hints, (opt == 's'), &conf
                                );
 
+                               memset(bind, 0, sizeof(bind));
                                break;
 
 #ifdef HAVE_TLS
@@ -590,6 +597,11 @@ int main (int argc, char **argv)
                                }
                                break;
 
+                       /* don't follow symlinks */
+                       case 'S':
+                               conf.no_symlinks = 1;
+                               break;
+
 #ifdef HAVE_CGI
                        /* cgi prefix */
                        case 'x':
@@ -616,6 +628,11 @@ int main (int argc, char **argv)
                                break;
 #endif
 
+                       /* network timeout */
+                       case 'T':
+                               conf.network_timeout = atoi(optarg);
+                               break;
+
                        /* no fork */
                        case 'f':
                                nofork = 1;
@@ -661,6 +678,7 @@ int main (int argc, char **argv)
                                        "       -K file         ASN.1 server private key file\n"
 #endif
                                        "       -h directory    Specify the document root, default is '.'\n"
+                                       "       -S              Do not follow symbolic links outside of the docroot\n"
 #ifdef HAVE_LUA
                                        "       -l string       URL prefix for Lua handler, default is '/lua'\n"
                                        "       -L file         Lua handler script, omit to disable Lua\n"
@@ -671,6 +689,7 @@ int main (int argc, char **argv)
 #if defined(HAVE_CGI) || defined(HAVE_LUA)
                                        "       -t seconds      CGI and Lua script timeout in seconds, default is 60\n"
 #endif
+                                       "       -T seconds      Network timeout in seconds, default is 30\n"
                                        "       -d string       URL decode given string\n"
                                        "       -r string       Specify basic auth realm\n"
                                        "       -m string       MD5 crypt given string\n"
@@ -710,6 +729,10 @@ int main (int argc, char **argv)
        /* config file */
        uh_config_parse(conf.file);
 
+       /* default network timeout */
+       if( conf.network_timeout <= 0 )
+               conf.network_timeout = 30;
+
 #if defined(HAVE_CGI) || defined(HAVE_LUA)
        /* default script timeout */
        if( conf.script_timeout <= 0 )
@@ -724,7 +747,7 @@ int main (int argc, char **argv)
 
 #ifdef HAVE_LUA
        /* load Lua plugin */
-       if( ! (lua_lib = dlopen("uhttpd_lua.so", RTLD_LAZY | RTLD_GLOBAL)) )
+       if( ! (lib = dlopen("uhttpd_lua.so", RTLD_LAZY | RTLD_GLOBAL)) )
        {
                fprintf(stderr,
                        "Notice: Unable to load Lua plugin - disabling Lua support! "
@@ -734,9 +757,9 @@ int main (int argc, char **argv)
        else
        {
                /* resolve functions */
-               if( !(conf.lua_init    = dlsym(lua_lib, "uh_lua_init"))    ||
-                   !(conf.lua_close   = dlsym(lua_lib, "uh_lua_close"))   ||
-                   !(conf.lua_request = dlsym(lua_lib, "uh_lua_request"))
+               if( !(conf.lua_init    = dlsym(lib, "uh_lua_init"))    ||
+                   !(conf.lua_close   = dlsym(lib, "uh_lua_close"))   ||
+                   !(conf.lua_request = dlsym(lib, "uh_lua_request"))
                ) {
                        fprintf(stderr,
                                "Error: Failed to lookup required symbols "
This page took 0.030488 seconds and 4 git commands to generate.