From 981ca5ee03fb3be15a63a8f1353d38dbc42b7ceb Mon Sep 17 00:00:00 2001 From: dgaudet Date: Sun, 20 Jul 1997 18:18:56 +0000 Subject: [PATCH] PR#832: Fix Solaris -HUP problem introduced in 1.2.1. Reviewed by: Roy Fielding, (and it's been in 1.3 for a few weeks) git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3@78690 13f79535-47bb-0310-9956-ffa450edef68 --- APACHE_1_2_X/src/main/http_main.c | 53 +++++++++++++++++++------------ 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/APACHE_1_2_X/src/main/http_main.c b/APACHE_1_2_X/src/main/http_main.c index aa5c41b9b4c..50824f80875 100644 --- a/APACHE_1_2_X/src/main/http_main.c +++ b/APACHE_1_2_X/src/main/http_main.c @@ -1971,6 +1971,32 @@ int make_child(server_rec *server_conf, int child_num) return 0; } + +static void sock_bind (int s, const struct sockaddr_in *server) +{ +#ifdef MPE +/* MPE requires CAP=PM and GETPRIVMODE to bind to ports less than 1024 */ + if (ntohs(server->sin_port) < 1024) GETPRIVMODE(); +#endif + if(bind(s, (struct sockaddr *)server,sizeof(struct sockaddr_in)) == -1) + { + perror("bind"); +#ifdef MPE + if (ntohs(server->sin_port) < 1024) GETUSERMODE(); +#endif + if (server->sin_addr.s_addr != htonl(INADDR_ANY)) + fprintf(stderr,"httpd: could not bind to address %s port %d\n", + inet_ntoa(server->sin_addr), ntohs(server->sin_port)); + else + fprintf(stderr,"httpd: could not bind to port %d\n", + ntohs(server->sin_port)); + exit(1); + } +#ifdef MPE + if (ntohs(server->sin_port) < 1024) GETUSERMODE(); +#endif +} + static int make_sock(pool *pconf, const struct sockaddr_in *server) { int s; @@ -1982,6 +2008,10 @@ static int make_sock(pool *pconf, const struct sockaddr_in *server) exit(1); } +#ifdef SOLARIS2 + sock_bind (s, server); +#endif + s = ap_slack(s, AP_SLACK_HIGH); note_cleanups_for_fd(pconf, s); /* arrange to close on exec or restart */ @@ -2031,27 +2061,10 @@ static int make_sock(pool *pconf, const struct sockaddr_in *server) } } -#ifdef MPE -/* MPE requires CAP=PM and GETPRIVMODE to bind to ports less than 1024 */ - if (ntohs(server->sin_port) < 1024) GETPRIVMODE(); -#endif - if(bind(s, (struct sockaddr *)server,sizeof(struct sockaddr_in)) == -1) - { - perror("bind"); -#ifdef MPE - if (ntohs(server->sin_port) < 1024) GETUSERMODE(); -#endif - if (server->sin_addr.s_addr != htonl(INADDR_ANY)) - fprintf(stderr,"httpd: could not bind to address %s port %d\n", - inet_ntoa(server->sin_addr), ntohs(server->sin_port)); - else - fprintf(stderr,"httpd: could not bind to port %d\n", - ntohs(server->sin_port)); - exit(1); - } -#ifdef MPE - if (ntohs(server->sin_port) < 1024) GETUSERMODE(); +#ifndef SOLARIS2 + sock_bind (s, server); #endif + listen(s, 512); return s; } -- 2.47.2