)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+ADD_SUBDIRECTORY(src/tizenid)
+
IF(UNIX)
ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution)
--- /dev/null
+/*
+ * Copyright (c) 2014 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 __TIZEN_SYSTEM_SYSTEM_INFO_DOC_H__
+#define __TIZEN_SYSTEM_SYSTEM_INFO_DOC_H__
+
+/**
+ * @ingroup CAPI_SYSTEM_FRAMEWORK
+ * @defgroup CAPI_SYSTEM_SYSTEM_INFO_MODULE System Information
+ * @brief The System Information API provides functions which can be used to obtain device information. This section provides more information about the System Information API.
+ *
+ * @section CAPI_SYSTEM_SYSTEM_INFO_MODULE_HEADER Required Header
+ * \#include <system_info.h>
+ *
+ * @section CAPI_SYSTEM_SYSTEM_INFO_MODULE_OVERVIEW Overview
+ * The System Information API provides functions which can be used to obtain system information such as the device API and platform versions, device model number, supported device features, and device screen dimensions.
+ * The available system information is stored in key/value pairs. Depending on their respective key, values can have different data types.
+ * The keys for the platform functions are specified by the Tizen platform and can be seen <a href="../org.tizen.mobile.native.appprogramming/html/guide/system/sysinfo.htm">here.</a>
+ * The keys for the custom functions are specified by OEM's and vendors. Developers should check with their OEM's Tizen OS support if they wish to use a custom functions.
+ *
+ */
+
+#endif /* __TIZEN_SYSTEM_SYSTEM_INFO_DOC_H__ */
/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2011 - 2015 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.
#ifndef __TIZEN_SYSTEM_SYSTEM_INFO_H__
#define __TIZEN_SYSTEM_SYSTEM_INFO_H__
-#include <tizen.h>
+#include "system_info_type.h"
#ifdef __cplusplus
extern "C"
*/
/**
- * @brief Enumeration of error code for system information
- */
-typedef enum {
- SYSTEM_INFO_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
- SYSTEM_INFO_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
- SYSTEM_INFO_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
- SYSTEM_INFO_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< An input/output error occurred when read value from system */
-} system_info_error_e;
-
-/**
- * @brief Enumeration of key for system information
- */
-typedef enum {
- SYSTEM_INFO_KEY_MODEL, /**< The model of the device */
- SYSTEM_INFO_KEY_TIZEN_VERSION, /**< The version of the Tizen API */
- SYSTEM_INFO_KEY_PLATFORM_NAME, /**< The name of platform */
- SYSTEM_INFO_KEY_TIZEN_VERSION_NAME, /**< The name of tizen version */
- SYSTEM_INFO_KEY_MANUFACTURER, /**< The manufacturer of the device */
- SYSTEM_INFO_KEY_CORE_CPU_ARCH, /**< The CORE CPU architecture of model */
- SYSTEM_INFO_KEY_CORE_CPU_FREQ, /**< The CORE CPU frequency of model */
- SYSTEM_INFO_KEY_BUILD_STRING, /**< The build string of platform binary */
- SYSTEM_INFO_KEY_BUILD_DATE, /**< The build date of platform binary */
- SYSTEM_INFO_KEY_BUILD_TIME, /**< The build time of platform binary */
- SYSTEM_INFO_KEY_SCREEN_HEIGHT, /**< The height of the screen in pixels */
- SYSTEM_INFO_KEY_SCREEN_WIDTH, /**< The width of the screen in pixels */
- SYSTEM_INFO_KEY_PHYSICAL_SCREEN_HEIGHT, /**< The physical screen height in millimeters */
- SYSTEM_INFO_KEY_PHYSICAL_SCREEN_WIDTH, /**< The physical screen width in millimeters */
- SYSTEM_INFO_KEY_TETHERING_SUPPORTED, /**< Indicates whether the device supports tethering */
-} system_info_key_e;
-
-/**
- * @brief Gets the integer value of the system information
- * @param[in] key The name of the system information to get
- * @param[out] value The value of the given system information
- * @return 0 on success, otherwise a negative error value.
- * @retval #SYSTEM_INFO_ERROR_NONE Successful
- * @retval #SYSTEM_INFO_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SYSTEM_INFO_ERROR_IO_ERROR An input/output error occurred when read value from system
- */
-int system_info_get_value_int(system_info_key_e key, int *value);
-
-/**
- * @brief Gets the boolean value of the system information
- * @param[in] key The name of the system information to get
- * @param[out] value The value of the given system information
- * @return 0 on success, otherwise a negative error value.
- * @retval #SYSTEM_INFO_ERROR_NONE Successful
- * @retval #SYSTEM_INFO_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SYSTEM_INFO_ERROR_IO_ERROR An input/output error occurred when read value from system
- */
-int system_info_get_value_bool(system_info_key_e key, bool *value);
-
-/**
- * @brief Gets the double value of the system information
- * @param[in] key The name of the system information to get
- * @param[out] value The value of the given system information
- * @return 0 on success, otherwise a negative error value.
- * @retval #SYSTEM_INFO_ERROR_NONE Successful
- * @retval #SYSTEM_INFO_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SYSTEM_INFO_ERROR_IO_ERROR An input/output error occurred when read value from system
- */
-int system_info_get_value_double(system_info_key_e key, double *value);
-
-/**
- * @brief Gets the string value of the system information
- * @remarks The @a value must be released with free() by you.
- * @param[in] key The name of the system information to get
- * @param[out] value The value of the given system information
- * @return 0 on success, otherwise a negative error value.
- * @retval #SYSTEM_INFO_ERROR_NONE Successful
- * @retval #SYSTEM_INFO_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SYSTEM_INFO_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #SYSTEM_INFO_ERROR_IO_ERROR An input/output error occurred when read value from system
- */
-int system_info_get_value_string(system_info_key_e key, char **value);
-
-/**
- * @brief Gets the boolean value of the platform feature
+ * @brief Gets the boolean value of the @a platform feature.
+ * @since_tizen 2.3
* @param[in] key The name of the platform feature to get
* @param[out] value The value of the given platform feature
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #SYSTEM_INFO_ERROR_NONE Successful
- * @retval #SYSTEM_INFO_ERROR_INVALID_PARAMETER cannot find key in model config file
- * @retval #SYSTEM_INFO_ERROR_IO_ERROR An input/output error occurred when read value from model config file
+ * @retval #SYSTEM_INFO_ERROR_INVALID_PARAMETER Cannot find the @a key in the model config file
+ * @retval #SYSTEM_INFO_ERROR_IO_ERROR An input/output error occurred while reading the @a value from the model config file
+ * @retval #SYSTEM_INFO_ERROR_PERMISSION_DENIED No permission to use the API
*/
int system_info_get_platform_bool(const char *key, bool *value);
/**
- * @brief Gets the integer value of the platform feature
+ * @brief Gets the integer value of the @a platform feature.
+ * @since_tizen 2.3
* @param[in] key The name of the platform feature to get
* @param[out] value The value of the given platform feature
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #SYSTEM_INFO_ERROR_NONE Successful
- * @retval #SYSTEM_INFO_ERROR_INVALID_PARAMETER cannot find key in model config file
- * @retval #SYSTEM_INFO_ERROR_IO_ERROR An input/output error occurred when read value from model config file
+ * @retval #SYSTEM_INFO_ERROR_INVALID_PARAMETER Cannot find the @a key in the model config file
+ * @retval #SYSTEM_INFO_ERROR_IO_ERROR An input/output error occurred while reading the @a value from the model config file
+ * @retval #SYSTEM_INFO_ERROR_PERMISSION_DENIED No permission to use the API
*/
int system_info_get_platform_int(const char *key, int *value);
/**
- * @brief Gets the string value of the platform feature
- * @remarks The @a value must be released with free() by you.
+ * @brief Gets the double value of the @a platform feature.
+ * @since_tizen 2.3
* @param[in] key The name of the platform feature to get
* @param[out] value The value of the given platform feature
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #SYSTEM_INFO_ERROR_NONE Successful
- * @retval #SYSTEM_INFO_ERROR_INVALID_PARAMETER cannot find key in model config file
- * @retval #SYSTEM_INFO_ERROR_IO_ERROR An input/output error occurred when read value from model config file
+ * @retval #SYSTEM_INFO_ERROR_INVALID_PARAMETER Cannot find the @a key in the model config file
+ * @retval #SYSTEM_INFO_ERROR_IO_ERROR An input/output error occurred while reading the @a value from the model config file
+ * @retval #SYSTEM_INFO_ERROR_PERMISSION_DENIED No permission to use the API
*/
int system_info_get_platform_double(const char *key, double *value);
/**
- * @brief Gets the string value of the platform feature
- * @remarks The @a value must be released with free() by you.
+ * @brief Gets the string value of the @a platform feature.
+ * @since_tizen 2.3
+ * @remarks You must release the @a value using free().
* @param[in] key The name of the platform feature to get
* @param[out] value The value of the given platform feature
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #SYSTEM_INFO_ERROR_NONE Successful
* @retval #SYSTEM_INFO_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #SYSTEM_INFO_ERROR_INVALID_PARAMETER cannot find key in model config file
- * @retval #SYSTEM_INFO_ERROR_IO_ERROR An input/output error occurred when read value from model config file
+ * @retval #SYSTEM_INFO_ERROR_INVALID_PARAMETER Cannot find the @a key in the model config file
+ * @retval #SYSTEM_INFO_ERROR_IO_ERROR An input/output error occurred while reading the @a value from the model config file
+ * @retval #SYSTEM_INFO_ERROR_PERMISSION_DENIED No permission to use the API
*/
int system_info_get_platform_string(const char *key, char **value);
/**
- * @brief Gets the boolean value of the custom feature
- * @param[in] key The name of the custom feature to get
+ * @brief Gets the boolean value of the @a custom feature.
+ * @since_tizen 2.3
+ * @param[in] key The name of the custom feature to get. NOTE: This custom function uses a custom key which is provided by OEM's
* @param[out] value The value of the given custom feature
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #SYSTEM_INFO_ERROR_NONE Successful
- * @retval #SYSTEM_INFO_ERROR_INVALID_PARAMETER cannot find key in model config file
- * @retval #SYSTEM_INFO_ERROR_IO_ERROR An input/output error occurred when read value from model config file
+ * @retval #SYSTEM_INFO_ERROR_INVALID_PARAMETER Cannot find the @a key in the model config file
+ * @retval #SYSTEM_INFO_ERROR_IO_ERROR An input/output error occurred while reading the @a value from the model config file
+ * @retval #SYSTEM_INFO_ERROR_PERMISSION_DENIED No permission to use the API
*/
int system_info_get_custom_bool(const char *key, bool *value);
/**
- * @brief Gets the string value of the custom feature
- * @remarks The @a value must be released with free() by you.
- * @param[in] key The name of the custom feature to get
+ * @brief Gets the integer value of the @a custom feature.
+ * @since_tizen 2.3
+ * @param[in] key The name of the custom feature to get. NOTE: This custom function uses a custom key which is provided by OEM's
* @param[out] value The value of the given custom feature
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #SYSTEM_INFO_ERROR_NONE Successful
- * @retval #SYSTEM_INFO_ERROR_INVALID_PARAMETER cannot find key in model config file
- * @retval #SYSTEM_INFO_ERROR_IO_ERROR An input/output error occurred when read value from model config file
+ * @retval #SYSTEM_INFO_ERROR_INVALID_PARAMETER Cannot the find @a key in the model config file
+ * @retval #SYSTEM_INFO_ERROR_IO_ERROR An input/output error occurred while reading the @a value from the model config file
+ * @retval #SYSTEM_INFO_ERROR_PERMISSION_DENIED No permission to use the API
*/
int system_info_get_custom_int(const char *key, int *value);
/**
- * @brief Gets the string value of the custom feature
- * @remarks The @a value must be released with free() by you.
- * @param[in] key The name of the custom feature to get
+ * @brief Gets the double value of the @a custom feature.
+ * @since_tizen 2.3
+ * @param[in] key The name of the custom feature to get. NOTE: This custom function uses a custom key which is provided by OEM's
* @param[out] value The value of the given custom feature
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #SYSTEM_INFO_ERROR_NONE Successful
- * @retval #SYSTEM_INFO_ERROR_INVALID_PARAMETER cannot find key in model config file
- * @retval #SYSTEM_INFO_ERROR_IO_ERROR An input/output error occurred when read value from model config file
+ * @retval #SYSTEM_INFO_ERROR_INVALID_PARAMETER Cannot find the @a key in the model config file
+ * @retval #SYSTEM_INFO_ERROR_IO_ERROR An input/output error occurred while reading the @a value from the model config file
+ * @retval #SYSTEM_INFO_ERROR_PERMISSION_DENIED No permission to use the API
*/
int system_info_get_custom_double(const char *key, double *value);
/**
- * @brief Gets the string value of the custom feature
- * @remarks The @a value must be released with free() by you.
- * @param[in] key The name of the custom feature to get
+ * @brief Gets the string value of the @a custom feature.
+ * @since_tizen 2.3
+ * @remarks You must release the @a value using free().
+ * @param[in] key The name of the custom feature to get. NOTE: This custom function uses a custom key which is provided by OEM's
* @param[out] value The value of the given custom feature
- * @return 0 on success, otherwise a negative error value.
+ * @return @c 0 on success,
+ * otherwise a negative error value
* @retval #SYSTEM_INFO_ERROR_NONE Successful
* @retval #SYSTEM_INFO_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #SYSTEM_INFO_ERROR_INVALID_PARAMETER cannot find key in model config file
- * @retval #SYSTEM_INFO_ERROR_IO_ERROR An input/output error occurred when read value from model config file
+ * @retval #SYSTEM_INFO_ERROR_INVALID_PARAMETER Cannot find the @a key in the model config file
+ * @retval #SYSTEM_INFO_ERROR_IO_ERROR An input/output error occurred while reading the @a value from the model config file
+ * @retval #SYSTEM_INFO_ERROR_PERMISSION_DENIED No permission to use the API
*/
int system_info_get_custom_string(const char *key, char **value);
+
/**
* @}
*/
/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2011 - 2015 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.
#define CPU_INFO_FILE_PATH "/proc/cpuinfo"
#define CPU_INFO_MAX_FREQ_PATH "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq"
#define CONFIG_FILE_PATH "/etc/config/model-config.xml"
+#define SERIAL_PATH "/csa/imei/serialno.dat"
#define MAXBUFSIZE 512
#define PLATFORM_TAG "platform"
-#define CUSTOM_TAG "custom"
+#define CUSTOM_TAG "custom"
#define INTERNAL_TAG "internal"
#define BOOL_TYPE "bool"
#define DBL_TYPE "double"
#define STR_TYPE "string"
+#define BOARD_CONFIG "board"
+
+/**
+ * @brief Enumeration of key for system information
+ */
+typedef enum {
+ SYSTEM_INFO_KEY_MODEL, /**< The model of the device */
+ SYSTEM_INFO_KEY_TIZEN_VERSION, /**< The version of the Tizen API */
+ SYSTEM_INFO_KEY_PLATFORM_NAME, /**< The name of platform */
+ SYSTEM_INFO_KEY_TIZEN_VERSION_NAME, /**< The name of tizen version */
+ SYSTEM_INFO_KEY_MANUFACTURER, /**< The manufacturer of the device */
+ SYSTEM_INFO_KEY_CORE_CPU_ARCH, /**< The CORE CPU architecture of model */
+ SYSTEM_INFO_KEY_CORE_CPU_FREQ, /**< The CORE CPU frequency of model */
+ SYSTEM_INFO_KEY_BUILD_STRING, /**< The build string of platform binary */
+ SYSTEM_INFO_KEY_BUILD_DATE, /**< The build date of platform binary */
+ SYSTEM_INFO_KEY_BUILD_TIME, /**< The build time of platform binary */
+ SYSTEM_INFO_KEY_SCREEN_HEIGHT, /**< The height of the screen in pixels */
+ SYSTEM_INFO_KEY_SCREEN_WIDTH, /**< The width of the screen in pixels */
+ SYSTEM_INFO_KEY_PHYSICAL_SCREEN_HEIGHT, /**< The physical screen height in millimeters */
+ SYSTEM_INFO_KEY_PHYSICAL_SCREEN_WIDTH, /**< The physical screen width in millimeters */
+ SYSTEM_INFO_KEY_TETHERING_SUPPORTED, /**< Indicates whether the device supports tethering */
+} system_info_key_e;
+
typedef enum {
SYSTEM_INFO_DATA_TYPE_STRING,
SYSTEM_INFO_DATA_TYPE_INT,
int system_info_get_build_date(system_info_key_e key, system_info_data_type_e data_type, void **value);
int system_info_get_build_time(system_info_key_e key, system_info_data_type_e data_type, void **value);
int system_info_get_tethering_supported(system_info_key_e key, system_info_data_type_e data_type, void **value);
+
+int system_info_get_no_file(const char *key, void **value);
+
#ifdef __cplusplus
}
#endif
--- /dev/null
+/*
+ * Copyright (c) 2014 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 __TIZEN_SYSTEM_SYSTEM_INFO_TYPE_H__
+#define __TIZEN_SYSTEM_SYSTEM_INFO_TYPE_H__
+
+#include <tizen.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * @addtogroup CAPI_SYSTEM_SYSTEM_INFO_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumeration of error codes for system information
+ */
+typedef enum {
+ SYSTEM_INFO_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ SYSTEM_INFO_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ SYSTEM_INFO_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+ SYSTEM_INFO_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< An input/output error occurred when reading value from system */
+ SYSTEM_INFO_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< No permission to use the API */
+} system_info_error_e;
+
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_SYSTEM_SYSTEM_INFO_TYPE_H__ */
<manifest>
- <request>
- <domain name="_"/>
- </request>
+ <request>
+ <domain name="_"/>
+ </request>
+ <assign>
+ <filesystem path="/etc/make_info_file.sh" exec_label="none" />
+ </assign>
</manifest>
Version: 0.2.0
Release: 0
License: Apache-2.0
-Summary: A System Information library in SLP C API
+Summary: A System Information library in Core API
Group: System/API
Source0: %{name}-%{version}.tar.gz
-Source1001: capi-system-info.manifest
+Source1001: %{name}.manifest
+Source2001: tizenid.service
BuildRequires: cmake
BuildRequires: pkgconfig(capi-base-common)
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(iniparser)
BuildRequires: pkgconfig(libxml-2.0)
-BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(openssl)
+BuildRequires: pkgconfig(cryptsvc)
%if %{with wayland}
BuildRequires: pkgconfig(ecore-wayland)
%endif
%endif
%description
-A System Information library in SLP C API package.
-
+
+
%package devel
-Summary: A System Information library in SLP C API (Development)
-Group: Development/System
-Requires: %{name} = %{version}
+Summary: A System Information library in Core API (Development)
+Group: Development/System
+Requires: %{name} = %{version}-%{release}
%description devel
-A System Information library in SLP C API (Development) package.
-%devel_desc
+
%prep
%setup -q
%install
%make_install
-mkdir -p %{buildroot}%{_bindir}
-cp -f script/make_info_file.sh %{buildroot}%{_bindir}/make_info_file.sh
+mkdir -p %{buildroot}/etc
+cp -f script/make_info_file.sh %{buildroot}/etc/make_info_file.sh
+
+mkdir -p %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants
+install -m 0644 %SOURCE2001 %{buildroot}%{_libdir}/systemd/system/tizenid.service
+ln -s ../tizenid.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/tizenid.service
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
+
%files
%manifest %{name}.manifest
%license LICENSE.APLv2
%{_libdir}/libcapi-system-info.so.*
-%attr(0744,root,-) %{_bindir}/make_info_file.sh
+%attr(0744,root,-) /etc/make_info_file.sh
+%{_bindir}/tizen_id
+%{_libdir}/systemd/system/tizenid.service
+%{_libdir}/systemd/system/multi-user.target.wants/tizenid.service
%files devel
%manifest %{name}.manifest
%{_includedir}/system/system_info.h
+%{_includedir}/system/system_info_type.h
%{_libdir}/pkgconfig/*.pc
%{_libdir}/libcapi-system-info.so
--- /dev/null
+[Unit]
+Description=Making Tizen ID
+Requires=opt-usr.mount
+
+[Service]
+Type=simple
+ExecStart=/usr/bin/tizen_id
+
+[Install]
+WantedBy=multi-user.target
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <ctype.h>
#include <dlog.h>
void __attribute__((constructor)) system_info_init(void)
{
- int ret;
- char *str;
+ int ret, len, i;
+ char *str = NULL;
ret = system_info_get_platform_string("tizen.org/system/model_name", &str);
return;
}
- if (!strcmp(str, "Emulator"))
- system_info_system_info_model_type = SYSTEM_INFO_MODEL_TYPE_EMULATOR;
- else
+ if (!str) {
+ LOGE("Failed to get model name");
+ return;
+ }
+
+ len = strlen(str);
+ for (i = 0 ; i < len ; i++) {
+ str[i] = toupper(str[i]);
+ }
+
+ if (!strcmp(str, "EMULATOR"))
+ system_info_system_info_model_type = SYSTEM_INFO_MODEL_TYPE_EMULATOR;
+ else
system_info_system_info_model_type = SYSTEM_INFO_MODEL_TYPE_TARGET;
free(str);
return system_info_getter(key, system_info->data_type, value);
}
-API int system_info_get_value_int(system_info_key_e key, int *value)
-{
- return system_info_get_value(key, SYSTEM_INFO_DATA_TYPE_INT, (void **)value);
-}
-
-API int system_info_get_value_bool(system_info_key_e key, bool *value)
-{
- return system_info_get_value(key, SYSTEM_INFO_DATA_TYPE_BOOL, (void **)value);
-}
-
-API int system_info_get_value_double(system_info_key_e key, double *value)
-{
- return system_info_get_value(key, SYSTEM_INFO_DATA_TYPE_DOUBLE, (void **)value);
-}
-
-API int system_info_get_value_string(system_info_key_e key, char **value)
-{
- return system_info_get_value(key, SYSTEM_INFO_DATA_TYPE_STRING, (void **)value);
-}
-
API int system_info_get_platform_bool(const char *key, bool *value)
{
int ret;
if (access(CONFIG_FILE_PATH, R_OK)) {
LOGE("cannot find file %s!!!", CONFIG_FILE_PATH);
+ if (errno == EPERM || errno == EACCES)
+ return SYSTEM_INFO_ERROR_PERMISSION_DENIED;
return SYSTEM_INFO_ERROR_IO_ERROR;
}
if (access(CONFIG_FILE_PATH, R_OK)) {
LOGE("cannot find file %s!!!", CONFIG_FILE_PATH);
+ if (errno == EPERM || errno == EACCES)
+ return SYSTEM_INFO_ERROR_PERMISSION_DENIED;
return SYSTEM_INFO_ERROR_IO_ERROR;
}
if (access(CONFIG_FILE_PATH, R_OK)) {
LOGE("cannot find file %s!!!", CONFIG_FILE_PATH);
+ if (errno == EPERM || errno == EACCES)
+ return SYSTEM_INFO_ERROR_PERMISSION_DENIED;
return SYSTEM_INFO_ERROR_IO_ERROR;
}
if (access(CONFIG_FILE_PATH, R_OK)) {
LOGE("cannot find file %s!!!", CONFIG_FILE_PATH);
+ if (errno == EPERM || errno == EACCES)
+ return SYSTEM_INFO_ERROR_PERMISSION_DENIED;
return SYSTEM_INFO_ERROR_IO_ERROR;
}
+ ret = system_info_get_no_file(key, (void**)&string);
+ if (ret == 0) {
+ *value = string;
+ return SYSTEM_INFO_ERROR_NONE;
+ }
+
ret = system_info_get_value_from_config_xml(PLATFORM_TAG, key, STR_TYPE, &string);
if (ret) {
LOGE("cannot get %s", key);
if (access(CONFIG_FILE_PATH, R_OK)) {
LOGE("cannot find file %s!!!", CONFIG_FILE_PATH);
+ if (errno == EPERM || errno == EACCES)
+ return SYSTEM_INFO_ERROR_PERMISSION_DENIED;
return SYSTEM_INFO_ERROR_IO_ERROR;
}
ret = system_info_get_value_from_config_xml(CUSTOM_TAG, key, BOOL_TYPE, &string);
if (ret) {
- LOGI("cannot get %s", key);
- *supported = false;
- return SYSTEM_INFO_ERROR_NONE;
+ LOGE("cannot get %s info from %s!!!", key, CONFIG_FILE_PATH);
+ return ret;
}
if (!strcmp(string, "true") || !strcmp(string, "TRUE"))
if (access(CONFIG_FILE_PATH, R_OK)) {
LOGE("cannot find file %s!!!", CONFIG_FILE_PATH);
+ if (errno == EPERM || errno == EACCES)
+ return SYSTEM_INFO_ERROR_PERMISSION_DENIED;
return SYSTEM_INFO_ERROR_IO_ERROR;
}
ret = system_info_get_value_from_config_xml(CUSTOM_TAG, key, INT_TYPE, &string);
if (ret) {
- LOGI("cannot get %s", key);
- *ret_val = 0;
- return SYSTEM_INFO_ERROR_NONE;
+ LOGE("cannot get %s info from %s!!!", key, CONFIG_FILE_PATH);
+ return ret;
}
*ret_val = atoi(string);
if (access(CONFIG_FILE_PATH, R_OK)) {
LOGE("cannot find file %s!!!", CONFIG_FILE_PATH);
+ if (errno == EPERM || errno == EACCES)
+ return SYSTEM_INFO_ERROR_PERMISSION_DENIED;
return SYSTEM_INFO_ERROR_IO_ERROR;
}
ret = system_info_get_value_from_config_xml(CUSTOM_TAG, key, DBL_TYPE, &string);
if (ret) {
- LOGI("cannot get %s", key);
- *ret_val = 0;
- return SYSTEM_INFO_ERROR_NONE;
-}
+ LOGE("cannot get %s info from %s!!!", key, CONFIG_FILE_PATH);
+ return ret;
+ }
*ret_val = atof(string);
if (access(CONFIG_FILE_PATH, R_OK)) {
LOGE("cannot find file %s!!!", CONFIG_FILE_PATH);
+ if (errno == EPERM || errno == EACCES)
+ return SYSTEM_INFO_ERROR_PERMISSION_DENIED;
return SYSTEM_INFO_ERROR_IO_ERROR;
}
if (manufacturer == NULL) {
LOGE("OUT_OF_MEMORY(0x%08x)", SYSTEM_INFO_ERROR_OUT_OF_MEMORY);
return SYSTEM_INFO_ERROR_OUT_OF_MEMORY;
- }
+ }
*value = manufacturer;
supported = (bool *)value;
if (access(TETHERING_INFO_FILE_PATH, R_OK)) {
- *supported = false;
- return SYSTEM_INFO_ERROR_NONE;
+ *supported = false;
+ return SYSTEM_INFO_ERROR_NONE;
}
if (system_info_get_value_from_xml(TETHERING_INFO_FILE_PATH, model, "tethering-support", &string)) {
- LOGE("cannot get tethering-support info from %s!!!", TETHERING_INFO_FILE_PATH);
- return SYSTEM_INFO_ERROR_IO_ERROR;
+ LOGE("cannot get tethering-support info from %s!!!", TETHERING_INFO_FILE_PATH);
+ return SYSTEM_INFO_ERROR_IO_ERROR;
}
if (!strcmp(string, "true") || !strcmp(string, "TRUE"))
--- /dev/null
+/*
+ * Copyright (c) 2011 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdint.h>
+#include <unistd.h>
+
+#include <dlog.h>
+
+#include <system_info.h>
+#include <system_info_private.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "CAPI_SYSTEM_INFO"
+
+int system_info_get_value_from_cpuinfo(char *field, char **value)
+{
+ int tmpStrlen = 0;
+ FILE *cpuinfo = NULL;
+ char *name = NULL;
+ char str[MAXBUFSIZE] = { 0, };
+ char tmpStr[MAXBUFSIZE] = { 0, };
+
+ if (system_info_get_system_info_model_type() == SYSTEM_INFO_MODEL_TYPE_EMULATOR) {
+ snprintf(tmpStr, sizeof(tmpStr), "default");
+ goto out;
+ }
+
+ cpuinfo = fopen(CPU_INFO_FILE_PATH, "r");
+ if (NULL == cpuinfo) {
+ LOGE("cannot file open %s file!!!", CPU_INFO_FILE_PATH);
+ if (errno == EPERM || errno == EACCES)
+ return SYSTEM_INFO_ERROR_PERMISSION_DENIED;
+ return SYSTEM_INFO_ERROR_IO_ERROR;
+ }
+
+ while (fgets(str, sizeof(str), cpuinfo)) {
+ if (strncmp(field, str, strlen(field)))
+ continue;
+
+ name = strchr(str, ':');
+ tmpStrlen = strlen(name+2);
+ strncpy(tmpStr, name+2, tmpStrlen);
+ tmpStr[tmpStrlen-1] = '\0';
+ break;
+ }
+
+ fclose(cpuinfo);
+
+out:
+ if (strlen(tmpStr) == 0) {
+ LOGE("Failed to get (%s) info", field);
+ return SYSTEM_INFO_ERROR_OUT_OF_MEMORY;
+ }
+
+ *value = strdup(tmpStr);
+ if (*value == NULL) {
+ LOGE("malloc() failed to get (%s) info", field);
+ return SYSTEM_INFO_ERROR_OUT_OF_MEMORY;
+ }
+
+ return SYSTEM_INFO_ERROR_NONE;
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <dlog.h>
+
+#include <system_info.h>
+#include <system_info_private.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "CAPI_SYSTEM_INFO"
+
+#define SERIAL_TOK_DELIMITER ","
+#define BUF_MAX 256
+
+#define TIZEN_ID_PATH "/opt/home/root/tizenid"
+
+static int get_tizenid(char **value)
+{
+ char id[BUF_MAX];
+ FILE *fp;
+
+ fp = fopen(TIZEN_ID_PATH, "r");
+ if (!fp) {
+ LOGE("Failed to open file (%s)", TIZEN_ID_PATH);
+ return SYSTEM_INFO_ERROR_IO_ERROR;
+ }
+
+ if (fgets(id, sizeof(id), fp) == NULL) {
+ LOGE("Failed to get string (errno:%d)", errno);
+ fclose(fp);
+ return SYSTEM_INFO_ERROR_IO_ERROR;
+ }
+
+ fclose(fp);
+
+ if (strlen(id) == 0) {
+ LOGE("String length of id is 0");
+ return SYSTEM_INFO_ERROR_IO_ERROR;
+ }
+
+ *value = strdup(id);
+
+ return 0;
+}
+
+int system_info_get_no_file(const char *key, void **value)
+{
+ char *p_key;
+
+ if (!key || !value)
+ return -EINVAL;
+
+ p_key = strstr(key, "http://");
+ if (p_key && p_key == key)
+ p_key = (char *)key + strlen("http://");
+ else
+ p_key = (char *)key;
+
+ if (!strncmp(p_key, "tizen.org/system/tizenid", strlen(p_key))) {
+ return get_tizenid((char **)value);
+ }
+
+ if (!strncmp(p_key, "tizen.org/system/build.date", strlen(p_key)) ||
+ !strncmp(p_key, "tizen.org/system/build.string", strlen(p_key)) ||
+ !strncmp(p_key, "tizen.org/system/build.time", strlen(p_key)))
+ return system_info_get_platform_string(p_key, (char **)value);
+
+ return -ENOENT;
+}
return SYSTEM_INFO_ERROR_IO_ERROR;
}
- str = iniparser_getstring(ini, key, NULL);
+ str = iniparser_getstr(ini, key);
if (str == NULL) {
LOGE("NOT found %s(0x%08x)", key, SYSTEM_INFO_ERROR_IO_ERROR);
continue;
}
- *value = strdup(string);
+ *value = strdup(string);
free(id);
free(string);
xmlFreeDoc(doc);
continue;
}
- *value = strdup(string);
- free(id);
- free(string);
+ *value = strdup(string);
+ free(id);
+ free(string);
xmlFreeDoc(doc);
if (*value == NULL) {
LOGE("OUT_OF_MEMORY(0x%08x)", SYSTEM_INFO_ERROR_OUT_OF_MEMORY);
}
}
- LOGE("cannot find %s field from %s file!!!", id_field, xml_file_path);
- xmlFreeDoc(doc);
- return SYSTEM_INFO_ERROR_IO_ERROR;
- }
+ LOGE("cannot find %s field from %s file!!!", id_field, xml_file_path);
+ xmlFreeDoc(doc);
+ return SYSTEM_INFO_ERROR_IO_ERROR;
+}
int system_info_get_value_from_config_xml(char *feature_tag, const char *name_field, char *type_field, char **value)
{
xmlNodePtr cur = NULL;
xmlNodePtr model_node = NULL;
xmlNode *cur_node = NULL;
- char *name = NULL;
+ char *name = NULL, *p_name = NULL;
char *type = NULL;
char *string = NULL;
if (model_node == NULL) {
LOGE("cannot find %s field from %s file!!!", name_field, CONFIG_FILE_PATH);
xmlFreeDoc(doc);
- return SYSTEM_INFO_ERROR_IO_ERROR;
+ return SYSTEM_INFO_ERROR_INVALID_PARAMETER;
}
if (model_node) {
name = (char *)xmlGetProp(cur_node, (const xmlChar*)"name");
type = (char *)xmlGetProp(cur_node, (const xmlChar*)"type");
- if (!strncmp(name, name_field, strlen(name))) {
- if (!strncmp(name, name_field, strlen(name_field))) {
+ p_name = strstr(name_field, "http://");
+ if (p_name && p_name == name_field)
+ p_name = (char *)name_field + strlen("http://");
+ else
+ p_name = (char *)name_field;
+
+ if (!strncmp(name, p_name, strlen(name))) {
+ if (!strncmp(name, p_name, strlen(p_name))) {
if (strncmp(type, type_field, strlen(type_field))) {
LOGE("INVALID_PARAMETER(0x%08x) : invalid output param", SYSTEM_INFO_ERROR_INVALID_PARAMETER);
free(name);
if (!cur_node) {
LOGE("cannot find %s field from %s file!!!", name_field, CONFIG_FILE_PATH);
xmlFreeDoc(doc);
- return SYSTEM_INFO_ERROR_IO_ERROR;
+ return SYSTEM_INFO_ERROR_INVALID_PARAMETER;
}
if (*value == NULL) {
&& cpu_arch == true)
CORE_CPU_ARCH = strdup("x86");
- if (CORE_CPU_ARCH == NULL) {
+ if (CORE_CPU_ARCH == NULL) {
LOGE("Unknown cpu");
return SYSTEM_INFO_ERROR_IO_ERROR;
}
cpuinfo_max_freq = fopen(CPU_INFO_MAX_FREQ_PATH, "r");
if (NULL == cpuinfo_max_freq) {
LOGE("cannot file open %s file!!!", CPU_INFO_MAX_FREQ_PATH);
+ if (errno == EPERM || errno == EACCES)
+ return SYSTEM_INFO_ERROR_PERMISSION_DENIED;
return SYSTEM_INFO_ERROR_IO_ERROR;
} else {
if (fscanf(cpuinfo_max_freq, "%lf", &max_freq) < 1) {
cpuinfo = fopen(CPU_INFO_FILE_PATH, "r");
if (NULL == cpuinfo) {
LOGE("cannot file open %s file!!!", CPU_INFO_FILE_PATH);
+ if (errno == EPERM || errno == EACCES)
+ return SYSTEM_INFO_ERROR_PERMISSION_DENIED;
return SYSTEM_INFO_ERROR_IO_ERROR;
} else {
while (fgets(str, MAXBUFSIZE, cpuinfo)) {
int system_info_get_platform_name(system_info_key_e key, system_info_data_type_e data_type, void **value)
{
return system_info_get_platform_string("tizen.org/system/platform.name", (char**)value);
- }
+}
int system_info_get_tizen_version_name(system_info_key_e key, system_info_data_type_e data_type, void **value)
{
info = fopen(OS_RELEASE_FILE_PATH, "r");
if (NULL == info) {
LOGE("cannot file open %s file!!!", OS_RELEASE_FILE_PATH);
+ if (errno == EPERM || errno == EACCES)
+ return SYSTEM_INFO_ERROR_PERMISSION_DENIED;
return SYSTEM_INFO_ERROR_IO_ERROR;
}
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+SET(TIZENID "tizen_id")
+SET(SRCS
+ ${CMAKE_SOURCE_DIR}/src/tizenid/tizenid.c
+)
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(tizenid_pkgs REQUIRED
+ dlog
+ openssl
+ cryptsvc
+)
+
+FOREACH(flag ${tizenid_pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -fno-omit-frame-pointer -finstrument-functions -fpie")
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+
+ADD_EXECUTABLE(${TIZENID} ${SRCS})
+TARGET_LINK_LIBRARIES(${TIZENID} ${tizenid_pkgs_LDFLAGS})
+
+INSTALL(TARGETS ${TIZENID} DESTINATION bin)
--- /dev/null
+/*
+ * tizenid
+ *
+ * Copyright (c) 2014 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 <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <openssl/evp.h>
+#include <openssl/rand.h>
+#include <dlog.h>
+#include <SecCryptoSvc.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "TIZENID"
+
+#define _D(fmt, args...) SLOGD(fmt, ##args)
+#define _E(fmt, args...) SLOGE(fmt, ##args)
+#define _I(fmt, args...) SLOGI(fmt, ##args)
+
+#define KEY_MAX 20
+
+#define TIZEN_ID_PATH "/opt/home/root/tizenid"
+#define RANDOM_PATH "/dev/random"
+#define MODEL_CONFIG_PATH "/etc/config/model-config.xml"
+
+static int get_pw_key(char *pw, unsigned int len)
+{
+ char key[KEY_MAX];/* 128 bit */
+ int fd, ret, i, key_len;
+
+ if (!pw)
+ return -EINVAL;
+
+ fd = open(RANDOM_PATH, O_RDONLY);
+ if (fd == -1) {
+ _E("Failed to open (%s, errno:%d)", RANDOM_PATH, errno);
+ return -errno;
+ }
+
+ key_len = sizeof(key);
+ ret = read(fd, key, key_len);
+ close(fd);
+ if (ret == -1) {
+ _E("Failed to read (%s, errno:%d)", RANDOM_PATH, errno);
+ return -errno;
+ }
+
+ for(i = 0 ; i < len - 1 ; i++) {
+ if (i >= key_len)
+ break;
+ pw[i] = key[i];
+ }
+ pw[i] = '\0';
+
+ return 0;
+}
+
+static int get_salt_by_model(char *salt, unsigned int len)
+{
+ int i;
+ char *str = NULL, *start, *stop;
+ char buf[256];
+ char *key = "tizen.org/system/model_name";
+ FILE *fp;
+
+ if (!salt)
+ return -EINVAL;
+
+ fp = fopen(MODEL_CONFIG_PATH, "r");
+ if (!fp) {
+ _E("Failed to open (%s)", MODEL_CONFIG_PATH);
+ return -ENOENT;
+ }
+
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
+ str = strstr(buf, key);
+ if (!str)
+ continue;
+
+ start = strchr(str, '>');
+ if (!start)
+ continue;
+ stop = strchr(str, '<');
+ if (!stop)
+ continue;
+ if (start >= stop)
+ continue;
+
+ for(start += 1, i = 0; (start < stop) && (i < len-1) ; start++, i++) {
+ salt[i] = start[i];
+ }
+ salt[i] = '\0';
+
+ break;
+ }
+
+ fclose(fp);
+
+ return 0;
+}
+
+static int store_tizen_id(char *id)
+{
+ FILE *fp;
+ int ret;
+
+ if (!id)
+ return -EINVAL;
+
+ fp = fopen(TIZEN_ID_PATH, "w");
+ if (!fp) {
+ _E("Failed to open file (%s)", TIZEN_ID_PATH);
+ return -ENOMEM;
+ }
+
+ ret = fputs(id, fp);
+ fclose(fp);
+ if (ret == EOF) {
+ _E("Failed to store id");
+ return -ENOMEM;
+ }
+
+ ret = chmod(TIZEN_ID_PATH, 0554);
+ if (ret == -1) {
+ _E("chmod() failed(errno:%d)", errno);
+ return -errno;
+ }
+
+ return 0;
+}
+
+static int make_tizen_id(void)
+{
+ char salt[KEY_MAX], pw_key[KEY_MAX];
+ char *id = NULL, *id_64 = NULL;
+ int ret;
+
+ ret = get_salt_by_model(salt, sizeof(salt));
+ if (ret < 0) {
+ _E("Failed to get salt value (%d)", ret);
+ return ret;
+ }
+
+ ret = get_pw_key(pw_key, sizeof(pw_key));
+ if (ret < 0) {
+ _E("Failed to get pw key value (%d)", ret);
+ return ret;
+ }
+
+ id = (char *)malloc(sizeof(char) * KEY_MAX);
+ if (!id) {
+ _E("malloc() failed");
+ return -ENOMEM;
+ }
+
+ ret = PKCS5_PBKDF2_HMAC_SHA1(pw_key, strlen(pw_key), /* pw key */
+ (unsigned char *)salt, sizeof(salt), /*salt*/
+ 1, /* nr of iteration */
+ KEY_MAX, (unsigned char *)id); /* output */
+ if (ret == 0) { /* 0: failed, 1: successful */
+ _E("PKCS5_PBKDF2_HMAC_SHA1() failed");
+ ret = -ENOENT;
+ goto out;
+ }
+
+ id[KEY_MAX-1] = '\0';
+ _I("ID: (%s)", id);
+
+ id_64 = Base64Encoding(id, KEY_MAX);
+
+ ret = store_tizen_id(id_64);
+ if (ret < 0) {
+ _E("Failed to store tizen id to file (%d)", ret);
+ goto out;
+ }
+
+ ret = 0;
+
+out:
+ if (id)
+ free(id);
+ if (id_64)
+ free(id_64);
+
+ return ret;
+}
+
+int main(int argc, char *argv[])
+{
+ if (access(TIZEN_ID_PATH, F_OK) == 0)
+ return 0;
+
+ return make_tizen_id();
+}