Apache sets the env REMOTE_USER which is nice, but in several CGI applications I
missed the ability to know which group the user authenticated as, without having
to parse the group-file. So I made this little patch that sets the env
REMOTE_GROUP to the group (first match) a user was authenticated with. I think
the performance penalty is microscopic.

-- 
Regards
Tele Danmark InterNordia
P�l Baltzersen
Seniorkonsulent, Cand. Scient.
********************************************************************
Addr:   Fredrik Selmers vei 2, P.O. Box 6299 Etterstad, NO-0603 Oslo
Phone:  +47 23 18 10 00         Direct: +47 23 18 11 74
Fax:    +47 23 18 10 01         Mobile: +47 93 08 11 74
Mail:   [EMAIL PROTECTED]       [EMAIL PROTECTED]
Web:    www.teledanmark.no
********************************************************************
ElTele �st endrer profil til Tele Danmark InterNordia
--- Begin Message ---
*** src/include/httpd.h~        Tue Oct  9 05:56:05 2001
--- src/include/httpd.h Mon Dec 10 14:44:36 2001
***************
*** 890,895 ****
--- 890,898 ----
                                 * this gets set to the user name.  We assume
                                 * that there's only one user per connection(!)
                                 */
+     char *group;              /* If a group authentication check was
+                                * made, this gets set to the matced
+                                * group name. */
      char *ap_auth_type;               /* Ditto. */
  
      unsigned aborted:1;               /* Are we still talking? */
*** src/main/util_script.c~     Wed May  9 07:17:11 2001
--- src/main/util_script.c      Mon Dec 10 14:44:36 2001
***************
*** 304,309 ****
--- 304,312 ----
      if (c->user) {
        ap_table_addn(e, "REMOTE_USER", c->user);
      }
+     if (c->group) {
+       ap_table_addn(e, "REMOTE_GROUP", c->group);
+     }
      if (c->ap_auth_type) {
        ap_table_addn(e, "AUTH_TYPE", c->ap_auth_type);
      }
*** src/modules/standard/mod_auth.c~    Mon Dec 10 14:44:36 2001
--- src/modules/standard/mod_auth.c     Mon Dec 10 14:47:49 2001
***************
*** 380,385 ****
--- 380,386 ----
            while (t[0]) {
                w = ap_getword_conf(r->pool, &t);
                if (ap_table_get(grpstatus, w)) {
+                   r->connection->group = w;
                    return OK;
                  }
            }
*** src/modules/standard/mod_rewrite.c~ Wed May 30 09:41:02 2001
--- src/modules/standard/mod_rewrite.c  Mon Dec 10 14:44:36 2001
***************
*** 3491,3496 ****
--- 3491,3499 ----
      else if (strcasecmp(var, "REMOTE_USER") == 0) {
          result = r->connection->user;
      }
+     else if (strcasecmp(var, "REMOTE_GROUP") == 0) {
+         result = r->connection->group;
+     }
      else if (strcasecmp(var, "REMOTE_IDENT") == 0) {
          result = (char *)ap_get_remote_logname(r);
      }
--- End Message ---

Reply via email to