Changeset 1681

Show
Ignore:
Timestamp:
02/17/10 16:52:56 (7 months ago)
Author:
swalsh
Message:

add support for the new ircd AUTH command

Location:
trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/include/interface.h

    r1559 r1681  
    5454extern struct Callback *send_chops_notice_cb; 
    5555extern struct Callback *send_squit_cb; 
     56extern struct Callback *send_autojoin_cb; 
     57extern struct Callback *send_auth_cb; 
    5658 
    5759extern struct Callback *on_umode_change_cb; 
     
    7981extern struct Callback *on_db_init_cb; 
    8082extern struct Callback *on_ctcp_cb; 
     83extern struct Callback *on_auth_request_cb; 
    8184 
    8285extern struct Callback *do_event_cb; 
     
    114117void send_kill(struct Service *, struct Client *, const char *); 
    115118void set_limit(struct Service *, struct Channel *, int); 
     119void send_auth_reply(struct Service *, char *, char *, int, char *); 
    116120 
    117121unsigned int enforce_mode_lock(struct Service *, struct Channel *, const char *, char *, 
  • trunk/modules/nickserv.c

    r1592 r1681  
    5353static dlink_node *ns_quit_hook; 
    5454static dlink_node *ns_certfp_hook; 
     55static dlink_node *ns_on_auth_req_hook; 
    5556 
    5657static dlink_list nick_enforce_list = { NULL, NULL, 0 }; 
     
    6768static void *ns_on_quit(va_list); 
    6869static void *ns_on_certfp(va_list); 
     70static void *ns_on_auth_requested(va_list); 
    6971static void m_drop(struct Service *, struct Client *, int, char *[]); 
    7072static void m_help(struct Service *, struct Client *, int, char *[]); 
     
    304306  ns_quit_hook        = install_hook(on_quit_cb, ns_on_quit); 
    305307  ns_certfp_hook      = install_hook(on_certfp_cb, ns_on_certfp); 
     308  ns_on_auth_req_hook = install_hook(on_auth_request_cb, ns_on_auth_requested); 
    306309   
    307310  guest_number = 0; 
     
    319322  uninstall_hook(on_quit_cb, ns_on_quit); 
    320323  uninstall_hook(on_certfp_cb, ns_on_certfp); 
     324  uninstall_hook(on_auth_request_cb, ns_on_auth_requested); 
    321325  eventDelete(process_enforce_list, NULL); 
    322326  eventDelete(process_release_list, NULL); 
     
    20362040} 
    20372041 
     2042static void * 
     2043ns_on_auth_requested(va_list args) 
     2044{ 
     2045  char *user    = va_arg(args, char *); 
     2046  char *n       = va_arg(args, char *); 
     2047  char *certfp  = va_arg(args, char *); 
     2048  Nickname *nick, *nick2; 
     2049 
     2050  nick = nickname_find(user); 
     2051  if(nick == NULL) 
     2052  { 
     2053    send_auth_reply(nickserv, user, n, 0, "User not found"); 
     2054  } 
     2055  else 
     2056  { 
     2057    nick2 = nickname_find(n); 
     2058    if(nick2 == NULL) 
     2059    { 
     2060      nickname_free(nick); 
     2061      send_auth_reply(nickserv, user, n, 0, "Nickname not found"); 
     2062      return pass_callback(ns_on_auth_req_hook, user, n, certfp); 
     2063    } 
     2064    if(nickname_get_id(nick) != nickname_get_id(nick2)) 
     2065    { 
     2066      nickname_free(nick); 
     2067      nickname_free(nick2); 
     2068      send_auth_reply(nickserv, user, n, 0, "Nickname not on account"); 
     2069      return pass_callback(ns_on_auth_req_hook, user, n, certfp); 
     2070    } 
     2071    else 
     2072    { 
     2073      if(!nickname_cert_check(nick, certfp, NULL)) 
     2074        send_auth_reply(nickserv, user, n, 0, "CertFP Mismatch"); 
     2075      else 
     2076        send_auth_reply(nickserv, user, n, 1, "Success"); 
     2077     
     2078      nickname_free(nick); 
     2079    } 
     2080 
     2081  } 
     2082   
     2083  return pass_callback(ns_on_auth_req_hook, user); 
     2084} 
     2085 
    20382086static void 
    20392087m_status(struct Service *service, struct Client *client, int parc, char *parv[]) 
  • trunk/modules/oftc.c

    r1662 r1681  
    4444static void *oftc_sendmsg_svscloak(va_list); 
    4545static void *oftc_sendmsg_svsnick(va_list); 
    46 //static void *oftc_sendmsg_svsjoin(va_list); 
     46static void *oftc_sendmsg_svsjoin(va_list); 
    4747static void *oftc_identify(va_list); 
    4848static void *oftc_chops_notice(va_list); 
    4949static void *oftc_sendmsg_newuser(va_list); 
    5050static void *oftc_sendmsg_notice(va_list); 
     51static void *oftc_sendmsg_auth(va_list); 
    5152 
    5253static dlink_node *oftc_gnotice_hook; 
     
    5455static dlink_node *oftc_svscloak_hook; 
    5556static dlink_node *oftc_svsnick_hook; 
    56 //static dlink_node *oftc_svsjoin_hook; 
     57static dlink_node *oftc_svsjoin_hook; 
    5758static dlink_node *oftc_identify_hook; 
    5859static dlink_node *oftc_connected_hook; 
     
    6061static dlink_node *oftc_newuser_hook; 
    6162static dlink_node *oftc_notice_hook; 
     63static dlink_node *oftc_auth_hook; 
    6264 
    6365static void m_pass(struct Client *, struct Client *, int, char *[]); 
     
    7274static void m_realhost(struct Client *, struct Client *, int, char *[]); 
    7375static void m_certfp(struct Client *, struct Client *, int, char *[]); 
     76static void m_auth(struct Client *, struct Client *, int, char *[]); 
    7477 
    7578static struct Message gnotice_msgtab = { 
     
    114117 
    115118static struct Message svsmode_msgtab = { 
    116   "SVSMODE", 0, 0, 2, 0, 0, 0, { m_svsmode, m_svsmode } 
     119  "SVSMODE", 0, 0, 2, 0, 0, 0,  
     120  { m_svsmode, m_svsmode } 
    117121}; 
    118122 
    119123static struct Message eob_msgtab = { 
    120   "EOB", 0, 0, 0, 0, 0, 0, { m_eob, m_eob }  
     124  "EOB", 0, 0, 0, 0, 0, 0,  
     125  { m_eob, m_eob }  
    121126}; 
    122127 
    123128static struct Message realhost_msgtab = { 
    124   "REALHOST", 0, 0, 3, 0, 0, 0, 
     129  "REALHOST", 0, 0, 3, 0, 0, 0,  
    125130  { m_realhost, m_realhost } 
    126131}; 
     
    129134  "CERTFP", 0, 0, 3, 0, 0, 0, 
    130135  { m_certfp, m_certfp } 
     136}; 
     137 
     138static struct Message auth_msgtab = { 
     139  "AUTH", 0, 0, 3, 0, 0, 0, 
     140  { m_auth, m_auth } 
    131141}; 
    132142 
     
    147157INIT_MODULE(oftc, "$Revision$") 
    148158{ 
    149   oftc_connected_hook  = install_hook(connected_cb, oftc_server_connected); 
    150   oftc_gnotice_hook   = install_hook(send_gnotice_cb, oftc_sendmsg_gnotice); 
    151   oftc_umode_hook     = install_hook(send_umode_cb, oftc_sendmsg_svsmode); 
    152   oftc_svscloak_hook  = install_hook(send_cloak_cb, oftc_sendmsg_svscloak); 
    153 //  oftc_svsjoin_hook   = install_hook(send_nick_cb, oftc_sendmsg_svsjoin); 
    154   oftc_svsnick_hook   = install_hook(send_nick_cb, oftc_sendmsg_svsnick); 
    155   oftc_identify_hook  = install_hook(on_identify_cb, oftc_identify); 
    156   oftc_chops_notice_hook = install_hook(send_chops_notice_cb, oftc_chops_notice); 
    157   oftc_newuser_hook = install_hook(send_newuser_cb, oftc_sendmsg_newuser); 
    158   oftc_notice_hook = install_hook(send_notice_cb, oftc_sendmsg_notice); 
     159  oftc_connected_hook   = install_hook(connected_cb, oftc_server_connected); 
     160  oftc_gnotice_hook     = install_hook(send_gnotice_cb, oftc_sendmsg_gnotice); 
     161  oftc_umode_hook       = install_hook(send_umode_cb, oftc_sendmsg_svsmode); 
     162  oftc_svscloak_hook    = install_hook(send_cloak_cb, oftc_sendmsg_svscloak); 
     163  oftc_svsjoin_hook     = install_hook(send_autojoin_cb, oftc_sendmsg_svsjoin); 
     164  oftc_svsnick_hook     = install_hook(send_nick_cb, oftc_sendmsg_svsnick); 
     165  oftc_identify_hook    = install_hook(on_identify_cb, oftc_identify); 
     166  oftc_chops_notice_hook= install_hook(send_chops_notice_cb, oftc_chops_notice); 
     167  oftc_newuser_hook     = install_hook(send_newuser_cb, oftc_sendmsg_newuser); 
     168  oftc_notice_hook      = install_hook(send_notice_cb, oftc_sendmsg_notice); 
     169  oftc_auth_hook        = install_hook(send_auth_cb, oftc_sendmsg_auth); 
    159170  mod_add_cmd(&gnotice_msgtab); 
    160171  mod_add_cmd(&pass_msgtab); 
     
    169180  mod_add_cmd(&realhost_msgtab); 
    170181  mod_add_cmd(&certfp_msgtab); 
     182  mod_add_cmd(&auth_msgtab); 
     183 
    171184  return ModeList; 
    172185} 
     
    186199  mod_del_cmd(&realhost_msgtab); 
    187200  mod_del_cmd(&certfp_msgtab); 
     201  mod_del_cmd(&auth_msgtab); 
    188202 
    189203  uninstall_hook(send_gnotice_cb, oftc_sendmsg_gnotice); 
     
    194208  uninstall_hook(send_newuser_cb, oftc_sendmsg_newuser); 
    195209  uninstall_hook(send_notice_cb, oftc_sendmsg_notice); 
     210  uninstall_hook(send_auth_cb, oftc_sendmsg_auth); 
     211  uninstall_hook(send_autojoin_cb, oftc_sendmsg_svsjoin); 
    196212} 
    197213 
     
    290306  strlcpy(target->certfp, parv[2], sizeof(target->certfp)); 
    291307  execute_callback(on_certfp_cb, target); 
     308} 
     309 
     310static void 
     311m_auth(struct Client *client, struct Client *source, int parc, char *parv[]) 
     312{ 
     313  ilog(L_DEBUG, "AUTH request for %s[%s] certfp %s from %s", parv[1],  
     314      parv[2], parv[3], parv[0]); 
     315 
     316  execute_callback(on_auth_request_cb, parv[1], parv[2], parv[3]); 
    292317} 
    293318 
     
    663688 
    664689static void * 
     690oftc_sendmsg_svsjoin(va_list args) 
     691{ 
     692  struct Client *uplink = va_arg(args, struct Client *); 
     693  struct Client *user = va_arg(args, struct Client *); 
     694  char *channel = va_arg(args, char *); 
     695 
     696  if(!HasID(user)) 
     697    sendto_server(uplink, ":%s SVSJOIN %s :%s", me.name, user->name, channel); 
     698  else 
     699    sendto_server(uplink, ":%s SVSJOIN %s :%s", me.name, user->id, channel); 
     700 
     701  return pass_callback(oftc_svsjoin_hook, uplink, user, channel); 
     702} 
     703 
     704static void * 
    665705oftc_chops_notice(va_list args) 
    666706{ 
     
    750790  return NULL; 
    751791} 
     792 
     793static void* 
     794oftc_sendmsg_auth(va_list args) 
     795{ 
     796  struct Client *client = va_arg(args, struct Client *); 
     797  char          *user   = va_arg(args, char *); 
     798  char          *nick   = va_arg(args, char *); 
     799  int           ret     = va_arg(args, int); 
     800  char          *reason = va_arg(args, char *); 
     801 
     802  sendto_server(client, ":%s AUTH %s %s %d :%s", me.id, user, nick, ret, reason); 
     803 
     804  return NULL; 
     805} 
  • trunk/src/interface.c

    r1676 r1681  
    7171struct Callback *send_chops_notice_cb; 
    7272struct Callback *send_squit_cb; 
     73struct Callback *send_autojoin_cb; 
     74struct Callback *send_auth_cb; 
    7375 
    7476static BlockHeap *services_heap  = NULL; 
     
    9193struct Callback *on_certfp_cb; 
    9294struct Callback *on_db_init_cb; 
     95struct Callback *on_auth_request_cb; 
    9396 
    9497struct Callback *on_nick_reg_cb; 
     
    133136  send_chops_notice_cb = register_callback("Send NOTICE to channel ops", NULL); 
    134137  send_squit_cb       = register_callback("Send SQUIT Message", NULL); 
     138  send_autojoin_cb    = register_callback("Auto join a user to a channel", NULL); 
     139  send_auth_cb        = register_callback("Send an AUTH response", NULL); 
    135140  on_nick_change_cb   = register_callback("Propagate NICK", NULL); 
    136141  on_join_cb          = register_callback("Propagate JOIN", NULL); 
     
    158163  on_chan_reg_cb      = register_callback("Newly Registered Chan", NULL); 
    159164  on_group_reg_cb     = register_callback("Newly Registered Group", NULL); 
     165  on_auth_request_cb  = register_callback("Authetication requested", NULL); 
    160166  do_event_cb         = register_callback("Event Loop Callback", NULL); 
    161167 
     
    182188  unregister_callback(send_kill_cb); 
    183189  unregister_callback(send_resv_cb); 
     190  unregister_callback(send_topic_cb); 
     191  unregister_callback(send_kill_cb); 
     192  unregister_callback(send_resv_cb); 
    184193  unregister_callback(send_unresv_cb); 
    185194  unregister_callback(send_newserver_cb); 
     
    189198  unregister_callback(send_chops_notice_cb); 
    190199  unregister_callback(send_squit_cb); 
     200  unregister_callback(send_autojoin_cb); 
     201  unregister_callback(send_auth_cb); 
    191202  unregister_callback(on_nick_change_cb); 
    192203  unregister_callback(on_join_cb); 
     
    211222  unregister_callback(on_chan_reg_cb); 
    212223  unregister_callback(on_group_reg_cb); 
     224  unregister_callback(on_auth_request_cb); 
    213225  unregister_callback(do_event_cb); 
    214226 
     
    370382{ 
    371383  execute_callback(send_privmsg_cb, me.uplink, service->name, channel->chname, text); 
     384} 
     385 
     386void 
     387send_auth_reply(struct Service *service, char *user, char *nick, int response, char *reason) 
     388{ 
     389  execute_callback(send_auth_cb, me.uplink, user, nick, response, reason); 
     390   
     391  ilog(L_DEBUG, "Sending auth reply %s %s %d %s", user, nick, response, reason); 
    372392} 
    373393