~ubuntu-branches/ubuntu/saucy/haproxy/saucy

« back to all changes in this revision

Viewing changes to src/haproxy.c

  • Committer: Package Import Robot
  • Author(s): Vincent Bernat, Apollon Oikonomopoulos, Vincent Bernat, Prach Pongpanich
  • Date: 2013-05-06 20:02:14 UTC
  • mfrom: (1.1.13) (14.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20130506200214-21m58va04oazl7ot
Tags: 1.4.23-1
[ Apollon Oikonomopoulos ]
* New upstream version (Closes: #643650, #678953)
   + This fixes CVE-2012-2942 (Closes: #674447)
   + This fixes CVE-2013-1912 (Closes: #704611)
* Ship vim addon as vim-haproxy (Closes: #702893)
* Check for the configuration file after sourcing /etc/default/haproxy
  (Closes: #641762)
* Use /dev/log for logging by default (Closes: #649085)

[ Vincent Bernat ]
* debian/control:
   + add Vcs-* fields
   + switch maintenance to Debian HAProxy team. (Closes: #706890)
   + drop dependency to quilt: 3.0 (quilt) format is in use.
* debian/rules:
   + don't explicitly call dh_installchangelog.
   + use dh_installdirs to install directories.
   + use dh_install to install error and configuration files.
   + switch to `linux2628` Makefile target for Linux.
* debian/postrm:
   + remove haproxy user and group on purge.
* Ship a more minimal haproxy.cfg file: no `listen` blocks but `global`
  and `defaults` block with appropriate configuration to use chroot and
  logging in the expected way.

[ Prach Pongpanich ]
* debian/copyright:
   + add missing copyright holders
   + update years of copyright
* debian/rules:
   + build with -Wl,--as-needed to get rid of unnecessary depends
* Remove useless files in debian/haproxy.{docs,examples}
* Update debian/watch file, thanks to Bart Martens

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * HA-Proxy : High Availability-enabled HTTP/TCP proxy
3
 
 * Copyright 2000-2010  Willy Tarreau <w@1wt.eu>.
 
3
 * Copyright 2000-2013  Willy Tarreau <w@1wt.eu>.
4
4
 *
5
5
 * This program is free software; you can redistribute it and/or
6
6
 * modify it under the terms of the GNU General Public License
44
44
#include <sys/resource.h>
45
45
#include <time.h>
46
46
#include <syslog.h>
 
47
#include <grp.h>
47
48
 
48
49
#ifdef DEBUG_FULL
49
50
#include <assert.h>
158
159
void display_version()
159
160
{
160
161
        printf("HA-Proxy version " HAPROXY_VERSION " " HAPROXY_DATE"\n");
161
 
        printf("Copyright 2000-2011 Willy Tarreau <w@1wt.eu>\n\n");
 
162
        printf("Copyright 2000-2013 Willy Tarreau <w@1wt.eu>\n\n");
162
163
}
163
164
 
164
165
void display_build_opts()
649
650
        if (arg_mode & (MODE_DEBUG | MODE_FOREGROUND)) {
650
651
                /* command line debug mode inhibits configuration mode */
651
652
                global.mode &= ~(MODE_DAEMON | MODE_QUIET);
652
 
        }
653
 
        global.mode |= (arg_mode & (MODE_DAEMON | MODE_FOREGROUND | MODE_QUIET |
654
 
                                    MODE_VERBOSE | MODE_DEBUG ));
 
653
                global.mode |= (arg_mode & (MODE_DEBUG | MODE_FOREGROUND));
 
654
        }
 
655
 
 
656
        if (arg_mode & MODE_DAEMON) {
 
657
                /* command line daemon mode inhibits foreground and debug modes mode */
 
658
                global.mode &= ~(MODE_DEBUG | MODE_FOREGROUND);
 
659
                global.mode |= (arg_mode & MODE_DAEMON);
 
660
        }
 
661
 
 
662
        global.mode |= (arg_mode & (MODE_QUIET | MODE_VERBOSE));
655
663
 
656
664
        if ((global.mode & MODE_DEBUG) && (global.mode & (MODE_DAEMON | MODE_QUIET))) {
657
665
                Warning("<debug> mode incompatible with <quiet> and <daemon>. Keeping <debug> only.\n");
703
711
                list_pollers(stderr);
704
712
 
705
713
        if (!init_pollers()) {
706
 
                Alert("No polling mechanism available.\n");
 
714
                Alert("No polling mechanism available.\n"
 
715
                      "  It is likely that haproxy was built with TARGET=generic and that FD_SETSIZE\n"
 
716
                      "  is too low on this platform to support maxconn and the number of listeners\n"
 
717
                      "  and servers. You should rebuild haproxy specifying your system using TARGET=\n"
 
718
                      "  in order to support other polling systems (poll, epoll, kqueue) or reduce the\n"
 
719
                      "  global maxconn setting to accommodate the system's limitation. For reference,\n"
 
720
                      "  FD_SETSIZE=%d on this system, global.maxconn=%d resulting in a maximum of\n"
 
721
                      "  %d file descriptors. You should thus reduce global.maxconn by %d. Also,\n"
 
722
                      "  check build settings using 'haproxy -vv'.\n\n",
 
723
                      FD_SETSIZE, global.maxconn, global.maxsock, (global.maxsock + 1 - FD_SETSIZE) / 2);
707
724
                exit(1);
708
725
        }
709
726
        if (global.mode & (MODE_VERBOSE|MODE_DEBUG)) {
732
749
        int i;
733
750
 
734
751
        while (p) {
 
752
                free(p->conf.file);
735
753
                free(p->id);
736
754
                free(p->check_req);
737
755
                free(p->cookie_name);
861
879
                                task_free(s->check);
862
880
                        }
863
881
 
 
882
                        if (s->warmup) {
 
883
                                task_delete(s->warmup);
 
884
                                task_free(s->warmup);
 
885
                        }
 
886
 
864
887
                        free(s->id);
865
888
                        free(s->cookie);
866
889
                        free(s->check_data);
1156
1179
 
1157
1180
        /* chroot if needed */
1158
1181
        if (global.chroot != NULL) {
1159
 
                if (chroot(global.chroot) == -1) {
 
1182
                if (chroot(global.chroot) == -1 || chdir("/") == -1) {
1160
1183
                        Alert("[%s.main()] Cannot chroot(%s).\n", argv[0], global.chroot);
1161
1184
                        if (nb_oldpids)
1162
1185
                                tell_old_pids(SIGTTIN);
1163
1186
                        protocol_unbind_all();
1164
1187
                        exit(1);
1165
1188
                }
1166
 
                chdir("/");
1167
1189
        }
1168
1190
 
1169
1191
        if (nb_oldpids)
1174
1196
         */
1175
1197
 
1176
1198
        /* setgid / setuid */
1177
 
        if (global.gid && setgid(global.gid) == -1) {
1178
 
                Alert("[%s.main()] Cannot set gid %d.\n", argv[0], global.gid);
1179
 
                protocol_unbind_all();
1180
 
                exit(1);
 
1199
        if (global.gid) {
 
1200
                if (getgroups(0, NULL) > 0 && setgroups(0, NULL) == -1)
 
1201
                        Warning("[%s.main()] Failed to drop supplementary groups. Using 'gid'/'group'"
 
1202
                                " without 'uid'/'user' is generally useless.\n", argv[0]);
 
1203
 
 
1204
                if (setgid(global.gid) == -1) {
 
1205
                        Alert("[%s.main()] Cannot set gid %d.\n", argv[0], global.gid);
 
1206
                        protocol_unbind_all();
 
1207
                        exit(1);
 
1208
                }
1181
1209
        }
1182
1210
 
1183
1211
        if (global.uid && setuid(global.uid) == -1) {