SET(libprivilege-control_SOURCES
${src_dir}/privilege-control.c
${src_dir}/access-db.c
+ ${src_dir}/common.c
)
SET(libprivilege-control_LDFLAGS " -module -avoid-version ")
SET(libprivilege-control_CFLAGS " ${CFLAGS} -fPIC -I${include_dir}")
--- /dev/null
+/*
+ * libprivilege control
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Rafal Krypa <r.krypa@samsung.com>
+ *
+ * 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 COMMON_H_
+#define COMMON_H_
+
+#include <dlog.h>
+
+
+#ifdef LOG_TAG
+ #undef LOG_TAG
+#endif // LOG_TAG
+#ifndef LOG_TAG
+ #define LOG_TAG "PRIVILEGE_CONTROL"
+#endif // LOG_TAG
+
+// conditional log macro for dlogutil (debug)
+#ifdef DLOG_DEBUG_ENABLED
+#define C_LOGD(...) LOGD(__VA_ARGS__)
+#else
+#define C_LOGD(...) do { } while(0)
+#endif //DDLOG_DEBUG_ENABLED
+
+// conditional log macro for dlogutil (error)
+#ifdef DLOG_ERROR_ENABLED
+#define C_LOGE(...) LOGE(__VA_ARGS__)
+#else
+#define C_LOGE(...) do { } while(0)
+#endif //DLOG_ERROR_ENABLED
+
+#ifdef SMACK_ENABLED
+int smack_label_is_valid(const char* smack_label);
+#endif
+
+#endif /* COMMON_H_ */
#include <dlog.h>
#include <ctype.h>
+#include "access-db.h"
#include "privilege-control.h"
-
-#ifdef LOG_TAG
- #undef LOG_TAG
-#endif // LOG_TAG
-#ifndef LOG_TAG
- #define LOG_TAG "PRIVILEGE_CONTROL"
-#endif // LOG_TAG
-
-// conditional log macro for dlogutil (debug)
-#ifdef DLOG_DEBUG_ENABLED
-#define C_LOGD(...) LOGD(__VA_ARGS__)
-#else
-#define C_LOGD(...) do { } while(0)
-#endif //DDLOG_DEBUG_ENABLED
-
-// conditional log macro for dlogutil (error)
-#ifdef DLOG_ERROR_ENABLED
-#define C_LOGE(...) LOGE(__VA_ARGS__)
-#else
-#define C_LOGE(...) do { } while(0)
-#endif //DLOG_ERROR_ENABLED
+#include "common.h"
typedef enum {
DB_APP_TYPE_APPLICATION,
return 0;
}
-/* TODO: implement such function in libsmack instead -- copied from privilege-control.c*/
-static int smack_label_is_valid(const char* smack_label)
-{
- C_LOGD("Enter function: %s", __func__);
- int i;
-
- if (!smack_label || smack_label[0] == '\0' || !smack_label[0] == '-')
- goto err;
-
- for (i = 0; smack_label[i]; ++i) {
- if (i >= SMACK_LABEL_LEN)
- return 0;
- switch (smack_label[i]) {
- case '~':
- case ' ':
- case '/':
- case '"':
- case '\\':
- case '\'':
- goto err;
- default:
- break;
- }
- }
-
- return 1;
-err:
- C_LOGE("Invalid Smack label: %s", smack_label);
- return 0;
-}
-
static int add_id_to_database_internal(const char * id, db_app_type_t app_type)
{
C_LOGD("Enter function: %s", __func__);
--- /dev/null
+/*
+ * libprivilege control
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Rafal Krypa <r.krypa@samsung.com>
+ *
+ * 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 <sys/smack.h>
+#include "common.h"
+
+#ifdef SMACK_ENABLED
+/* TODO: implement such function in libsmack instead */
+int smack_label_is_valid(const char* smack_label)
+{
+ C_LOGD("Enter function: %s", __func__);
+ int i;
+
+ if (!smack_label || smack_label[0] == '\0' || smack_label[0] == '-')
+ goto err;
+
+ for (i = 0; smack_label[i]; ++i) {
+ if (i >= SMACK_LABEL_LEN)
+ return 0;
+ switch (smack_label[i]) {
+ case '~':
+ case ' ':
+ case '/':
+ case '"':
+ case '\\':
+ case '\'':
+ goto err;
+ default:
+ break;
+ }
+ }
+
+ return 1;
+err:
+ C_LOGE("Invalid Smack label: %s", smack_label);
+ return 0;
+}
+#endif
#include "privilege-control.h"
#include "access-db.h"
+#include "common.h"
#define APP_GID 5000
#define APP_UID 5000
static int set_smack_for_wrt(const char* widget_id);
#endif
-#ifdef LOG_TAG
- #undef LOG_TAG
-#endif // LOG_TAG
-#ifndef LOG_TAG
- #define LOG_TAG "PRIVILEGE_CONTROL"
-#endif // LOG_TAG
-
-// conditional log macro for dlogutil (debug)
-#ifdef DLOG_DEBUG_ENABLED
-#define C_LOGD(...) LOGD(__VA_ARGS__)
-#else
-#define C_LOGD(...) do { } while(0)
-#endif //DDLOG_DEBUG_ENABLED
-
-// conditional log macro for dlogutil (error)
-#ifdef DLOG_ERROR_ENABLED
-#define C_LOGE(...) LOGE(__VA_ARGS__)
-#else
-#define C_LOGE(...) do { } while(0)
-#endif //DLOG_ERROR_ENABLED
-
typedef struct {
char user_name[10];
int uid;
}
#ifdef SMACK_ENABLED
-/* TODO: implement such function in libsmack instead */
-static int smack_label_is_valid(const char* smack_label)
-{
- C_LOGD("Enter function: %s", __func__);
- int i;
-
- if (!smack_label || smack_label[0] == '\0' || smack_label[0] != '-')
- goto err;
-
- for (i = 0; smack_label[i]; ++i) {
- if (i >= SMACK_LABEL_LEN)
- return 0;
- switch (smack_label[i]) {
- case '~':
- case ' ':
- case '/':
- case '"':
- case '\\':
- case '\'':
- goto err;
- default:
- break;
- }
- }
-
- return 1;
-err:
- C_LOGE("Invalid Smack label: %s", smack_label);
- return 0;
-}
/**
* Set process SMACK label from EXEC label of a file.