home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 25 / CDROM25.iso / Share / linux / apache / contrib / modules / mod_setclass.c~ < prev    next >
Encoding:
Text File  |  1998-06-11  |  5.1 KB  |  127 lines

  1. /* ====================================================================
  2.  * Copyright (c) 1995-1997 The Apache Group.  All rights reserved.
  3.  *
  4.  * Redistribution and use in source and binary forms, with or without
  5.  * modification, are permitted provided that the following conditions
  6.  * are met:
  7.  *
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  *
  11.  * 2. Redistributions in binary form must reproduce the above copyright
  12.  *    notice, this list of conditions and the following disclaimer in
  13.  *    the documentation and/or other materials provided with the
  14.  *    distribution.
  15.  *
  16.  * 3. All advertising materials mentioning features or use of this
  17.  *    software must display the following acknowledgment:
  18.  *    "This product includes software developed by the Apache Group
  19.  *    for use in the Apache HTTP server project (http://www.apache.org/)."
  20.  *
  21.  * 4. The names "Apache Server" and "Apache Group" must not be used to
  22.  *    endorse or promote products derived from this software without
  23.  *    prior written permission. For written permission, please contact
  24.  *    apache@apache.org.
  25.  * 
  26.  * 5. Redistributions of any form whatsoever must retain the following
  27.  *    acknowledgment:
  28.  *    "This product includes software developed by the Apache Group
  29.  *    for use in the Apache HTTP server project (http://www.apache.org/)."
  30.  *    
  31.  * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
  32.  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
  33.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  34.  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE APACHE GROUP OR
  35.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  36.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  37.  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  38.  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  39.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  40.  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  41.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  42.  * OF THE POSSIBILITY OF SUCH DAMAGE.
  43.  * ====================================================================
  44.  *    
  45.  * This software consists of voluntary contributions made by many
  46.  * individuals on behalf of the Apache Group and was originally based
  47.  * on public domain software written at the National Center for
  48.  * Supercomputing Applications, University of Illinois, Urbana-Champaign.
  49.  * For more information on the Apache Group and the Apache HTTP server
  50.  * project, please see <http://www.apache.org/>.
  51.  *    
  52.  */
  53.  
  54. #include "httpd.h"
  55. #include "http_config.h"
  56. #include "http_log.h"
  57.  
  58. #include <sys/types.h>
  59. #include <login_cap.h>
  60.  
  61. typedef struct {
  62.     char *class;
  63. } process_class_rec;
  64.  
  65. module MODULE_VAR_EXPORT setclass_module;
  66.  
  67. static void *create_class_store(pool *p, server_rec *dummy)
  68. {
  69.         process_class_rec *new =
  70.                 (process_class_rec *) ap_palloc(p, sizeof(process_class_rec));
  71.         new->class = NULL;
  72.         return new;
  73. }
  74.  
  75. static void set_freebsd_class(server_rec *s, pool *p) 
  76. {
  77.         int err;
  78.         process_class_rec *class_rec =
  79.                 ap_get_module_config(s->module_config, &setclass_module);
  80.         if (class_rec->class) {
  81.             err = setclasscontext(class_rec->class, LOGIN_SETRESOURCES);
  82.             if (err == -1) ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, s,
  83.                      "Failed to set loginclass to: %s", class_rec->class);
  84.  
  85.         }
  86. }
  87.  
  88. static const char *remember_class(cmd_parms *cmd, void *dconf, char *class)
  89. {
  90.         process_class_rec *class_rec = ap_get_module_config(cmd->server->module_config, &setclass_module);
  91.         class_rec->class = ap_pstrdup(cmd->pool, class);
  92. /*        ap_aplog_error(APLOG_MARK, APLOG_NOTICE|APLOG_NOERRNO, cmd->server,
  93.                "loginclass will be set to '%s' for each child; see syslog for errors", class);
  94. */
  95.         return NULL;
  96. }
  97.  
  98. static command_rec class_cmds[] =
  99. {
  100.         {"LoginClass", remember_class, NULL, RSRC_CONF, TAKE1,
  101.         "a login class name"},
  102.         {NULL}
  103. };
  104.  
  105. module MODULE_VAR_EXPORT setclass_module =
  106. {
  107.     STANDARD_MODULE_STUFF,
  108.     NULL,                       /* initializer */
  109.     NULL,                       /* dir config creater */
  110.     NULL,                       /* dir merger --- default is to override */
  111.     create_class_store,         /* server config */
  112.     NULL,                       /* merge server configs */
  113.     class_cmds,                 /* command table */
  114.     NULL,                       /* handlers */
  115.     NULL,                       /* filename translation */
  116.     NULL,                       /* check_user_id */
  117.     NULL,                       /* check auth */
  118.     NULL,                       /* check access */
  119.     NULL,                       /* type_checker */
  120.     NULL,                       /* fixups */
  121.     NULL,                       /* logger */
  122.     NULL,                       /* header parser */
  123.     set_freebsd_class,          /* child_init */
  124.     NULL,                       /* child_exit */
  125.     NULL                        /* post read-request */
  126. };
  127.