From d14da247dcb27cf3c81fcff2113c70bdee9f4630 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Fri, 28 Mar 2014 17:07:21 +0800 Subject: [PATCH] update scripts --- debian/shadowsocks.default | 3 +++ debian/shadowsocks.init | 5 ++++- src/local.c | 10 +--------- src/redir.c | 10 +--------- src/server.c | 10 +--------- src/tunnel.c | 10 +--------- 6 files changed, 11 insertions(+), 37 deletions(-) diff --git a/debian/shadowsocks.default b/debian/shadowsocks.default index 5b60264b..eb6e15a6 100644 --- a/debian/shadowsocks.default +++ b/debian/shadowsocks.default @@ -18,3 +18,6 @@ DAEMON_ARGS="" # User and group to run the server as USER=root GROUP=root + +# Number of maximum file descriptors +MAXFD=1024 diff --git a/debian/shadowsocks.init b/debian/shadowsocks.init index a1e52a2b..8013228f 100644 --- a/debian/shadowsocks.init +++ b/debian/shadowsocks.init @@ -45,6 +45,9 @@ SCRIPTNAME=/etc/init.d/$NAME # do_start() { + # Modify the file descriptor limit + ulimit -n ${MAXFD} + # Take care of pidfile permissions mkdir /var/run/$NAME 2>/dev/null || true chown "$USER:$GROUP" /var/run/$NAME @@ -56,7 +59,7 @@ do_start() start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid $USER:$GROUP --exec $DAEMON --test > /dev/null \ || return 1 start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid $USER:$GROUP --exec $DAEMON -- \ - -c "$CONFFILE" -a "$USER" -u -f $PIDFILE $DAEMON_ARGS \ + -c "$CONFFILE" -u -f $PIDFILE $DAEMON_ARGS \ || return 2 } diff --git a/src/local.c b/src/local.c index 81f290d8..fff3f2af 100644 --- a/src/local.c +++ b/src/local.c @@ -797,7 +797,6 @@ int main (int argc, char **argv) int i, c; int pid_flags = 0; - char *user = NULL; char *local_port = NULL; char *local_addr = NULL; char *password = NULL; @@ -813,7 +812,7 @@ int main (int argc, char **argv) opterr = 0; - while ((c = getopt (argc, argv, "f:s:p:l:k:t:m:i:c:b:a:uv")) != -1) + while ((c = getopt (argc, argv, "f:s:p:l:k:t:m:i:c:b:uv")) != -1) { switch (c) { @@ -849,9 +848,6 @@ int main (int argc, char **argv) case 'b': local_addr = optarg; break; - case 'a': - user = optarg; - break; case 'u': udprelay = 1; break; @@ -959,10 +955,6 @@ int main (int argc, char **argv) udprelay_init(local_addr, local_port, remote_addr[0].host, remote_addr[0].port, m, listen_ctx.timeout, iface); } - // setuid - if (user != NULL) - run_as(user); - ev_run (loop, 0); #ifdef __MINGW32__ diff --git a/src/redir.c b/src/redir.c index 0b234409..01b54911 100644 --- a/src/redir.c +++ b/src/redir.c @@ -660,7 +660,6 @@ int main (int argc, char **argv) int i, c; int pid_flags = 0; - char *user = NULL; char *local_port = NULL; char *local_addr = NULL; char *password = NULL; @@ -675,7 +674,7 @@ int main (int argc, char **argv) opterr = 0; - while ((c = getopt (argc, argv, "f:s:p:l:k:t:m:c:b:a:")) != -1) + while ((c = getopt (argc, argv, "f:s:p:l:k:t:m:c:b:")) != -1) { switch (c) { @@ -708,9 +707,6 @@ int main (int argc, char **argv) case 'b': local_addr = optarg; break; - case 'a': - user = optarg; - break; } } @@ -800,10 +796,6 @@ int main (int argc, char **argv) ev_io_init (&listen_ctx.io, accept_cb, listenfd, EV_READ); ev_io_start (loop, &listen_ctx.io); - // setuid - if (user != NULL) - run_as(user); - ev_run (loop, 0); return 0; diff --git a/src/server.c b/src/server.c index f28915d6..a4ea49f2 100644 --- a/src/server.c +++ b/src/server.c @@ -898,7 +898,6 @@ int main (int argc, char **argv) int i, c; int pid_flags = 0; - char *user = NULL; char *password = NULL; char *timeout = NULL; char *method = NULL; @@ -914,7 +913,7 @@ int main (int argc, char **argv) opterr = 0; - while ((c = getopt (argc, argv, "f:s:p:l:k:t:m:c:i:d:a:uv")) != -1) + while ((c = getopt (argc, argv, "f:s:p:l:k:t:m:c:i:d:uv")) != -1) { switch (c) { @@ -947,9 +946,6 @@ int main (int argc, char **argv) dns_thread_num = atoi(optarg); if (!dns_thread_num) FATAL("Invalid DNS thread number"); break; - case 'a': - user = optarg; - break; case 'u': udprelay = 1; break; @@ -1056,10 +1052,6 @@ int main (int argc, char **argv) udprelay_init(server_host[0], server_port, asyncns, m, listen_ctx.timeout, iface); } - // setuid - if (user != NULL) - run_as(user); - // start ev loop ev_run (loop, 0); return 0; diff --git a/src/tunnel.c b/src/tunnel.c index 4c06119c..d5ccb208 100644 --- a/src/tunnel.c +++ b/src/tunnel.c @@ -704,7 +704,6 @@ int main (int argc, char **argv) int i, c; int pid_flags = 0; - char *user = NULL; char *local_port = NULL; char *local_addr = NULL; char *password = NULL; @@ -723,7 +722,7 @@ int main (int argc, char **argv) opterr = 0; - while ((c = getopt (argc, argv, "f:s:p:l:k:t:m:i:c:b:L:a:uv")) != -1) + while ((c = getopt (argc, argv, "f:s:p:l:k:t:m:i:c:b:L:uv")) != -1) { switch (c) { @@ -765,9 +764,6 @@ int main (int argc, char **argv) case 'L': tunnel_addr_str = optarg; break; - case 'a': - user = optarg; - break; case 'v': verbose = 1; break; @@ -877,10 +873,6 @@ int main (int argc, char **argv) tunnel_addr, m, listen_ctx.timeout, iface); } - // setuid - if (user != NULL) - run_as(user); - ev_run (loop, 0); #ifdef __MINGW32__