Example #1
0
	virtual bool OnLoad(const CString& sArgs, CString& sMessage) {
		VCString vsArgs;
		VCString::const_iterator it;
		sArgs.Split(" ", vsArgs, false);

		for (it = vsArgs.begin(); it != vsArgs.end(); ++it) {
			if (it->Equals("saslauthd") || it->Equals("auxprop")) {
				m_sMethod += *it + " ";
			} else {
				CUtils::PrintError("Ignoring invalid SASL pwcheck method: " + *it);
				sMessage = "Ignored invalid SASL pwcheck method";
			}
		}

		m_sMethod.TrimRight();

		if (m_sMethod.empty()) {
			sMessage = "Need a pwcheck method as argument (saslauthd, auxprop)";
			return false;
		}

		if (sasl_server_init(NULL, NULL) != SASL_OK) {
			sMessage = "SASL Could Not Be Initialized - Halting Startup";
			return false;
		}

		m_cbs[0].id = SASL_CB_GETOPT;
		m_cbs[0].proc = reinterpret_cast<int(*)()>(CSASLAuthMod::getopt);
		m_cbs[0].context = this;
		m_cbs[1].id = SASL_CB_LIST_END;
		m_cbs[1].proc = NULL;
		m_cbs[1].context = NULL;

		return true;
	}
Example #2
0
	virtual bool OnLoad(const CString& sArgs, CString& sMessage) {
		VCString vsChans;
		VCString::const_iterator it;
		sArgs.Split(" ", vsChans, false);

		for (it = vsChans.begin(); it != vsChans.end(); ++it) {
			if (it->StrCmp("saslauthd") || it->StrCmp("auxprop")) {
				method += *it + " ";
			}
			else {
				CUtils::PrintError("Ignoring invalid SASL pwcheck method: " + *it);
				sMessage = "Ignored invalid SASL pwcheck method";
			}
		}
		method.TrimRight();

		if (method.empty()) {
			sMessage = "Need a pwcheck method as argument (saslauthd, auxprop)";
			return false;
		}

		if (sasl_server_init(NULL, NULL) != SASL_OK) {
			sMessage = "SASL Could Not Be Initialized - Halting Startup";
			return false;
		}

		return true;
	}
Example #3
0
	bool OnLoad(const CString& sArgs, CString& sMessage)
	{
		size_t uIndex = 0;

		if(sArgs.Token(0).Equals("-force"))
		{
			m_bForce = true;
			++uIndex;
		}

		if(sArgs.Token(uIndex + 1).empty() || !sArgs.Token(uIndex + 2).empty())
		{
			sMessage = "This module needs two charset lists as arguments: [-force] "
				"<client_charset1[,client_charset2[,...]]> "
				"<server_charset1[,server_charset2[,...]]>";
			return false;
			// the first charset in each list is the preferred one for
			// messages to the client / to the server.
		}

		VCString vsFrom, vsTo;
		sArgs.Token(uIndex).Split(",", vsFrom);
		sArgs.Token(uIndex + 1).Split(",", vsTo);

		// probe conversions:
		for(VCString::const_iterator itf = vsFrom.begin(); itf != vsFrom.end(); ++itf)
		{
			for(VCString::const_iterator itt = vsTo.begin(); itt != vsTo.end(); ++itt)
			{
				iconv_t icTest = iconv_open(itt->c_str(), itf->c_str());
				if(icTest == (iconv_t)-1)
				{
					sMessage = "Conversion from '" + *itf + "' to '" + *itt + "' is not possible.";
					return false;
				}
				iconv_close(icTest);

				icTest = iconv_open(itf->c_str(), itt->c_str());
				if(icTest == (iconv_t)-1)
				{
					sMessage = "Conversion from '" + *itt + "' to '" + *itf + "' is not possible.";
					return false;
				}
				iconv_close(icTest);
			}
		}

		m_vsClientCharsets = vsFrom;
		m_vsServerCharsets = vsTo;

		return true;
	}