ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/client.c
(Generate patch)

Comparing ircd-hybrid-7.2/src/client.c (file contents):
Revision 886 by michael, Wed Oct 31 18:09:24 2007 UTC vs.
Revision 887 by michael, Thu Nov 1 11:54:48 2007 UTC

# Line 697 | Line 697 | get_client_name(struct Client *client, i
697   void
698   free_exited_clients(void)
699   {
700 <  dlink_node *ptr, *next;
701 <  struct Client *target_p;
700 >  dlink_node *ptr = NULL, *next = NULL;
701    
702    DLINK_FOREACH_SAFE(ptr, next, dead_list.head)
703    {
704 <    target_p = ptr->data;
706 <
707 <    if (ptr->data == NULL)
708 <    {
709 <      sendto_realops_flags(UMODE_ALL, L_ALL,
710 <                           "Warning: null client on dead_list!");
711 <      dlinkDelete(ptr, &dead_list);
712 <      free_dlink_node(ptr);
713 <      continue;
714 <    }
715 <
716 <    free_client(target_p);
704 >    free_client(ptr->data);
705      dlinkDelete(ptr, &dead_list);
706      free_dlink_node(ptr);
707    }
# Line 761 | Line 749 | exit_one_client(struct Client *source_p,
749      DLINK_FOREACH_SAFE(lp, next_lp, source_p->channel.head)
750        remove_user_from_channel(lp->data);
751  
764    /* Clean up allow lists */
765    del_all_accepts(source_p);
752      add_history(source_p, 0);
753      off_history(source_p);
754  
# Line 778 | Line 764 | exit_one_client(struct Client *source_p,
764        /* Clean up invitefield */
765        DLINK_FOREACH_SAFE(lp, next_lp, source_p->localClient->invited.head)
766          del_invite(lp->data, source_p);
767 +
768 +      del_all_accepts(source_p);
769      }
770    }
771  
# Line 1038 | Line 1026 | exit_client(struct Client *source_p, str
1026      assert(source_p->serv != NULL && source_p->servptr != NULL);
1027  
1028      if (ConfigServerHide.hide_servers)
1029 <      /* set netsplit message to "*.net *.split" to still show
1029 >      /*
1030 >       * Set netsplit message to "*.net *.split" to still show
1031         * that its a split, but hide the servers splitting
1032         */
1033        strcpy(splitstr, "*.net *.split");
# Line 1202 | Line 1191 | exit_aborted_clients(void)
1191  
1192   /*
1193   * accept processing, this adds a form of "caller ID" to ircd
1194 < *
1194 > *
1195   * If a client puts themselves into "caller ID only" mode,
1196 < * only clients that match a client pointer they have put on
1196 > * only clients that match a client pointer they have put on
1197   * the accept list will be allowed to message them.
1198   *
1199 < * [ source.on_allow_list ] -> [ target1 ] -> [ target2 ]
1211 < *
1212 < * [target.allow_list] -> [ source1 ] -> [source2 ]
1213 < *
1214 < * i.e. a target will have a link list of source pointers it will allow
1215 < * each source client then has a back pointer pointing back
1216 < * to the client that has it on its accept list.
1217 < * This allows for exit_one_client to remove these now bogus entries
1218 < * from any client having an accept on them.
1199 > * Diane Bruce, "Dianora" db@db.net
1200   */
1201  
1202 < /* accept_message()
1203 < *
1223 < * inputs       - pointer to source client
1224 < *              - pointer to target client
1225 < * output       - 1 if accept this message 0 if not
1226 < * side effects - See if source is on target's allow list
1227 < */
1228 < int
1229 < accept_message(struct Client *source, struct Client *target)
1202 > void
1203 > del_accept(struct split_nuh_item *accept_p, struct Client *client_p)
1204   {
1205 <  dlink_node *ptr;
1205 >  dlinkDelete(&accept_p->node, &client_p->localClient->acceptlist);
1206  
1207 <  DLINK_FOREACH(ptr, target->allow_list.head)
1208 <  {
1209 <    struct Client *target_p = ptr->data;
1207 >  MyFree(accept_p->nickptr);
1208 >  MyFree(accept_p->userptr);
1209 >  MyFree(accept_p->hostptr);
1210 >  MyFree(accept_p);
1211 > }
1212  
1213 <    if (source == target_p)
1214 <      return (1);
1215 <  }
1213 > struct split_nuh_item *
1214 > find_accept(const char *nick, const char *user,
1215 >            const char *host, struct Client *client_p, int do_match)
1216 > {
1217 >  dlink_node *ptr = NULL;
1218 >  /* XXX We wouldn't need that if match() would return 0 on match */
1219 >  int (*cmpfunc)(const char *, const char *) = do_match ? match : irccmp;
1220  
1221 <  if (IsSoftCallerId(target))
1221 >  DLINK_FOREACH(ptr, client_p->localClient->acceptlist.head)
1222    {
1223 <    DLINK_FOREACH(ptr, target->channel.head)
1224 <      if (IsMember(source, ((struct Membership *)ptr->data)->chptr))
1225 <        return (1);
1223 >    struct split_nuh_item *accept_p = ptr->data;
1224 >
1225 >    if (cmpfunc(accept_p->nickptr, nick) == do_match &&
1226 >        cmpfunc(accept_p->userptr, user) == do_match &&
1227 >        cmpfunc(accept_p->hostptr, host) == do_match)
1228 >      return accept_p;
1229    }
1230  
1231 <  return (0);
1231 >  return NULL;
1232   }
1233  
1234 < /* del_from_accept()
1252 < *
1253 < * inputs       - pointer to source client
1254 < *              - pointer to target client
1255 < * output       - NONE
1256 < * side effects - Delete's source pointer to targets allow list
1234 > /* accept_message()
1235   *
1236 < * Walk through the target's accept list, remove if source is found,
1237 < * Then walk through the source's on_accept_list remove target if found.
1236 > * inputs       - pointer to source client
1237 > *              - pointer to target client
1238 > * output       - 1 if accept this message 0 if not
1239 > * side effects - See if source is on target's allow list
1240   */
1241 < void
1242 < del_from_accept(struct Client *source, struct Client *target)
1241 > int
1242 > accept_message(struct Client *source,
1243 >               struct Client *target)
1244   {
1245 <  dlink_node *ptr;
1265 <  dlink_node *ptr2;
1266 <  dlink_node *next_ptr;
1267 <  dlink_node *next_ptr2;
1268 <  struct Client *target_p;
1245 >  dlink_node *ptr = NULL;
1246  
1247 <  DLINK_FOREACH_SAFE(ptr, next_ptr, target->allow_list.head)
1248 <  {
1249 <    target_p = ptr->data;
1273 <
1274 <    if (source == target_p)
1275 <    {
1276 <      dlinkDelete(ptr, &target->allow_list);
1277 <      free_dlink_node(ptr);
1247 >  if (source == target || find_accept(source->name, source->username,
1248 >                                      source->host, target, 1))
1249 >    return 1;
1250  
1251 <      DLINK_FOREACH_SAFE(ptr2, next_ptr2, source->on_allow_list.head)
1252 <      {
1253 <        target_p = ptr2->data;
1251 >  if (IsSoftCallerId(target))
1252 >    DLINK_FOREACH(ptr, target->channel.head)
1253 >      if (IsMember(source, ((struct Membership *)ptr->data)->chptr))
1254 >        return 1;
1255  
1256 <        if (target == target_p)
1284 <        {
1285 <          dlinkDelete(ptr2, &source->on_allow_list);
1286 <          free_dlink_node(ptr2);
1287 <        }
1288 <      }
1289 <    }
1290 <  }
1256 >  return 0;
1257   }
1258  
1259   /* del_all_accepts()
1260   *
1261 < * inputs       - pointer to exiting client
1262 < * output       - NONE
1263 < * side effects - Walk through given clients allow_list and on_allow_list
1298 < *                remove all references to this client
1261 > * inputs       - pointer to exiting client
1262 > * output       - NONE
1263 > * side effects - Walk through given clients acceptlist and remove all entries
1264   */
1265   void
1266   del_all_accepts(struct Client *client_p)
1267   {
1268 <  dlink_node *ptr, *next_ptr;
1304 <
1305 <  DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->allow_list.head)
1306 <    del_from_accept(ptr->data, client_p);
1307 <
1308 <  DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->on_allow_list.head)
1309 <    del_from_accept(client_p, ptr->data);
1310 < }
1311 <
1312 < /* del_all_their_accepts()
1313 < *
1314 < * inputs       - pointer to exiting client
1315 < * output       - NONE
1316 < * side effects - Walk through given clients on_allow_list
1317 < *                remove all references to this client,
1318 < *                allow this client to keep their own allow_list
1319 < */
1320 < void
1321 < del_all_their_accepts(struct Client *client_p)
1322 < {
1323 <  dlink_node *ptr, *next_ptr;
1268 >  dlink_node *ptr = NULL, *next_ptr = NULL;
1269  
1270 <  DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->on_allow_list.head)
1271 <    del_from_accept(client_p, ptr->data);
1270 >  DLINK_FOREACH_SAFE(ptr, next_ptr, client_p->localClient->acceptlist.head)
1271 >    del_accept(ptr->data, client_p);
1272   }
1273  
1274   /* set_initial_nick()
# Line 1408 | Line 1353 | change_local_nick(struct Client *client_
1353  
1354      if (!samenick)
1355      {
1411      /*
1412       * Make sure everyone that has this client on its accept list
1413       * loses that reference.
1414       */
1415      del_all_their_accepts(source_p);
1356        source_p->tsinfo = CurrentTime;
1357        clear_ban_cache_client(source_p);
1358        watch_check_hash(source_p, RPL_LOGOFF);

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)