New APIs will be added by another commit.
CLI and speed-test will be commented until new APIs are added.
Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
Change-Id: Ia71f5cdf85d7dc7269df638fe42c6e3e9c53f7a7
SET(PC_FILE "${PROJECT_NAME}.pc")
SET(SOURCES client.cpp
- discretionary-access-control.cpp
- mandatory-access-control.cpp
- system-call.cpp
- user.cpp
rule-management.cpp
- audit-trail/dac.cpp
- audit-trail/mac.cpp
- audit-trail/user.cpp
- audit-trail/syscall.cpp
audit-trail/audit-trail.cpp
audit-trail/rule-management.cpp
)
SET(CAPI_INCLUDE_FILES audit-trail/audit-trail.h
- audit-trail/dac.h
- audit-trail/mac.h
- audit-trail/user.h
- audit-trail/syscall.h
audit-trail/rule-management.h
)
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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
- */
-#include <cstring>
-
-#include "debug.h"
-#include "dac.h"
-
-#include "client.h"
-#include "rmi/discretionary-access-control.h"
-
-using namespace AuditTrail;
-
-int audit_trail_foreach_dac(audit_trail_h handle, audit_trail_dac_cb callback, void *user_data)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(callback, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- AuditTrailContext &client = GetAuditTrailContext(handle);
- auto dac = client.createInterface<DiscretionaryAccessControl>();
-
- int end = dac.size();
- for (int i = 0; i < end; i++) {
- auto log(dac.get(i));
- if (log.subject.name.size() > 0) {
- callback(&log, user_data);
- }
- }
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_clear_dac(audit_trail_h handle)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- AuditTrailContext &client = GetAuditTrailContext(handle);
- auto dac = client.createInterface<DiscretionaryAccessControl>();
- dac.clear();
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_add_dac_cb(audit_trail_h handle, audit_trail_dac_cb callback, void* user_data, int *id)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(callback, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- AuditTrailContext &client = GetAuditTrailContext(handle);
- int ret = client.subscribeNotification("DiscretionaryAccessControl",
- [callback, user_data, &client] (std::string name, int position)
- {
- auto dac = client.createInterface<DiscretionaryAccessControl>();
- auto log(dac.get(position));
- callback(&log, user_data);
- });
- if (ret < 0)
- return AUDIT_TRAIL_ERROR_INVALID_PARAMETER;
-
- *id = ret;
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_remove_dac_cb(audit_trail_h handle, int callback_id)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(callback_id >= 0, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- AuditTrailContext &context = GetAuditTrailContext(handle);
- int ret = context.unsubscribeNotification(callback_id);
- if (ret)
- return AUDIT_TRAIL_ERROR_INVALID_PARAMETER;
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_enable_dac(audit_trail_h handle, bool en)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- AuditTrailContext &client = GetAuditTrailContext(handle);
- auto dac = client.createInterface<DiscretionaryAccessControl>();
-
- int ret = dac.enable(en);
- if (ret)
- return AUDIT_TRAIL_ERROR_INVALID_PARAMETER;
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_is_enabled_dac(audit_trail_h handle, bool *en)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(en, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- AuditTrailContext &client = GetAuditTrailContext(handle);
- auto dac = client.createInterface<DiscretionaryAccessControl>();
- *en = dac.isEnabled();
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_get_dac_time(audit_trail_dac_h handle, time_t *time, unsigned short *ms)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(time, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(ms, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- const auto *pAudit = (DiscretionaryAccessControl::AuditTrail*)handle;
- *time = pAudit->time.time;
- *ms = pAudit->time.millisec;
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_get_dac_subject_name(audit_trail_dac_h handle, const char **name)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(name, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- const auto *pAudit = (DiscretionaryAccessControl::AuditTrail*)handle;
- *name = pAudit->subject.name.c_str();
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_get_dac_subject_owner(audit_trail_dac_h handle, uid_t *uid, gid_t *gid)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(uid, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(gid, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- const auto *pAudit = (DiscretionaryAccessControl::AuditTrail*)handle;
- *uid = pAudit->subject.uid;
- *gid = pAudit->subject.gid;
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_get_dac_subject_effective_owner(audit_trail_dac_h handle, uid_t *euid, gid_t *egid)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(euid, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(egid, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- const auto *pAudit = (DiscretionaryAccessControl::AuditTrail*)handle;
- *euid = pAudit->subject.euid;
- *egid = pAudit->subject.egid;
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_get_dac_subject_pid(audit_trail_dac_h handle, pid_t *pid)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(pid, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- const auto *pAudit = (DiscretionaryAccessControl::AuditTrail*)handle;
- *pid = pAudit->subject.pid;
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_get_dac_object_name(audit_trail_dac_h handle, const char **name)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(name, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- const auto *pAudit = (DiscretionaryAccessControl::AuditTrail*)handle;
- *name = pAudit->object.name.c_str();
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_get_dac_object_owner(audit_trail_dac_h handle, uid_t *uid, gid_t *gid)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(uid, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(gid, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- const auto *pAudit = (DiscretionaryAccessControl::AuditTrail*)handle;
- *uid = pAudit->object.uid;
- *gid = pAudit->object.gid;
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_get_dac_object_mode(audit_trail_dac_h handle, mode_t *mode){
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(mode, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- const auto *pAudit = (DiscretionaryAccessControl::AuditTrail*)handle;
- *mode = pAudit->object.mode;
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_get_dac_action_syscall(audit_trail_dac_h handle, unsigned int *syscall)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(syscall, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- const auto *pAudit = (DiscretionaryAccessControl::AuditTrail*)handle;
- *syscall = pAudit->action.systemCall;
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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 __CAPI_AUDIT_TRAIL_DAC_H__
-#define __CAPI_AUDIT_TRAIL_DAC_H__
-
-#include <time.h>
-#include <unistd.h>
-#include <sys/stat.h>
-
-#include <audit-trail/audit-trail.h>
-
-/**
- * @file dac.h
- * @brief This file provides APIs to get DAC(Discretionary Access Control) logs
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @addtogroup DAC Discretionary Access Control
- * @{
- */
-
-/**
- * @brief The audit-trail DAC log handle
- * @details The audit-trail DAC log handle is an abstraction of the DAC log
- * data. This can be used to get information of each log.
- * This must be used in audit_trail_dac_cb() and not be freed,
- * because this will be freed internally.
- * @since_tizen 5.0
- * @see audit_trail_dac_cb()
- */
-typedef void* audit_trail_dac_h;
-
-/**
- * @brief Called to get all DAC logs in an array
- * @since_tizen 5.0
- * @param[in] handle The handle of each DAC logs
- * @param[in] user_data The user data passed from the function
- * @see audit_trail_add_dac_cb
- * @see audit_trail_remove_dac_cb
- * @see audit_trail_foreach_dac
- */
-typedef void (*audit_trail_dac_cb)(audit_trail_dac_h handle, void* user_data);
-
-/**
- * @brief Retrieves all DAC logs that occured in system.
- * @details This API calls audit_trail_dac_cb() once for each DAC
- * (Discretionary Access Control) logs collected by audit-trail
- * when DAC auditing is enabled.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail handle
- * @param[in] callback The iteration callback function
- * @param[in] user_data The user data passed to the callback function
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre The handle must be created by audit_trail_create().
- * @see audit_trail_create()
- * @see audit_trail_destroy()
- * @see audit_trail_enable_dac()
- */
-AUDIT_TRAIL_API int audit_trail_foreach_dac(audit_trail_h handle, audit_trail_dac_cb callback, void *user_data);
-
-/**
- * @brief Clears all DAC logs saved in audit-trail.
- * @details This API removes all DAC(Discretionary Access Control) logs
- * collected by audit-trail.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail handle
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre The handle must be created by audit_trail_create().
- * @see audit_trail_create()
- * @see audit_trail_destroy()
- * @see audit_trail_foreach_dac()
- */
-AUDIT_TRAIL_API int audit_trail_clear_dac(audit_trail_h handle);
-
-/**
- * @brief Adds a DAC log callback.
- * @details This API can be used to receive DAC(Discretionary Access
- * Control) logs of system. The callback specified to this
- * function is automatically called when a new log occurs.
- * @since_tizen 5.0
- * @param[in] context The audit_trail handle
- * @param[in] callback The callback to get DAC(Discretionary Access Control) logs
- * @param[in] user_data The user data passed to the callback function
- * @param[out] id Callback identifier
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @pre The handle must be created by audit_trail_create().
- * @pre DAC auditing must be enabled by audit_trail_enable_dac().
- * @see audit_trail_create()
- * @see audit_trail_destroy()
- * @see audit_trail_enable_dac()
- * @see audit_trail_remove_dac_cb()
- */
-AUDIT_TRAIL_API int audit_trail_add_dac_cb(audit_trail_h handle,
- audit_trail_dac_cb callback, void* user_data,
- int* id);
-
-/**
- * @brief Removes the DAC log callback.
- * @details This API can be used to remove the DAC(Discretionary Access
- * Control) logs callback.
- * @since_tizen 5.0
- * @param[in] context The audit trail handle
- * @param[in] id Callback identifier
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @pre The context must be created by audit_trail_create().
- * @see audit_trail_create()
- * @see audit_trail_destroy()
- * @see audit_trail_add_dac_cb()
- */
-AUDIT_TRAIL_API int audit_trail_remove_dac_cb(audit_trail_h handle, int id);
-
-/**
- * @brief Enables DAC auditing.
- * @details This API can be used to enable to collect the DAC(Discretionary
- * Access Control) logs. Any DAC log will not be collected
- * until auditing is enabled
- * @since_tizen 5.0
- * @param[in] handle The audit-trail handle
- * @param[in] en True enables DAC auditing, Otherwise disables
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre The handle must be created by audit_trail_create().
- * @see audit_trail_create()
- * @see audit_trail_destroy()
- * @see audit_trail_foreach_dac()
- * @see audit_trail_add_dac_cb()
- */
-AUDIT_TRAIL_API int audit_trail_enable_dac(audit_trail_h handle, bool en);
-
-/**
- * @brief Retrieves if DAC auditing is enabled.
- * @details This API can be used to know if DAC(Discretionary Access
- * Control) auditing is enabled now.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail handle
- * @param[out] en If true, DAC auditing was enabled, Otherwise disabled
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre The handle must be created by audit_trail_create().
- * @see audit_trail_create()
- * @see audit_trail_destroy()
- */
-AUDIT_TRAIL_API int audit_trail_is_enabled_dac(audit_trail_h handle, bool *en);
-
-/**
- * @brief Get the time of the DAC log
- * @details This API can be used to get when the DAC log occured.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail DAC log handle
- * @param[out] time The time as UNIX epoch timestamp
- * @param[out] ms milliseconds of the time
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- */
-AUDIT_TRAIL_API int audit_trail_get_dac_time(audit_trail_dac_h handle, time_t *time, unsigned short *ms);
-
-/**
- * @brief Get the subject name of the DAC log
- * @details This API can be used to get the subject names in each DAC logs.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail DAC log handle
- * @param[out] name The subject name
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @post The subject name must not be freed.
- */
-AUDIT_TRAIL_API int audit_trail_get_dac_subject_name(audit_trail_dac_h handle, const char **name);
-
-/**
- * @brief Get subject owner's user and group ID of the DAC log
- * @details This API can be used to get subject owner's user ID and group ID
- * in each DAC logs.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail DAC log handle
- * @param[out] uid The subject user ID
- * @param[out] gid The subject group ID
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- */
-AUDIT_TRAIL_API int audit_trail_get_dac_subject_owner(audit_trail_dac_h handle, uid_t *uid, gid_t *gid);
-
-/**
- * @brief Get subject effective owner's user and group ID of the DAC log
- * @details This API can be used to get subject effective owner's user and
- * group ID in each DAC logs.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail DAC log handle
- * @param[out] euid The subject effective user ID
- * @param[out] egid The subject effective group ID
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- */
-AUDIT_TRAIL_API int audit_trail_get_dac_subject_effective_owner(audit_trail_dac_h handle, uid_t *euid, gid_t *egid);
-
-/**
- * @brief Get the subject process ID of the DAC log
- * @details This API can be used to get the subject process ID in
- * each DAC logs.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail DAC log handle
- * @param[out] pid The subject process ID
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- */
-AUDIT_TRAIL_API int audit_trail_get_dac_subject_pid(audit_trail_dac_h handle, pid_t *pid);
-
-/**
- * @brief Get the object name of the DAC log
- * @details This API can be used to get the object names in each DAC logs.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail DAC log handle
- * @param[out] name The object name
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @post The object name must not be freed.
- */
-AUDIT_TRAIL_API int audit_trail_get_dac_object_name(audit_trail_dac_h handle, const char **name);
-
-/**
- * @brief Get object owner's user and group ID of the DAC log
- * @details This API can be used to get object owner's user ID and group ID
- * in each DAC logs.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail DAC log handle
- * @param[out] uid The object user ID if exists, otherwise UINT_MAX
- * @param[out] gid The object group ID if exists, otherwise UINT_MAX
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- */
-AUDIT_TRAIL_API int audit_trail_get_dac_object_owner(audit_trail_dac_h handle, uid_t *uid, gid_t *gid);
-
-/**
- * @brief Get object file mode bits of the DAC log
- * @details This API can be used to get object file mode bits in each DAC
- * logs.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail DAC log handle
- * @param[out] mode The object file mode bits if exists, otherwise UINT_MAX
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- */
-AUDIT_TRAIL_API int audit_trail_get_dac_object_mode(audit_trail_dac_h handle, mode_t *mode);
-
-/**
- * @brief Get the system call number of the DAC log
- * @details This API can be used to get the system call number in each DAC
- * logs.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail DAC log handle
- * @param[out] syscall the system call number
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- */
-AUDIT_TRAIL_API int audit_trail_get_dac_action_syscall(audit_trail_dac_h handle, unsigned int *syscall);
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __CAPI_AUDIT_TRAIL_DAC_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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
- */
-#include <cstring>
-
-#include "debug.h"
-#include "mac.h"
-
-#include "client.h"
-#include "rmi/mandatory-access-control.h"
-
-using namespace AuditTrail;
-
-int audit_trail_foreach_mac(audit_trail_h handle, audit_trail_mac_cb callback, void *user_data)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(callback, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- AuditTrailContext &client = GetAuditTrailContext(handle);
- auto mac = client.createInterface<MandatoryAccessControl>();
-
- int end = mac.size();
- for (int i = 0; i < end; i++) {
- auto log(mac.get(i));
- if (log.subject.name.size() > 0) {
- callback(&log, user_data);
- }
- }
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_clear_mac(audit_trail_h handle)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- AuditTrailContext &client = GetAuditTrailContext(handle);
- auto mac = client.createInterface<MandatoryAccessControl>();
- mac.clear();
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_add_mac_cb(audit_trail_h handle, audit_trail_mac_cb callback, void* user_data, int *id)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(callback, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- AuditTrailContext &client = GetAuditTrailContext(handle);
- int ret = client.subscribeNotification("MandatoryAccessControl",
- [callback, user_data, &client] (std::string name, int position)
- {
- auto mac = client.createInterface<MandatoryAccessControl>();
- auto log(mac.get(position));
- callback(&log, user_data);
- });
- if (ret < 0)
- return AUDIT_TRAIL_ERROR_INVALID_PARAMETER;
-
- *id = ret;
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_remove_mac_cb(audit_trail_h handle, int callback_id)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(callback_id >= 0, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- AuditTrailContext &client = GetAuditTrailContext(handle);
- int ret = client.unsubscribeNotification(callback_id);
- if (ret)
- return AUDIT_TRAIL_ERROR_INVALID_PARAMETER;
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_enable_mac(audit_trail_h handle, bool en)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- AuditTrailContext &client = GetAuditTrailContext(handle);
- auto mac = client.createInterface<MandatoryAccessControl>();
-
- int ret = mac.enable(en);
- if (ret)
- return AUDIT_TRAIL_ERROR_INVALID_PARAMETER;
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_is_enabled_mac(audit_trail_h handle, bool *en)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(en, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- AuditTrailContext &client = GetAuditTrailContext(handle);
- auto mac = client.createInterface<MandatoryAccessControl>();
- *en = mac.isEnabled();
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_get_mac_time(audit_trail_mac_h handle, time_t *time, unsigned short *ms)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(time, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(ms, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- const auto *pAudit = (MandatoryAccessControl::AuditTrail*)handle;
- *time = pAudit->time.time;
- *ms = pAudit->time.millisec;
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_get_mac_subject_name(audit_trail_mac_h handle, const char **name)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(name, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- const auto *pAudit = (MandatoryAccessControl::AuditTrail*)handle;
- *name = pAudit->subject.name.c_str();
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_get_mac_subject_label(audit_trail_mac_h handle, const char **label)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(label, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- const auto *pAudit = (MandatoryAccessControl::AuditTrail*)handle;
- *label = pAudit->subject.label.c_str();
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_get_mac_subject_pid(audit_trail_mac_h handle, pid_t *pid)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(pid, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- const auto *pAudit = (MandatoryAccessControl::AuditTrail*)handle;
- *pid = pAudit->subject.pid;
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_get_mac_object_name(audit_trail_mac_h handle, const char **name)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(name, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- const auto *pAudit = (MandatoryAccessControl::AuditTrail*)handle;
- *name = pAudit->object.name.c_str();
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_get_mac_object_label(audit_trail_mac_h handle, const char **label)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(label, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- const auto *pAudit = (MandatoryAccessControl::AuditTrail*)handle;
- *label = pAudit->object.label.c_str();
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_get_mac_action_syscall(audit_trail_mac_h handle, unsigned int *syscall)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(syscall, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- const auto *pAudit = (MandatoryAccessControl::AuditTrail*)handle;
- *syscall = pAudit->action.systemCall;
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_get_mac_action_request(audit_trail_mac_h handle, const char **req)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(req, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- const auto *pAudit = (MandatoryAccessControl::AuditTrail*)handle;
- *req = pAudit->action.request.c_str();
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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 __CAPI_AUDIT_TRAIL_MAC_H__
-#define __CAPI_AUDIT_TRAIL_MAC_H__
-
-#include <time.h>
-#include <unistd.h>
-
-#include <audit-trail/audit-trail.h>
-
-/**
- * @file mac.h
- * @brief This file provides APIs to get MAC(Mandatory Access Control) logs
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @addtogroup MAC Mandatory Access Control
- * @{
- */
-
-/**
- * @brief The audit-trail MAC log handle
- * @details The audit-trail MAC log handle is an abstraction of the MAC log
- * data. This can be used to get information of each log.
- * This must be used only in audit_trail_mac_cb() and not be freed,
- * because this will be freed internally.
- * @since_tizen 5.0
- * @see audit_trail_mac_cb()
- */
-typedef void* audit_trail_mac_h;
-
-/**
- * @brief Called to get all MAC logs in an array
- * @since_tizen 5.0
- * @param[in] handle The handle of each MAC logs
- * @param[in] user_data The user data passed from the function
- * @see audit_trail_add_mac_cb
- * @see audit_trail_remove_mac_cb
- * @see audit_trail_foreach_mac
- */
-typedef void (*audit_trail_mac_cb)(audit_trail_mac_h handle, void* user_data);
-
-/**
- * @brief Retrieves all MAC logs that occured in system.
- * @details This API calls audit_trail_mac_cb() once for each MAC
- * (Mandatory Access Control) logs collected by audit-trail
- * when MAC auditing is enabled.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail handle
- * @param[in] callback The iteration callback function
- * @param[in] user_data The user data passed to the callback function
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre The handle must be created by audit_trail_create().
- * @see audit_trail_create()
- * @see audit_trail_destroy()
- * @see audit_trail_enable_mac()
- */
-AUDIT_TRAIL_API int audit_trail_foreach_mac(audit_trail_h handle, audit_trail_mac_cb callback, void *user_data);
-
-/**
- * @brief Clears all MAC logs saved in audit-trail.
- * @details This API removes all MAC(Mandatory Access Control) logs
- * collected by audit-trail.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail handle
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre The handle must be created by audit_trail_create().
- * @see audit_trail_create()
- * @see audit_trail_destroy()
- * @see audit_trail_foreach_mac()
- */
-AUDIT_TRAIL_API int audit_trail_clear_mac(audit_trail_h handle);
-
-/**
- * @brief Adds a MAC log callback.
- * @details This API can be used to receive MAC(Mandatory Access Control)
- * logs of system. The callback specified to this function is
- * automatically called when a new log occurs.
- * @since_tizen 5.0
- * @param[in] context The audit_trail handle
- * @param[in] callback The callback to get MAC(Mandatory Access Control) logs
- * @param[in] user_data The user data passed to the callback function
- * @param[out] id Callback identifier
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @pre The handle must be created by audit_trail_create().
- * @pre MAC auditing must be enabled by audit_trail_enable_mac().
- * @see audit_trail_create()
- * @see audit_trail_destroy()
- * @see audit_trail_remove_mac_cb()
- */
-AUDIT_TRAIL_API int audit_trail_add_mac_cb(audit_trail_h handle,
- audit_trail_mac_cb callback, void* user_data,
- int* id);
-
-/**
- * @brief Removes the MAC log callback.
- * @details This API can be used to remove the MAC(Mandatory Access
- * Control) logs callback.
- * @since_tizen 5.0
- * @param[in] context The audit trail handle
- * @param[in] id Callback identifier
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @pre The context must be created by audit_trail_create().
- * @see audit_trail_create()
- * @see audit_trail_destroy()
- * @see audit_trail_add_mac_cb()
- */
-AUDIT_TRAIL_API int audit_trail_remove_mac_cb(audit_trail_h handle, int id);
-
-/**
- * @brief Enables MAC auditing.
- * @details This API can be used to enable to collect the MAC(Mandatory
- * Access Control) logs. Any MAC log will not be collected
- * until auditing is enabled
- * @since_tizen 5.0
- * @param[in] handle The audit-trail handle
- * @param[in] en True enables MAC auditing, Otherwise disables
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre The handle must be created by audit_trail_create().
- * @see audit_trail_create()
- * @see audit_trail_destroy()
- * @see audit_trail_mac_syscall()
- * @see audit_trail_add_mac_cb()
- */
-AUDIT_TRAIL_API int audit_trail_enable_mac(audit_trail_h handle, bool en);
-
-/**
- * @brief Retrieves if MAC auditing is enabled.
- * @details This API can be used to know if MAC(Mandatory Access Control)
- * auditing is enabled now.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail handle
- * @param[out] en If true, MAC auditing was enabled, Otherwise disabled
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre The handle must be created by audit_trail_create().
- * @see audit_trail_create()
- * @see audit_trail_destroy()
- */
-AUDIT_TRAIL_API int audit_trail_is_enabled_mac(audit_trail_h handle, bool *en);
-
-/**
- * @brief Get the time of the MAC log
- * @details This API can be used to get when the MAC log occured.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail MAC log handle
- * @param[out] time The time as UNIX epoch timestamp
- * @param[out] ms milliseconds of the time
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- */
-AUDIT_TRAIL_API int audit_trail_get_mac_time(audit_trail_mac_h handle, time_t *time, unsigned short *ms);
-
-/**
- * @brief Get the subject name of the MAC log
- * @details This API can be used to get the subject names in each MAC logs.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail MAC log handle
- * @param[out] name The subject name
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @post The subject name must not be freed.
- */
-AUDIT_TRAIL_API int audit_trail_get_mac_subject_name(audit_trail_mac_h handle, const char **name);
-
-/**
- * @brief Get the subject label of the MAC log
- * @details This API can be used to get the subject labels in each MAC logs.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail MAC log handle
- * @param[out] label The subject label
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @post The subject label must not be freed.
- */
-AUDIT_TRAIL_API int audit_trail_get_mac_subject_label(audit_trail_mac_h handle, const char **label);
-
-/**
- * @brief Get the subject process ID of the MAC log
- * @details This API can be used to get the subject process ID in
- * each MAC logs.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail MAC log handle
- * @param[out] pid The subject process ID
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- */
-AUDIT_TRAIL_API int audit_trail_get_mac_subject_pid(audit_trail_mac_h handle, pid_t *pid);
-
-/**
- * @brief Get the object name of the MAC log
- * @details This API can be used to get the object names in each MAC logs.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail MAC log handle
- * @param[out] name The object name
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @post The object name must not be freed.
- */
-AUDIT_TRAIL_API int audit_trail_get_mac_object_name(audit_trail_mac_h handle, const char **name);
-
-/**
- * @brief Get the object label of the MAC log
- * @details This API can be used to get the object labels in each MAC logs.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail MAC log handle
- * @param[out] label The object label
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @post The object label must not be freed.
- */
-AUDIT_TRAIL_API int audit_trail_get_mac_object_label(audit_trail_mac_h handle, const char **label);
-
-/**
- * @brief Get the function name of the MAC log
- * @details This API can be used to get the function that causes a MAC log.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail MAC log handle
- * @param[out] syscall the system call number
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @post The function name must not be freed.
- */
-AUDIT_TRAIL_API int audit_trail_get_mac_action_syscall(audit_trail_mac_h handle, unsigned int *syscall);
-
-/**
- * @brief Get what operation is requested by the function of the MAC log
- * @details This API can be used to get what operation such as rwx (Read,
- * Write, eXcute) is requested by the function that causes a NAC
- * log.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail MAC log handle
- * @param[out] req The requested operation
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @post The requested operation must not be freed.
- */
-AUDIT_TRAIL_API int audit_trail_get_mac_action_request(audit_trail_mac_h handle, const char **req);
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __CAPI_AUDIT_TRAIL_MAC_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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
- */
-#include <cstring>
-
-#include "debug.h"
-#include "syscall.h"
-
-#include "client.h"
-#include "rmi/system-call.h"
-
-using namespace AuditTrail;
-
-int audit_trail_foreach_syscall(audit_trail_h handle, audit_trail_syscall_cb callback, void *user_data)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(callback, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- AuditTrailContext &client = GetAuditTrailContext(handle);
- SystemCall syscall = client.createInterface<SystemCall>();
-
- int end = syscall.size();
- for (int i = 0; i < end; i++) {
- auto log(syscall.get(i));
- if (log.subject.name.size() > 0) {
- callback(&log, user_data);
- }
- }
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_clear_syscall(audit_trail_h handle)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- AuditTrailContext &client = GetAuditTrailContext(handle);
- SystemCall syscall = client.createInterface<SystemCall>();
- syscall.clear();
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_add_syscall_cb(audit_trail_h handle, audit_trail_syscall_cb callback, void* user_data, int *id)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(callback, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- AuditTrailContext &client = GetAuditTrailContext(handle);
- int ret = client.subscribeNotification("SystemCall",
- [callback, user_data, &client] (std::string name, int position)
- {
- auto syscall = client.createInterface<SystemCall>();
- auto log(syscall.get(position));
- callback(&log, user_data);
- });
- if (ret < 0)
- return AUDIT_TRAIL_ERROR_INVALID_PARAMETER;
-
- *id = ret;
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_remove_syscall_cb(audit_trail_h handle, int callback_id)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(callback_id >= 0, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- AuditTrailContext &client = GetAuditTrailContext(handle);
- int ret = client.unsubscribeNotification(callback_id);
- if (ret)
- return AUDIT_TRAIL_ERROR_INVALID_PARAMETER;
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_enable_syscall(audit_trail_h handle, bool en)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- AuditTrailContext &client = GetAuditTrailContext(handle);
- auto syscall = client.createInterface<SystemCall>();
-
- int ret = syscall.enable(en);
- if (ret)
- return AUDIT_TRAIL_ERROR_INVALID_PARAMETER;
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_is_enabled_syscall(audit_trail_h handle, bool *en)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(en, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- AuditTrailContext &client = GetAuditTrailContext(handle);
- auto syscall = client.createInterface<SystemCall>();
- *en = syscall.isEnabled();
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_get_syscall_time(audit_trail_syscall_h handle, time_t *time, unsigned short *ms)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(time, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(ms, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- const auto *pAudit = (SystemCall::AuditTrail*)handle;
- *time = pAudit->time.time;
- *ms = pAudit->time.millisec;
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_get_syscall_subject_name(audit_trail_syscall_h handle, const char **name)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(name, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- const auto *pAudit = (SystemCall::AuditTrail*)handle;
- *name = pAudit->subject.name.c_str();
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_get_syscall_subject_owner(audit_trail_syscall_h handle, uid_t *uid, gid_t *gid)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(uid, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(gid, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- const auto *pAudit = (SystemCall::AuditTrail*)handle;
- *uid = pAudit->subject.uid;
- *gid = pAudit->subject.gid;
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_get_syscall_subject_effective_owner(audit_trail_syscall_h handle, uid_t *euid, gid_t *egid)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(euid, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(egid, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- const auto *pAudit = (SystemCall::AuditTrail*)handle;
- *euid = pAudit->subject.euid;
- *egid = pAudit->subject.egid;
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_get_syscall_subject_pid(audit_trail_syscall_h handle, pid_t *pid)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(pid, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- const auto *pAudit = (SystemCall::AuditTrail*)handle;
- *pid = pAudit->subject.pid;
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_get_syscall_action_syscall(audit_trail_syscall_h handle, unsigned int *syscall)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(syscall, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- const auto *pAudit = (SystemCall::AuditTrail*)handle;
- *syscall = pAudit->action.systemCall;
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_get_syscall_action_exitcode(audit_trail_syscall_h handle, unsigned int *exit)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(exit, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- const auto *pAudit = (SystemCall::AuditTrail*)handle;
- *exit = pAudit->action.exitCode;
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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 __CAPI_AUDIT_TRAIL_SYSTEM_CALL_H__
-#define __CAPI_AUDIT_TRAIL_SYSTEM_CALL_H__
-
-#include <time.h>
-#include <unistd.h>
-
-#include <audit-trail/audit-trail.h>
-
-/**
- * @file syscall.h
- * @brief This file provides APIs to get system call logs
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @addtogroup System-call
- * @{
- */
-
-/**
- * @brief The audit-trail system call log handle
- * @details The audit-trail system call log handle is an abstraction of the system call log
- * data. This can be used to get information of each log.
- * This must be used in audit_trail_syscall_cb() and not be freed,
- * because this will be freed internally.
- * internally.
- * @since_tizen 5.0
- * @see audit_trail_syscall_cb()
- */
-typedef void* audit_trail_syscall_h;
-
-/**
- * @brief Called to get all system call logs in an array
- * @since_tizen 5.0
- * @param[in] handle The handle of each system call logs
- * @param[in] user_data The user data passed from the function
- * @see audit_trail_add_syscall_cb
- * @see audit_trail_remove_syscall_cb
- * @see audit_trail_foreach_syscall
- */
-typedef void (*audit_trail_syscall_cb)(audit_trail_syscall_h handle, void* user_data);
-
-/**
- * @brief Retrieves all system call logs that occured in system.
- * @details This API calls audit_trail_syscall_cb() once for each system
- * call logs collected by audit-trail when system call auditing
- * is enabled.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail handle
- * @param[in] callback The iteration callback function
- * @param[in] user_data The user data passed to the callback function
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre The handle must be created by audit_trail_create().
- * @see audit_trail_create()
- * @see audit_trail_destroy()
- * @see audit_trail_enable_syscall()
- */
-AUDIT_TRAIL_API int audit_trail_foreach_syscall(audit_trail_h handle, audit_trail_syscall_cb callback, void *user_data);
-
-/**
- * @brief Clears all system call logs saved in audit-trail.
- * @details This API removes all system call logs
- * collected by audit-trail.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail handle
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre The handle must be created by audit_trail_create().
- * @see audit_trail_create()
- * @see audit_trail_destroy()
- * @see audit_trail_foreach_syscall()
- */
-AUDIT_TRAIL_API int audit_trail_clear_syscall(audit_trail_h handle);
-
-/**
- * @brief Adds a system call log callback.
- * @details This API can be used to receive system call logs of system.
- * The callback specified to this function is automatically called
- * when a new log occurs.
- * @since_tizen 5.0
- * @param[in] context The audit_trail handle
- * @param[in] callback The callback to get system call logs
- * @param[in] user_data The user data passed to the callback function
- * @param[out] id Callback identifier
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @pre The handle must be created by audit_trail_create().
- * @pre System call auditing must be enabled by
- * audit_trail_enable_syscall().
- * @see audit_trail_create()
- * @see audit_trail_destroy()
- * @see audit_trail_enable_syscall()
- * @see audit_trail_remove_syscall_cb()
- */
-AUDIT_TRAIL_API int audit_trail_add_syscall_cb(audit_trail_h handle,
- audit_trail_syscall_cb callback, void* user_data,
- int* id);
-
-/**
- * @brief Removes the system call log callback.
- * @details This API can be used to remove the system call logs callback.
- * @since_tizen 5.0
- * @param[in] context The audit trail handle
- * @param[in] id Callback identifier
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @pre The context must be created by audit_trail_create().
- * @see audit_trail_create()
- * @see audit_trail_destroy()
- * @see audit_trail_add_syscall_cb()
- */
-AUDIT_TRAIL_API int audit_trail_remove_syscall_cb(audit_trail_h handle, int id);
-
-/**
- * @brief Enables system call auditing.
- * @details This API can be used to enable to collect the system call logs.
- * Any system call log will not be collected until auditing is
- * enabled
- * @since_tizen 5.0
- * @param[in] handle The audit-trail handle
- * @param[in] en True enables system call auditing, Otherwise disables
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre The handle must be created by audit_trail_create().
- * @see audit_trail_create()
- * @see audit_trail_destroy()
- * @see audit_trail_foreach_syscall()
- * @see audit_trail_add_syscall_cb()
- */
-AUDIT_TRAIL_API int audit_trail_enable_syscall(audit_trail_h handle, bool en);
-
-/**
- * @brief Retrieves if system call auditing is enabled.
- * @details This API can be used to know if system call auditing is
- * enabled now.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail handle
- * @param[out] en If true, system call auditing was enabled, Otherwise disabled
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre The handle must be created by audit_trail_create().
- * @see audit_trail_create()
- * @see audit_trail_destroy()
- */
-AUDIT_TRAIL_API int audit_trail_is_enabled_syscall(audit_trail_h handle, bool *en);
-
-/**
- * @brief Get the time of the system call log
- * @details This API can be used to get when the system call log occured.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail system call log handle
- * @param[out] time The time as UNIX epoch timestamp
- * @param[out] ms milliseconds of the time
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- */
-AUDIT_TRAIL_API int audit_trail_get_syscall_time(audit_trail_syscall_h handle, time_t *time, unsigned short *ms);
-
-/**
- * @brief Get the subject name of the system call log
- * @details This API can be used to get the subject names in each system call logs.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail system call log handle
- * @param[out] name The subject name
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @post The subject name must not be freed.
- */
-AUDIT_TRAIL_API int audit_trail_get_syscall_subject_name(audit_trail_syscall_h handle, const char **name);
-
-/**
- * @brief Get subject owner's user and group ID of the system call log
- * @details This API can be used to get subject owner's user ID and group ID
- * in each system call logs.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail system call log handle
- * @param[out] uid The subject user ID
- * @param[out] gid The subject group ID
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- */
-AUDIT_TRAIL_API int audit_trail_get_syscall_subject_owner(audit_trail_syscall_h handle, uid_t *uid, gid_t *gid);
-
-/**
- * @brief Get subject effective owner's user and group ID of the system call log
- * @details This API can be used to get subject effective owner's user and
- * group ID in each system call logs.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail system call log handle
- * @param[out] euid The subject effective user ID
- * @param[out] egid The subject effective group ID
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- */
-AUDIT_TRAIL_API int audit_trail_get_syscall_subject_effective_owner(audit_trail_syscall_h handle, uid_t *euid, gid_t *egid);
-
-/**
- * @brief Get the subject process ID of the system call log
- * @details This API can be used to get the subject process ID in
- * each system call logs.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail system call log handle
- * @param[out] pid The subject process ID
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- */
-AUDIT_TRAIL_API int audit_trail_get_syscall_subject_pid(audit_trail_syscall_h handle, pid_t *pid);
-
-/**
- * @brief Get the system call number of the system call log
- * @details This API can be used to get the system call number in each system call
- * logs.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail system call log handle
- * @param[out] syscall the system call number
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- */
-AUDIT_TRAIL_API int audit_trail_get_syscall_action_syscall(audit_trail_syscall_h handle, unsigned int *syscall);
-
-/**
- * @brief Get the exit code returned by system call of the system call log
- * @details This API can be used to get the exit codes returned by each
- * system call
- * logs.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail system call log handle
- * @param[out] exit The exit code
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- */
-AUDIT_TRAIL_API int audit_trail_get_syscall_action_exitcode(audit_trail_syscall_h handle, unsigned int *exit);
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __CAPI_AUDIT_TRAIL_SYSTEM_CALL_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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
- */
-#include <cstring>
-
-#include "debug.h"
-#include "user.h"
-
-#include "client.h"
-#include "rmi/user.h"
-
-using namespace AuditTrail;
-
-int audit_trail_foreach_user(audit_trail_h handle, audit_trail_user_cb callback, void *user_data)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(callback, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- AuditTrailContext &client = GetAuditTrailContext(handle);
- User user = client.createInterface<User>();
-
- int end = user.size();
- for (int i = 0; i < end; i++) {
- auto log(user.get(i));
- if (log.log.type == 0)
- callback(&log, user_data);
- }
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_clear_user(audit_trail_h handle)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- AuditTrailContext &client = GetAuditTrailContext(handle);
- User user = client.createInterface<User>();
- user.clear();
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_add_user_cb(audit_trail_h handle, audit_trail_user_cb callback, void* user_data, int *id)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(callback, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(id, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- AuditTrailContext &client = GetAuditTrailContext(handle);
- int ret = client.subscribeNotification("User",
- [callback, user_data, &client] (std::string name, int position)
- {
- auto user = client.createInterface<User>();
- auto log(user.get(position));
- callback(&log, user_data);
- });
- if (ret < 0)
- return AUDIT_TRAIL_ERROR_INVALID_PARAMETER;
-
- *id = ret;
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_remove_user_cb(audit_trail_h handle, int callback_id)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(callback_id >= 0, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- AuditTrailContext &client = GetAuditTrailContext(handle);
- int ret = client.unsubscribeNotification(callback_id);
- if (ret)
- return AUDIT_TRAIL_ERROR_INVALID_PARAMETER;
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_enable_user(audit_trail_h handle, bool en)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- AuditTrailContext &client = GetAuditTrailContext(handle);
- auto user = client.createInterface<User>();
-
- int ret = user.enable(en);
- if (ret)
- return AUDIT_TRAIL_ERROR_INVALID_PARAMETER;
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_is_enabled_user(audit_trail_h handle, bool *en)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(en, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- AuditTrailContext &client = GetAuditTrailContext(handle);
- auto user = client.createInterface<User>();
- *en = user.isEnabled();
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_get_user_time(audit_trail_user_h handle, time_t *time, unsigned short *ms)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(time, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(ms, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- const auto *pAudit = (User::AuditTrail*)handle;
- *time = pAudit->time.time;
- *ms = pAudit->time.millisec;
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_get_user_log_type(audit_trail_user_h handle, int *type)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(type, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- const auto *pAudit = (User::AuditTrail*)handle;
- *type = pAudit->log.type;
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
-
-int audit_trail_get_user_log_text(audit_trail_user_h handle, const char **text)
-{
- RET_ON_FAILURE(handle, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
- RET_ON_FAILURE(text, AUDIT_TRAIL_ERROR_INVALID_PARAMETER);
-
- const auto *pAudit = (User::AuditTrail*)handle;
- *text = pAudit->log.text.c_str();
-
- return AUDIT_TRAIL_ERROR_NONE;
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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 __CAPI_AUDIT_TRAIL_USER_H__
-#define __CAPI_AUDIT_TRAIL_USER_H__
-
-#include <time.h>
-#include <unistd.h>
-
-#include <audit-trail/audit-trail.h>
-
-/**
- * @file user.h
- * @brief This file provides APIs to get user space logs
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @addtogroup User-space
- * @{
- */
-
-/**
- * @brief The audit-trail user space log handle
- * @details The audit-trail user space log handle is an abstraction of the user space log
- * data. This can be used to get information of each log.
- * This must be used in audit_trail_user_cb() and not be freed,
- * because this will be freed internally.
- * internally.
- * @since_tizen 5.0
- * @see audit_trail_user_cb()
- */
-typedef void* audit_trail_user_h;
-
-/**
- * @brief Called to get all user space logs in an array
- * @since_tizen 5.0
- * @param[in] handle The handle of each user space logs
- * @param[in] user_data The user data passed from the function
- * @see audit_trail_add_user_cb
- * @see audit_trail_remove_user_cb
- * @see audit_trail_foreach_user
- */
-typedef void (*audit_trail_user_cb)(audit_trail_user_h handle, void* user_data);
-
-/**
- * @brief Retrieves all user space logs that occured in system.
- * @details This API calls audit_trail_user_cb() once for each system
- * call logs collected by audit-trail when user auditing
- * is enabled.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail handle
- * @param[in] callback The iteration callback function
- * @param[in] user_data The user data passed to the callback function
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre The handle must be created by audit_trail_create().
- * @see audit_trail_create()
- * @see audit_trail_destroy()
- * @see audit_trail_enable_user()
- */
-AUDIT_TRAIL_API int audit_trail_foreach_user(audit_trail_h handle, audit_trail_user_cb callback, void *user_data);
-
-/**
- * @brief Clears all user space logs saved in audit-trail.
- * @details This API removes all user space logs
- * collected by audit-trail.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail handle
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre The handle must be created by audit_trail_create().
- * @see audit_trail_create()
- * @see audit_trail_destroy()
- * @see audit_trail_foreach_user()
- */
-AUDIT_TRAIL_API int audit_trail_clear_user(audit_trail_h handle);
-
-/**
- * @brief Adds a user space log callback.
- * @details This API can be used to receive user space logs of system.
- * The callback specified to this function is automatically called
- * when a new log occurs.
- * @since_tizen 5.0
- * @param[in] context The audit_trail handle
- * @param[in] callback The callback to get user space logs
- * @param[in] user_data The user data passed to the callback function
- * @param[out] id Callback identifier
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @pre The handle must be created by audit_trail_create().
- * @pre System call auditing must be enabled by
- * audit_trail_enable_user().
- * @see audit_trail_create()
- * @see audit_trail_destroy()
- * @see audit_trail_enable_user()
- * @see audit_trail_remove_user_cb()
- */
-AUDIT_TRAIL_API int audit_trail_add_user_cb(audit_trail_h handle,
- audit_trail_user_cb callback, void* user_data,
- int* id);
-
-/**
- * @brief Removes the user space log callback.
- * @details This API can be used to remove the user space logs callback.
- * @since_tizen 5.0
- * @param[in] context The audit trail handle
- * @param[in] id Callback identifier
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @pre The context must be created by audit_trail_create().
- * @see audit_trail_create()
- * @see audit_trail_destroy()
- * @see audit_trail_add_user_cb()
- */
-AUDIT_TRAIL_API int audit_trail_remove_user_cb(audit_trail_h handle, int id);
-
-/**
- * @brief Enables user auditing.
- * @details This API can be used to enable to collect the user space logs.
- * Any user space log will not be collected until auditing is
- * enabled
- * @since_tizen 5.0
- * @param[in] handle The audit-trail handle
- * @param[in] en True enables user auditing, Otherwise disables
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre The handle must be created by audit_trail_create().
- * @see audit_trail_create()
- * @see audit_trail_destroy()
- * @see audit_trail_foreach_user()
- * @see audit_trail_add_user_cb()
- */
-AUDIT_TRAIL_API int audit_trail_enable_user(audit_trail_h handle, bool en);
-
-/**
- * @brief Retrieves if user auditing is enabled.
- * @details This API can be used to know if user auditing is
- * enabled now.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail handle
- * @param[out] en If true, user auditing was enabled, Otherwise disabled
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre The handle must be created by audit_trail_create().
- * @see audit_trail_create()
- * @see audit_trail_destroy()
- */
-AUDIT_TRAIL_API int audit_trail_is_enabled_user(audit_trail_h handle, bool *en);
-
-/**
- * @brief Get the time of the user space log
- * @details This API can be used to get when the user space log occured.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail user space log handle
- * @param[out] time The time as UNIX epoch timestamp
- * @param[out] ms milliseconds of the time
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- */
-AUDIT_TRAIL_API int audit_trail_get_user_time(audit_trail_user_h handle, time_t *time, unsigned short *ms);
-
-/**
- * @brief Get the type number of the user space log
- * @details This API can be used to get the exit codes returned by each
- * user logs.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail user space log handle
- * @param[out] type The type number
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- */
-AUDIT_TRAIL_API int audit_trail_get_user_log_type(audit_trail_user_h handle, int *type);
-
-/**
- * @brief Get the text of the user space log
- * @details This API can be used to get the text data in each user space
- * logs, which was not parsed.
- * @since_tizen 5.0
- * @param[in] handle The audit-trail user space log handle
- * @param[out] text The text data of log
- * @return #AUDIT_TRAIL_ERROR_NONE on success, otherwise a negative value
- * @retval #AUDIT_TRAIL_ERROR_NONE Successful
- * @retval #AUDIT_TRAIL_ERROR_TIMED_OUT Time out
- * @retval #AUDIT_TRAIL_ERROR_INVALID_PARAMETER Invalid parameter
- * @post The subject name must not be freed.
- */
-AUDIT_TRAIL_API int audit_trail_get_user_log_text(audit_trail_user_h handle, const char **text);
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __CAPI_AUDIT_TRAIL_USER_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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
- */
-#include "rmi/discretionary-access-control.h"
-
-namespace AuditTrail {
-
-DiscretionaryAccessControl::DiscretionaryAccessControl(AuditTrailControlContext& ctx) :
- context(ctx)
-{
-}
-
-DiscretionaryAccessControl::~DiscretionaryAccessControl()
-{
-}
-
-DiscretionaryAccessControl::AuditTrail DiscretionaryAccessControl::get(unsigned int pos)
-{
- try {
- return context->methodCall<AuditTrail>("DiscretionaryAccessControl::get", pos);
- } catch (runtime::Exception& e) {}
- return AuditTrail();
-}
-
-unsigned int DiscretionaryAccessControl::size()
-{
- try {
- return context->methodCall<unsigned int>("DiscretionaryAccessControl::size");
- } catch (runtime::Exception& e) {}
- return 0;
-}
-
-int DiscretionaryAccessControl::clear()
-{
- try {
- return context->methodCall<int>("DiscretionaryAccessControl::clear");
- } catch (runtime::Exception& e) {}
- return -1;
-}
-
-int DiscretionaryAccessControl::enable(bool en)
-{
- try {
- return context->methodCall<int>("DiscretionaryAccessControl::enable", en);
- } catch (runtime::Exception& e) {}
- return -1;
-}
-
-bool DiscretionaryAccessControl::isEnabled()
-{
- try {
- return context->methodCall<bool>("DiscretionaryAccessControl::isEnabled");
- } catch (runtime::Exception& e) {}
- return false;
-}
-
-} // namespace AuditTrail
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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
- */
-#include "rmi/mandatory-access-control.h"
-
-namespace AuditTrail {
-
-MandatoryAccessControl::MandatoryAccessControl(AuditTrailControlContext& ctx) :
- context(ctx)
-{
-}
-
-MandatoryAccessControl::~MandatoryAccessControl()
-{
-}
-
-MandatoryAccessControl::AuditTrail MandatoryAccessControl::get(unsigned int pos)
-{
- try {
- return context->methodCall<AuditTrail>("MandatoryAccessControl::get", pos);
- } catch (runtime::Exception& e) {}
- return AuditTrail();
-}
-
-unsigned int MandatoryAccessControl::size()
-{
- try {
- return context->methodCall<unsigned int>("MandatoryAccessControl::size");
- } catch (runtime::Exception& e) {}
- return 0;
-}
-
-int MandatoryAccessControl::clear()
-{
- try {
- return context->methodCall<int>("MandatoryAccessControl::clear");
- } catch (runtime::Exception& e) {}
- return -1;
-}
-
-int MandatoryAccessControl::enable(bool en)
-{
- try {
- return context->methodCall<int>("MandatoryAccessControl::enable", en);
- } catch (runtime::Exception& e) {}
- return -1;
-}
-
-bool MandatoryAccessControl::isEnabled()
-{
- try {
- return context->methodCall<bool>("MandatoryAccessControl::isEnabled");
- } catch (runtime::Exception& e) {}
- return false;
-}
-
-} // namespace AuditTrail
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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
- */
-#include "rmi/system-call.h"
-
-namespace AuditTrail {
-
-SystemCall::SystemCall(AuditTrailControlContext& ctx) :
- context(ctx)
-{
-}
-
-SystemCall::~SystemCall()
-{
-}
-
-SystemCall::AuditTrail SystemCall::get(unsigned int pos)
-{
- try {
- return context->methodCall<AuditTrail>("SystemCall::get", pos);
- } catch (runtime::Exception& e) {}
- return AuditTrail();
-}
-
-unsigned int SystemCall::size()
-{
- try {
- return context->methodCall<unsigned int>("SystemCall::size");
- } catch (runtime::Exception& e) {}
- return 0;
-}
-
-int SystemCall::clear()
-{
- try {
- return context->methodCall<int>("SystemCall::clear");
- } catch (runtime::Exception& e) {}
- return -1;
-}
-
-int SystemCall::enable(bool en)
-{
- try {
- return context->methodCall<int>("SystemCall::enable", en);
- } catch (runtime::Exception& e) {}
- return -1;
-}
-
-bool SystemCall::isEnabled()
-{
- try {
- return context->methodCall<bool>("SystemCall::isEnabled");
- } catch (runtime::Exception& e) {}
- return false;
-}
-
-} // namespace AuditTrail
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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
- */
-#include "rmi/user.h"
-
-namespace AuditTrail {
-
-User::User(AuditTrailControlContext& ctx) :
- context(ctx)
-{
-}
-
-User::~User()
-{
-}
-
-User::AuditTrail User::get(unsigned int pos)
-{
- try {
- return context->methodCall<AuditTrail>("User::get", pos);
- } catch (runtime::Exception& e) {}
- return AuditTrail();
-}
-
-unsigned int User::size()
-{
- try {
- return context->methodCall<unsigned int>("User::size");
- } catch (runtime::Exception& e) {}
- return 0;
-}
-
-int User::clear()
-{
- try {
- return context->methodCall<int>("User::clear");
- } catch (runtime::Exception& e) {}
- return -1;
-}
-
-int User::enable(bool en)
-{
- try {
- return context->methodCall<int>("User::enable", en);
- } catch (runtime::Exception& e) {}
- return -1;
-}
-
-bool User::isEnabled()
-{
- try {
- return context->methodCall<bool>("User::isEnabled");
- } catch (runtime::Exception& e) {}
- return false;
-}
-
-} // namespace AuditTrail
%attr(755,root,root) %{_bindir}/audit-trail-daemon
%{_unitdir}/audit-trail.service
%{_unitdir}/multi-user.target.wants/audit-trail.service
-%attr(700,root,root) %{_sbindir}/audit-trail-admin-cli
+#%attr(700,root,root) %{_sbindir}/audit-trail-admin-cli
%prep
%setup -q
%manifest audit-trail.manifest
%defattr(644,root,root,755)
%attr(700,root,root) %{_sbindir}/audit-trail-send-test
-%attr(700,root,root) %{_sbindir}/audit-trail-speed-test
+#%attr(700,root,root) %{_sbindir}/audit-trail-speed-test
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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 __AUDIT_TRAIL_DISCRETIONARY_ACCESS_CONTROL_H__
-#define __AUDIT_TRAIL_DISCRETIONARY_ACCESS_CONTROL_H__
-
-#include "context.h"
-
-namespace AuditTrail {
-
-/**
- * This class provides APIs to receive the logs
- */
-
-class DiscretionaryAccessControl final {
-public:
- struct AuditTrail {
- struct {
- time_t time;
- unsigned short millisec;
- REFLECTABLE(time, millisec);
- } time;
- struct {
- uid_t uid, euid;
- gid_t gid, egid;
- std::string name;
- pid_t pid;
- REFLECTABLE(uid, euid, gid, egid, name, pid);
- } subject;
- struct {
- uid_t uid;
- gid_t gid;
- std::string name;
- mode_t mode;
- REFLECTABLE(uid, gid, name, mode);
- } object;
- struct {
- unsigned int systemCall;
- REFLECTABLE(systemCall);
- } action;
- REFLECTABLE(time, subject, object, action);
- };
-
- DiscretionaryAccessControl(AuditTrailControlContext& ctxt);
- ~DiscretionaryAccessControl();
-
- AuditTrail get(unsigned int pos);
- unsigned int size();
-
- int clear();
-
- int enable(bool en);
- bool isEnabled();
-
-private:
- AuditTrailControlContext& context;
-};
-
-} // namespace AuditTrail
-#endif // __AUDIT_TRAIL_DISCRETIONARY_ACCESS_CONTROL_H__
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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 __AUDIT_TRAIL_MANDATORY_ACCESS_CONTROL_H__
-#define __AUDIT_TRAIL_MANDATORY_ACCESS_CONTROL_H__
-
-#include "context.h"
-
-namespace AuditTrail {
-
-/**
- * This class provides APIs to receive the logs
- */
-
-class MandatoryAccessControl final {
-public:
- struct AuditTrail {
- struct {
- time_t time;
- unsigned short millisec;
- REFLECTABLE(time, millisec);
- } time;
- struct {
- std::string label;
- std::string name;
- pid_t pid;
- REFLECTABLE(label, name, pid);
- } subject;
- struct {
- std::string label;
- std::string name;
- REFLECTABLE(label, name);
- } object;
- struct {
- unsigned int systemCall;
- std::string request;
- REFLECTABLE(systemCall, request);
- } action;
- REFLECTABLE(time, subject, object, action);
- };
-
- MandatoryAccessControl(AuditTrailControlContext& ctxt);
- ~MandatoryAccessControl();
-
- AuditTrail get(unsigned int pos);
- unsigned int size();
-
- int clear();
-
- int enable(bool en);
- bool isEnabled();
-
-private:
- AuditTrailControlContext& context;
-};
-
-} // namespace AuditTrail
-#endif // __AUDIT_TRAIL_MANDATORY_ACCESS_CONTROL_H__
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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 __AUDIT_TRAIL_SYSTEM_CALL_H__
-#define __AUDIT_TRAIL_SYSTEM_CALL_H__
-
-#include "context.h"
-
-namespace AuditTrail {
-
-/**
- * This class provides APIs to receive the logs
- */
-
-class SystemCall final {
-public:
- struct AuditTrail {
- struct {
- time_t time;
- unsigned short millisec;
- REFLECTABLE(time, millisec);
- } time;
- struct {
- uid_t uid, euid;
- gid_t gid, egid;
- std::string name;
- pid_t pid;
- REFLECTABLE(uid, euid, gid, egid, name, pid);
- } subject;
- struct {
- unsigned int systemCall;
- int exitCode;
- REFLECTABLE(systemCall, exitCode);
- } action;
- REFLECTABLE(time, subject, action);
- };
-
- SystemCall(AuditTrailControlContext& ctxt);
- ~SystemCall();
-
- AuditTrail get(unsigned int pos);
- unsigned int size();
-
- int clear();
-
- int enable(bool en);
- bool isEnabled();
-
-private:
- AuditTrailControlContext& context;
-};
-
-} // namespace AuditTrail
-#endif // __AUDIT_TRAIL_SYSTEM_CALL_H__
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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 __AUDIT_TRAIL_USER_H__
-#define __AUDIT_TRAIL_USER_H__
-
-#include "context.h"
-
-namespace AuditTrail {
-
-/**
- * This class provides APIs to receive the logs
- */
-
-class User final {
-public:
- struct AuditTrail {
- struct {
- time_t time;
- unsigned short millisec;
- REFLECTABLE(time, millisec);
- } time;
- struct {
- int type;
- std::string text;
- REFLECTABLE(type, text);
- } log;
- REFLECTABLE(time, log);
- };
-
- User(AuditTrailControlContext& ctxt);
- ~User();
-
- AuditTrail get(unsigned int pos);
- unsigned int size();
-
- int clear();
-
- int enable(bool en);
- bool isEnabled();
-
-private:
- AuditTrailControlContext& context;
-};
-
-} // namespace AuditTrail
-#endif // __AUDIT_TRAIL_USER_H__
#
SET(SERVER_SRCS main.cpp
server.cpp
- user.cpp
- system-call.cpp
- mandatory-access-control.cpp
- discretionary-access-control.cpp
rule-management.cpp
)
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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
- */
-#include <fstream>
-
-#include <limits.h>
-#include <unistd.h>
-#include <asm/unistd.h>
-
-#include "rmi/discretionary-access-control.h"
-
-#define AUDIT_RULE_KEY "DAC"
-#define PRIVILEGE_PLATFORM "http://tizen.org/privilege/internal/default/platform"
-
-namespace AuditTrail {
-
-namespace {
-
-std::vector<DiscretionaryAccessControl::AuditTrail> logs;
-bool enabled;
-
-std::string logNoObj;
-bool isMAC = false;
-
-const std::string keyString = " key=\"" AUDIT_RULE_KEY "\"";
-AuditRule ruleDacAccess, ruleDacPerm;
-
-DiscretionaryAccessControl::AuditTrail convertLog(std::string &log)
-{
- DiscretionaryAccessControl::AuditTrail ret;
- std::stringstream tok(log);
- std::string word;
-
- getline(tok, word, ' ');
- word = word.substr(sizeof("audit(") - 1);
- size_t dot = word.find_first_of('.');
- ret.time.time = std::stoll(word.substr(0, dot));
- ret.time.millisec = std::stoi(word.substr(dot + 1, 3));
-
- ret.object.uid = UINT_MAX;
- ret.object.gid = UINT_MAX;
- ret.object.mode = UINT_MAX;
-
- while (getline(tok, word, ' ')) {
- size_t equal = word.find_first_of('=');
- std::string item = word.substr(0, equal);
- std::string value = word.substr(equal + 1);
-
- if (item == "exe") {
- ret.subject.name = value.substr(1, value.size() - 2);
- } else if (item == "uid") {
- ret.subject.uid = std::stoi(value);
- } else if (item == "euid") {
- ret.subject.euid = std::stoi(value);
- } else if (item == "gid") {
- ret.subject.gid = std::stoi(value);
- } else if (item == "egid") {
- ret.subject.egid = std::stoi(value);
- } else if (item == "pid") {
- ret.subject.pid = std::stoi(value);
- } else if (item == "ouid") {
- ret.object.uid = std::stoi(value);
- } else if (item == "ogid") {
- ret.object.gid = std::stoi(value);
- } else if (item == "mode") {
- ret.object.mode = std::stoi(value, nullptr, 8);
- } else if (item == "name") {
- ret.object.name = value.substr(1, value.size() - 2);
- } else if (item == "ocomm") {
- ret.object.name = value.substr(1, value.size() - 2);
- } else if (item == "syscall") {
- ret.action.systemCall = std::stoi(value);
- }
- }
-
- return ret;
-}
-
-} // namespace
-
-DiscretionaryAccessControl::DiscretionaryAccessControl(AuditTrailControlContext &ctx) :
- context(ctx)
-{
- context.expose(this, "", (AuditTrail)(DiscretionaryAccessControl::get)(unsigned int));
- context.expose(this, "", (unsigned int)(DiscretionaryAccessControl::size)());
- context.expose(this, PRIVILEGE_PLATFORM, (int)(DiscretionaryAccessControl::clear)());
- context.expose(this, PRIVILEGE_PLATFORM, (int)(DiscretionaryAccessControl::enable)(bool));
- context.expose(this, "", (bool)(DiscretionaryAccessControl::isEnabled)());
-
- context.createNotification("DiscretionaryAccessControl");
-
- ruleDacAccess.addCondition({AUDIT_FILTERKEY, AUDIT_EQUAL, AUDIT_RULE_KEY});
-
- //Both EACCESS and EPERM
- ruleDacAccess.addSystemcall(__NR_execve);
-#ifdef __NR_chmod
- ruleDacAccess.addSystemcall(__NR_chmod);
-#endif
-#ifdef __NR_lchown
- ruleDacAccess.addSystemcall(__NR_lchown);
-#endif
-#ifdef __NR_rename
- ruleDacAccess.addSystemcall(__NR_rename);
-#endif
-#ifdef __NR_rmdir
- ruleDacAccess.addSystemcall(__NR_rmdir);
-#endif
-#ifdef __NR_chown
- ruleDacAccess.addSystemcall(__NR_chown);
-#endif
- ruleDacAccess.addSystemcall(__NR_fchown);
- ruleDacAccess.addSystemcall(__NR_fchmod);
-#ifdef __NR_chown32
- ruleDacAccess.addSystemcall(__NR_chown32);
-#endif
-#ifdef __NR_fchown32
- ruleDacAccess.addSystemcall(__NR_fchown32);
-#endif
- ruleDacAccess.addSystemcall(__NR_fchownat);
- ruleDacAccess.addSystemcall(__NR_renameat);
- ruleDacAccess.addSystemcall(__NR_fchmodat);
- ruleDacAccess.addSystemcall(__NR_kill);
- ruleDacAccess.addSystemcall(__NR_tkill);
- ruleDacAccess.addSystemcall(__NR_tgkill);
- // Does __NR_syscall have to be considered?
-
- ruleDacPerm = ruleDacAccess;
-
- //EACCES only
-
-#ifdef __NR_open
- ruleDacAccess.addSystemcall(__NR_open);
-#endif
-#ifdef __NR_creat
- ruleDacAccess.addSystemcall(__NR_creat);
-#endif
-#ifdef __NR_link
- ruleDacAccess.addSystemcall(__NR_link);
-#endif
-#ifdef __NR_unlink
- ruleDacAccess.addSystemcall(__NR_unlink);
-#endif
- ruleDacAccess.addSystemcall(__NR_chdir);
-#ifdef __NR_mknod
- ruleDacAccess.addSystemcall(__NR_mknod);
-#endif
-#ifdef __NR_access
- ruleDacAccess.addSystemcall(__NR_access);
-#endif
-#ifdef __NR_mkdir
- ruleDacAccess.addSystemcall(__NR_mkdir);
-#endif
- ruleDacAccess.addSystemcall(__NR_acct);
- ruleDacAccess.addSystemcall(__NR_chroot);
-#ifdef __NR_symlink
- ruleDacAccess.addSystemcall(__NR_symlink);
-#endif
-#ifdef __NR_readlink
- ruleDacAccess.addSystemcall(__NR_readlink);
-#endif
-#ifdef __NR_uselib
- ruleDacAccess.addSystemcall(__NR_uselib);
-#endif
- ruleDacAccess.addSystemcall(__NR_truncate);
- ruleDacAccess.addSystemcall(__NR_ftruncate);
- ruleDacAccess.addSystemcall(__NR_fchdir);
- ruleDacAccess.addSystemcall(__NR_statfs);
-#ifdef __NR_stat
- ruleDacAccess.addSystemcall(__NR_stat);
-#endif
-#ifdef __NR_lstat
- ruleDacAccess.addSystemcall(__NR_lstat);
-#endif
-#ifdef __NR_truncate64
- ruleDacAccess.addSystemcall(__NR_truncate64);
-#endif
-#ifdef __NR_ftruncate64
- ruleDacAccess.addSystemcall(__NR_ftruncate64);
-#endif
-#ifdef __NR_stat64
- ruleDacAccess.addSystemcall(__NR_stat64);
-#endif
-#ifdef __NR_lstat64
- ruleDacAccess.addSystemcall(__NR_lstat64);
-#endif
-#ifdef __NR_statfs64
- ruleDacAccess.addSystemcall(__NR_statfs64);
-#endif
- ruleDacAccess.addSystemcall(__NR_inotify_add_watch);
- ruleDacAccess.addSystemcall(__NR_openat);
- ruleDacAccess.addSystemcall(__NR_mkdirat);
- ruleDacAccess.addSystemcall(__NR_mknodat);
-#ifdef __NR_fstatat64
- ruleDacAccess.addSystemcall(__NR_fstatat64);
-#endif
-#ifdef __NR_newfstatat
- ruleDacAccess.addSystemcall(__NR_newfstatat);
-#endif
- ruleDacAccess.addSystemcall(__NR_unlinkat);
- ruleDacAccess.addSystemcall(__NR_symlinkat);
- ruleDacAccess.addSystemcall(__NR_readlinkat);
- ruleDacAccess.addSystemcall(__NR_faccessat);
-
- ruleDacAccess.addCondition({AUDIT_EXIT, AUDIT_EQUAL, -EACCES});
-
- //EPERM only
-
- ruleDacPerm.addCondition({AUDIT_EXIT, AUDIT_EQUAL, -EPERM});
-
- try {
- context.removeAuditRule(ruleDacAccess);
- context.removeAuditRule(ruleDacPerm);
- } catch (runtime::Exception& e) {}
- enabled = false;
-
- context.setAuditHandler([&ctx] (int type, std::vector<char> &buf) {
- if (!enabled) {
- return;
- }
-
- if (type == AUDIT_AVC) {
- isMAC = true;
- } else if (type == AUDIT_SYSCALL) {
- if (!isMAC) {
- std::string log(buf.begin(), buf.end());
- ssize_t keyPos = log.size() - keyString.size();
-
- if (log.substr(keyPos) == keyString) {
- logNoObj = log.substr(0, keyPos);
- }
- }
- isMAC = false;
- } else if ((type == AUDIT_PATH || type == AUDIT_OBJ_PID)
- && logNoObj.size() > 0) {
- std::string log(buf.begin(), buf.end());
- log += " " + logNoObj;
- logs.push_back(convertLog(log));
- ctx.notify("DiscretionaryAccessControl", logs.size() - 1);
- logNoObj.clear();
- }
- });
-}
-
-DiscretionaryAccessControl::~DiscretionaryAccessControl()
-{
-}
-
-DiscretionaryAccessControl::AuditTrail DiscretionaryAccessControl::get(unsigned int pos)
-{
- if (pos >= logs.size()) {
- return AuditTrail();
- }
-
- return logs[pos];
-}
-
-unsigned int DiscretionaryAccessControl::size()
-{
- return logs.size();
-}
-
-int DiscretionaryAccessControl::clear()
-{
- logs.clear();
- return 0;
-}
-
-bool DiscretionaryAccessControl::isEnabled()
-{
- return enabled;
-}
-
-int DiscretionaryAccessControl::enable(bool en)
-{
- if (en != enabled) {
- enabled = en;
- try {
- if (en) {
- context.addAuditRule(ruleDacAccess);
- context.addAuditRule(ruleDacPerm);
- } else {
- context.removeAuditRule(ruleDacAccess);
- context.removeAuditRule(ruleDacPerm);
- }
- } catch (runtime::Exception& e) {
- return -1;
- }
- }
- return 0;
-}
-
-} // namespace AuditTrail
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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
- */
-#include <fstream>
-
-#include <unistd.h>
-
-#include "rmi/mandatory-access-control.h"
-
-#define PRIVILEGE_PLATFORM "http://tizen.org/privilege/internal/default/platform"
-
-namespace AuditTrail {
-
-namespace {
-
-std::vector<MandatoryAccessControl::AuditTrail> logs;
-bool enabled;
-
-std::string logNoSyscall;
-
-MandatoryAccessControl::AuditTrail convertLog(std::string &log)
-{
- MandatoryAccessControl::AuditTrail ret;
- std::stringstream tok(log);
- std::string word;
-
- getline(tok, word, ' ');
- word = word.substr(sizeof("audit(") - 1);
- size_t dot = word.find_first_of('.');
- ret.time.time = std::stoll(word.substr(0, dot));
- ret.time.millisec = std::stoi(word.substr(dot + 1, 3));
-
- while (getline(tok, word, ' ')) {
- size_t equal = word.find_first_of('=');
- std::string item = word.substr(0, equal);
- std::string value = word.substr(equal + 1);
-
- if (item == "subject") {
- ret.subject.label = value.substr(1, value.size() - 2);
- } else if (item == "comm") {
- ret.subject.name = value.substr(1, value.size() - 2);
- } else if (item == "pid") {
- ret.subject.pid = std::stoi(value);
- } else if (item == "object") {
- ret.object.label = value.substr(1, value.size() - 2);
- } else if (item == "path") {
- ret.object.name = value.substr(1, value.size() - 2);
- } else if (item == "syscall") {
- ret.action.systemCall = std::stoi(value);
- } else if (item == "requested") {
- ret.action.request = value;
- }
-
- }
-
- return ret;
-}
-
-} // namespace
-
-
-MandatoryAccessControl::MandatoryAccessControl(AuditTrailControlContext &ctx) :
- context(ctx)
-{
- context.expose(this, "", (AuditTrail)(MandatoryAccessControl::get)(unsigned int));
- context.expose(this, "", (unsigned int)(MandatoryAccessControl::size)());
- context.expose(this, PRIVILEGE_PLATFORM, (int)(MandatoryAccessControl::clear)());
- context.expose(this, PRIVILEGE_PLATFORM, (int)(MandatoryAccessControl::enable)(bool));
- context.expose(this, "", (bool)(MandatoryAccessControl::isEnabled)());
-
- context.createNotification("MandatoryAccessControl");
-
- enabled = false;
-
- context.setAuditHandler([&ctx] (int type, std::vector<char> &buf) {
- if (!enabled) {
- return;
- }
-
- if (type == AUDIT_AVC) {
- std::string log(buf.begin(), buf.end());
- logNoSyscall = log;
- } else if (type == AUDIT_SYSCALL && logNoSyscall.size() > 0) {
- std::string log(buf.begin(), buf.end());
- log += " " + logNoSyscall;
- logs.push_back(convertLog(log));
- ctx.notify("MandatoryAccessControl", logs.size() - 1);
- logNoSyscall.clear();
- }
- });
-}
-
-MandatoryAccessControl::~MandatoryAccessControl()
-{
-}
-
-MandatoryAccessControl::AuditTrail MandatoryAccessControl::get(unsigned int pos)
-{
- if (pos >= logs.size()) {
- return AuditTrail();
- }
-
- return logs[pos];
-}
-
-unsigned int MandatoryAccessControl::size()
-{
- return logs.size();
-}
-
-int MandatoryAccessControl::clear()
-{
- logs.clear();
- return 0;
-}
-
-bool MandatoryAccessControl::isEnabled()
-{
- return enabled;
-}
-
-int MandatoryAccessControl::enable(bool en)
-{
- enabled = en;
- return 0;
-}
-
-} // namespace AuditTrail
#include <cynara-client.h>
#include <cynara-session.h>
-#include "rmi/discretionary-access-control.h"
-#include "rmi/mandatory-access-control.h"
-#include "rmi/system-call.h"
-#include "rmi/user.h"
-
#include "server.h"
using namespace std::placeholders;
const std::string AUDIT_RAIL_MANAGER_ADDRESS = "/tmp/.audit-trail.sock";
-std::unique_ptr<AuditTrail::DiscretionaryAccessControl> dac;
-std::unique_ptr<AuditTrail::MandatoryAccessControl> mac;
-std::unique_ptr<AuditTrail::SystemCall> systemCall;
-std::unique_ptr<AuditTrail::User> user;
-
} // namespace
Server::Server()
handler(msg.first, msg.second);
}
});
-
- dac.reset(new AuditTrail::DiscretionaryAccessControl(*this));
- mac.reset(new AuditTrail::MandatoryAccessControl(*this));
- systemCall.reset(new AuditTrail::SystemCall(*this));
- user.reset(new AuditTrail::User(*this));
}
Server::~Server()
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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
- */
-#include <fstream>
-
-#include <unistd.h>
-#include <asm/unistd.h>
-
-#include "rmi/system-call.h"
-
-#define AUDIT_RULE_KEY "syscall"
-#define PRIVILEGE_PLATFORM "http://tizen.org/privilege/internal/default/platform"
-
-namespace AuditTrail {
-
-namespace {
-
-std::vector<SystemCall::AuditTrail> logs;
-bool enabled;
-
-const std::string keyString = " key=\"" AUDIT_RULE_KEY "\"";
-AuditRule ruleAllSyscall;
-
-SystemCall::AuditTrail convertLog(std::string &log)
-{
- SystemCall::AuditTrail ret;
- std::stringstream tok(log);
- std::string word;
-
- getline(tok, word, ' ');
- word = word.substr(sizeof("audit(") - 1);
- size_t dot = word.find_first_of('.');
- ret.time.time = std::stoll(word.substr(0, dot));
- ret.time.millisec = std::stoi(word.substr(dot + 1, 3));
-
- while (getline(tok, word, ' ')) {
- size_t equal = word.find_first_of('=');
- std::string item = word.substr(0, equal);
- std::string value = word.substr(equal + 1);
-
- if (item == "exe") {
- ret.subject.name = value.substr(1, value.size() - 2);
- } else if (item == "uid") {
- ret.subject.uid = std::stoi(value);
- } else if (item == "euid") {
- ret.subject.euid = std::stoi(value);
- } else if (item == "gid") {
- ret.subject.gid = std::stoi(value);
- } else if (item == "egid") {
- ret.subject.egid = std::stoi(value);
- } else if (item == "pid") {
- ret.subject.pid = std::stoi(value);
- } else if (item == "syscall") {
- ret.action.systemCall = std::stoi(value);
- } else if (item == "exit") {
- ret.action.exitCode = std::stoi(value);
- }
- }
-
- return ret;
-}
-
-} // namespace
-
-
-SystemCall::SystemCall(AuditTrailControlContext &ctx) :
- context(ctx)
-{
- context.expose(this, "", (AuditTrail)(SystemCall::get)(unsigned int));
- context.expose(this, "", (unsigned int)(SystemCall::size)());
- context.expose(this, PRIVILEGE_PLATFORM, (int)(SystemCall::clear)());
- context.expose(this, PRIVILEGE_PLATFORM, (int)(SystemCall::enable)(bool));
- context.expose(this, "", (bool)(SystemCall::isEnabled)());
-
- context.createNotification("SystemCall");
-
- ruleAllSyscall.addCondition({AUDIT_FILTERKEY, AUDIT_EQUAL, AUDIT_RULE_KEY});
- ruleAllSyscall.addAllSystemcalls();
-
- try {
- context.removeAuditRule(ruleAllSyscall);
- } catch (runtime::Exception& e) {}
- enabled = false;
-
- context.setAuditHandler([&ctx] (int type, std::vector<char> &buf) {
- if (type == AUDIT_SYSCALL) {
- std::string log(buf.begin(), buf.end());
- ssize_t keyPos = log.size() - keyString.size();
-
- if (log.substr(keyPos) == keyString) {
- log = log.substr(0, keyPos);
- logs.push_back(convertLog(log));
- ctx.notify("SystemCall", logs.size() - 1);
- }
- }
- });
-}
-
-SystemCall::~SystemCall()
-{
-}
-
-SystemCall::AuditTrail SystemCall::get(unsigned int pos)
-{
- if (pos >= logs.size()) {
- return AuditTrail();
- }
-
- return logs[pos];
-}
-
-unsigned int SystemCall::size()
-{
- return logs.size();
-}
-
-int SystemCall::clear()
-{
- logs.clear();
- return 0;
-}
-
-bool SystemCall::isEnabled()
-{
- return enabled;
-}
-
-int SystemCall::enable(bool en)
-{
- if (en != enabled) {
- enabled = en;
- try {
- if (en) {
- context.addAuditRule(ruleAllSyscall);
- } else {
- context.removeAuditRule(ruleAllSyscall);
- }
- } catch (runtime::Exception& e) {
- return -1;
- }
- }
- return 0;
-}
-
-} // namespace AuditTrail
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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
- */
-#include <fstream>
-
-#include <unistd.h>
-
-#include "rmi/user.h"
-
-#define PRIVILEGE_PLATFORM "http://tizen.org/privilege/internal/default/platform"
-
-namespace AuditTrail {
-
-namespace {
-
-std::vector<User::AuditTrail> logs;
-bool enabled;
-
-User::AuditTrail convertLog(int type, const std::string &log)
-{
- User::AuditTrail ret;
- std::stringstream tok(log);
- std::string word, msg;
-
- getline(tok, word, ' ');
- word = word.substr(sizeof("audit(") - 1);
- size_t dot = word.find_first_of('.');
- ret.time.time = std::stoll(word.substr(0, dot));
- ret.time.millisec = std::stoi(word.substr(dot + 1, 3));
-
- while (getline(tok, word, ' ')) {
- size_t equal = word.find_first_of('=');
- std::string item = word.substr(0, equal);
- std::string value = word.substr(equal + 1);
-
- if (item == "msg") {
- if (value[value.size() - 1] != '\'') {
- getline(tok, word, '\'');
- value += " " + word + '\'';
- }
- msg = value.substr(1, value.size() - 2);
- }
- }
-
- // TODO : If the format given by user access control is specified,
- // Following code will be replaced by parsing a message.
- ret.log.type = type;
- ret.log.text = msg;
-
- return ret;
-}
-
-} // namespace
-
-
-User::User(AuditTrailControlContext &ctx) :
- context(ctx)
-{
- context.expose(this, "", (AuditTrail)(User::get)(unsigned int));
- context.expose(this, "", (unsigned int)(User::size)());
- context.expose(this, PRIVILEGE_PLATFORM, (int)(User::clear)());
- context.expose(this, PRIVILEGE_PLATFORM, (int)(User::enable)(bool));
- context.expose(this, "", (bool)(User::isEnabled)());
-
- context.createNotification("User");
-
- enabled = false;
-
- context.setAuditHandler([&ctx] (int type, std::vector<char> &buf) {
- if (!enabled)
- return;
-
- if ((type >= AUDIT_FIRST_USER_MSG && type <= AUDIT_LAST_USER_MSG) ||
- (type >= AUDIT_FIRST_USER_MSG2 && type <= AUDIT_LAST_USER_MSG2)) {
- std::string log(buf.begin(), buf.end());
- logs.push_back(convertLog(type, log));
- ctx.notify("User", logs.size() - 1);
- }
- });
-}
-
-User::~User()
-{
-}
-
-User::AuditTrail User::get(unsigned int pos)
-{
- if (pos >= logs.size()) {
- AuditTrail empty;
- empty.log.type = 0;
- return empty;
- }
-
- return logs[pos];
-}
-
-unsigned int User::size()
-{
- return logs.size();
-}
-
-int User::clear()
-{
- logs.clear();
- return 0;
-}
-
-bool User::isEnabled()
-{
- return enabled;
-}
-
-int User::enable(bool en)
-{
- enabled = en;
- return 0;
-}
-
-} // namespace AuditTrail
# See the License for the specific language governing permissions and
# limitations under the License.
#
-SET(AUDIT_TRAIL_CLI ${AUDIT_TRAIL_TOOLS}/cli)
+#SET(AUDIT_TRAIL_CLI ${AUDIT_TRAIL_TOOLS}/cli)
SET(AUDIT_TRAIL_TEST ${AUDIT_TRAIL_TOOLS}/tests)
-ADD_SUBDIRECTORY(${AUDIT_TRAIL_CLI})
+#ADD_SUBDIRECTORY(${AUDIT_TRAIL_CLI})
ADD_SUBDIRECTORY(${AUDIT_TRAIL_TEST})
#
FILE(GLOB SEND_SRCS send.cpp)
-FILE(GLOB SPEED_SRCS speed.cpp)
+#FILE(GLOB SPEED_SRCS speed.cpp)
SET(SEND_NAME ${PROJECT_NAME}-send-test)
-SET(SPEED_NAME ${PROJECT_NAME}-speed-test)
+#SET(SPEED_NAME ${PROJECT_NAME}-speed-test)
ADD_EXECUTABLE(${SEND_NAME} ${SEND_SRCS})
-ADD_EXECUTABLE(${SPEED_NAME} ${SPEED_SRCS})
+#ADD_EXECUTABLE(${SPEED_NAME} ${SPEED_SRCS})
SET_TARGET_PROPERTIES(${SEND_NAME} PROPERTIES PREFIX ""
glib-2.0
)
-INCLUDE_DIRECTORIES(SYSTEM ${CLI_DEPS_INCLUDE_DIRS} ${AUDIT_TRAIL_LIB})
-TARGET_LINK_LIBRARIES(${SPEED_NAME} ${CLI_DEPS_LIBRARIES} ${PROJECT_NAME} audit-trail)
+#INCLUDE_DIRECTORIES(SYSTEM ${CLI_DEPS_INCLUDE_DIRS} ${AUDIT_TRAIL_LIB})
+#TARGET_LINK_LIBRARIES(${SPEED_NAME} ${CLI_DEPS_LIBRARIES} ${PROJECT_NAME} audit-trail)
INSTALL(TARGETS ${SEND_NAME} DESTINATION sbin)
-INSTALL(TARGETS ${SPEED_NAME} DESTINATION sbin)
+#INSTALL(TARGETS ${SPEED_NAME} DESTINATION sbin)