1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-08-01 03:47:23 +03:00

v1.1.9-2 changes

git-svn-id: svn://svn.code.sf.net/p/axtls/code/trunk@150 9a5d90b5-6617-0410-8a86-bb477d3ed2e3
This commit is contained in:
cameronrich
2008-05-13 11:32:33 +00:00
parent d02abde904
commit bc1e70c101
12 changed files with 116 additions and 23 deletions

View File

@ -129,6 +129,20 @@ config CONFIG_HTTP_HAS_IPV6
Does not work under Win32
config CONFIG_HTTP_ENABLE_DIFFERENT_USER
bool "Enable different user"
default n
depends on !CONFIG_PLATFORM_WIN32
help
Allow the web server to be run as a different user
config CONFIG_HTTP_USER
string "As User"
default "nobody"
depends on CONFIG_HTTP_ENABLE_DIFFERENT_USER
help
The user name that will be used to run axhttpd.
config CONFIG_HTTP_VERBOSE
bool "Verbose Mode"
default y if CONFIG_SSL_FULL_MODE

View File

@ -34,6 +34,7 @@
#include <signal.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <pwd.h>
#include "axhttp.h"
struct serverstruct *servers;
@ -186,6 +187,28 @@ int main(int argc, char *argv[])
ax_chdir();
#ifdef CONFIG_HTTP_ENABLE_DIFFERENT_USER
{
struct passwd *pd = getpwnam(CONFIG_HTTP_USER);
if (pd != NULL)
{
int res = setuid(pd->pw_uid);
res |= setgid(pd->pw_gid);
#if defined(CONFIG_HTTP_VERBOSE)
if (res == 0)
{
printf("change to '%s' successful\n", CONFIG_HTTP_USER);
TTY_FLUSH();
}
#endif
}
}
#endif
#ifndef WIN32
#ifdef CONFIG_HTTP_IS_DAEMON
if (fork() > 0) /* parent will die */