summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-11-05 18:09:54 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-11-05 18:09:54 +0300
commit9b6b141a936bb7ba89c431176fa53a5878b8a9bd (patch)
treebfe875c900f2e865ece4d00f223b7529a86dc625 /src
parentd78ac2d1060c2b049b4eebc176d3823f82f9ea76 (diff)
downloadrspamd-9b6b141a936bb7ba89c431176fa53a5878b8a9bd.tar.gz
rspamd-9b6b141a936bb7ba89c431176fa53a5878b8a9bd.zip
* Add more advanced signal processing routine
Diffstat (limited to 'src')
-rw-r--r--src/controller.c8
-rw-r--r--src/filter.c6
-rw-r--r--src/fuzzy_storage.c5
-rw-r--r--src/lmtp.c8
-rw-r--r--src/main.c87
-rw-r--r--src/util.c13
-rw-r--r--src/util.h6
-rw-r--r--src/worker.c8
8 files changed, 125 insertions, 16 deletions
diff --git a/src/controller.c b/src/controller.c
index 64ef75d59..d59690da2 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -86,9 +86,13 @@ extern rspamd_hash_t *counters;
static gboolean controller_write_socket (void *arg);
-static
- void
+#ifndef HAVE_SA_SIGINFO
+static void
sig_handler (int signo)
+#else
+static void
+sig_handler (int signo, siginfo_t *info, void *unused)
+#endif
{
switch (signo) {
case SIGINT:
diff --git a/src/filter.c b/src/filter.c
index fc23d81b9..11683d0d4 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -22,11 +22,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/types.h>
-#include <glib.h>
-#include <string.h>
-#include <stdlib.h>
-
+#include "config.h"
#include "mem_pool.h"
#include "filter.h"
#include "main.h"
diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c
index 68da96b44..74ad90694 100644
--- a/src/fuzzy_storage.c
+++ b/src/fuzzy_storage.c
@@ -66,8 +66,13 @@ struct rspamd_fuzzy_node {
uint64_t time;
};
+#ifndef HAVE_SA_SIGINFO
static void
sig_handler (int signo)
+#else
+static void
+sig_handler (int signo, siginfo_t *info, void *unused)
+#endif
{
switch (signo) {
case SIGINT:
diff --git a/src/lmtp.c b/src/lmtp.c
index f9bd6f65e..e07971f5e 100644
--- a/src/lmtp.c
+++ b/src/lmtp.c
@@ -38,9 +38,13 @@ static struct timeval io_tv;
static gboolean lmtp_write_socket (void *arg);
-static
- void
+#ifndef HAVE_SA_SIGINFO
+static void
sig_handler (int signo)
+#else
+static void
+sig_handler (int signo, siginfo_t *info, void *unused)
+#endif
{
switch (signo) {
case SIGINT:
diff --git a/src/main.c b/src/main.c
index 4a02fa159..df3945ae1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -51,7 +51,6 @@ struct config_file *cfg;
rspamd_hash_t *counters;
-static void sig_handler (int);
static struct rspamd_worker *fork_worker (struct rspamd_main *, struct worker_conf *);
sig_atomic_t do_restart;
@@ -59,6 +58,10 @@ sig_atomic_t do_terminate;
sig_atomic_t child_dead;
sig_atomic_t got_alarm;
+#ifdef HAVE_SA_SIGINFO
+GQueue *signals_info;
+#endif
+
extern int yynerrs;
extern FILE *yyin;
@@ -73,10 +76,21 @@ extern PerlInterpreter *perl_interpreter;
/* List of workers that are pending to start */
static GList *workers_pending = NULL;
-static
- void
+#ifndef HAVE_SA_SIGINFO
+static void
sig_handler (int signo)
+#else
+static void
+sig_handler (int signo, siginfo_t *info, void *unused)
+#endif
{
+#ifdef HAVE_SA_SIGINFO
+ siginfo_t *new_info;
+ new_info = g_malloc (sizeof (siginfo_t));
+ memcpy (new_info, info, sizeof (siginfo_t));
+ g_queue_push_head (signals_info, new_info);
+#endif
+
switch (signo) {
case SIGHUP:
do_restart = 1;
@@ -98,6 +112,67 @@ sig_handler (int signo)
}
}
+#ifdef HAVE_SA_SIGINFO
+
+static const char *
+strsigcode (int code)
+{
+ switch (code) {
+ case SI_USER:
+ return "kill(2) or raise(3)";
+ break;
+ case SI_KERNEL:
+ return "sent by the kernel";
+ break;
+ case SI_TIMER:
+ return "POSIX timer expired";
+ break;
+ case SI_SIGIO:
+ return "queued SIGIO";
+ break;
+ default:
+ return "unknown reason";
+ }
+}
+
+static const char *
+chldsigcode (int code) {
+ switch (code) {
+ case CLD_EXITED:
+ return "Child exited normally";
+ case CLD_KILLED:
+ return "Child has terminated abnormally but did not create a core file";
+ case CLD_DUMPED:
+ return "Child has terminated abnormally and created a core file";
+ case CLD_TRAPPED:
+ return "Traced child has trapped";
+ default:
+ return "Unknown reason";
+ }
+}
+
+/* Prints info about incoming signals by parsing siginfo structures */
+static void
+print_signals_info ()
+{
+ siginfo_t *inf;
+
+ while ((inf = g_queue_pop_head (signals_info))) {
+ if (inf->si_signo == SIGCHLD) {
+ msg_info ("main: got SIGCHLD from child: %ld; reason: '%s'",
+ (long int)inf->si_pid, chldsigcode (inf->si_code));
+ }
+ else {
+ msg_info ("main: got signal: '%s'; received from pid: %ld; uid: %ld; reason: '%s'",
+ g_strsignal (inf->si_signo), (long int)inf->si_pid, (long int)inf->si_uid,
+ strsigcode (inf->si_code));
+ }
+ g_free (inf);
+ }
+}
+#endif
+
+
static void
read_cmd_line (int argc, char **argv, struct config_file *cfg)
{
@@ -506,6 +581,9 @@ main (int argc, char **argv, char **env)
char *args[] = { "", "-e", "0", NULL };
#endif
+#ifdef HAVE_SA_SIGINFO
+ signals_info = g_queue_new ();
+#endif
rspamd = (struct rspamd_main *)g_malloc (sizeof (struct rspamd_main));
bzero (rspamd, sizeof (struct rspamd_main));
rspamd->server_pool = memory_pool_new (memory_pool_get_size ());
@@ -734,6 +812,9 @@ main (int argc, char **argv, char **env)
msg_debug ("main: calling sigsuspend");
sigemptyset (&signals.sa_mask);
sigsuspend (&signals.sa_mask);
+#ifdef HAVE_SA_SIGINFO
+ print_signals_info ();
+#endif
if (do_terminate) {
msg_debug ("main: catch termination signal, waiting for childs");
pass_signal_worker (rspamd->workers, SIGTERM);
diff --git a/src/util.c b/src/util.c
index fbb5cb547..425aed439 100644
--- a/src/util.c
+++ b/src/util.c
@@ -305,8 +305,13 @@ write_pid (struct rspamd_main *main)
return 0;
}
+#ifdef HAVE_SA_SIGINFO
void
-init_signals (struct sigaction *signals, sig_t sig_handler)
+init_signals (struct sigaction *signals, void (*sig_handler)(int, siginfo_t *, void *))
+#else
+void
+init_signals (struct sigaction *signals, sighandler_t sig_handler)
+#endif
{
struct sigaction sigpipe_act;
/* Setting up signal handlers */
@@ -322,8 +327,14 @@ init_signals (struct sigaction *signals, sig_t sig_handler)
sigaddset (&signals->sa_mask, SIGALRM);
+#ifdef HAVE_SA_SIGINFO
+ signals->sa_flags = SA_SIGINFO;
+ signals->sa_handler = NULL;
+ signals->sa_sigaction = sig_handler;
+#else
signals->sa_handler = sig_handler;
signals->sa_flags = 0;
+#endif
sigaction (SIGTERM, signals, NULL);
sigaction (SIGINT, signals, NULL);
sigaction (SIGHUP, signals, NULL);
diff --git a/src/util.h b/src/util.h
index dfc08aa7d..3def85b8a 100644
--- a/src/util.h
+++ b/src/util.h
@@ -25,7 +25,11 @@ int make_socket_blocking (int);
/* Poll sync socket for specified events */
int poll_sync_socket (int fd, int timeout, short events);
/* Init signals */
-void init_signals (struct sigaction *, sig_t);
+#ifdef HAVE_SA_SIGINFO
+void init_signals (struct sigaction *sa, void (*sig_handler)(int, siginfo_t *, void *));
+#else
+void init_signals (struct sigaction *sa, sighandler_t);
+#endif
/* Send specified signal to each worker */
void pass_signal_worker (GHashTable *, int );
/* Convert string to lowercase */
diff --git a/src/worker.c b/src/worker.c
index 222b36971..21fcc9041 100644
--- a/src/worker.c
+++ b/src/worker.c
@@ -56,9 +56,13 @@ static gboolean is_mime;
static gboolean write_socket (void *arg);
-static
- void
+#ifndef HAVE_SA_SIGINFO
+static void
sig_handler (int signo)
+#else
+static void
+sig_handler (int signo, siginfo_t *info, void *unused)
+#endif
{
switch (signo) {
case SIGINT:
28 Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
summaryrefslogtreecommitdiffstats
path: root/.htaccess
blob: 4f2a6f35af4aa6ef5f44ebc3bda8dccae9d13c91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Version: 9.0.0
<IfModule mod_headers.c>
  <IfModule mod_fcgid.c>
    <IfModule mod_setenvif.c>
       SetEnvIfNoCase ^Authorization$ "(.+)" XAUTHORIZATION=$1
       RequestHeader set XAuthorization %{XAUTHORIZATION}e env=XAUTHORIZATION
    </IfModule>
  </IfModule>

  <IfModule mod_env.c>
    # Add security and privacy related headers
    Header set X-Content-Type-Options "nosniff"
    Header set X-XSS-Protection "1; mode=block"
    Header set X-Robots-Tag "none"
    Header set X-Frame-Options "SAMEORIGIN"
    SetEnv modHeadersAvailable true
  </IfModule>

  # Add cache control for CSS and JS files
  <FilesMatch "\.(css|js)$">
    Header set Cache-Control "max-age=7200, public"
  </FilesMatch>
</IfModule>
<IfModule mod_php5.c>
  php_value upload_max_filesize 513M
  php_value post_max_size 513M
  php_value memory_limit 512M
  php_value mbstring.func_overload 0
  php_value always_populate_raw_post_data -1
  php_value default_charset 'UTF-8'
  php_value output_buffering 0
  <IfModule mod_env.c>
    SetEnv htaccessWorking true
  </IfModule>
</IfModule>
<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  RewriteRule ^\.well-known/host-meta /public.php?service=host-meta [QSA,L]
  RewriteRule ^\.well-known/host-meta\.json /public.php?service=host-meta-json [QSA,L]
  RewriteRule ^\.well-known/carddav /remote.php/dav/ [R=301,L]
  RewriteRule ^\.well-known/caldav /remote.php/dav/ [R=301,L]
  RewriteRule ^remote/(.*) remote.php [QSA,L]
  RewriteRule ^(build|tests|config|lib|3rdparty|templates)/.* - [R=404,L]
  RewriteRule ^(\.|autotest|occ|issue|indie|db_|console).* - [R=404,L]

  # Rewrite rules for `front_controller_active`
  Options -MultiViews
  <IfModule mod_dir.c>
    DirectorySlash off
  </IfModule>
  RewriteRule ^core/js/oc.js$ index.php/core/js/oc.js [PT,E=PATH_INFO:$1]
  RewriteRule ^core/preview.png$ index.php/core/preview.png [PT,E=PATH_INFO:$1]
  RewriteCond %{REQUEST_FILENAME} !\.(css|js|svg|gif|png|html|ttf|woff)$
  RewriteCond %{REQUEST_FILENAME} !/remote.php
  RewriteCond %{REQUEST_FILENAME} !/public.php
  RewriteCond %{REQUEST_FILENAME} !/cron.php
  RewriteCond %{REQUEST_FILENAME} !/core/ajax/update.php
  RewriteCond %{REQUEST_FILENAME} !/status.php
  RewriteCond %{REQUEST_FILENAME} !/ocs/v1.php
  RewriteCond %{REQUEST_FILENAME} !/ocs/v2.php
  RewriteRule .* index.php [PT,E=PATH_INFO:$1]
</IfModule>
<IfModule mod_mime.c>
  AddType image/svg+xml svg svgz
  AddEncoding gzip svgz
</IfModule>
<IfModule mod_dir.c>
  DirectoryIndex index.php index.html
</IfModule>
AddDefaultCharset utf-8
Options -Indexes
<IfModule pagespeed_module>
  ModPagespeed Off
</IfModule>