#define WRT_CLIENT_PATH "/usr/bin/wrt-client"
#define ACC_LEN 5
-#ifdef SMACK_ENABLED
static int set_smack_for_wrt(const char* widget_id);
-#endif
typedef struct {
char user_name[10];
glist_cnt++;
}
-#ifdef SMACK_ENABLED
/* FIXME: this should be reworked to not depend on SMACK
* proper solution is not trivial (no app_id is passed to set_app_privilege())
*/
}
}
}
-#endif
/*
* setgroups()
return result;
}
-#ifdef SMACK_ENABLED
-
/**
* Set process SMACK label from EXEC label of a file.
* This function is emulating EXEC label behaviour of SMACK for programs
C_LOGD("return widget id: %s", basename);
return basename;
}*/
-#endif // SMACK_ENABLED
API int set_app_privilege(const char* name, const char* type, const char* path)
{
C_LOGD("Enter function: %s", __func__);
C_LOGD("Function params: name = %s, type = %s, path = %s", name, type, path);
-#ifdef SMACK_ENABLED
const char* widget_id;
int ret = PC_OPERATION_SUCCESS;
if (ret != PC_OPERATION_SUCCESS)
return ret;
-#endif // SMACK_ENABLED
return set_dac(name);
}
return PC_OPERATION_SUCCESS;
}
-#ifdef SMACK_ENABLED
static bool file_exists(const char* path) {
FILE* file = fopen(path, "r");
if (file) {
return PC_OPERATION_SUCCESS;
}
-#endif //SMACK_ENABLED
static int perm_to_dac(const char* app_label, app_type_t app_type, const char* perm)
{
return PC_OPERATION_SUCCESS;
}
-#ifdef SMACK_ENABLED
static int dir_set_smack_r(const char *path, const char* label,
enum smack_label_type type, mode_t type_mask)
{
return PC_OPERATION_SUCCESS;
}
-#endif
API char* app_id_from_socket(int sockfd)
{
if (!have_smack())
return NULL;
-#ifdef SMACK_ENABLED
char* app_id;
int ret;
C_LOGD("app_id: %s", app_id);
return app_id;
-#else
- return NULL;
-#endif
}
-
static int smack_file_name(const char* app_id, char** path)
{
if (asprintf(path, SMACK_RULES_DIR "/%s", app_id) == -1) {
return PC_OPERATION_SUCCESS;
}
-#ifdef SMACK_ENABLED
static int load_smack_from_file(const char* app_id, struct smack_accesses** smack, int *fd, char** path)
{
C_LOGD("Enter function: %s", __func__);
return ret;
}
-#endif
static int app_add_permissions_internal(const char* app_id, app_type_t app_type, const char** perm_list, int permanent)
{
C_LOGD("Enter function: %s", __func__);
int i, ret;
-#ifdef SMACK_ENABLED
char* smack_path AUTO_FREE;
int fd AUTO_CLOSE;
struct smack_accesses *smack AUTO_SMACK_FREE;
return ret;
}
}
-#endif // SMACK_ENABLED
for (i = 0; perm_list[i] != NULL; ++i) {
-#ifdef SMACK_ENABLED
C_LOGD("perm_to_smack params: app_id: %s, perm_list[%d]: %s", app_id, i, perm_list[i]);
ret = perm_to_smack(smack, app_id, app_type, perm_list[i]);
if (ret != PC_OPERATION_SUCCESS){
C_LOGE("perm_to_smack failed");
return ret;
}
-#endif //SMACK_ENABLED
+
ret = perm_to_dac(app_id, app_type, perm_list[i]);
if (ret != PC_OPERATION_SUCCESS){
C_LOGE("perm_to_dac failed");
return ret;
}
}
-#ifdef SMACK_ENABLED
+
if (have_smack() && smack_accesses_apply(smack)) {
C_LOGE("smack_accesses_apply failed");
return PC_ERR_INVALID_OPERATION;
return PC_ERR_INVALID_OPERATION;
}
-#endif
return PC_OPERATION_SUCCESS;
}
static int app_revoke_permissions_internal(const char* app_id, bool persistent)
{
C_LOGD("Enter function: %s", __func__);
-#ifdef SMACK_ENABLED
char* smack_path AUTO_FREE;
int ret;
int fd AUTO_CLOSE;
if (persistent && ftruncate(fd, 0) == -1)
C_LOGE("file truncate failed");
-#endif
+
return PC_OPERATION_SUCCESS;
}
API int app_label_dir(const char* label, const char* path)
{
C_LOGD("Enter function: %s", __func__);
-#ifdef SMACK_ENABLED
int ret = PC_OPERATION_SUCCESS;
ret = dir_set_smack_r(path, "", SMACK_LABEL_EXEC, S_IFMT & ~S_IFREG);
return ret;
-#else
- return PC_OPERATION_SUCCESS;
-#endif
}
-#ifdef SMACK_ENABLED
static int smack_get_access_new(const char* subject, const char* object, char** label)
{
char buff[ACC_LEN] = {'r', 'w', 'x', 'a', 't'};
(*label)[ACC_LEN] = 0;
return PC_OPERATION_SUCCESS;
}
-#endif
/*
* This function will be used to allow direct communication between 2 OSP application.
{
C_LOGD("Enter function: %s", __func__);
int ret = PC_OPERATION_SUCCESS;
-#ifdef SMACK_ENABLED
struct smack_accesses *smack AUTO_SMACK_FREE;
static const char * const revoke = "-----";
char *current_permissions AUTO_FREE;
ret = state_save(subject, object, current_permissions);
-#endif
return ret;
}
API int app_revoke_access(const char* subject, const char* object)
{
C_LOGD("Enter function: %s", __func__);
-#ifdef SMACK_ENABLED
if (!have_smack())
return PC_OPERATION_SUCCESS;
return PC_ERR_INVALID_PARAM;
return state_restore(subject, object);
-#else
- return PC_OPERATION_SUCCESS;
-#endif
}
API int app_label_shared_dir(const char* app_label, const char* shared_label, const char* path)
{
C_LOGD("Enter function: %s", __func__);
-#ifdef SMACK_ENABLED
char* smack_path AUTO_FREE;
int ret;
int fd AUTO_CLOSE;
C_LOGE("smack_accesses_save failed");
return PC_ERR_INVALID_OPERATION;
}
-#endif
+
return PC_OPERATION_SUCCESS;
}
API int add_shared_dir_readers(const char* shared_label, const char** app_list)
{
C_LOGD("Enter function: %s", __func__);
-#ifdef SMACK_ENABLED
int ret = PC_ERR_INVALID_PARAM;
int i;
int fd AUTO_CLOSE;
return PC_ERR_INVALID_OPERATION;
}
}
-#endif
+
return PC_OPERATION_SUCCESS;
}
API int app_add_friend(const char* app_id1, const char* app_id2)
{
C_LOGD("Enter function: %s", __func__);
-#ifdef SMACK_ENABLED
int ret;
int fd1 AUTO_CLOSE;
int fd2 AUTO_CLOSE;
C_LOGE("smack_accesses_save failed");
return PC_ERR_INVALID_OPERATION;
}
-#endif
+
return PC_OPERATION_SUCCESS;
}
return ret;
}
-#ifdef SMACK_ENABLED
ret = register_app_for_av(app_id);
if (ret != PC_OPERATION_SUCCESS) {
C_LOGE("Error while adding rules for anti viruses to app %s: %s ", app_id, strerror(errno));
return ret;
}
-#endif //SMACK_ENABLED
return PC_OPERATION_SUCCESS;
}
return PC_OPERATION_SUCCESS;
}
-#ifdef SMACK_ENABLED
static int save_rules(int fd, struct smack_accesses* accesses) {
if (flock(fd, LOCK_EX)) {
C_LOGE("flock failed, error %s", strerror(errno));
}
return ret;
}
-#endif // SMACK_ENABLED
API int add_api_feature(app_type_t app_type,
const char* api_feature_name,
size_t list_size) {
C_LOGD("Enter function: %s", __func__);
-#ifdef SMACK_ENABLED
int ret = PC_OPERATION_SUCCESS;
char* smack_file = NULL;
char* dac_file = NULL;
}
return ret;
-#else
- return PC_OPERATION_SUCCESS;
-#endif // SMACK_ENABLED
}
API int app_register_av(const char* app_av_id)
{
C_LOGD("Enter function: %s", __func__);
-#ifdef SMACK_ENABLED
int ret;
int i;
int fd AUTO_CLOSE;
for (i=0; i<smack_label_app_list_len; ++i) {
free(smack_label_app_list[i]);
}
-#endif //SMACK_ENABLED
+
return PC_OPERATION_SUCCESS;
}