imei, meid, icc_id is a nonresettable unique idendifier.
An app should have "http://tizen.org/privilege/securesysteminfo"
which is a partner level privilege since 5.5.
For backward compatibility, apps with api-version of 5.0 or less
will get dummy value if they have "http://tizen.org/privilege/telephony"
privilege.
Change-Id: I00bb9d423a0a96cb6c133cbaf91374c55eae096f
Signed-off-by: Semun Lee <semun.lee@samsung.com>
SET(maintainer "Wootak Jung<wootak.jung@samsung.com>")
SET(description "Telephony Core API")
SET(service "telephony")
-SET(dependents "dlog tapi glib-2.0 capi-base-common openssl1.1 capi-system-info")
+SET(dependents "dlog tapi glib-2.0 \
+ capi-base-common openssl1.1 capi-system-info \
+ cynara-client cynara-session cynara-creds-self")
SET(pc_dependents "capi-base-common tapi")
SET(Services
bool conference_status; /**< true: Conference call, false: Single call */
} telephony_call_info_s;
+/**
+ * @brief Check if the caller process has a privilege.
+ * @return @c 1 when the caller has the privilege,
+ * otherwise 0
+ */
+bool telephony_check_legacy_telephony_privilege();
+
#endif /* __CAPI_TELEPHONY_PRIVATE_H__ */
Name: capi-telephony
Summary: Telephony Core API
-Version: 0.1.81
+Version: 0.1.82
Release: 1
Group: System/Libraries
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
-BuildRequires: cmake
-BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(tapi)
-BuildRequires: pkgconfig(glib-2.0)
-BuildRequires: pkgconfig(capi-base-common)
-BuildRequires: pkgconfig(openssl1.1)
-BuildRequires: pkgconfig(capi-system-info)
+BuildRequires: cmake
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(tapi)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(capi-base-common)
+BuildRequires: pkgconfig(openssl1.1)
+BuildRequires: pkgconfig(capi-system-info)
+BuildRequires: pkgconfig(cynara-client)
+BuildRequires: pkgconfig(cynara-session)
+BuildRequires: pkgconfig(cynara-creds-self)
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
/* LCOV_EXCL_START */
LOGE("g_dbus_conn failed. error (%s)", gerr->message);
if (strstr(gerr->message, "AccessDenied")) {
- LOGE("PERMISSION_DENIED");
- error = TELEPHONY_ERROR_PERMISSION_DENIED;
+ if (telephony_check_legacy_telephony_privilege()) {
+ LOGI("return pseudo value");
+ *imei = strdup("000000000000000");
+ } else {
+ LOGE("PERMISSION_DENIED");
+ error = TELEPHONY_ERROR_PERMISSION_DENIED;
+ }
} else {
LOGE("OPERATION_FAILED");
error = TELEPHONY_ERROR_OPERATION_FAILED;
/* LCOV_EXCL_START */
LOGE("g_dbus_conn failed. error (%s)", gerr->message);
if (strstr(gerr->message, "AccessDenied")) {
- LOGE("PERMISSION_DENIED");
- ret = TELEPHONY_ERROR_PERMISSION_DENIED;
+ if (telephony_check_legacy_telephony_privilege()) {
+ LOGI("return pseudo value");
+ *meid = strdup("000000000000000");
+ } else {
+ LOGE("PERMISSION_DENIED");
+ ret = TELEPHONY_ERROR_PERMISSION_DENIED;
+ }
} else {
LOGE("OPERATION_FAILED");
ret = TELEPHONY_ERROR_OPERATION_FAILED;
--- /dev/null
+/*
+ * Copyright (c) 2019 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.
+ */
+#define _GNU_SOURCE
+
+#include <string.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#include <dlog.h>
+#include <cynara-client.h>
+#include <cynara-session.h>
+#include <cynara-creds-self.h>
+
+#include "telephony_private.h"
+
+static bool telephony_check_privilege(const char *privilege)
+{
+ cynara *cynara_handle;
+ char *client;
+ char *uid;
+ char *session;
+ int ret;
+
+ ret = cynara_initialize(&cynara_handle, NULL);
+ if (ret != CYNARA_API_SUCCESS) {
+ LOGE("failed to cynara_initialize: %d", ret);
+ return false;
+ }
+
+ session = cynara_session_from_pid(getpid());
+ if (!session) {
+ cynara_finish(cynara_handle);
+ LOGE("failed to get cynara session");
+ return false;
+ }
+
+ ret = cynara_creds_self_get_client(CLIENT_METHOD_SMACK, &client);
+ if (ret != CYNARA_API_SUCCESS) {
+ free(session);
+ cynara_finish(cynara_handle);
+ LOGE("failed to get cynara client cred: %d", ret);
+ return false;
+ }
+
+ ret = cynara_creds_self_get_user(USER_METHOD_UID, &uid);
+ if (ret != CYNARA_API_SUCCESS) {
+ free(client);
+ free(session);
+ cynara_finish(cynara_handle);
+ LOGE("failed to get cynara user cred: %d", ret);
+ return false;
+ }
+
+ ret = cynara_check(cynara_handle, client, session, uid, privilege);
+
+ free(uid);
+ free(client);
+ free(session);
+ cynara_finish(cynara_handle);
+
+ if (ret == CYNARA_API_ACCESS_ALLOWED)
+ return true;
+
+ return false;
+}
+
+bool telephony_check_legacy_telephony_privilege()
+{
+ char *api_version;
+
+ api_version = getenv("TIZEN_API_VERSION");
+
+ if (!api_version) {
+ LOGE("failed to find api version");
+ return false;
+ }
+
+ /* since Tizen 5.5, this function always returns */
+ /* since Tizen 5.5, this function always returns false */
+ if (strverscmp(api_version, "5.5") >= 0)
+ return false;
+
+ return telephony_check_privilege(
+ "http://tizen.org/privilege/telephony");
+}
/* LCOV_EXCL_START */
LOGE("g_dbus_conn failed. error (%s)", gerr->message);
error_code = _convert_dbus_errmsg_to_sim_error(gerr->message);
+ if (error_code == TELEPHONY_ERROR_PERMISSION_DENIED) {
+ if (telephony_check_legacy_telephony_privilege()) {
+ LOGI("return pseudo value");
+ *icc_id = strdup("0000000000000000000");
+ error_code = TELEPHONY_ERROR_NONE;
+ } else {
+ LOGE("PERMISSION_DENIED");
+ }
+ }
g_error_free(gerr);
/* LCOV_EXCL_STOP */
}