From 777dc58a0ecd98e7de698ed0cd6235f79a322e8a Mon Sep 17 00:00:00 2001 From: Jean-Benoit MARTIN Date: Thu, 23 Jan 2014 17:30:28 +0100 Subject: [PATCH] remove hardcoded path for multiuser support Bug-Tizen: PTREL-338 Change-Id: Iac0b1f033b8ad12324eacd68a58c693051d7c986 Signed-off-by: Jean-Benoit MARTIN --- agent/CMakeLists.txt | 1 + agent/download-agent-file.c | 4 +++- agent/include/download-agent-file.h | 2 +- packaging/download-provider.spec | 17 ++++------------- provider/CMakeLists.txt | 9 +++------ provider/download-provider-db.c | 3 +++ 6 files changed, 15 insertions(+), 21 deletions(-) diff --git a/agent/CMakeLists.txt b/agent/CMakeLists.txt index 26f2b34..92c1677 100755 --- a/agent/CMakeLists.txt +++ b/agent/CMakeLists.txt @@ -21,6 +21,7 @@ pkg_check_modules(subpkgs REQUIRED capi-network-connection glib-2.0 dlog + libtzplatform-config ) FOREACH(flag ${subpkgs_CFLAGS}) diff --git a/agent/download-agent-file.c b/agent/download-agent-file.c index 0da5445..59b093a 100755 --- a/agent/download-agent-file.c +++ b/agent/download-agent-file.c @@ -19,6 +19,8 @@ #include #include #include +#include + #include "download-agent-client-mgr.h" #include "download-agent-debug.h" #include "download-agent-utils.h" @@ -1152,7 +1154,7 @@ da_result_t create_dir(const char *install_dir) ret = DA_ERR_FAIL_TO_ACCESS_STORAGE; } else { DA_SECURE_LOGD("[%s] is created!", install_dir); - if (chown(install_dir, 5000, 5000) < 0) { + if (chown(install_dir, tzplatform_getuid(TZ_USER_NAME),tzplatform_getuid(TZ_SYS_USER_GROUP)) < 0) { DA_LOG_ERR(FileManager, "Fail to chown"); ret = DA_ERR_FAIL_TO_ACCESS_STORAGE; } diff --git a/agent/include/download-agent-file.h b/agent/include/download-agent-file.h index b4d3995..a537bb7 100755 --- a/agent/include/download-agent-file.h +++ b/agent/include/download-agent-file.h @@ -24,7 +24,7 @@ #include "download-agent-type.h" #include "download-agent-dl-mgr.h" -#define DA_DEFAULT_INSTALL_PATH_FOR_PHONE "/opt/usr/media/Downloads" +#define DA_DEFAULT_INSTALL_PATH_FOR_PHONE tzplatform_getenv(TZ_USER_DOWNLOADS) da_bool_t is_file_exist(const char *file_path); da_bool_t is_dir_exist(const char *dir_path); diff --git a/packaging/download-provider.spec b/packaging/download-provider.spec index 81ed6f7..d05584a 100755 --- a/packaging/download-provider.spec +++ b/packaging/download-provider.spec @@ -32,6 +32,8 @@ BuildRequires: pkgconfig(wifi-direct) BuildRequires: pkgconfig(libsmack) BuildRequires: gettext-devel BuildRequires: pkgconfig(libsystemd-daemon) +BuildRequires: pkgconfig(libtzplatform-config) +Requires: libtzplatform-config %description Description: download the contents in background @@ -47,15 +49,13 @@ Description: download the contents in background (development files) %prep %setup -q -%define _data_install_path /usr/share/%{name} +%define _data_install_path %{_datadir}/%{name} %define _imagedir %{_data_install_path}/images %define _localedir %{_data_install_path}/locales %define _sqlschemadir %{_data_install_path}/sql -%define _databasedir /opt/usr/dbspace -%define _databasefile %{_databasedir}/.download-provider.db %define _sqlschemafile %{_sqlschemadir}/download-provider-schema.sql %define _licensedir /usr/share/license -%define _smackruledir /opt/etc/smack/accesses.d +%define _smackruledir %{TZ_SYS_SMACK}/accesses.d %define cmake \ CFLAGS="${CFLAGS:-%optflags} -fPIC -D_REENTRANT -fvisibility=hidden"; export CFLAGS \ @@ -72,7 +72,6 @@ Description: download the contents in background (development files) -DIMAGE_DIR:PATH=%{_imagedir} \\\ -DLOCALE_DIR:PATH=%{_localedir} \\\ -DDATABASE_SCHEMA_DIR=%{_sqlschemadir} \\\ - -DDATABASE_FILE:PATH=%{_databasefile} \\\ -DDATABASE_SCHEMA_FILE=%{_sqlschemafile} \\\ -DLICENSE_DIR:PATH=%{_licensedir} \\\ -DSMACK_RULE_DIR:PATH=%{_smackruledir} \\\ @@ -114,16 +113,8 @@ ln -s ../download-provider.socket %{buildroot}%{_libdir}/systemd/system/sockets. /sbin/ldconfig %post -mkdir -p %{_databasedir} /sbin/ldconfig -if [ ! -f %{_databasefile} ]; -then -sqlite3 %{_databasefile} '.read %{_sqlschemafile}' -chmod 660 %{_databasefile} -chmod 660 %{_databasefile}-journal -fi - %files %defattr(-,root,root,-) %manifest download-provider.manifest diff --git a/provider/CMakeLists.txt b/provider/CMakeLists.txt index be89a9d..fef1222 100755 --- a/provider/CMakeLists.txt +++ b/provider/CMakeLists.txt @@ -19,8 +19,9 @@ pkg_check_modules(dp2_pkgs REQUIRED glib-2.0 appsvc bundle libsmack - dlog - libsystemd-daemon) + libsystemd-daemon + libtzplatform-config + dlog) FOREACH(flag ${dp2_pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") @@ -38,10 +39,6 @@ set(DP2_LINK_LIBRARIES ${GLIB-2_LIBRARIES} SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -Wall") -IF(DEFINED DATABASE_FILE) - ADD_DEFINITIONS(-DDATABASE_FILE=\"${DATABASE_FILE}\") -ENDIF(DEFINED DATABASE_FILE) - IF(DEFINED DATABASE_SCHEMA_FILE) ADD_DEFINITIONS(-DDATABASE_SCHEMA_FILE=\"${DATABASE_SCHEMA_FILE}\") ENDIF(DEFINED DATABASE_SCHEMA_FILE) diff --git a/provider/download-provider-db.c b/provider/download-provider-db.c index 4bc1353..8a86d30 100755 --- a/provider/download-provider-db.c +++ b/provider/download-provider-db.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -27,6 +28,8 @@ #include "download-provider-log.h" #include "download-provider-pthread.h" +#define DATABASE_FILE tzplatform_mkpath(TZ_USER_DB,".download-provider.db") + //BASIC #define DP_DB_BASIC_GET_QUERY_FORMAT "SELECT %s FROM %s WHERE id = ?" #define DP_DB_BASIC_SET_QUERY_FORMAT "UPDATE %s SET %s = ? WHERE id = ?" -- 2.7.4