예제 #1
0
bool execute_certificate_validation_script(const fs::path& script, fl::core& core, fl::security_configuration::cert_type cert)
{
	static unsigned int counter = 0;

	try
	{
		const fs::path filename = get_temporary_directory() / ("freelan_certificate_" + boost::lexical_cast<std::string>(counter++) + ".crt");

		if (core.logger().level() <= freelan::LL_DEBUG)
		{
			core.logger()(freelan::LL_DEBUG) << "Writing temporary certificate file at: " << filename;
		}

#ifdef WINDOWS
#ifdef UNICODE
		cert.write_certificate(cryptoplus::file::open(filename.string<std::basic_string<TCHAR> >(), L"w"));
#else
		cert.write_certificate(cryptoplus::file::open(filename.string<std::basic_string<TCHAR> >(), "w"));
#endif
#else
		cert.write_certificate(cryptoplus::file::open(filename.string<std::basic_string<char> >(), "w"));
#endif

		const int exit_status = execute(script, filename.c_str(), NULL);

		if (core.logger().level() <= freelan::LL_DEBUG)
		{
			core.logger()(freelan::LL_DEBUG) << script << " terminated execution with exit status " << exit_status ;
		}

		fs::remove(filename);

		return (exit_status == 0);
	}
	catch (std::exception& ex)
	{
		core.logger()(freelan::LL_WARNING) << "Error while executing certificate validation script (" << script << "): " << ex.what() ;

		return false;
	}
}
예제 #2
0
temp_dirt::temp_dirt(const std::string &name_template)
{
  path=get_temporary_directory(name_template);
}