Changeset 772


Ignore:
Timestamp:
09/27/06 05:15:07 (6 years ago)
Author:
wd
Message:

Add CGI:IRC hostmasking support.

Location:
branches/ithildin-1.1/modules/ircd
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/ithildin-1.1/modules/ircd/addons/acl.c

    r751 r772  
    411411        /* check password/info first, since they're cheaper than all the 
    412412         * match calls (I guess */ 
    413         if (ap->pass != NULL && strcmp(ap->pass, cp->pass)) 
     413        if (ap->pass != NULL && cp->pass != NULL && strcmp(ap->pass, cp->pass)) 
    414414            continue; /* password incorrect */ 
    415415        if (ap->info != NULL && !match(ap->info, cp->cli->info)) 
  • branches/ithildin-1.1/modules/ircd/addons/hostmask.c

    r579 r772  
    6565HOOK_FUNCTION(hostmask_cc_hook) { 
    6666    client_t *cli = (client_t *)data; 
    67     char *mask = NULL; 
     67    char *mask; 
    6868 
    69     if (cli->conn != NULL) 
    70         mask = mdext(cli->conn->cls, class_hostmask_mdi); 
     69    if (cli->conn == NULL) 
     70        return NULL; /* nothing to do */ 
    7171 
     72    mask = mdext(cli->conn->cls, class_hostmask_mdi); 
    7273    if (mask != NULL && *mask != '\0') { 
     74        if (!strcasecmp(mask, "cgi:irc")) { 
     75            /* Special CGI:IRC hack.  We take the password, if supplied, and 
     76             * use it as a hostname (as long as it's valid) */ 
     77            if (cli->conn->pass != NULL && *cli->conn->pass != '\0' && 
     78                    istr_okay(ircd.maps.host, cli->conn->pass)) 
     79                mask = cli->conn->pass; 
     80            else { 
     81                log_warn("cgi:irc hostmasked connection did not provide a " 
     82                        "valid host (%s!%s@%s)", cli->nick, cli->user, 
     83                        cli->host); 
     84                return NULL; 
     85            } 
     86            /* fallthrough to normal mask case. */ 
     87        } 
    7388        sendto_flag(SFLAG("SPY"), "Changing hostname for %s!%s@%s to %s", 
    7489                cli->nick, cli->user, cli->host, mask); 
  • branches/ithildin-1.1/modules/ircd/client.c

    r758 r772  
    200200            LIST_INSERT_HEAD(ircd.connections.clients, cp, lp); 
    201201            ircd.stats.serv.unkclients--; 
     202 
     203            /* clean out their password */ 
     204            if (cp->pass != NULL) { 
     205                free(cp->pass); 
     206                cp->pass = NULL; 
     207            } 
    202208        } 
    203209 
    204210        cli->signon = cli->ts = me.now; 
    205211        cli->hops = 0; /* our client, they're 0 hops from us <G> */ 
     212 
    206213    } 
    207214 
  • branches/ithildin-1.1/modules/ircd/commands/pass.c

    r577 r772  
    1717*/ 
    1818 
     19static void copy_in_pass(connection_t *, char *); 
     20 
    1921CLIENT_COMMAND(pass, 1, 1, COMMAND_FL_UNREGISTERED) { 
     22 
    2023    /* just copy the pass in */ 
    21     strncpy(cli->conn->pass, argv[1], PASSWDLEN); 
    22  
     24    copy_in_pass(cli->conn, argv[1]); 
    2325    return COMMAND_WEIGHT_NONE; 
    2426} 
    2527 
    2628SERVER_COMMAND(pass, 1, 1, COMMAND_FL_UNREGISTERED) { 
     29 
    2730    /* just copy the pass in */ 
    28     strncpy(srv->conn->pass, argv[1], PASSWDLEN); 
    29  
     31    copy_in_pass(srv->conn, argv[1]); 
    3032    return 0; 
    3133} 
     34 
     35static void copy_in_pass(connection_t *conn, char *pass) { 
     36 
     37    /* Hack to support CGI IRC, which sends the 'real hostname' as the client 
     38     * password.  What?  Let's use HOSTLEN I guess! */ 
     39    if (conn->pass != NULL) 
     40        free(conn->pass); /* dump whatever was there before.. */ 
     41    conn->pass = malloc(HOSTLEN + 1); 
     42    strlcpy(conn->pass, pass, HOSTLEN + 1); 
     43} 
     44 
    3245/* vi:set ts=8 sts=4 sw=4 tw=76 et: */ 
  • branches/ithildin-1.1/modules/ircd/commands/server.c

    r717 r772  
    118118            } 
    119119 
    120             if (strcmp(pass, srv->conn->pass)) { 
     120            if (srv->conn->pass == NULL || strcmp(pass, srv->conn->pass)) { 
    121121                destroy_connection(srv->conn, "password mismatch"); 
    122122                return IRCD_CONNECTION_CLOSED; /* password mismatch */ 
  • branches/ithildin-1.1/modules/ircd/connection.c

    r728 r772  
    5858            sendq_pop(c); 
    5959    } 
     60 
     61    if (c->pass != NULL) 
     62        free(c->pass); 
    6063 
    6164    if (c->buf != NULL) 
  • branches/ithildin-1.1/modules/ircd/connection.h

    r717 r772  
    22 * connection.h: support structures/prototypes for connection.c 
    33 *  
    4  * Copyright 2002 the Ithildin Project. 
     4 * Copyright 2002-2006 the Ithildin Project. 
    55 * See the COPYING file for more information on licensing and use. 
    66 *  
     
    88 */ 
    99 
    10 #ifndef IRCD_SOCKET_H 
    11 #define IRCD_SOCKET_H 
     10#ifndef IRCD_CONNECTION_H 
     11#define IRCD_CONNECTION_H 
    1212 
    1313struct connection { 
     
    1818                                       identd/dns) */ 
    1919    char    user[USERLEN + 1]; 
    20     char    pass[PASSWDLEN + 1];    /* password, after registration feel 
    21                                        free to use this as empty bufferspace */ 
     20    char    *pass;                  /* password, if not NULL it must be 
     21                                       malloc'd memory.  It will be 
     22                                       destroyed after client registration.  */ 
    2223 
    2324    char    *buf;                   /* temporary buffer pointer, possibly 
  • branches/ithildin-1.1/modules/ircd/server.c

    r728 r772  
    293293        LIST_REMOVE(sp->conn, lp); 
    294294        LIST_INSERT_HEAD(ircd.connections.servers, sp->conn, lp); 
     295         
     296        /* clean out the password area */ 
     297        if (sp->conn->pass != NULL) { 
     298            free(sp->conn->pass); 
     299            sp->conn->pass = NULL; 
     300        } 
    295301    } 
    296302 
Note: See TracChangeset for help on using the changeset viewer.