httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dgau...@hyperreal.org
Subject cvs commit: apache-2.0/mpm/src/os/beos Makefile.tmpl beosd.c beosd.h iol_socket.c iol_socket.h os-inline.c os.c os.h
Date Mon, 12 Jul 1999 22:51:18 GMT
dgaudet     99/07/12 15:51:17

  Modified:    mpm/src  CHANGES Configure
               mpm/src/include ap_config.h httpd.h
               mpm/src/main util.c
  Added:       mpm/src/os/beos Makefile.tmpl beosd.c beosd.h iol_socket.c
                        iol_socket.h os-inline.c os.c os.h
  Log:
  commit David's beos port.
  
  Submitted by:	David Reid <abb37@dial.pipex.com>
  
  Revision  Changes    Path
  1.13      +2 -0      apache-2.0/mpm/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apache-2.0/mpm/src/CHANGES,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- CHANGES	1999/07/05 13:00:39	1.12
  +++ CHANGES	1999/07/12 22:51:05	1.13
  @@ -1,5 +1,7 @@
   Changes with MPM
   
  +    * MPM BEOS port.  [David Reid <abb37@dial.pipex.com>]
  +
       * Start to implement module-defined hooks that are a) fast and b) typesafe.
         Replace pre_connection module call with a register_hook call and
         implement pre_connection as a hook. The intent is that these hooks will
  
  
  
  1.12      +2 -1      apache-2.0/mpm/src/Configure
  
  Index: Configure
  ===================================================================
  RCS file: /home/cvs/apache-2.0/mpm/src/Configure,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Configure	1999/07/11 14:49:03	1.11
  +++ Configure	1999/07/12 22:51:06	1.12
  @@ -729,7 +729,8 @@
   	OS='BeOS';
   	CFLAGS="$CFLAGS -DBEOS"
   	DEF_WANTHSREGEX=yes
  -	;;
  +	OSDIR='os/beos'
  +       ;;
       4850-*.*)
   	OS='NCR MP/RAS'
   	CFLAGS="$CFLAGS -DSVR4 -DMPRAS"
  
  
  
  1.3       +3 -0      apache-2.0/mpm/src/include/ap_config.h
  
  Index: ap_config.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/mpm/src/include/ap_config.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ap_config.h	1999/07/12 08:47:47	1.2
  +++ ap_config.h	1999/07/12 22:51:08	1.3
  @@ -877,6 +877,9 @@
   
   #elif defined(BEOS)
   #include <stddef.h>
  +#include <kernel/OS.h>
  +#include <kernel/image.h>
  +#include <sys/uio.h>
   
   #define NO_WRITEV
   #define NO_KILLPG
  
  
  
  1.6       +3 -0      apache-2.0/mpm/src/include/httpd.h
  
  Index: httpd.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/mpm/src/include/httpd.h,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- httpd.h	1999/07/04 09:13:32	1.5
  +++ httpd.h	1999/07/12 22:51:09	1.6
  @@ -86,6 +86,9 @@
   #elif defined(WIN32)
   /* Set default for Windows file system */
   #define HTTPD_ROOT "/apache"
  +#elif defined (BEOS)
  +/* Set the default for BeOS */
  +#define HTTPD_ROOT "/boot/home/apache"
   #else
   #define HTTPD_ROOT "/usr/local/apache"
   #endif
  
  
  
  1.2       +6 -1      apache-2.0/mpm/src/main/util.c
  
  Index: util.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/mpm/src/main/util.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- util.c	1999/06/18 18:39:30	1.1
  +++ util.c	1999/07/12 22:51:10	1.2
  @@ -1962,7 +1962,12 @@
       struct hostent *p;
   
       /* ZZZ change to use AP funcs. */
  -    if (gethostname(str, sizeof(str) - 1) != 0) {
  +#ifdef BEOS
  +    if (gethostname(str, sizeof(str) - 1) == 0)
  +#else
  +    if (gethostname(str, sizeof(str) - 1) != 0)
  +#endif
  +    {
   	perror("Unable to gethostname");
   	exit(1);
       }
  
  
  
  1.1                  apache-2.0/mpm/src/os/beos/Makefile.tmpl
  
  Index: Makefile.tmpl
  ===================================================================
  CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS)
  LIBS=$(EXTRA_LIBS) $(LIBS1)
  INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES)
  LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS)
  
  OBJS=	os.o beosd.o iol_socket.o
  
  LIB=	libos.a
  
  all:	$(LIB)
  
  $(LIB): $(OBJS)
  	rm -f $@
  	ar cr $@ $(OBJS)
  	$(RANLIB) $@
  
  .c.o:
  	$(CC) -c $(INCLUDES) $(CFLAGS) $<
  
  clean:
  	rm -f $(OBJS) $(LIB)
  
  distclean: clean
  	-rm -f Makefile
  
  # We really don't expect end users to use this rule.  It works only with
  # gcc, and rebuilds Makefile.tmpl.  You have to re-run Configure after
  # using it.
  depend:
  	cp Makefile.tmpl Makefile.tmpl.bak \
  	    && sed -ne '1,/^# DO NOT REMOVE/p' Makefile.tmpl > Makefile.new \
  	    && gcc -MM $(INCLUDES) $(CFLAGS) *.c >> Makefile.new \
  	    && sed -e '1,$$s: $(INCDIR)/: $$(INCDIR)/:g' \
  	           -e '1,$$s: $(OSDIR)/: $$(OSDIR)/:g' Makefile.new \
  		> Makefile.tmpl \
  	    && rm Makefile.new
  
  $(OBJS): Makefile
  
  # DO NOT REMOVE
  
  
  
  1.1                  apache-2.0/mpm/src/os/beos/beosd.c
  
  Index: beosd.c
  ===================================================================
  /* ====================================================================
   * Copyright (c) 1998-1999 The Apache Group.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Apache Group
   *    for use in the Apache HTTP server project (http://www.apache.org/)."
   *
   * 4. The names "Apache Server" and "Apache Group" must not be used to
   *    endorse or promote products derived from this software without
   *    prior written permission. For written permission, please contact
   *    apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Apache Group
   *    for use in the Apache HTTP server project (http://www.apache.org/)."
   *
   * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE APACHE GROUP OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Group and was originally based
   * on public domain software written at the National Center for
   * Supercomputing Applications, University of Illinois, Urbana-Champaign.
   * For more information on the Apache Group and the Apache HTTP server
   * project, please see <http://www.apache.org/>.
   *
   */
  
  #include "httpd.h"
  #include "http_config.h"
  #include "http_main.h"
  #include "http_log.h"
  #include "unixd.h"
  
  unixd_config_rec unixd_config;
  
  void unixd_detach(void)
  {
      int x;
      pid_t pgrp;
  
      chdir("/");
  
      if ((x = fork()) > 0)
  	exit(0);
      else if (x == -1) {
  	perror("fork");
  	fprintf(stderr, "%s: unable to fork new process\n", ap_server_argv0);
  	exit(1);
      }
      RAISE_SIGSTOP(DETACH);
  
  #ifndef NO_SETSID
      if ((pgrp = setsid()) == -1) {
  	perror("setsid");
  	fprintf(stderr, "%s: setsid failed\n", ap_server_argv0);
  	exit(1);
      }
  #else
      if ((pgrp = setpgrp(getpid(), 0)) == -1) {
  	perror("setpgrp");
  	fprintf(stderr, "%s: setpgrp failed\n", ap_server_argv0);
  	exit(1);
      }
  #endif
  
      /* close out the standard file descriptors */
      if (freopen("/dev/null", "r", stdin) == NULL) {
  	fprintf(stderr, "%s: unable to replace stdin with /dev/null: %s\n",
  		ap_server_argv0, strerror(errno));
  	/* continue anyhow -- note we can't close out descriptor 0 because we
  	 * have nothing to replace it with, and if we didn't have a descriptor
  	 * 0 the next file would be created with that value ... leading to
  	 * havoc.
  	 */
      }
      if (freopen("/dev/null", "w", stdout) == NULL) {
  	fprintf(stderr, "%s: unable to replace stdout with /dev/null: %s\n",
  		ap_server_argv0, strerror(errno));
      }
      /* stderr is a tricky one, we really want it to be the error_log,
       * but we haven't opened that yet.  So leave it alone for now and it'll
       * be reopened moments later.
       */
  }
  
  /* Set group privileges.
   *
   * Note that we use the username as set in the config files, rather than
   * the lookup of to uid --- the same uid may have multiple passwd entries,
   * with different sets of groups for each.
   */
  
  static int set_group_privs(void)
  {
      if (!geteuid()) {
  	char *name;
  
  	/* Get username if passed as a uid */
  
  	if (unixd_config.user_name[0] == '#') {
  	    struct passwd *ent;
  	    uid_t uid = atoi(&unixd_config.user_name[1]);
  
  	    if ((ent = getpwuid(uid)) == NULL) {
  		ap_log_error(APLOG_MARK, APLOG_ALERT, NULL,
  			 "getpwuid: couldn't determine user name from uid %u, "
  			 "you probably need to modify the User directive",
  			 (unsigned)uid);
  		return -1;
  	    }
  
  	    name = ent->pw_name;
  	}
  	else
  	    name = unixd_config.user_name;
  
  	if (setgid(unixd_config.group_id) == -1) {
  	    ap_log_error(APLOG_MARK, APLOG_ALERT, NULL,
  			"setgid: unable to set group id to Group %u",
  			(unsigned)unixd_config.group_id);
  	    return -1;
  	}
  
  	/* Reset `groups' attributes. */
  
  	if (initgroups(name, unixd_config.group_id) == -1) {
  	    ap_log_error(APLOG_MARK, APLOG_ALERT, NULL,
  			"initgroups: unable to set groups for User %s "
  			"and Group %u", name, (unsigned)unixd_config.group_id);
  	    return -1;
  	}
      }
      return 0;
  }
  
  
  int unixd_setup_child(void)
  {
      if (set_group_privs()) {
  	return -1;
      }
  
      /* Only try to switch if we're running as root */
      if (!geteuid() && (
  	setuid(unixd_config.user_id) == -1)) {
  	ap_log_error(APLOG_MARK, APLOG_ALERT, NULL,
  		    "setuid: unable to change uid");
  	return -1;
      }
      return 0;
  }
  
  
  const char *unixd_set_user(cmd_parms *cmd, void *dummy, char *arg)
  {
      const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
      if (err != NULL) {
          return err;
      }
  
      unixd_config.user_name = arg;
      unixd_config.user_id = ap_uname2id(arg);
  #if !defined (BIG_SECURITY_HOLE) && !defined (OS2)
      if (unixd_config.user_id == 0) {
  	return "Error:\tApache has not been designed to serve pages while\n"
  		"\trunning as root.  There are known race conditions that\n"
  		"\twill allow any local user to read any file on the system.\n"
  		"\tIf you still desire to serve pages as root then\n"
  		"\tadd -DBIG_SECURITY_HOLE to the EXTRA_CFLAGS line in your\n"
  		"\tsrc/Configuration file and rebuild the server.  It is\n"
  		"\tstrongly suggested that you instead modify the User\n"
  		"\tdirective in your httpd.conf file to list a non-root\n"
  		"\tuser.\n";
      }
  #endif
  
      return NULL;
  }
  
  const char *unixd_set_group(cmd_parms *cmd, void *dummy, char *arg)
  {
      const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
      if (err != NULL) {
          return err;
      }
  
      unixd_config.group_id = ap_gname2id(arg);
  
      return NULL;
  }
  
  void unixd_pre_config(void)
  {
      unixd_config.user_name = DEFAULT_USER;
      unixd_config.user_id = ap_uname2id(DEFAULT_USER);
      unixd_config.group_id = ap_gname2id(DEFAULT_GROUP);
  }
  
  
  
  1.1                  apache-2.0/mpm/src/os/beos/beosd.h
  
  Index: beosd.h
  ===================================================================
  /* ====================================================================
   * Copyright (c) 1998-1999 The Apache Group.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Apache Group
   *    for use in the Apache HTTP server project (http://www.apache.org/)."
   *
   * 4. The names "Apache Server" and "Apache Group" must not be used to
   *    endorse or promote products derived from this software without
   *    prior written permission. For written permission, please contact
   *    apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Apache Group
   *    for use in the Apache HTTP server project (http://www.apache.org/)."
   *
   * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE APACHE GROUP OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Group and was originally based
   * on public domain software written at the National Center for
   * Supercomputing Applications, University of Illinois, Urbana-Champaign.
   * For more information on the Apache Group and the Apache HTTP server
   * project, please see <http://www.apache.org/>.
   *
   */
  
  #ifndef UNIXD_H
  #define UNIXD_H
  
  /* common stuff that unix MPMs will want */
  
  typedef struct {
      char *user_name;
      uid_t user_id;
      gid_t group_id;
  } unixd_config_rec;
  extern unixd_config_rec unixd_config;
  
  void unixd_detach(void);
  int unixd_setup_child(void);
  void unixd_pre_config(void);
  const char *unixd_set_user(cmd_parms *cmd, void *dummy, char *arg);
  const char *unixd_set_group(cmd_parms *cmd, void *dummy, char *arg);
  
  #define UNIX_DAEMON_COMMANDS	\
  { "User", unixd_set_user, NULL, RSRC_CONF, TAKE1, \
    "Effective user id for this server"}, \
  { "Group", unixd_set_group, NULL, RSRC_CONF, TAKE1, \
    "Effective group id for this server"}, \
  
  #endif
  
  
  
  1.1                  apache-2.0/mpm/src/os/beos/iol_socket.c
  
  Index: iol_socket.c
  ===================================================================
  /* ====================================================================
   * Copyright (c) 1996-1999 The Apache Group.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Apache Group
   *    for use in the Apache HTTP server project (http://www.apache.org/)."
   *
   * 4. The names "Apache Server" and "Apache Group" must not be used to
   *    endorse or promote products derived from this software without
   *    prior written permission. For written permission, please contact
   *    apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Apache Group
   *    for use in the Apache HTTP server project (http://www.apache.org/)."
   *
   * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE APACHE GROUP OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Group and was originally based
   * on public domain software written at the National Center for
   * Supercomputing Applications, University of Illinois, Urbana-Champaign.
   * For more information on the Apache Group and the Apache HTTP server
   * project, please see <http://www.apache.org/>.
   *
   */
  
  
  #include "httpd.h"
  #include "ap_iol.h"
  
  #include <errno.h>
  #include <sys/types.h>
  #include <sys/uio.h>
  
  #define FD_NONBLOCKING_SET	(1)
  
  typedef struct {
      ap_iol iol;
      int fd;
      int flags;
      int timeout;
  } iol_socket;
  
  static int beos_setopt(ap_iol *viol, ap_iol_option opt, const void *value)
  {
      iol_socket *iol = (iol_socket *)viol;
  
      switch (opt) {
      case AP_IOL_TIMEOUT:
  	iol->timeout = *(const int *)value;
  	break;
      default:
  	errno = EINVAL;
  	return -1;
      }
      return 0;
  }
  
  static int beos_getopt(ap_iol *viol, ap_iol_option opt, void *value)
  {
      iol_socket *iol = (iol_socket *)viol;
  
      switch (opt) {
      case AP_IOL_TIMEOUT:
  	*(int *)value = iol->timeout;
  	break;
      default:
  	errno = EINVAL;
  	return -1;
      }
      return 0;
  }
  
  static int set_nonblock(int fd)
  {
      int on = 1;
      return setsockopt(fd, SOL_SOCKET, SO_NONBLOCK, &on, sizeof(on));
  }
  
  /* the timeout code is a separate routine because it requires
      a stack frame... and we don't want to pay that setup cost
      on every call */
  
  /* this macro expands into the four basic i/o methods */
  
  #define method(name, args, syscall, selread, selwrite)	\
      static int beos_##name##_timeout args \
      { \
  	iol_socket *iol = (iol_socket *)viol; \
  	fd_set fdset; \
  	struct timeval tv; \
  	int rv; \
   \
  	FD_ZERO(&fdset); \
  	FD_SET(iol->fd, &fdset); \
  	tv.tv_sec = iol->timeout; \
  	tv.tv_usec = 0; \
  	do { \
  	    rv = select(iol->fd + 1, selread, selwrite, NULL, iol->timeout < 0 ? NULL
: &tv); \
  	} while (rv == -1 && errno == EINTR); \
  	if (!FD_ISSET(iol->fd, &fdset)) { \
  	    errno = ETIMEDOUT; \
  	    return -1; \
  	} \
  	do { \
  	    rv = syscall(iol->fd, arg1, arg2, 0); \
  	} while (rv == -1 && errno == EINTR); \
  	return rv; \
      } \
   \
      static int beos_##name args \
      { \
  	iol_socket *iol = (iol_socket *)viol; \
  	int rv; \
   \
  	if (!(iol->flags & FD_NONBLOCKING_SET)) { \
  	    if (iol->timeout < 0) { \
  		return syscall(iol->fd, arg1, arg2, 0); \
  	    } \
  	    /* must shift descriptor to blocking mode now */ \
  	    if (set_nonblock(iol->fd)) { \
  		return -1; \
  	    } \
  	    iol->flags |= FD_NONBLOCKING_SET; \
  	} \
   \
  	/* try writing, ignoring EINTR, the upper layer has to handle \
  	    partial read/writes anyhow, so we can return early */ \
  	do { \
  	    rv = syscall(iol->fd, arg1, arg2, 0); \
  	} while (rv == -1 && errno == EINTR); \
  	if (rv >= 0) { \
  	    return rv; \
  	} \
  	if (errno == EWOULDBLOCK && iol->timeout != 0) { \
  	    return beos_##name##_timeout(viol, arg1, arg2); \
  	} \
  	return -1; \
      } \
  
  method(write, (ap_iol *viol, const char *arg1, int arg2), send, NULL, &fdset)
  method(read, (ap_iol *viol, char *arg1, int arg2), recv, &fdset, NULL)
  
  static int beos_close(ap_iol *viol)
  {
      iol_socket *iol = (iol_socket *)viol;
      int rv;
      int saved_errno;
  
      rv = closesocket(iol->fd);
      saved_errno = errno;
      free(iol);
      errno = saved_errno;
      return rv;
  }
  
  static int beos_writev(ap_iol *viol, const struct iovec *vec, int nvec)
  {
  return beos_write(viol,vec[0].iov_base,vec[0].iov_len);
  }
  
  static const ap_iol_methods beos_methods = {
      beos_close,
      beos_write,
      beos_writev,
      beos_read,
      beos_setopt,
      beos_getopt
  };
  
  ap_iol *beos_attach_socket(int fd)
  {
      iol_socket *iol;
  
      if (fd >= FD_SETSIZE) {
  	errno = EBADF;
  	return NULL;
      }
      iol = malloc(sizeof(iol_socket));
      iol->iol.methods = &beos_methods;
      iol->fd = fd;
      iol->timeout = -1;
      iol->flags = 0;
      return (ap_iol *)iol;
  }
  
  
  
  1.1                  apache-2.0/mpm/src/os/beos/iol_socket.h
  
  Index: iol_socket.h
  ===================================================================
  /* ====================================================================
   * Copyright (c) 1998-1999 The Apache Group.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Apache Group
   *    for use in the Apache HTTP server project (http://www.apache.org/)."
   *
   * 4. The names "Apache Server" and "Apache Group" must not be used to
   *    endorse or promote products derived from this software without
   *    prior written permission. For written permission, please contact
   *    apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Apache Group
   *    for use in the Apache HTTP server project (http://www.apache.org/)."
   *
   * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE APACHE GROUP OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Group and was originally based
   * on public domain software written at the National Center for
   * Supercomputing Applications, University of Illinois, Urbana-Champaign.
   * For more information on the Apache Group and the Apache HTTP server
   * project, please see <http://www.apache.org/>.
   *
   */
  
  #ifndef OS_UNIX_IOL_SOCKET_H
  #define OS_UNIX_IOL_SOCKET_H
  
  ap_iol *beos_attach_socket(int fd);
  
  #endif
  
  
  
  1.1                  apache-2.0/mpm/src/os/beos/os-inline.c
  
  Index: os-inline.c
  ===================================================================
  /*
   * This file contains functions which can be inlined if the compiler
   * has an "inline" modifier. Because of this, this file is both a
   * header file and a compilable module.
   *
   * Only inlineable functions should be defined in here. They must all
   * include the INLINE modifier. 
   *
   * If the compiler supports inline, this file will be #included as a
   * header file from os.h to create all the inline function
   * definitions. INLINE will be defined to whatever is required on
   * function definitions to make them inline declarations.
   *
   * If the compiler does not support inline, this file will be compiled
   * as a normal C file into libos.a (along with os.c). In this case
   * INLINE will _not_ be set so we can use this to test if we are
   * compiling this source file.  
   */
  #include <unistd.h>
  
  #ifndef INLINE
  #define INLINE
  
  /* Anything required only when compiling */
  #include "ap_config.h"
  
  #endif
  
  INLINE int ap_os_is_path_absolute(const char *file)
  {
    return file[0] == '/';
  }
  
  INLINE int ap_spawnvp(const char *file, char *const argv[])
  {
      int pid;
  
      if ((pid = fork()) == -1) {
          return pid;
      } else if (pid == 0) {
          if (execvp(file, argv) == -1)
              return -1;
          else
              return -1;  /* If we get, we have a real error, but this keeps
                             us from getting a warning during compile time. */
      } else 
          return pid;
  }
      
  
  
  
  1.1                  apache-2.0/mpm/src/os/beos/os.c
  
  Index: os.c
  ===================================================================
  /*
   * This file will include OS specific functions which are not inlineable.
   * Any inlineable functions should be defined in os-inline.c instead.
   */
  
  #include "ap_config.h"
  #include "os.h"
  
  int ap_os_is_path_absolute(const char *file)
  {
    return file[0] == '/';
  }
  
  int ap_spawnvp(const char *file, char *const argv[])
  {
      int pid;
  
      if ((pid = fork()) == -1) {
          return pid;
      } else if (pid == 0) {
          if (execvp(file, argv) == -1)
              return -1;
          else
              return -1;  /* If we get, we have a real error, but this keeps
                             us from getting a warning during compile time. */
      } else 
          return pid;
  }
  
  
  /* some linkers complain unless there's at least one function in each
   * .o file... and extra prototype is for gcc -Wmissing-prototypes
   */
  extern void ap_is_not_here(void);
  void ap_is_not_here(void) {}
  
  /*
   *  Abstraction layer for loading
   *  Apache modules under run-time via 
   *  dynamic shared object (DSO) mechanism
   */
  
  void ap_os_dso_init(void)
  {
      /* Nothing required to be done! */ 
  }
  
  void* ap_os_dso_load(const char *path)
  {
      return (void*) load_add_on(path);
  }
  
  void ap_os_dso_unload(void* handle)
  {
      unload_add_on((image_id)handle);
  }
  
  void *ap_os_dso_sym(void *handle, const char *symname)
  {
      void * retval = 0;
  #if defined(DLSYM_NEEDS_UNDERSCORE)
      char *symbol = (char*)malloc(sizeof(char)*(strlen(symname)+2));
      sprintf(symbol, "_%s", symname);
      get_image_symbol((image_id)handle, symbol, B_SYMBOL_TYPE_ANY, (void **)&retval);
      free(symbol);
      return retval;
  #endif
      get_image_symbol((image_id)handle, symname, B_SYMBOL_TYPE_ANY, (void **)&retval);
      return retval;
  }
  
  const char *ap_os_dso_error(void)
  {
      return NULL;
  }
  
  
  
  1.1                  apache-2.0/mpm/src/os/beos/os.h
  
  Index: os.h
  ===================================================================
  /* ====================================================================
   * Copyright (c) 1998-1999 The Apache Group.  All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. All advertising materials mentioning features or use of this
   *    software must display the following acknowledgment:
   *    "This product includes software developed by the Apache Group
   *    for use in the Apache HTTP server project (http://www.apache.org/)."
   *
   * 4. The names "Apache Server" and "Apache Group" must not be used to
   *    endorse or promote products derived from this software without
   *    prior written permission. For written permission, please contact
   *    apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * 6. Redistributions of any form whatsoever must retain the following
   *    acknowledgment:
   *    "This product includes software developed by the Apache Group
   *    for use in the Apache HTTP server project (http://www.apache.org/)."
   *
   * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
   * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE APACHE GROUP OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Group and was originally based
   * on public domain software written at the National Center for
   * Supercomputing Applications, University of Illinois, Urbana-Champaign.
   * For more information on the Apache Group and the Apache HTTP server
   * project, please see <http://www.apache.org/>.
   *
   */
  
  #ifndef APACHE_OS_H
  #define APACHE_OS_H
  
  #include "ap_config.h"
  #include <kernel/image.h>
  
  #ifndef PLATFORM
  #define PLATFORM "BeOS"
  #endif
  
  /*
   * This file in included in all Apache source code. It contains definitions
   * of facilities available on _this_ operating system (HAVE_* macros),
   * and prototypes of OS specific functions defined in os.c or os-inline.c
   */
  
  extern int ap_os_is_path_absolute(const char *file);
  extern int ap_spawnvp(const char *file, char *const argv[]);
  #define ap_os_is_filename_valid(f)          (1)
  #define ap_os_kill(pid, sig)                kill(pid, sig)
  
  /*
   *  Abstraction layer for loading
   *  Apache modules under run-time via 
   *  dynamic shared object (DSO) mechanism
   */
  
  void *dlopen(const char *, int);
  int dlclose(void *);
  void *dlsym(void *, const char *);
  const char *dlerror(void);
  
  #define RTLD_NOW 1
  #define RTLD_GLOBAL 0
  
  #define     ap_os_dso_handle_t  image_id *
  void        ap_os_dso_init(void);
  void *      ap_os_dso_load(const char *);
  void        ap_os_dso_unload(void *);
  void *      ap_os_dso_sym(void *, const char *);
  const char *ap_os_dso_error(void);
  
  #endif	/* !APACHE_OS_H */
  
  
  

Mime
View raw message