Changeset 6317

Show
Ignore:
Timestamp:
06/16/08 10:52:27 (6 months ago)
Author:
eugene
Message:

Revised the group changing for ICQ protocol. Added checks to avoid manipulating with the top-level root group.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/licq/src/icqd-srv.cpp

    r6314 r6317  
    271271                                unsigned short _nNewType, unsigned short _nOldType) 
    272272{ 
    273   if (!UseServerContactList())  return; 
     273  if (!UseServerContactList()) 
     274    return; 
     275 
     276  if (_nNewGroup == 0) 
     277  { 
     278    gLog.Warn(tr("%sProtocol prohibits for users to be in the root group.\n" 
     279                 "%sAborting group change attempt for %s.\n"), 
     280        L_SRVxSTR, L_BLANKxSTR, _szId); 
     281    return; 
     282  } 
    274283 
    275284  // Get their old SID 
    276   ICQUser *u = gUserManager.FetchUser(_szId, _nPPID, LOCK_R); 
     285  ICQUser* u = gUserManager.FetchUser(_szId, _nPPID, LOCK_R); 
     286  char* alias = u->GetAlias(); 
    277287  int nSID = u->GetSID(); 
    278288  gUserManager.DropUser(u); 
    279289 
    280   gLog.Info(tr("%sChanging group on server list for %s ...\n"), L_SRVxSTR, _szId); 
     290  gLog.Info(tr("%sChanging group on server list for %s (%s)...\n"), 
     291      L_SRVxSTR, alias, _szId); 
    281292 
    282293  // Start transaction 
    283   CSrvPacketTcp *pStart = new CPU_GenericFamily(ICQ_SNACxFAM_LIST, 
    284                                                 ICQ_SNACxLIST_ROSTxEDITxSTART); 
     294  CSrvPacketTcp* pStart = 
     295    new CPU_GenericFamily(ICQ_SNACxFAM_LIST, ICQ_SNACxLIST_ROSTxEDITxSTART); 
    285296  SendEvent_Server(pStart); 
    286297 
    287298  // Delete the user 
    288   CSrvPacketTcp *pRemove = new CPU_RemoveFromServerList(_szId, _nOldGSID, 
    289                                                         nSID, _nOldType); 
    290   addToModifyUsers(pRemove->SubSequence(), _szId); 
    291   SendExpectEvent_Server(pRemove, NULL); 
     299  if (_nOldGSID != 0) 
     300  { 
     301    // Don't attempt removing users from the root group, they can't be there 
     302    CSrvPacketTcp* pRemove = 
     303      new CPU_RemoveFromServerList(_szId, _nOldGSID, nSID, _nOldType); 
     304    addToModifyUsers(pRemove->SubSequence(), _szId); 
     305    SendExpectEvent_Server(pRemove, NULL); 
     306  } 
    292307 
    293308  // Add the user, with the new group 
    294   CPU_AddToServerList *pAdd = new CPU_AddToServerList(_szId, _nNewType, 
    295                                                       _nNewGroup); 
     309  CPU_AddToServerList* pAdd = 
     310    new CPU_AddToServerList(_szId, _nNewType, _nNewGroup); 
    296311  addToModifyUsers(pAdd->SubSequence(), _szId); 
    297312  SendExpectEvent_Server(pAdd, NULL); 
    298  
    299313} 
    300314