Logo Search packages:      
Sourcecode: sbnc version File versions  Download package

RESULT< bool > CCore::RemoveUser ( const char *  Username,
bool  RemoveConfig = true 
)

RemoveUser

Removes a bouncer user.

Parameters:
Username the name of the user
RemoveConfig whether the user's config file should be deleted

Definition at line 1146 of file Core.cpp.

References CUser::GetConfig(), CLog::GetFilename(), CConfig::GetFilename(), CVector< Type >::GetLength(), CUser::GetLog(), GetUser(), CUser::GetUsername(), Log(), m_Modules, m_Users, and UpdateUserConfig().

Referenced by CClientConnection::ProcessBncCommand().

                                                                      {
      RESULT<bool> Result;
      CUser *User;
      char *UsernameCopy;
      char *ConfigCopy = NULL, *LogCopy = NULL;
      
      User = GetUser(Username);

      if (User == NULL) {
            THROW(bool, Generic_Unknown, "There is no such user.");
      }

      for (unsigned int i = 0; i < m_Modules.GetLength(); i++) {
            m_Modules[i]->UserDelete(Username);
      }

      UsernameCopy = strdup(User->GetUsername());

      if (RemoveConfig) {
            ConfigCopy = strdup(User->GetConfig()->GetFilename());
            LogCopy = strdup(User->GetLog()->GetFilename());
      }

      delete User;

      Result = m_Users.Remove(UsernameCopy);

      if (IsError(Result)) {
            free(UsernameCopy);

            THROWRESULT(bool, Result);
      }

      if (UsernameCopy != NULL) {
            Log("User removed: %s", UsernameCopy);
            free(UsernameCopy);
      }

      if (RemoveConfig) {
            unlink(ConfigCopy);
            unlink(LogCopy);
      }

      free(ConfigCopy);
      free(LogCopy);

      UpdateUserConfig();

      RETURN(bool, true);
}


Generated by  Doxygen 1.6.0   Back to index