~ubuntu-branches/ubuntu/lucid/lighttpd/lucid-security

« back to all changes in this revision

Viewing changes to src/server.c

  • Committer: Bazaar Package Importer
  • Author(s): Krzysztof Krzyzaniak (eloy)
  • Date: 2006-01-16 20:06:39 UTC
  • mto: (6.1.1 lenny)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20060116200639-nejjwyvlkgjhzasa
Tags: upstream-1.4.9
ImportĀ upstreamĀ versionĀ 1.4.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
#include <sys/resource.h>
51
51
#endif
52
52
 
 
53
#ifdef HAVE_SYS_PRCTL_H
 
54
#include <sys/prctl.h>
 
55
#endif
 
56
 
53
57
#ifndef __sgi
54
58
/* IRIX doesn't like the alarm based time() optimization */
55
59
/* #define USE_ALARM */
67
71
 
68
72
        switch (sig) {
69
73
        case SIGTERM: srv_shutdown = 1; break;
70
 
        case SIGINT: graceful_shutdown = 1; break;
 
74
        case SIGINT: 
 
75
             if (graceful_shutdown) srv_shutdown = 1;
 
76
             else graceful_shutdown = 1; 
 
77
 
 
78
             break;
71
79
        case SIGALRM: handle_sig_alarm = 1; break;
72
80
        case SIGHUP:  handle_sig_hup = 1; break;
73
81
        case SIGCHLD: break;
77
85
static void signal_handler(int sig) {
78
86
        switch (sig) {
79
87
        case SIGTERM: srv_shutdown = 1; break;
80
 
        case SIGINT: graceful_shutdown = 1; break;
 
88
        case SIGINT: 
 
89
             if (graceful_shutdown) srv_shutdown = 1;
 
90
             else graceful_shutdown = 1; 
 
91
 
 
92
             break;
81
93
        case SIGALRM: handle_sig_alarm = 1; break;
82
94
        case SIGHUP:  handle_sig_hup = 1; break;
83
95
        case SIGCHLD:  break;
144
156
        
145
157
        CLEAN(config_context);
146
158
        CLEAN(config_touched);
 
159
        CLEAN(status);
147
160
#undef CLEAN
148
161
        
149
162
        for (i = 0; i < FILE_CACHE_MAX; i++) {
241
254
        
242
255
        CLEAN(config_context);
243
256
        CLEAN(config_touched);
 
257
        CLEAN(status);
244
258
#undef CLEAN
245
259
        
246
260
        joblist_free(srv, srv->joblist);
323
337
        setlocale(LC_TIME, "C");
324
338
        
325
339
        if (NULL == (srv = server_init())) {
326
 
                fprintf(stderr, "did this really happend ?\n");
 
340
                fprintf(stderr, "did this really happen?\n");
327
341
                return -1;
328
342
        }
329
343
        
521
535
                } else {
522
536
                        srv->max_fds = rlim.rlim_cur;
523
537
                }
 
538
 
 
539
                /* set core file rlimit, if enable_cores is set */
 
540
                if (use_rlimit && srv->srvconf.enable_cores && getrlimit(RLIMIT_CORE, &rlim) == 0) {
 
541
                        rlim.rlim_cur = rlim.rlim_max;
 
542
                        setrlimit(RLIMIT_CORE, &rlim);
 
543
                }
524
544
#endif
525
545
                if (srv->event_handler == FDEVENT_HANDLER_SELECT) {
526
546
                        /* don't raise the limit above FD_SET_SIZE */
593
613
                        initgroups(srv->srvconf.username->ptr, grp->gr_gid);
594
614
                if (srv->srvconf.username->used) setuid(pwd->pw_uid);
595
615
#endif
 
616
#ifdef HAVE_PRCTL
 
617
                if (srv->srvconf.enable_cores) {
 
618
                        prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
 
619
                }
 
620
#endif
596
621
        } else {
597
622
 
598
623
#ifdef HAVE_GETRLIMIT
608
633
                } else {
609
634
                        srv->max_fds = rlim.rlim_cur;
610
635
                }
 
636
 
 
637
                /* set core file rlimit, if enable_cores is set */
 
638
                if (srv->srvconf.enable_cores && getrlimit(RLIMIT_CORE, &rlim) == 0) {
 
639
                        rlim.rlim_cur = rlim.rlim_max;
 
640
                        setrlimit(RLIMIT_CORE, &rlim);
 
641
                }
 
642
 
611
643
#endif
612
644
                if (srv->event_handler == FDEVENT_HANDLER_SELECT) {
613
645
                        /* don't raise the limit above FD_SET_SIZE */