Change owner from root and Modify 3.0 APIs for UTC 48/43448/1 submit/tizen/20150709.101841
authorYongjin Kim <youth.kim@samsung.com>
Thu, 9 Jul 2015 10:00:53 +0000 (19:00 +0900)
committerYongjin Kim <youth.kim@samsung.com>
Thu, 9 Jul 2015 10:00:53 +0000 (19:00 +0900)
Change-Id: I9ef9dca85e275381030a88722ab7bdec017e7cb2
Signed-off-by: Yongjin Kim <youth.kim@samsung.com>
CMakeLists.txt
client/sal_service_adaptor.c
client/sal_service_storage.c
client/sal_service_task.c
include/service_adaptor_internal.h
packaging/org.tizen.serviceadaptor.client.conf
packaging/org.tizen.serviceadaptor.client.service
packaging/service-adaptor.service
packaging/service-adaptor.spec
service-adaptor.manifest
service-adaptor.pc.in

index ed2d584..bbc6f3c 100644 (file)
@@ -43,6 +43,9 @@ ADD_SUBDIRECTORY(test)
 # Define Install Files
 ##########################################################
 
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/packaging/service-adaptor.service DESTINATION /usr/lib/systemd/user)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/packaging/org.tizen.serviceadaptor.client.service DESTINATION /usr/share/dbus-1/system-services)
+
 CONFIGURE_FILE(service-adaptor.pc.in service-adaptor.pc @ONLY)
 INSTALL(FILES ${CMAKE_BINARY_DIR}/service-adaptor.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
 
index 971c316..fbe67b0 100644 (file)
@@ -55,6 +55,7 @@ typedef struct _service_adaptor_s *service_adaptor_h;
 typedef struct _service_plugin_s
 {
        char *uri;
+       GHashTable *property;
 } service_plugin_s;
 
 service_adaptor_h service_adaptor = NULL;
@@ -188,6 +189,7 @@ API int service_plugin_create(const char *uri, service_plugin_h *plugin)
        service_plugin_h service_plugin = (service_plugin_h) g_malloc0(sizeof(service_plugin_s));
 
        service_plugin->uri = strdup(uri);
+       service_plugin->property = g_hash_table_new(g_str_hash, g_str_equal);
 
        *plugin = service_plugin;
 
@@ -217,6 +219,8 @@ API int service_plugin_add_property(service_plugin_h plugin, const char *key, co
        RETV_IF(NULL == key, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == value, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
 
+       g_hash_table_insert(plugin->property, key, value);
+
        return SERVICE_ADAPTOR_ERROR_NONE;
 }
 
@@ -226,6 +230,8 @@ API int service_plugin_remove_property(service_plugin_h plugin, const char *key)
        RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == key, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
 
+       g_hash_table_remove(plugin->property, key);
+
        return SERVICE_ADAPTOR_ERROR_NONE;
 }
 
@@ -236,7 +242,23 @@ API int service_plugin_get_property(service_plugin_h plugin, const char *key, ch
        RETV_IF(NULL == key, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == value, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
 
-       return SERVICE_ADAPTOR_ERROR_NONE;
+       if (0 < g_hash_table_size(plugin->property))
+       {
+               GHashTableIter iter;
+               gpointer iter_key, iter_value;
+
+               g_hash_table_iter_init(&iter, plugin->property);
+               while (g_hash_table_iter_next(&iter, &iter_key, &iter_value))
+               {
+                       if (strcmp(key, (char *) iter_key) == 0)
+                       {
+                               *value = g_strdup(iter_value);
+                               return SERVICE_ADAPTOR_ERROR_NONE;
+                       }
+               }
+       }
+
+       return SERVICE_ADAPTOR_ERROR_NO_DATA;
 }
 
 API int service_plugin_login(service_plugin_h plugin, service_plugin_login_cb callback, void *user_data)
index 02422cf..cb17303 100644 (file)
@@ -89,6 +89,14 @@ API int service_storage_cloud_file_create(service_plugin_h plugin, service_stora
 
        service_storage_cloud_file_h cloud_file = (service_storage_cloud_file_h) g_malloc0(sizeof(service_storage_cloud_file_s));
        cloud_file->plugin = plugin;
+       cloud_file->callback = NULL;
+       cloud_file->is_dir = false;
+       cloud_file->size = 0;
+       cloud_file->dir_path = NULL;
+       cloud_file->local_path = NULL;
+       cloud_file->cloud_path = NULL;
+       cloud_file->operation = NULL;
+       cloud_file->files = NULL;
 
        *file = cloud_file;
 
@@ -100,18 +108,26 @@ API int service_storage_cloud_file_clone(service_storage_cloud_file_h src_file,
        SAL_FN_CALL;
 
        RETV_IF(NULL == src_file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == dst_file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
 
        service_storage_cloud_file_h cloud_file = (service_storage_cloud_file_h) g_malloc0(sizeof(service_storage_cloud_file_s));
        cloud_file->plugin = src_file->plugin;
        cloud_file->callback = src_file->callback;
        cloud_file->is_dir = src_file->is_dir;
-       cloud_file->dir_path = strdup(src_file->dir_path);
-       cloud_file->local_path = strdup(src_file->local_path);
-       cloud_file->cloud_path = strdup(src_file->cloud_path);
        cloud_file->size = src_file->size;
-       cloud_file->operation = strdup(src_file->operation);
+       cloud_file->dir_path = g_strdup(src_file->dir_path);
+       cloud_file->local_path = g_strdup(src_file->local_path);
+       cloud_file->cloud_path = g_strdup(src_file->cloud_path);
+       cloud_file->operation = g_strdup(src_file->operation);
        // TODO: g_list_copy_deep()
-       cloud_file->files = g_list_copy(src_file->files);
+       if (NULL != src_file->files)
+       {
+               cloud_file->files = g_list_copy(src_file->files);
+       }
+       else
+       {
+               cloud_file->files = NULL;
+       }
 
        *dst_file = cloud_file;
 
@@ -122,6 +138,8 @@ API int service_storage_cloud_file_destroy(service_storage_cloud_file_h file)
 {
        SAL_FN_CALL;
 
+       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
        SAL_FREE(file->dir_path);
        SAL_FREE(file->local_path);
        SAL_FREE(file->cloud_path);
@@ -175,7 +193,7 @@ API int service_storage_cloud_file_get_cloud_path(service_storage_cloud_file_h f
        RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == cloud_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
 
-       *cloud_path = strdup(file->cloud_path);
+       *cloud_path = g_strdup(file->cloud_path);
 
        return SERVICE_ADAPTOR_ERROR_NONE;
 }
@@ -199,7 +217,7 @@ API int service_storage_cloud_file_get_local_path(service_storage_cloud_file_h f
        RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == local_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
 
-       *local_path = strdup(file->local_path);
+       *local_path = g_strdup(file->local_path);
 
        return SERVICE_ADAPTOR_ERROR_NONE;
 }
@@ -209,7 +227,6 @@ API int service_storage_cloud_file_set_size(service_storage_cloud_file_h file, u
        SAL_FN_CALL;
 
        RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(0 > size, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
 
        file->size = size;
 
@@ -247,7 +264,7 @@ API int service_storage_cloud_file_get_operation(service_storage_cloud_file_h fi
        RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == operation, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
 
-       *operation = strdup(file->operation);
+       *operation = g_strdup(file->operation);
 
        return SERVICE_ADAPTOR_ERROR_NONE;
 }
@@ -271,7 +288,7 @@ API int service_storage_cloud_file_foreach_file(service_storage_cloud_file_h fil
        RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
 
-       RETV_IF(false == file->is_dir, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(false == file->is_dir, SERVICE_ADAPTOR_ERROR_NO_DATA);
 
        RETV_IF(0 == g_list_length(file->files), SERVICE_ADAPTOR_ERROR_NO_DATA);
 
index 4bbd229..3787456 100644 (file)
@@ -141,7 +141,7 @@ API int service_task_get_uri(service_task_h task, char **uri)
        RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == uri, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
 
-       *uri = strdup(task->uri);
+       *uri = g_strdup(task->uri);
 
        return SERVICE_ADAPTOR_ERROR_NONE;
 }
index 8bf04cc..d5cef4d 100644 (file)
@@ -78,8 +78,6 @@
 
         #define SAL_FN_CALL DBG(">>>>>>>> called")
         #define SAL_FN_END DBG("<<<<<<<< ended")
-//        #define SAL_FN_CALL INFO(">>>>>>>> called")
-//        #define SAL_FN_END INFO("<<<<<<<< ended")
 
         #define SAL_DBG(fmt, arg...) DBG(fmt, ##arg)
         #define SAL_WARN(fmt, arg...) WARN(fmt, ##arg)
 #define SAL_STRDUP(dst, ptr) do { \
        if (ptr) \
                dst = strdup(ptr); \
-       ptr = NULL; \
+       else \
+               dst = NULL; \
 } while(0)
 
 #define SAL_FREE(ptr) do { \
index d575a9d..c6083cf 100644 (file)
@@ -2,8 +2,12 @@
 <!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
  "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
 <busconfig>
-    <policy user="system">
+    <policy group="users">
         <allow own="org.tizen.serviceadaptor.client"/>
+       <allow send_type="method_call"/>
+    </policy>
+    <policy at_console="true">
+       <allow send_destination="org.tizen.serviceadaptor.client"/>
     </policy>
     <policy context="default">
         <allow send_destination="org.tizen.serviceadaptor.client"/>
index 0f3d406..4bd3a84 100644 (file)
@@ -2,5 +2,4 @@
 Name=org.tizen.serviceadaptor.client
 Exec=/bin/false
 SystemdService=service-adaptor.service
-User=system
-Group=system
+User=root
index 6529108..b279867 100644 (file)
@@ -1,17 +1,12 @@
 [Unit]
 Description=Service Adaptor daemon
-Requires=tizen-runtime.target
-After=tizen-runtime.target
 
 [Service]
-User=system
-Group=system
-SmackProcessLabel=service-adaptor
 Type=dbus
 BusName=org.tizen.serviceadaptor.client
 ExecStart=/usr/bin/service-adaptor-server
-Restart=always
-RestartSec=1
+Restart=none
+RestartSec=0
 
 [Install]
-WantedBy=multi-user.target
+WantedBy=default.target
index ed0b387..c9bc252 100644 (file)
@@ -57,13 +57,12 @@ make %{?_smp_mflags}
 rm -rf %{buildroot}
 %make_install
 
-mkdir -p %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants
-install -m 0644 %SOURCE1 %{buildroot}%{_libdir}/systemd/system/
-ln -sf ../service-adaptor.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/
+mkdir -p %{buildroot}%{_libdir}/systemd/user/default.target.wants
+ln -s %{_libdir}/systemd/user/service-adaptor.service %{buildroot}%{_libdir}/systemd/user/default.target.wants/service-adaptor.service
 
-mkdir -p %{buildroot}/usr/lib/systemd/user/tizen-middleware.target.wants
-cp %SOURCE1 %{buildroot}/usr/lib/systemd/user/service-adaptor.service
-ln -s ../service-adaptor.service %{buildroot}/usr/lib/systemd/user/tizen-middleware.target.wants/
+mkdir -p %{buildroot}/etc/dbus-1/system.d
+ls -l
+install -m 0644 packaging/org.tizen.serviceadaptor.client.conf %{buildroot}/etc/dbus-1/system.d/org.tizen.serviceadaptor.client.conf
 
 mkdir -p %{buildroot}/usr/share/license
 cp LICENSE.APLv2 %{buildroot}/usr/share/license/service-adaptor
@@ -76,19 +75,17 @@ cp LICENSE.APLv2 %{buildroot}/usr/share/license/service-adaptor-devel
 
 %files -n service-adaptor
 %manifest service-adaptor.manifest
-#%defattr(-,system,system,-)
 %defattr(-,root,root,-)
 %{_libdir}/lib*.so.*
-%{_bindir}/service-adaptor-server
-%{_bindir}/sal-test
-/usr/lib/systemd/user/service-adaptor.service
-/usr/lib/systemd/user/tizen-middleware.target.wants/service-adaptor.service
-%{_libdir}/systemd/system/service-adaptor.service
-%{_libdir}/systemd/system/multi-user.target.wants/service-adaptor.service
+%caps(cap_mac_admin,cap_chown,cap_dac_override,cap_lease,cap_setgid,cap_setuid=eip) %attr(755,root,root) %{_bindir}/service-adaptor-server
+%caps(cap_mac_admin,cap_chown,cap_dac_override,cap_lease,cap_setgid,cap_setuid=eip) %attr(755,root,root) %{_bindir}/sal-test
+%attr(644,root,root) %{_libdir}/systemd/user/service-adaptor.service
+%attr(644,root,root) %{_libdir}/systemd/user/default.target.wants/service-adaptor.service
+/usr/share/dbus-1/system-services/org.tizen.serviceadaptor.client.service
+/etc/dbus-1/system.d/org.tizen.serviceadaptor.client.conf
 /usr/share/license/%{name}
 
 %files -n service-adaptor-devel
-#%defattr(-,system,system,-)
 %defattr(-,root,root,-)
 %{_libdir}/lib*.so
 %{_libdir}/pkgconfig/service-adaptor.pc
index fcb2a80..dd8b60a 100644 (file)
@@ -7,7 +7,7 @@
                <request>
                        <smack request="system::use_internet" type="rw"/>
                        <smack request="system::media" type="rwxt"/>
-                       <smack request="sys-assert::core" type="rwx"/>
+                       <smack request="sys-assert::core" type="rwxat"/>
                        <smack request="pkgmgr::info" type="rxw"/>
                        <smack request="pkgmgr::db" type="rxwl"/>
                        <smack request="pkgmgr::svc" type="rxw"/>
                </request>
        </define>
        <assign>
+               <filesystem path="/usr/share/dbus-1/system-services/org.tizen.serviceadaptor.client.service" label="_"/>
                <filesystem path="/usr/lib/systemd/system/service-adaptor.service" label="_"/>
-               <filesystem path="/usr/lib/systemd/system/multi-user.target.wants/service-adaptor.service" label="_"/>
+               <filesystem path="/etc/dbus-1/system.d/org.tizen.serviceadaptor.client.conf" label="_"/>
+               <filesystem path="/usr/lib/*" exec_label="none" label="_"/>
        </assign>
        <request>
                <domain name="service-adaptor" />
index f928be8..ef06945 100644 (file)
@@ -1,5 +1,5 @@
 prefix=/usr
-libdir=${prefix}/lib
+libdir=@LIB_INSTALL_DIR@
 includedir=${prefix}/include
 
 Name: service-adaptor library