2013-02-08 01:45:26 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _LOGD_LOG_AUDIT_H__
|
|
|
|
#define _LOGD_LOG_AUDIT_H__
|
|
|
|
|
2017-08-15 20:07:49 +02:00
|
|
|
#include <map>
|
2017-01-03 23:00:19 +01:00
|
|
|
|
2013-02-08 01:45:26 +01:00
|
|
|
#include <sysutils/SocketListener.h>
|
2016-02-23 17:55:43 +01:00
|
|
|
|
|
|
|
#include "LogBuffer.h"
|
|
|
|
|
|
|
|
class LogReader;
|
2013-02-08 01:45:26 +01:00
|
|
|
|
|
|
|
class LogAudit : public SocketListener {
|
2017-03-10 23:31:54 +01:00
|
|
|
LogBuffer* logbuf;
|
|
|
|
LogReader* reader;
|
|
|
|
int fdDmesg; // fdDmesg >= 0 is functionally bool dmesg
|
2016-12-30 00:16:06 +01:00
|
|
|
bool main;
|
|
|
|
bool events;
|
2014-10-13 18:59:37 +02:00
|
|
|
bool initialized;
|
2013-02-08 01:45:26 +01:00
|
|
|
|
2017-03-10 23:31:54 +01:00
|
|
|
public:
|
|
|
|
LogAudit(LogBuffer* buf, LogReader* reader, int fdDmesg);
|
|
|
|
int log(char* buf, size_t len);
|
|
|
|
bool isMonotonic() {
|
|
|
|
return logbuf->isMonotonic();
|
|
|
|
}
|
2013-02-08 01:45:26 +01:00
|
|
|
|
2017-03-10 23:31:54 +01:00
|
|
|
protected:
|
|
|
|
virtual bool onDataAvailable(SocketClient* cli);
|
2013-02-08 01:45:26 +01:00
|
|
|
|
2017-03-10 23:31:54 +01:00
|
|
|
private:
|
2013-02-08 01:45:26 +01:00
|
|
|
static int getLogSocket();
|
2017-08-15 20:07:49 +02:00
|
|
|
std::map<std::string, std::string> populateDenialMap();
|
|
|
|
std::string denialParse(const std::string& denial, char terminator,
|
|
|
|
const std::string& search_term);
|
2018-05-03 23:57:39 +02:00
|
|
|
void auditParse(const std::string& string, uid_t uid, std::string* bug_num);
|
2017-03-10 23:31:54 +01:00
|
|
|
int logPrint(const char* fmt, ...)
|
|
|
|
__attribute__((__format__(__printf__, 2, 3)));
|
2013-02-08 01:45:26 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|