httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stodd...@locus.apache.org
Subject cvs commit: apache-1.3/src/support httpd.exp
Date Mon, 13 Mar 2000 21:00:42 GMT
stoddard    00/03/13 13:00:42

  Modified:    src      ApacheCore.def CHANGES
               src/include httpd.h
               src/main util.c
               src/os/win32 registry.c registry.h service.c service.h
               src/support httpd.exp
  Log:
  NT does not handle spaces in service names well.
  Attached are two patches to correct how Apache
  deals with this.
  
    The first patch adds the util function
    ap_remove_spaces and exports it on all platforms.
  
    The second patch changes some service and registry
    functions to make use of this new function.
  
  NT developers of Apache admin modules could use
  some functionality from registry.c.
  
    The third patch exports four ap_x functions from
    registry.c
  
  Submitted by:	Keith Wannamaker
  Reviewed by:	Bill Stoddard
  
  Revision  Changes    Path
  1.21      +5 -0      apache-1.3/src/ApacheCore.def
  
  Index: ApacheCore.def
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/ApacheCore.def,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- ApacheCore.def	1999/11/05 15:41:06	1.20
  +++ ApacheCore.def	2000/03/13 21:00:38	1.21
  @@ -360,3 +360,8 @@
   	ap_SHA1Final   @355
   	ap_sha1_base64   @356
           ap_send_error_response @357
  +	ap_remove_spaces @358
  +	ap_get_service_key @359
  +	ap_registry_get_server_root @360
  +	ap_registry_get_service_conf @361
  +	ap_registry_set_service_conf @362
  
  
  
  1.1525    +7 -0      apache-1.3/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/CHANGES,v
  retrieving revision 1.1524
  retrieving revision 1.1525
  diff -u -r1.1524 -r1.1525
  --- CHANGES	2000/03/12 16:48:50	1.1524
  +++ CHANGES	2000/03/13 21:00:38	1.1525
  @@ -1,3 +1,10 @@
  +
  +  *) WinNT: Do a better job at handling spaces in service names.
  +     Add the util function ap_remove_spaces and export it on all
  +     platforms. Change some Win32 service and registry functions to 
  +     make use of this new function. 
  +     [Keith Wannamaker <wannamaker@us.ibm.com>]
  +
   Changes with Apache 1.3.13
   
     *) use send/recv instead of write/read in proxy_connect -- fixes
  
  
  
  1.310     +1 -0      apache-1.3/src/include/httpd.h
  
  Index: httpd.h
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/include/httpd.h,v
  retrieving revision 1.309
  retrieving revision 1.310
  diff -u -r1.309 -r1.310
  --- httpd.h	2000/03/11 13:39:14	1.309
  +++ httpd.h	2000/03/13 21:00:40	1.310
  @@ -1034,6 +1034,7 @@
   API_EXPORT(int) ap_rind(const char *, char);
   
   API_EXPORT(char *) ap_escape_quotes (pool *p, const char *instring);
  +API_EXPORT(void) ap_remove_spaces(char *dest, char *src);
   
   /* Common structure for reading of config files / passwd files etc. */
   typedef struct {
  
  
  
  1.182     +13 -0     apache-1.3/src/main/util.c
  
  Index: util.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/main/util.c,v
  retrieving revision 1.181
  retrieving revision 1.182
  diff -u -r1.181 -r1.182
  --- util.c	2000/03/01 09:13:37	1.181
  +++ util.c	2000/03/13 21:00:40	1.182
  @@ -2184,3 +2184,16 @@
       *outchr = '\0';
       return outstring;
   }
  +
  +/* dest = src with whitespace removed
  + * length of dest assumed >= length of src
  + */
  +API_EXPORT(void) ap_remove_spaces(char *dest, char *src)
  +{
  +    while (*src) {
  +        if (!ap_isspace(*src)) 
  +            *dest++ = *src;
  +        src++;
  +    }
  +    *dest = 0;
  +}
  
  
  
  1.33      +17 -9     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.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- registry.c	2000/02/23 23:06:38	1.32
  +++ registry.c	2000/03/13 21:00:41	1.33
  @@ -199,7 +199,7 @@
    * an error getting the key.
    */
   
  -int ap_registry_get_server_root(pool *p, char *dir, int size)
  +API_EXPORT(int) ap_registry_get_server_root(pool *p, char *dir, int size)
   {
       int rv;
   
  @@ -211,21 +211,29 @@
       return (rv < -1) ? -1 : 0;
   }
   
  -char *ap_get_service_key(char *service_name)
  +API_EXPORT(char *) ap_get_service_key(char *display_name)
   {
  -    char *key = malloc(strlen(SERVICEKEYPRE) +
  -                       strlen(service_name) +
  -                       strlen(SERVICEKEYPOST) + 1);
  +    char *key, *service_name;
  +    
  +    if (display_name == NULL)
  +        return strdup("");
  +
  +    service_name = strdup(display_name);
  +    ap_remove_spaces(service_name, display_name);
  +
  +    key = malloc(strlen(SERVICEKEYPRE) +
  +                 strlen(service_name) +
  +                 strlen(SERVICEKEYPOST) + 1);
   
       sprintf(key,"%s%s%s", SERVICEKEYPRE, service_name, SERVICEKEYPOST);
   
       return(key);
   }
   
  -int ap_registry_get_service_conf(pool *p, char *dir, int size, char *service_name)
  +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(service_name);
  +    char *key = ap_get_service_key(display_name);
   
       rv = ap_registry_get_key_int(p, key, "ConfPath", dir, size, NULL);
       if (rv < 0) {
  @@ -443,10 +451,10 @@
    * logged via aplog_error().
    */
   
  -int ap_registry_set_service_conf(char *conf, char *service_name)
  +API_EXPORT(int) ap_registry_set_service_conf(char *conf, char *display_name)
   {
       int rv;
  -    char *key = ap_get_service_key(service_name);
  +    char *key = ap_get_service_key(display_name);
       
       rv = ap_registry_store_key_int(key, "ConfPath", REG_SZ, conf, strlen(conf)+1);
       free(key);
  
  
  
  1.4       +3 -3      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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- registry.h	1999/04/08 21:04:46	1.3
  +++ registry.h	2000/03/13 21:00:41	1.4
  @@ -2,7 +2,7 @@
    * Declarations for users of the functions defined in registry.c
    */
   
  -extern int ap_registry_get_server_root(pool *p, char *dir, int size);
  +API_EXPORT(int) ap_registry_get_server_root(pool *p, char *dir, int size);
   extern int ap_registry_set_server_root(char *dir);
  -extern int ap_registry_get_service_conf(pool *p, char *dir, int size, char *service_name);
  -extern int ap_registry_set_service_conf(char *dir, char *service_name);
  +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);
  
  
  
  1.14      +34 -14    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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- service.c	1999/04/08 21:04:47	1.13
  +++ service.c	2000/03/13 21:00:41	1.14
  @@ -185,15 +185,16 @@
       return(1);
   }
   
  -void InstallService(char *service_name, char *conf)
  +void InstallService(char *display_name, char *conf)
   {
       SC_HANDLE   schService;
       SC_HANDLE   schSCManager;
   
       TCHAR szPath[512];
       TCHAR szQuotedPath[512];
  +    char *service_name;
   
  -    printf("Installing the %s service to use %s\n", service_name, conf);
  +    printf("Installing the %s service to use %s\n", display_name, conf);
   
       if (GetModuleFileName( NULL, szPath, 512 ) == 0)
       {
  @@ -202,6 +203,10 @@
           return;
       }
   
  +    /* Remove spaces from display name to create service name */
  +    service_name = strdup(display_name);
  +    ap_remove_spaces(service_name, display_name);
  +
       ap_snprintf(szQuotedPath, 512, "\"%s\"", szPath);
   
       schSCManager = OpenSCManager(
  @@ -217,7 +222,7 @@
           schService = CreateService(
               schSCManager,               // SCManager database
               service_name,               // name of service
  -            service_name,               // name to display
  +            display_name,               // name to display
               SERVICE_ALL_ACCESS,         // desired access
               SERVICE_WIN32_OWN_PROCESS,  // service type
               SERVICE_AUTO_START,       // start type
  @@ -234,7 +239,7 @@
   
               /* 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", service_name
);
  +                printf("The %s service has been installed successfully.\n", display_name);
           }
           else {
               ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, NULL, 
  @@ -246,13 +251,18 @@
   }
   
   
  -void RemoveService(char *service_name)
  +void RemoveService(char *display_name)
   {
       SC_HANDLE   schService;
       SC_HANDLE   schSCManager;
  +    char       *service_name;
   
  -    printf("Removing the %s service\n", service_name);
  +    printf("Removing the %s service\n", display_name);
   
  +    /* Remove spaces from display name to create service name */
  +    service_name = strdup(display_name);
  +    ap_remove_spaces(service_name, display_name);
  +    
       schSCManager = OpenSCManager(
                           NULL,                   // machine (NULL == local)
                           NULL,                   // database (NULL == default)
  @@ -279,7 +289,7 @@
   		ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, NULL,
   		    "DeleteService failed");
               else
  -                printf("The %s service has been removed successfully.\n", service_name
);
  +                printf("The %s service has been removed successfully.\n", display_name);
               CloseServiceHandle(schService);
           }
           /* SCM removes registry parameters  */
  @@ -302,10 +312,15 @@
   /* Determine is service_name is a valid service
    */
   
  -BOOL isValidService(char *service_name) {
  +BOOL isValidService(char *display_name) {
       SC_HANDLE schSCM, schSVC;
  +    char *service_name;
       int Err;
   
  +    /* Remove spaces from display name to create service name */
  +    service_name = strdup(display_name);
  +    ap_remove_spaces(service_name, display_name);
  +
       if (!(schSCM = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS))) {
           ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_WIN32ERROR, NULL,
           "OpenSCManager failed");
  @@ -326,9 +341,10 @@
       return FALSE;
   }
   
  -int send_signal_to_service(char *service_name, char *sig) {
  +int send_signal_to_service(char *display_name, char *sig) {
       SC_HANDLE   schService;
       SC_HANDLE   schSCManager;
  +    char       *service_name;
       int success = FALSE;
   
       enum                        { start,      restart,      stop, unknown } action;
  @@ -345,6 +361,10 @@
           return FALSE;
       }
   
  +    /* Remove spaces from display name to create service name */
  +    service_name = strdup(display_name);
  +    ap_remove_spaces(service_name, display_name);
  +
       schSCManager = OpenSCManager(
                           NULL,                   // machine (NULL == local)
                           NULL,                   // database (NULL == default)
  @@ -368,11 +388,11 @@
                                "QueryService failed");
               else {
                   if (globdat.ssStatus.dwCurrentState == SERVICE_STOPPED && action
== stop)
  -                    printf("The %s service is not started.\n", service_name);
  +                    printf("The %s service is not started.\n", display_name);
                   else if (globdat.ssStatus.dwCurrentState == SERVICE_RUNNING &&
action == start)
  -                    printf("The %s service has already been started.\n", service_name);
  +                    printf("The %s service has already been started.\n", display_name);
                   else {
  -                    printf("The %s service is %s.\n", service_name, participle[action]);
  +                    printf("The %s service is %s.\n", display_name, participle[action]);
   
                       if (action == stop || action == restart)
                           success = ap_stop_service(schService);
  @@ -380,9 +400,9 @@
                           success = ap_start_service(schService);
                   
                       if( success )
  -                        printf("The %s service has %s.\n", service_name, past[action]);
  +                        printf("The %s service has %s.\n", display_name, past[action]);
                       else
  -                        printf("Failed to %s the %s service.\n", sig, service_name );
  +                        printf("Failed to %s the %s service.\n", sig, display_name);
                   }
   
                   CloseServiceHandle(schService);
  
  
  
  1.5       +4 -4      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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- service.h	1999/04/08 21:04:48	1.4
  +++ service.h	2000/03/13 21:00:41	1.5
  @@ -7,11 +7,11 @@
   void service_set_status(int status);
   void service_cd();
   BOOL isProcessService();
  -BOOL isValidService(char *service_name);
  -void InstallService(char *service_name, char *conf);
  -void RemoveService(char *service_name);
  +BOOL isValidService(char *display_name);
  +void InstallService(char *display_name, char *conf);
  +void RemoveService(char *display_name);
   int service_init();
  -int send_signal_to_service(char *service_name, char *sig);
  +int send_signal_to_service(char *display_name, char *sig);
   #endif /* WIN32 */
   
   #endif /* SERVICE_H */
  
  
  
  1.30      +1 -0      apache-1.3/src/support/httpd.exp
  
  Index: httpd.exp
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/support/httpd.exp,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- httpd.exp	1999/12/09 19:21:51	1.29
  +++ httpd.exp	2000/03/13 21:00:41	1.30
  @@ -267,6 +267,7 @@
   ap_register_cleanup
   ap_register_other_child
   ap_remove_module
  +ap_remove_spaces
   ap_requires
   ap_reset_timeout
   ap_response_code_string
  
  
  

Mime
View raw message