void CDB_ODBC_ConnParams::x_MapPairToParam(const string& key, const string& value) { // MS SQL Server related attributes ... if (NStr::Equal(key, "SERVER", NStr::eNocase)) { SetServerName(value); } else if (NStr::Equal(key, "UID", NStr::eNocase)) { SetUserName(value); } else if (NStr::Equal(key, "PWD", NStr::eNocase)) { SetPassword(value); } else if (NStr::Equal(key, "DRIVER", NStr::eNocase)) { SetDriverName(value); } else if (NStr::Equal(key, "DATABASE", NStr::eNocase)) { SetDatabaseName(value); } else if (NStr::Equal(key, "ADDRESS", NStr::eNocase)) { string host; string port; NStr::SplitInTwo(value, ",", host, port); NStr::TruncateSpacesInPlace(host); NStr::TruncateSpacesInPlace(port); // SetHost(host); SetPort(static_cast<Uint2>(NStr::StringToInt(port))); } else { SetParam(key, value); } }
CDBDefaultConnParams::CDBDefaultConnParams( const string& srv_name, const string& user_name, const string& passwd, I_DriverContext::TConnectionMode mode, bool reusable, const string& pool_name) { SetServerName(srv_name); SetUserName(user_name); SetPassword(passwd); SetParam( "pool_name", pool_name ); SetParam( "secure_login", ((mode & I_DriverContext::fPasswordEncrypted) != 0) ? "true" : "false" ); SetParam( "is_pooled", reusable ? "true" : "false" ); SetParam( "do_not_connect", (mode & I_DriverContext::fDoNotConnect) != 0 ? "true" : "false" ); }
void CComputerInfo::AttachActiveMember(CActiveMember& ActiveMember) { SetMemberID( ActiveMember.GetMemberID() ); SetUserName( ActiveMember.GetUserName() ); SetNetId( ActiveMember.GetNetId() ); SetAvailavleBalance( ActiveMember.GetAvailavleBalance() ); m_Amount = ActiveMember.GetAmount(); m_PayType = ActiveMember.GetPayType(); m_IdType = ActiveMember.GetIdType(); m_strPersonalID = ActiveMember.GetPersonalID(); m_CheckInTime = ActiveMember.GetCheckInTime(); m_strMemberType = ActiveMember.GetUserClassName(); m_Sex = ActiveMember.GetSex(); }
/* ============ sdGUIDInfo::SetMatch ============ */ void sdGUIDInfo::SetMatch( const clientGUIDLookup_t& lookup ) { SetUserName( lookup.name.c_str() ); if ( lookup.clientId.IsValid() ) { SetGUID( lookup.clientId ); return; } if ( lookup.pbid != 0 ) { SetPBID( lookup.pbid ); return; } SetIP( lookup.ip ); }
CUser::CUser(const CString& sUserName) { m_pIRCSock = NULL; m_fTimezoneOffset = 0; SetUserName(sUserName); m_sNick = m_sCleanUserName; m_sIdent = m_sCleanUserName; m_sRealName = sUserName; m_uServerIdx = 0; m_uBytesRead = 0; m_uBytesWritten = 0; m_pModules = new CModules; m_RawBuffer.SetLineCount(100); // This should be more than enough raws, especially since we are buffering the MOTD separately m_MotdBuffer.SetLineCount(200); // This should be more than enough motd lines m_QueryBuffer.SetLineCount(250); m_bMultiClients = true; m_bBounceDCCs = true; m_eHashType = HASH_NONE; m_bUseClientIP = false; m_bDenyLoadMod = false; m_bAdmin= false; m_bIRCAway = false; m_bDenySetBindHost= false; m_sStatusPrefix = "*"; m_sChanPrefixes = ""; m_uBufferCount = 50; m_uMaxJoinTries = 10; m_uMaxJoins = 5; m_bKeepBuffer = false; m_bBeingDeleted = false; m_sTimestampFormat = "[%H:%M:%S]"; m_bAppendTimestamp = false; m_bPrependTimestamp = true; m_bIRCConnectEnabled = true; m_pUserTimer = new CUserTimer(this); CZNC::Get().GetManager().AddCron(m_pUserTimer); }
void BUrl::SetAuthority(const BString& authority) { fAuthority = authority; fHasPort = false; fHasUserName = false; fHasPassword = false; // An empty authority is still an authority, making it possible to have // URLs such as file:///path/to/file. // TODO however, there is no way to unset the authority once it is set... // We may want to take a const char* parameter and allow NULL. fHasHost = true; if (fAuthority.IsEmpty()) return; int32 userInfoEnd = fAuthority.FindFirst('@'); // URL contains userinfo field if (userInfoEnd != -1) { BString userInfo; fAuthority.CopyInto(userInfo, 0, userInfoEnd); int16 colonDelimiter = userInfo.FindFirst(':', 0); if (colonDelimiter == 0) { SetPassword(userInfo); } else if (colonDelimiter != -1) { userInfo.CopyInto(fUser, 0, colonDelimiter); userInfo.CopyInto(fPassword, colonDelimiter + 1, userInfo.Length() - colonDelimiter); SetUserName(fUser); SetPassword(fPassword); } else { SetUserName(fUser); } } // Extract the host part int16 hostEnd = fAuthority.FindFirst(':', userInfoEnd); userInfoEnd++; if (hostEnd < 0) { // no ':' found, the host extends to the end of the URL hostEnd = fAuthority.Length() + 1; } // The host is likely to be present if an authority is // defined, but in some weird cases, it's not. if (hostEnd != userInfoEnd) { fAuthority.CopyInto(fHost, userInfoEnd, hostEnd - userInfoEnd); SetHost(fHost); } // Extract the port part fPort = 0; if (fAuthority.ByteAt(hostEnd) == ':') { hostEnd++; int16 portEnd = fAuthority.Length(); BString portString; fAuthority.CopyInto(portString, hostEnd, portEnd - hostEnd); fPort = atoi(portString.String()); // Even if the port is invalid, the URL is considered to // have a port. fHasPort = portString.Length() > 0; } }
bool CUrlClient::SetUrl(LPCTSTR pszUrl, uint32 nIP) { USES_CONVERSION; TCHAR szCanonUrl[INTERNET_MAX_URL_LENGTH]; DWORD dwCanonUrlSize = ARRSIZE(szCanonUrl); if (!InternetCanonicalizeUrl(pszUrl, szCanonUrl, &dwCanonUrlSize, ICU_NO_ENCODE)) return false; TCHAR szUrl[INTERNET_MAX_URL_LENGTH]; DWORD dwUrlSize = ARRSIZE(szUrl); if (!InternetCanonicalizeUrl(szCanonUrl, szUrl, &dwUrlSize, ICU_DECODE | ICU_NO_ENCODE | ICU_BROWSER_MODE)) return false; TCHAR szScheme[INTERNET_MAX_SCHEME_LENGTH]; TCHAR szHostName[INTERNET_MAX_HOST_NAME_LENGTH]; TCHAR szUrlPath[INTERNET_MAX_PATH_LENGTH]; TCHAR szUserName[INTERNET_MAX_USER_NAME_LENGTH]; TCHAR szPassword[INTERNET_MAX_PASSWORD_LENGTH]; TCHAR szExtraInfo[INTERNET_MAX_URL_LENGTH]; URL_COMPONENTS Url = {0}; Url.dwStructSize = sizeof(Url); Url.lpszScheme = szScheme; Url.dwSchemeLength = ARRSIZE(szScheme); Url.lpszHostName = szHostName; Url.dwHostNameLength = ARRSIZE(szHostName); Url.lpszUserName = szUserName; Url.dwUserNameLength = ARRSIZE(szUserName); Url.lpszPassword = szPassword; Url.dwPasswordLength = ARRSIZE(szPassword); Url.lpszUrlPath = szUrlPath; Url.dwUrlPathLength = ARRSIZE(szUrlPath); Url.lpszExtraInfo = szExtraInfo; Url.dwExtraInfoLength = ARRSIZE(szExtraInfo); if (!InternetCrackUrl(szUrl, 0, 0, &Url)) return false; if (Url.dwSchemeLength == 0 || Url.nScheme != INTERNET_SCHEME_HTTP) // we only support "http://" return false; if (Url.dwHostNameLength == 0) // we must know the hostname return false; if (Url.dwUserNameLength != 0) // no support for user/password return false; if (Url.dwPasswordLength != 0) // no support for user/password return false; if (Url.dwUrlPathLength == 0) // we must know the URL path on that host return false; m_strHost = szHostName; TCHAR szEncodedUrl[INTERNET_MAX_URL_LENGTH]; DWORD dwEncodedUrl = ARRSIZE(szEncodedUrl); if (!InternetCanonicalizeUrl(szUrl, szEncodedUrl, &dwEncodedUrl, ICU_ENCODE_PERCENT)) return false; m_strUrlPath = szEncodedUrl; m_nUrlStartPos = (UINT)-1; SetUserName(szUrl); //NOTE: be very careful with what is stored in the following IP/ID/Port members! if (nIP) m_nConnectIP = nIP; else m_nConnectIP = inet_addr(T2A(szHostName)); // if (m_nConnectIP == INADDR_NONE) // m_nConnectIP = 0; m_nUserIDHybrid = htonl(m_nConnectIP); ASSERT( m_nUserIDHybrid != 0 ); m_nUserPort = Url.nPort; return true; }
CDBUriConnParams::CDBUriConnParams(const string& params) { string::size_type pos = 0; string::size_type cur_pos = 0; // Check for 'dbapi:' ... pos = params.find_first_of(":", pos); if (pos == string::npos) { DATABASE_DRIVER_ERROR("Invalid database locator format, should start with 'dbapi:'", 20001); } if (! NStr::StartsWith(params, "dbapi:", NStr::eNocase)) { DATABASE_DRIVER_ERROR("Invalid database locator format, should start with 'dbapi:'", 20001); } cur_pos = pos + 1; // Check for driver name ... pos = params.find("//", cur_pos); if (pos == string::npos) { DATABASE_DRIVER_ERROR("Invalid database locator format, should contain driver name", 20001); } if (pos != cur_pos) { string driver_name = params.substr(cur_pos, pos - cur_pos - 1); SetDriverName(driver_name); } cur_pos = pos + 2; // Check for user name and password ... pos = params.find_first_of(":@", cur_pos); if (pos != string::npos) { string user_name = params.substr(cur_pos, pos - cur_pos); if (params[pos] == '@') { SetUserName(user_name); cur_pos = pos + 1; ParseServer(params, cur_pos); } else { // Look ahead, we probably found a host name ... cur_pos = pos + 1; pos = params.find_first_of("@", cur_pos); if (pos != string::npos) { // Previous value was an user name ... SetUserName(user_name); string password = params.substr(cur_pos, pos - cur_pos); SetPassword(password); cur_pos = pos + 1; } ParseServer(params, cur_pos); } } else { ParseServer(params, cur_pos); } }
void BUrl::SetAuthority(const BString& authority) { fAuthority = authority; fUser.Truncate(0); fPassword.Truncate(0); fHost.Truncate(0); fPort = 0; fHasPort = false; fHasUserName = false; fHasPassword = false; bool hasUsernamePassword = B_ERROR != fAuthority.FindFirst('@'); authority_parse_state state = AUTHORITY_USERNAME; int32 offset = 0; int32 length = authority.Length(); const char *authority_c = authority.String(); while (AUTHORITY_COMPLETE != state && offset < length) { switch (state) { case AUTHORITY_USERNAME: { if (hasUsernamePassword) { int32 end_username = char_offset_until_fn_false( authority_c, length, offset, authority_is_username_char); SetUserName(BString(&authority_c[offset], end_username - offset)); state = AUTHORITY_PASSWORD; offset = end_username; } else { state = AUTHORITY_HOST; } break; } case AUTHORITY_PASSWORD: { if (hasUsernamePassword && ':' == authority[offset]) { offset++; // move past the delimiter int32 end_password = char_offset_until_fn_false( authority_c, length, offset, authority_is_password_char); SetPassword(BString(&authority_c[offset], end_password - offset)); offset = end_password; } // if the host was preceded by a username + password couple // then there will be an '@' delimiter to avoid. if (authority_c[offset] == '@') { offset++; } state = AUTHORITY_HOST; break; } case AUTHORITY_HOST: { // the host may be enclosed within brackets in order to express // an IPV6 address. if (authority_c[offset] == '[') { int32 end_ipv6_host = char_offset_until_fn_false( authority_c, length, offset + 1, authority_is_ipv6_host_char); if (authority_c[end_ipv6_host] == ']') { SetHost(BString(&authority_c[offset], (end_ipv6_host - offset) + 1)); state = AUTHORITY_PORT; offset = end_ipv6_host + 1; } } // if an IPV6 host was not found. if (AUTHORITY_HOST == state) { int32 end_host = char_offset_until_fn_false( authority_c, length, offset, authority_is_host_char); SetHost(BString(&authority_c[offset], end_host - offset)); state = AUTHORITY_PORT; offset = end_host; } break; } case AUTHORITY_PORT: { if (authority_c[offset] == ':') { offset++; int32 end_port = char_offset_until_fn_false( authority_c, length, offset, authority_is_port_char); SetPort(atoi(&authority_c[offset])); offset = end_port; } state = AUTHORITY_COMPLETE; break; } case AUTHORITY_COMPLETE: // should never be reached - keeps the compiler happy break; } } // An empty authority is still an authority, making it possible to have // URLs such as file:///path/to/file. // TODO however, there is no way to unset the authority once it is set... // We may want to take a const char* parameter and allow NULL. fHasHost = true; }
bool CUser::Clone(const CUser& User, CString& sErrorRet, bool bCloneChans) { unsigned int a = 0; sErrorRet.clear(); if (!User.IsValid(sErrorRet, true)) { return false; } if (GetUserName() != User.GetUserName()) { if (CZNC::Get().FindUser(User.GetUserName())) { sErrorRet = "New username already exists"; return false; } SetUserName(User.GetUserName()); } if (!User.GetPass().empty()) { SetPass(User.GetPass(), User.GetPassHashType(), User.GetPassSalt()); } SetNick(User.GetNick(false)); SetAltNick(User.GetAltNick(false)); SetIdent(User.GetIdent(false)); SetRealName(User.GetRealName()); SetStatusPrefix(User.GetStatusPrefix()); SetBindHost(User.GetBindHost()); SetDCCBindHost(User.GetDCCBindHost()); SetQuitMsg(User.GetQuitMsg()); SetSkinName(User.GetSkinName()); SetDefaultChanModes(User.GetDefaultChanModes()); SetBufferCount(User.GetBufferCount(), true); SetJoinTries(User.JoinTries()); SetMaxJoins(User.MaxJoins()); // Allowed Hosts m_ssAllowedHosts.clear(); const set<CString>& ssHosts = User.GetAllowedHosts(); for (set<CString>::const_iterator it = ssHosts.begin(); it != ssHosts.end(); ++it) { AddAllowedHost(*it); } for (a = 0; a < m_vClients.size(); a++) { CClient* pSock = m_vClients[a]; if (!IsHostAllowed(pSock->GetRemoteIP())) { pSock->PutStatusNotice("You are being disconnected because your IP is no longer allowed to connect to this user"); pSock->Close(); } } // !Allowed Hosts // Servers const vector<CServer*>& vServers = User.GetServers(); CString sServer; CServer* pCurServ = GetCurrentServer(); if (pCurServ) { sServer = pCurServ->GetName(); } DelServers(); for (a = 0; a < vServers.size(); a++) { CServer* pServer = vServers[a]; AddServer(pServer->GetName(), pServer->GetPort(), pServer->GetPass(), pServer->IsSSL()); } m_uServerIdx = 0; for (a = 0; a < m_vServers.size(); a++) { if (sServer.Equals(m_vServers[a]->GetName())) { m_uServerIdx = a + 1; break; } } if (m_uServerIdx == 0) { m_uServerIdx = m_vServers.size(); CIRCSock* pSock = GetIRCSock(); if (pSock) { PutStatus("Jumping servers because this server is no longer in the list"); pSock->Quit(); } } // !Servers // Chans const vector<CChan*>& vChans = User.GetChans(); for (a = 0; a < vChans.size(); a++) { CChan* pNewChan = vChans[a]; CChan* pChan = FindChan(pNewChan->GetName()); if (pChan) { pChan->SetInConfig(pNewChan->InConfig()); } else { AddChan(pNewChan->GetName(), pNewChan->InConfig()); } } for (a = 0; a < m_vChans.size(); a++) { CChan* pChan = m_vChans[a]; CChan* pNewChan = User.FindChan(pChan->GetName()); if (!pNewChan) { pChan->SetInConfig(false); } else { if (bCloneChans) pChan->Clone(*pNewChan); } } // !Chans // CTCP Replies m_mssCTCPReplies.clear(); const MCString& msReplies = User.GetCTCPReplies(); for (MCString::const_iterator it = msReplies.begin(); it != msReplies.end(); ++it) { AddCTCPReply(it->first, it->second); } // !CTCP Replies // Flags SetIRCConnectEnabled(User.GetIRCConnectEnabled()); SetKeepBuffer(User.KeepBuffer()); SetMultiClients(User.MultiClients()); SetBounceDCCs(User.BounceDCCs()); SetUseClientIP(User.UseClientIP()); SetDenyLoadMod(User.DenyLoadMod()); SetAdmin(User.IsAdmin()); SetDenySetBindHost(User.DenySetBindHost()); SetTimestampAppend(User.GetTimestampAppend()); SetTimestampPrepend(User.GetTimestampPrepend()); SetTimestampFormat(User.GetTimestampFormat()); SetTimezoneOffset(User.GetTimezoneOffset()); // !Flags // Modules set<CString> ssUnloadMods; CModules& vCurMods = GetModules(); const CModules& vNewMods = User.GetModules(); for (a = 0; a < vNewMods.size(); a++) { CString sModRet; CModule* pNewMod = vNewMods[a]; CModule* pCurMod = vCurMods.FindModule(pNewMod->GetModName()); if (!pCurMod) { vCurMods.LoadModule(pNewMod->GetModName(), pNewMod->GetArgs(), this, sModRet); } else if (pNewMod->GetArgs() != pCurMod->GetArgs()) { vCurMods.ReloadModule(pNewMod->GetModName(), pNewMod->GetArgs(), this, sModRet); } } for (a = 0; a < vCurMods.size(); a++) { CModule* pCurMod = vCurMods[a]; CModule* pNewMod = vNewMods.FindModule(pCurMod->GetModName()); if (!pNewMod) { ssUnloadMods.insert(pCurMod->GetModName()); } } for (set<CString>::iterator it = ssUnloadMods.begin(); it != ssUnloadMods.end(); ++it) { vCurMods.UnloadModule(*it); } // !Modules return true; }
void BUrl::SetAuthority(const BString& authority) { fAuthority = authority; fHasPort = false; fHasUserInfo = false; fHasHost = false; if (fAuthority.IsEmpty()) return; fHasAuthority = true; int32 userInfoEnd = fAuthority.FindFirst('@'); // URL contains userinfo field if (userInfoEnd != -1) { BString userInfo; fAuthority.CopyInto(userInfo, 0, userInfoEnd); int16 colonDelimiter = userInfo.FindFirst(':', 0); if (colonDelimiter == 0) { SetPassword(userInfo); } else if (colonDelimiter != -1) { userInfo.CopyInto(fUser, 0, colonDelimiter); userInfo.CopyInto(fPassword, colonDelimiter + 1, userInfo.Length() - colonDelimiter); SetUserName(fUser); SetPassword(fPassword); } else { SetUserName(fUser); } fHasUserInfo = true; } // Extract the host part int16 hostEnd = fAuthority.FindFirst(':', userInfoEnd); userInfoEnd++; if (hostEnd < 0) { // no ':' found, the host extends to the end of the URL hostEnd = fAuthority.Length() + 1; } // The host is likely to be present if an authority is // defined, but in some weird cases, it's not. if (hostEnd != userInfoEnd) { fAuthority.CopyInto(fHost, userInfoEnd, hostEnd - userInfoEnd); SetHost(fHost); } // Extract the port part fPort = 0; if (fAuthority.ByteAt(hostEnd) == ':') { hostEnd++; int16 portEnd = fAuthority.Length(); BString portString; fAuthority.CopyInto(portString, hostEnd, portEnd - hostEnd); fPort = atoi(portString.String()); // Even if the port is invalid, the URL is considered to // have a port. fHasPort = portString.Length() > 0; } }
/** Add a new user profile into the user profile database. **/ VOID CallAddUser ( VOID ) { EFI_STATUS Status; EFI_INPUT_KEY Key; EFI_USER_PROFILE_HANDLE User; UINTN UserNameLen; CHAR16 UserName[USER_NAME_LENGTH]; CHAR16 *QuestionStr; CHAR16 *PromptStr; QuestionStr = NULL; PromptStr = NULL; // // Get user name to add. // UserNameLen = sizeof (UserName); Status = GetUserNameInput (&UserNameLen, UserName); if (EFI_ERROR (Status)) { if (Status != EFI_ABORTED) { QuestionStr = GetStringById (STRING_TOKEN (STR_GET_USERNAME_FAILED)); PromptStr = GetStringById (STRING_TOKEN (STR_STROKE_KEY_CONTINUE)); goto Done; } return ; } // // Create a new user profile. // User = NULL; Status = mUserManager->Create (mUserManager, &User); if (EFI_ERROR (Status)) { QuestionStr = GetStringById (STRING_TOKEN (STR_CREATE_PROFILE_FAILED)); PromptStr = GetStringById (STRING_TOKEN (STR_STROKE_KEY_CONTINUE)); } else { // // Add default user information. // Status = SetUserName (User, UserNameLen, UserName); if (EFI_ERROR (Status)) { QuestionStr = GetStringById (STRING_TOKEN (STR_USER_ALREADY_EXISTED)); PromptStr = GetStringById (STRING_TOKEN (STR_STROKE_KEY_CONTINUE)); goto Done; } SetCreateDate (User); SetIdentityPolicy (User); SetAccessPolicy (User); QuestionStr = GetStringById (STRING_TOKEN (STR_CREATE_PROFILE_SUCCESS)); PromptStr = GetStringById (STRING_TOKEN (STR_STROKE_KEY_CONTINUE)); } Done: CreatePopUp ( EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, QuestionStr, L"", PromptStr, NULL ); FreePool (QuestionStr); FreePool (PromptStr); }