httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@locus.apache.org
Subject cvs commit: apache-1.3/src/main http_main.c
Date Wed, 27 Dec 2000 21:45:16 GMT
wrowe       00/12/27 13:45:16

  Modified:    src      CHANGES ApacheCore.def
               src/os/win32 service.h registry.c registry.h service.c
               src/main http_main.c
  Log:
    This patch for Win32 depreciates the ConfFile registry entry, and allows
    the user to create a ConfigArgs entry by adding arguments to the
    apache -n server -k install command, e.g. -D FOO, and always stores the
    -f and -d options, at minimum.  These default command line args are
    merged unless the user invokes -k install, -k uninstall, or -k config.
  
    To reconfigure, the user may use the new command option;
    apache -n server -k config  which blows away the existing defaults and
    replaces them with whatever the user specifies on that command line.
  
    The patch also leverages the -t option for Win32, so it also report the
    default arguments added before the usual httpd.conf file test.
  
  Revision  Changes    Path
  1.1611    +14 -0     apache-1.3/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/CHANGES,v
  retrieving revision 1.1610
  retrieving revision 1.1611
  diff -u -r1.1610 -r1.1611
  --- CHANGES	2000/12/20 23:48:36	1.1610
  +++ CHANGES	2000/12/27 21:45:10	1.1611
  @@ -1,5 +1,19 @@
   Changes with Apache 1.3.15
   
  +  *) The new Win32 command line option, -k config, replaces the default
  +     options for the existing, named service with the options given on 
  +     the -k config command line.  Apache -n servicename -t now displays
  +     the default options before it tests the httpd.conf.  Use the syntax
  +     apache -k config -n servicename -f conffile to upgrade an existing
  +     1.3.x service to the new 1.3.15 default arguments.  [William Rowe]
  +
  +  *) All Win32 services now support default command line options when
  +     starting an Apache service.  The command line options given with
  +     the apache -k install command, including -d, -f, -D, -C and -c, 
  +     are all saved in the registry.  This change superceeds the old
  +     ConfPath entry, so existing services must be reconfigured when
  +     upgrading to 1.3.15.  [William Rowe]
  +
     *) The Win32 build is overhauled to use mod_foo.so for all dynamic
        Apache modules.  [William Rowe]
   
  
  
  
  1.28      +2 -2      apache-1.3/src/ApacheCore.def
  
  Index: ApacheCore.def
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/ApacheCore.def,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- ApacheCore.def	2000/10/08 05:23:15	1.27
  +++ ApacheCore.def	2000/12/27 21:45:11	1.28
  @@ -380,8 +380,8 @@
           ap_get_win32_interpreter @371
           ap_is_rdirectory @372
           ap_registry_get_server_root @373
  -	ap_registry_get_service_conf @374
  -	ap_registry_set_service_conf @375
  +	; ap_registry_get_service_conf removed in 1.3.15
  +	; ap_registry_set_service_conf removed in 1.3.15
           ap_remove_spaces @376
   	ap_scan_script_header_err_strs @377
           ap_start_shutdown @378
  
  
  
  1.15      +1 -1      apache-1.3/src/os/win32/service.h
  
  Index: service.h
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/os/win32/service.h,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- service.h	2000/12/14 14:30:44	1.14
  +++ service.h	2000/12/27 21:45:13	1.15
  @@ -79,7 +79,7 @@
   void service_cd();
   BOOL isProcessService();
   BOOL isValidService(char *display_name);
  -void InstallService(char *display_name, char *conf);
  +void InstallService(pool *p, char *display_name, int argc, char **argv, int reconfig);
   void RemoveService(char *display_name);
   int send_signal_to_service(char *display_name, char *sig, 
                              int argc, char **argv);
  
  
  
  1.35      +99 -30    apache-1.3/src/os/win32/registry.c
  
  Index: registry.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/os/win32/registry.c,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- registry.c	2000/06/05 16:24:16	1.34
  +++ registry.c	2000/12/27 21:45:13	1.35
  @@ -210,7 +210,7 @@
   	dir[0] = '\0';
       }
   
  -    return (rv < -1) ? -1 : 0;
  +    return (rv < 0) ? -1 : 0;
   }
   
   API_EXPORT(char *) ap_get_service_key(char *display_name)
  @@ -232,20 +232,6 @@
       return(key);
   }
   
  -API_EXPORT(int) ap_registry_get_service_conf(pool *p, char *dir, int size, char *display_name)
  -{
  -    int rv;
  -    char *key = ap_get_service_key(display_name);
  -
  -    rv = ap_registry_get_key_int(p, key, "ConfPath", dir, size, NULL);
  -    if (rv < 0) {
  -    dir[0] = '\0';
  -    }
  -
  -    free(key);
  -    return (rv < -1) ? -1 : 0;
  -}
  -
   /**********************************************************************
    * The rest of this file deals with storing keys or values in the registry
    */
  @@ -448,34 +434,117 @@
   }
   
   /*
  - * Sets the service confpath value within the registry. Returns 0 on success
  + * Sets the serverroot value within the registry. Returns 0 on success
    * or -1 on error. If -1 is return the error will already have been
    * logged via aplog_error().
    */
   
  -API_EXPORT(int) ap_registry_set_service_conf(char *conf, char *display_name)
  +int ap_registry_set_server_root(char *dir)
   {
       int rv;
  -    char *key = ap_get_service_key(display_name);
  -    
  -    rv = ap_registry_store_key_int(key, "ConfPath", REG_SZ, conf, strlen(conf)+1);
  -    free(key);
   
  -    return rv < 0 ? -1: 0;
  +    rv = ap_registry_store_key_int(REGKEY, "ServerRoot", REG_SZ, dir, strlen(dir)+1);
  +
  +    return rv < 0 ? -1 : 0;
   }
   
  -/*
  - * Sets the serverroot value within the registry. Returns 0 on success
  - * or -1 on error. If -1 is return the error will already have been
  - * logged via aplog_error().
  +/* Creates and fills array pointed to by parray with the requested registry string
  + *
  + * Returns 0 on success, machine specific error code on error 
    */
  +int ap_registry_get_array(pool *p, char *key, char *name, 
  +                          array_header **pparray)
  +{
  +    char *pValue;
  +    char *tmp;
  +    char **newelem;
  +    int ret;
  +    int nSize = 0;
  +
  +    ret = ap_registry_get_key_int(p, key, name, NULL, 0, &pValue);
  +    if (ret < 0)
  +        return ret;
  +
  +    tmp = pValue;
  +    if ((ret > 2) && (tmp[0] || tmp[1]))
  +        nSize = 1;    /* Element Count */
  +    while ((tmp < pValue + ret) && (tmp[0] || tmp[1]))
  +    {
  +        if (!tmp[0])
  +            ++nSize;
  +        ++tmp;
  +    }
   
  -int ap_registry_set_server_root(char *dir)
  +    *pparray = ap_make_array(p, nSize, sizeof(char *));
  +    tmp = pValue;
  +    if (tmp[0] || tmp[1]) {
  +        newelem = (char **) ap_push_array(*pparray);
  +        *newelem = tmp;
  +    }
  +    while ((tmp < pValue + ret) && (tmp[0] || tmp[1]))
  +    {
  +        if (!tmp[0]) {
  +            newelem = (char **) ap_push_array(*pparray);
  +            *newelem = tmp + 1;
  +        }
  +        ++tmp;
  +    }
  +    
  +    return nSize;
  +}
  +
  +int ap_registry_get_service_args(pool *p, int *argc, char ***argv, char *display_name)
   {
  -    int rv;
  +    int ret;
  +    array_header *parray;
  +    char *key = ap_get_service_key(display_name);
  +    ret = ap_registry_get_array(p, key, "ConfigArgs", &parray);
  +    if (ret > 0) {
  +        *argc = parray->nelts;
  +        *argv = (char**) parray->elts;
  +    }
  +    else {
  +        *argc = 0;
  +        *argv = NULL;
  +    }
  +    free(key);
  +    return ret;
  +}
   
  -    rv = ap_registry_store_key_int(REGKEY, "ServerRoot", REG_SZ, dir, strlen(dir)+1);
  +int ap_registry_store_array(pool *p, char *key, char *name,
  +                            int nelts, char **elts)
  +{
  +    int  bufsize, i;
  +    char *buf, *tmp;
   
  -    return rv < 0 ? -1 : 0;
  +    bufsize = 1; /* For trailing second null */
  +    for (i = 0; i < nelts; ++i)
  +    {
  +        bufsize += strlen(elts[i]) + 1;
  +    }
  +    if (!nelts) 
  +        ++bufsize;
  +
  +    buf = ap_palloc(p, bufsize);
  +    tmp = buf;
  +    for (i = 0; i < nelts; ++i)
  +    {
  +        strcpy(tmp, elts[i]);
  +        tmp += strlen(elts[i]) + 1;
  +    }
  +    if (!nelts) 
  +        *(tmp++) = '\0';
  +    *(tmp++) = '\0'; /* Trailing second null */
  +
  +    return ap_registry_store_key_int(key, name, REG_MULTI_SZ, buf, tmp - buf);
  +}
  +
  +int ap_registry_set_service_args(pool *p, int argc, char **argv, char *display_name)
  +{
  +    int ret;
  +    char *key = ap_get_service_key(display_name);
  +    ret = ap_registry_store_array(p, key, "ConfigArgs", argc, argv);
  +    free(key);
  +    return ret;
   }
   
  
  
  
  1.5       +2 -2      apache-1.3/src/os/win32/registry.h
  
  Index: registry.h
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/os/win32/registry.h,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- registry.h	2000/03/13 21:00:41	1.4
  +++ registry.h	2000/12/27 21:45:13	1.5
  @@ -4,5 +4,5 @@
   
   API_EXPORT(int) ap_registry_get_server_root(pool *p, char *dir, int size);
   extern int ap_registry_set_server_root(char *dir);
  -API_EXPORT(int) ap_registry_get_service_conf(pool *p, char *dir, int size, char *display_name);
  -API_EXPORT(int) ap_registry_set_service_conf(char *dir, char *display_name);
  +extern int ap_registry_get_service_args(pool *p, int *argc, char ***argv, char *display_name);
  +extern int ap_registry_set_service_args(pool *p, int argc, char **argv, char *display_name);
  
  
  
  1.37      +101 -43   apache-1.3/src/os/win32/service.c
  
  Index: service.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/os/win32/service.c,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- service.c	2000/12/14 14:30:42	1.36
  +++ service.c	2000/12/27 21:45:13	1.37
  @@ -397,7 +397,7 @@
       /* Prevent holding open the (nonexistant) console and allow us past
        * the first NT service to parse the service's args in apache_main() 
        */
  -	ap_server_argv0 = argv[0];
  +    ap_server_argv0 = argv[0];
       real_exit_code = 0;
   
       /* keep the server from going to any real effort, since we know */
  @@ -426,6 +426,8 @@
       char buf[300], *p;
       GetModuleFileName(NULL, buf, 300);
       p = strrchr(buf, '\\');
  +    if (p < strrchr(buf, '/'))
  +        p = strrchr(buf, '/');
       if (p != NULL)
           *p = 0;
       chdir(buf);
  @@ -506,18 +508,11 @@
       HANDLE hPipeReadDup;
       HANDLE thread;
       DWORD  threadid;
  -    SECURITY_ATTRIBUTES sa = {0};  
  -    
  -	argv = (char**) memcpy(malloc((argc + 3) * sizeof(char*)), 
  -		                   argv, argc * sizeof(char*));
  -	argv[argc++] = "-n";
  -	argv[argc++] = argv[0];
  -	argv[argc] = NULL;
  -    argv[0] = ap_server_argv0;
  -	ap_server_argv0 = globdat.name = argv[0];
  +    SECURITY_ATTRIBUTES sa = {0};
  +    char **newargv;
   
  -    if(!(globdat.hServiceStatus = RegisterServiceCtrlHandler(globdat.name, 
  -                                                             service_ctrl)))
  +    if(!(globdat.hServiceStatus = RegisterServiceCtrlHandler(argv[0], 
  +		                                                     service_ctrl)))
       {
           ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, NULL,
           "Failure registering service handler");
  @@ -569,6 +564,20 @@
           }            
       }
   
  +    /* Fold the "Start Parameters" in with the true executable argv[0],
  +     * and insert a -n tag to pass the service name from the SCM's argv[0]
  +     */
  +    newargv = (char**) malloc((argc + 3) * sizeof(char*));
  +    newargv[0] = ap_server_argv0;  /* The true executable name */
  +    newargv[1] = "-n";             /* True service name follows (argv[0]) */
  +    memcpy (newargv + 2, argv, argc * sizeof(char*));
  +    newargv[argc + 2] = NULL;      /* SCM doesn't null terminate the array */
  +    argv = newargv;
  +    argc += 2;
  +
  +    /* Use the name of the service as the error log marker */
  +    ap_server_argv0 = globdat.name = argv[0];
  +
       service_cd();
       globdat.exit_status = globdat.main_fn( argc, argv );
   
  @@ -679,13 +688,30 @@
       return(1);
   }
   
  -void InstallService(char *display_name, char *conf)
  +void InstallService(pool *p, char *display_name, int argc, char **argv, int reconfig)
   {
       TCHAR szPath[MAX_PATH];
       TCHAR szQuotedPath[512];
       char *service_name;
  +    int regargc = 0;
  +    char **regargv = malloc((argc + 4) * sizeof(char*)), **newelem = regargv;
  +
  +    regargc += 4;
  +    *(newelem++) = "-d";
  +    *(newelem++) = ap_server_root;
  +    *(newelem++) = "-f";
  +    *(newelem++) = ap_server_confname;
  +
  +    while (++argv, --argc) {
  +        if ((**argv == '-') && strchr("kndf", argv[0][1]))
  +            --argc, ++argv; /* Skip already handled -k -n -d -f options */
  +        else
  +            *(newelem++) = *argv, ++regargc;
  +    }
   
  -    printf("Installing the %s service to use %s\n", display_name, conf);
  +    printf(reconfig ? "Reconfiguring the %s service\n"
  +                    : "Installing the %s service\n", 
  +           display_name);
   
       if (GetModuleFileName( NULL, szPath, 512 ) == 0)
       {
  @@ -710,10 +736,10 @@
                               NULL,                 // database (default)
                               SC_MANAGER_ALL_ACCESS // access required
                               );
  -       if (!schSCManager) {
  -           ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, NULL,
  -	       "OpenSCManager failed");
  -           return;
  +        if (!schSCManager) {
  +            ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, NULL,
  +                         "OpenSCManager failed");
  +            return;
           }
           
           /* Added dependencies for the following: TCPIP, AFD
  @@ -724,31 +750,59 @@
            * convinced we should toggle this, but be warned that
            * future apache modules or ISAPI dll's may depend on it.
            */
  -        schService = CreateService(
  -            schSCManager,               // SCManager database
  -            service_name,               // name of service
  -            display_name,               // name to display
  -            SERVICE_ALL_ACCESS,         // desired access
  -            SERVICE_WIN32_OWN_PROCESS,  // service type
  -            SERVICE_AUTO_START,         // start type
  -            SERVICE_ERROR_NORMAL,       // error control type
  -            szQuotedPath,               // service's binary
  -            NULL,                       // no load ordering group
  -            NULL,                       // no tag identifier
  -            "Tcpip\0Afd\0",             // dependencies
  -            NULL,                       // LocalSystem account
  -            NULL);                      // no password
  -
  -        if (schService) {
  -            CloseServiceHandle(schService);
  -
  +        if (reconfig) 
  +        {
  +            schService = OpenService(schSCManager, service_name, 
  +                                     SERVICE_ALL_ACCESS);
  +            if (!schService)
  +                ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, NULL, 
  +                             "OpenService failed");
  +            else if (!ChangeServiceConfig(
  +                        schService,                 // Service handle
  +                        SERVICE_WIN32_OWN_PROCESS,  // service type
  +                        SERVICE_AUTO_START,         // start type
  +                        SERVICE_ERROR_NORMAL,       // error control type
  +                        szQuotedPath,               // service's binary
  +                        NULL,                       // no load ordering group
  +                        NULL,                       // no tag identifier
  +                        "Tcpip\0Afd\0",             // dependencies
  +                        NULL,                       // user account
  +                        NULL,                       // account password
  +                        display_name)) {            // service display name
  +                ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, NULL, 
  +		             "ChangeServiceConfig failed");
  +                /* !schService aborts configuration below */
  +                CloseServiceHandle(schService);
  +                schService = NULL;
  +            }
           }
  -        else {
  -            ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, NULL, 
  -		"CreateService failed");
  +        else /* !reconfig */
  +        {
  +            schService = CreateService(
  +                        schSCManager,               // SCManager database
  +                        service_name,               // name of service
  +                        display_name,               // name to display
  +                        SERVICE_ALL_ACCESS,         // desired access
  +                        SERVICE_WIN32_OWN_PROCESS,  // service type
  +                        SERVICE_AUTO_START,         // start type
  +                        SERVICE_ERROR_NORMAL,       // error control type
  +                        szQuotedPath,               // service's binary
  +                        NULL,                       // no load ordering group
  +                        NULL,                       // no tag identifier
  +                        "Tcpip\0Afd\0",             // dependencies
  +                        NULL,                       // user account
  +                        NULL);                      // account password
  +            if (!schService)
  +                ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, NULL, 
  +                             "CreateService failed");
           }
  -
  +        if (schService)
  +            CloseServiceHandle(schService);
  +        
           CloseServiceHandle(schSCManager);
  +        
  +        if (!schService)
  +            return;
       }
       else /* !isWindowsNT() */
       {
  @@ -824,10 +878,14 @@
   
           RegCloseKey(hkey);
       }
  +
  +    /* Both Platforms: Now store the args in the registry */
  +    if (ap_registry_set_service_args(p, regargc, regargv, service_name)) {
  +        return;
  +    }
   
  -    /* Both Platforms: Now store the server_root in the registry */
  -    if(!ap_registry_set_service_conf(conf, service_name))
  -        printf("The %s service has been installed successfully.\n", display_name);
  +    printf("The %s service has been %s successfully.\n", 
  +           display_name, reconfig ? "reconfigured" : "installed");
   }
   
   void RemoveService(char *display_name)
  
  
  
  1.519     +78 -27    apache-1.3/src/main/http_main.c
  
  Index: http_main.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/main/http_main.c,v
  retrieving revision 1.518
  retrieving revision 1.519
  diff -u -r1.518 -r1.519
  --- http_main.c	2000/12/14 14:30:34	1.518
  +++ http_main.c	2000/12/27 21:45:14	1.519
  @@ -1076,12 +1076,13 @@
       fprintf(stderr, "  -t               : run syntax check for config files (with docroot
check)\n");
       fprintf(stderr, "  -T               : run syntax check for config files (without docroot
check)\n");
   #ifdef WIN32
  -    fprintf(stderr, "  -n name          : set service name and use its ServerConfigFile\n");
  +    fprintf(stderr, "  -n name          : name the Apache service for -k options below;\n");
       fprintf(stderr, "  -k shutdown      : tell running Apache to shutdown\n");
       fprintf(stderr, "  -k restart       : tell running Apache to do a graceful restart\n");
       fprintf(stderr, "  -k start         : tell Apache to start\n");
  -    fprintf(stderr, "  -i               : install an Apache service\n");
  -    fprintf(stderr, "  -u               : uninstall an Apache service\n");
  +    fprintf(stderr, "  -k install   | -i: install an Apache service\n");
  +    fprintf(stderr, "  -k config        : reconfigure an installed Apache service\n");
  +    fprintf(stderr, "  -k uninstall | -u: uninstall an Apache service\n");
   #endif
   
   #ifdef NETWARE
  @@ -6670,8 +6671,10 @@
       char cwd[MAX_STRING_LEN];
   
   #ifdef WIN32
  +    jmp_buf reparse_args;
       char *service_name = NULL;
       int install = 0;
  +    int reparsed = 0;
       int is_child_of_service = 0;
       char *signal_to_send = NULL;
   
  @@ -6726,6 +6729,25 @@
       ap_cpystrn(ap_server_root, cwd, sizeof(ap_server_root));
   #endif
   
  +#ifdef WIN32
  +    /* If this is a service, we will need to fall back here and 
  +     * reparse the entire options list.
  +     */
  +    if (setjmp(reparse_args)) {
  +        /* Reset and reparse the command line */
  +        ap_server_pre_read_config  = ap_make_array(pcommands, 1, sizeof(char *));
  +        ap_server_post_read_config = ap_make_array(pcommands, 1, sizeof(char *));
  +        ap_server_config_defines   = ap_make_array(pcommands, 1, sizeof(char *));
  +
  +        /* Reset optreset and optind to allow getopt to work correctly
  +         * the second time around, and assure we never come back here.
  +         */
  +        optreset = 1;
  +        optind = 1;
  +        reparsed = 1;
  +    }
  +#endif
  +
       while ((c = getopt(argc, argv, "D:C:c:Xd:f:vVlLz:Z:iusStThk:n:")) != -1) {
           char **new;
   	switch (c) {
  @@ -6765,10 +6787,10 @@
               service_name = ap_pstrdup(pcommands, optarg);
               break;
   	case 'i':
  -	    install = 1;
  +            install = 2;
   	    break;
   	case 'u':
  -	    install = -1;
  +            install = -1;
   	    break;
   	case 'S':
   	    ap_dump_settings = 1;
  @@ -6777,6 +6799,8 @@
               if (!strcasecmp(optarg, "stop"))
                   signal_to_send = "shutdown";
               else if (!strcasecmp(optarg, "install"))
  +                install = 2;
  +            else if (!strcasecmp(optarg, "config"))
                   install = 1;
               else if (!strcasecmp(optarg, "uninstall"))
                   install = -1;
  @@ -6871,17 +6895,54 @@
   
       if (service_name && isValidService(service_name)) 
       {
  -        ap_registry_get_service_conf(pconf, ap_server_confname, 
  -                                     sizeof(ap_server_confname),
  -                                     service_name);
  -        conf_specified = 1;
  -        if (install > 0) {
  +        if (install == 2) {
               ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, NULL,
                            "Service \"%s\" is already installed!", service_name);
               clean_parent_exit(1);
           }
  +        /* Don't proceed if we are configuring, uninstalling 
  +         * or already merged and reparsed the service args
  +         */
  +        if (!install && !reparsed)
  +        {
  +            int svcargc;
  +            char **newargv, **svcargv;
  +            if (ap_configtestonly)
  +                fprintf(stderr, "Default command options for service %s:\n", 
  +                        service_name);
  +                    
  +            /* Merge the service's default args */
  +            if (ap_registry_get_service_args(pcommands, &svcargc, &svcargv, 
  +                                             service_name) > 0) {
  +                newargv = (char**)malloc((svcargc + argc + 1) * sizeof(char*));
  +                newargv[0] = argv[0];  /* The true executable name */
  +                memcpy(newargv + 1, svcargv, svcargc * sizeof(char*)); 
  +                memcpy(newargv + 1 + svcargc, argv + 1, 
  +                       (argc - 1) * sizeof(char*));
  +                argc += svcargc; /* Add the startup options args */
  +                argv = newargv;
  +                argv[argc] = NULL;
  +
  +                if (ap_configtestonly) {
  +                    while (svcargc-- > 0) {
  +                        if ((**svcargv == '-') && strchr("dfDCc", svcargv[0][1])
  +                            && svcargc) {
  +                            fprintf(stderr, "    %s %s\n", 
  +                                    *svcargv, *(svcargv + 1));
  +                            svcargv += 2; --svcargc;
  +                        }
  +                        else
  +                            fprintf(stderr, "    %s\n", *(svcargv++));
  +                    }
  +                }
  +                /* Run through the command line args all over again */
  +                longjmp(reparse_args, 1);
  +            }
  +            else if (ap_configtestonly)
  +                fprintf (stderr, "    (none)\n");
  +        }
       }
  -    else if (service_name && (install <= 0))
  +    else if (service_name && (install <= 1))
       {
           ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, NULL,
                        "Service \"%s\" is not installed!", service_name);
  @@ -6900,7 +6961,7 @@
       if (!conf_specified) {
           ap_cpystrn(ap_server_confname, SERVER_CONFIG_FILE, sizeof(ap_server_confname));
           if (access(ap_server_root_relative(pcommands, ap_server_confname), 0)) {
  -#ifndef NETWARE
  +#ifdef WIN32
               ap_registry_get_server_root(pconf, ap_server_root, sizeof(ap_server_root));
   #endif
               if (!*ap_server_root)
  @@ -6910,16 +6971,12 @@
           }
       }
   
  -    if (!ap_os_is_path_absolute(ap_server_confname)) {
  -        char *full_conf_path;
  -
  -        full_conf_path = ap_pstrcat(pcommands, ap_server_root, "/", ap_server_confname,
NULL);
  -        full_conf_path = ap_os_canonical_filename(pcommands, full_conf_path);
  -        ap_cpystrn(ap_server_confname, full_conf_path, sizeof(ap_server_confname));
  -    }
  +    ap_cpystrn(ap_server_confname,
  +               ap_server_root_relative(pcommands, ap_server_confname),
  +               sizeof(ap_server_confname));
       ap_getparents(ap_server_confname);
       ap_no2slash(ap_server_confname);
  -
  +    
   #ifdef WIN32
       /* Read the conf now unless we are uninstalling the service,
        * or shutting down a running service 
  @@ -6934,16 +6991,10 @@
           if (!service_name)
               service_name = ap_pstrdup(pconf, DEFAULTSERVICENAME);
           if (install > 0) 
  -            InstallService(service_name, ap_server_root_relative(pcommands, 
  -                                                         ap_server_confname));
  +            InstallService(pconf, service_name, argc, argv, install == 1);
           else
               RemoveService(service_name);
           clean_parent_exit(0);
  -    }
  -
  -    if (service_name && !conf_specified) {
  -        printf("Unknown service: %s\n", service_name);
  -        clean_parent_exit(1);
       }
   
       /* All NT signals, and all but the 9x start signal are handled entirely.
  
  
  

Mime
View raw message