You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ma...@apache.org on 2003/05/09 23:37:06 UTC

cvs commit: httpd-2.0/include httpd.h

martin      2003/05/09 14:37:06

  Modified:    server   core.c
               os/bs2000 os.h os.c
               include  httpd.h
  Removed:     os/bs2000 bs2login.c
  Log:
  Porting to BS2000: the antique interface (BS2000Account) no longer exists
  
  Revision  Changes    Path
  1.234     +0 -16     httpd-2.0/server/core.c
  
  Index: core.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/core.c,v
  retrieving revision 1.233
  retrieving revision 1.234
  diff -u -r1.233 -r1.234
  --- core.c	2 May 2003 21:50:55 -0000	1.233
  +++ core.c	9 May 2003 21:37:05 -0000	1.234
  @@ -2314,18 +2314,6 @@
       return NULL;
   }
   
  -#ifdef _OSD_POSIX /* BS2000 Logon Passwd file */
  -static const char *set_bs2000_account(cmd_parms *cmd, void *dummy, char *name)
  -{
  -    const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
  -    if (err != NULL) {
  -        return err;
  -    }
  -
  -    return os_set_account(cmd->pool, name);
  -}
  -#endif /*_OSD_POSIX*/
  -
   /*
    * Handle a request to include the server's OS platform in the Server
    * response header field (the ServerTokens directive).  Unfortunately
  @@ -3033,10 +3021,6 @@
     "Level of verbosity in error logging"),
   AP_INIT_TAKE1("NameVirtualHost", ap_set_name_virtual_host, NULL, RSRC_CONF,
     "A numeric IP address:port, or the name of a host"),
  -#ifdef _OSD_POSIX
  -AP_INIT_TAKE1("BS2000Account", set_bs2000_account, NULL, RSRC_CONF,
  -  "Name of server User's bs2000 logon account name"),
  -#endif
   AP_INIT_TAKE1("ServerTokens", set_serv_tokens, NULL, RSRC_CONF,
     "Determine tokens displayed in the Server: header - Min(imal), OS or Full"),
   AP_INIT_TAKE1("LimitRequestLine", set_limit_req_line, NULL, RSRC_CONF,
  
  
  
  1.14      +4 -4      httpd-2.0/os/bs2000/os.h
  
  Index: os.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/os/bs2000/os.h,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- os.h	3 Feb 2003 17:53:15 -0000	1.13
  +++ os.h	9 May 2003 21:37:05 -0000	1.14
  @@ -56,12 +56,12 @@
    * University of Illinois, Urbana-Champaign.
    */
   
  -#ifndef APACHE_OS_H
  -#define APACHE_OS_H
  +#ifndef APACHE_OS_BS2000_H
  +#define APACHE_OS_BS2000_H
   
   #define PLATFORM "BS2000"
   
  -#include "apr.h"
  +#include "../unix/os.h"
   
   /*
    * This file in included in all Apache source code. It contains definitions
  @@ -73,4 +73,4 @@
   
   extern pid_t os_fork(const char *user);
   
  -#endif /*! APACHE_OS_H*/
  +#endif /* APACHE_OS_BS2000_H */
  
  
  
  1.14      +117 -8    httpd-2.0/os/bs2000/os.c
  
  Index: os.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/os/bs2000/os.c,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- os.c	3 Feb 2003 17:53:15 -0000	1.13
  +++ os.c	9 May 2003 21:37:05 -0000	1.14
  @@ -61,16 +61,125 @@
    * Any inlineable functions should be defined in os-inline.c instead.
    */
   
  -#include "httpd.h"
  +#ifdef _OSD_POSIX
  +
   #include "os.h"
   
  -AP_DECLARE(apr_status_t) ap_os_create_privileged_process(
  -    const request_rec *r,
  -    apr_proc_t *newproc, const char *progname,
  -    const char * const *args,
  -    const char * const *env,
  -    apr_procattr_t *attr, apr_pool_t *p)
  +#include "httpd.h"
  +#include "http_config.h"
  +#include "http_log.h"
  +#include "apr_lib.h"
  +
  +#define USER_LEN 8
  +
  +typedef enum
  +{
  +    bs2_unknown,     /* not initialized yet. */
  +    bs2_noFORK,      /* no fork() because -X flag was specified */
  +    bs2_FORK,        /* only fork() because uid != 0 */
  +    bs2_UFORK        /* Normally, ufork() is used to switch identities. */
  +} bs2_ForkType;
  +
  +static bs2_ForkType forktype = bs2_unknown;
  +
  +
  +static void ap_str_toupper(char *str)
   {
  -    return apr_proc_create(newproc, progname, args, env, attr, p);
  +    while (*str) {
  +	*str = apr_toupper(*str);
  +	++str;
  +    }
   }
   
  +/* Determine the method for forking off a child in such a way as to
  + * set both the POSIX and BS2000 user id's to the unprivileged user.
  + */
  +static bs2_ForkType os_forktype(int one_process)
  +{
  +    /* have we checked the OS version before? If yes return the previous
  +     * result - the OS release isn't going to change suddenly!
  +     */
  +    if (forktype == bs2_unknown) {
  +        /* not initialized yet */
  +
  +        /* No fork if the one_process option was set */
  +        if (one_process) {
  +            forktype = bs2_noFORK;
  +        }
  +        /* If the user is unprivileged, use the normal fork() only. */
  +        else if (getuid() != 0) {
  +            forktype = bs2_FORK;
  +        }
  +        else
  +            forktype = bs2_UFORK;
  +    }
  +    return forktype;
  +}
  +
  +
  +
  +/* This routine complements the setuid() call: it causes the BS2000 job
  + * environment to be switched to the target user's user id.
  + * That is important if CGI scripts try to execute native BS2000 commands.
  + */
  +int os_init_job_environment(server_rec *server, const char *user_name, int one_process)
  +{
  +    bs2_ForkType            type = os_forktype(one_process);
  +
  +    /* We can be sure that no change to uid==0 is possible because of
  +     * the checks in http_core.c:set_user()
  +     */
  +
  +    if (one_process) {
  +
  +	type = forktype = bs2_noFORK;
  +
  +	ap_log_error(APLOG_MARK, APLOG_ERR, 0, server,
  +		     "The debug mode of Apache should only "
  +		     "be started by an unprivileged user!");
  +	return 0;
  +    }
  +
  +    return 0;
  +}
  +
  +/* BS2000 requires a "special" version of fork() before a setuid() call */
  +pid_t os_fork(const char *user)
  +{
  +    pid_t pid;
  +    char  username[USER_LEN+1];
  +
  +    switch (os_forktype(0)) {
  +
  +      case bs2_FORK:
  +	pid = fork();
  +	break;
  +
  +      case bs2_UFORK:
  +	apr_cpystrn(username, user, sizeof username);
  +
  +	/* Make user name all upper case - for some versions of ufork() */
  +	ap_str_toupper(username);
  +
  +	pid = ufork(username);
  +	if (pid == -1 && errno == EPERM) {
  +	    ap_log_error(APLOG_MARK, APLOG_EMERG, errno,
  +			 NULL, "ufork: Possible mis-configuration "
  +			 "for user %s - Aborting.", user);
  +	    exit(1);
  +	}
  +	break;
  +
  +      default:
  +	pid = 0;
  +	break;
  +    }
  +
  +    return pid;
  +}
  +
  +#else /* _OSD_POSIX */
  +void bs2000_os_is_not_here()
  +{
  +}
  +#endif /* _OSD_POSIX */
  
  
  
  1.197     +0 -1      httpd-2.0/include/httpd.h
  
  Index: httpd.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/include/httpd.h,v
  retrieving revision 1.196
  retrieving revision 1.197
  diff -u -r1.196 -r1.197
  --- httpd.h	6 Mar 2003 23:53:51 -0000	1.196
  +++ httpd.h	9 May 2003 21:37:06 -0000	1.197
  @@ -1616,7 +1616,6 @@
   AP_DECLARE(int) ap_is_directory(apr_pool_t *p, const char *name);
   
   #ifdef _OSD_POSIX
  -extern const char *os_set_account(apr_pool_t *p, const char *account);
   extern int os_init_job_environment(server_rec *s, const char *user_name, int one_process);
   #endif /* _OSD_POSIX */