MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / checkAudit

Method checkAudit

src/jrd/trace/TraceConfigStorage.cpp:211–275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

209}
210
211void ConfigStorage::checkAudit()
212{
213 if (m_sharedMemory->getHeader()->change_number != 0)
214 return;
215
216 // Prevent second attempt to create audit session if first one was failed.
217 // This also prevents multiply logging of the same error.
218 setDirty();
219
220 // put default (audit) trace file contents into storage
221 AutoPtr<FILE> cfgFile;
222
223 try
224 {
225 PathName configFileName(Config::getAuditTraceConfigFile());
226
227 // remove quotes around path if present
228 configFileName.alltrim(" '\"");
229
230 if (configFileName.empty())
231 return;
232
233 if (PathUtils::isRelative(configFileName))
234 {
235 PathName root(Config::getRootDirectory());
236 PathUtils::ensureSeparator(root);
237 configFileName.insert(0, root);
238 }
239
240 cfgFile = os_utils::fopen(configFileName.c_str(), "rb");
241 if (!cfgFile) {
242 checkFileError(configFileName.c_str(), "fopen", isc_io_open_err);
243 }
244
245 TraceSession session(*getDefaultMemoryPool());
246
247 fseek(cfgFile, 0, SEEK_END);
248 const long len = ftell(cfgFile);
249 if (len)
250 {
251 fseek(cfgFile, 0, SEEK_SET);
252 char* p = session.ses_config.getBuffer(len + 1);
253
254 if (fread(p, 1, len, cfgFile) != size_t(len)) {
255 checkFileError(configFileName.c_str(), "fread", isc_io_read_err);
256 }
257 p[len] = 0;
258 }
259 else
260 {
261 gds__log("Audit configuration file \"%s\" is empty", configFileName.c_str());
262 return;
263 }
264
265 session.ses_user = DBA_USER_NAME;
266 session.ses_name = "Firebird Audit";
267 session.ses_flags = trs_admin | trs_system;
268

Callers

nothing calls this directly

Calls 12

checkFileErrorFunction · 0.85
getDefaultMemoryPoolFunction · 0.85
fseekFunction · 0.85
ftellFunction · 0.85
iscLogExceptionFunction · 0.85
alltrimMethod · 0.80
fopenFunction · 0.50
getHeaderMethod · 0.45
emptyMethod · 0.45
insertMethod · 0.45
c_strMethod · 0.45
getBufferMethod · 0.45

Tested by

no test coverage detected