From: jongmyeongko Date: Wed, 27 Jul 2016 10:24:25 +0000 (+0900) Subject: new internal API for parser-plugin to get target_uid. X-Git-Tag: submit/tizen/20160803.012753^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c9cb375d22f9360de16c7459c3f516dc31729040;p=platform%2Fcore%2Fappfw%2Fslp-pkgmgr.git new internal API for parser-plugin to get target_uid. Change-Id: Id6ae8ce79be686659baab096ed7db70a5e4263d4 Signed-off-by: jongmyeongko --- diff --git a/installer/CMakeLists.txt b/installer/CMakeLists.txt index aa2afa1..379aa14 100644 --- a/installer/CMakeLists.txt +++ b/installer/CMakeLists.txt @@ -40,21 +40,11 @@ set_target_properties(pkgmgr_installer PROPERTIES VERSION ${VERSION}) set_target_properties(pkgmgr_installer PROPERTIES COMPILE_FLAGS "${installer_pkgs_CFLAGS_str}") target_link_libraries(pkgmgr_installer ${installer_pkgs_LDFLAGS}) - ### Create pc file configure_file(pkgmgr-installer.pc.in ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer.pc @ONLY) - ## Install -INSTALL(TARGETS - pkgmgr_installer - DESTINATION ${LIB_INSTALL_DIR} - COMPONENT RuntimeLibraries) -INSTALL(FILES - pkgmgr_installer.h - DESTINATION include/pkgmgr) - - -INSTALL(FILES - ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer.pc - DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) +INSTALL(TARGETS pkgmgr_installer DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries) +INSTALL(FILES pkgmgr_installer.h DESTINATION include/pkgmgr) +INSTALL(FILES pkgmgr_installer_info.h DESTINATION include/pkgmgr) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) diff --git a/installer/pkgmgr_installer.c b/installer/pkgmgr_installer.c index 2f014d7..12273d1 100644 --- a/installer/pkgmgr_installer.c +++ b/installer/pkgmgr_installer.c @@ -32,6 +32,7 @@ #include "pkgmgr_installer.h" #include "pkgmgr_installer_config.h" #include "pkgmgr_installer_debug.h" +#include "pkgmgr_installer_info.h" #include "../client/include/comm_config.h" @@ -65,6 +66,8 @@ struct pkgmgr_installer { GDBusConnection *conn; }; +static uid_t g_target_uid; + static const char *__get_signal_name(pkgmgr_installer *pi, const char *key) { if (strcmp(key, PKGMGR_INSTALLER_INSTALL_PERCENT_KEY_STR) == 0) @@ -248,6 +251,7 @@ pkgmgr_installer_receive_request(pkgmgr_installer *pi, int mode = 0; pi->target_uid = getuid(); + g_target_uid = pi->target_uid; while (1) { c = getopt_long(argc, argv, short_opts, long_opts, &opt_idx); /* printf("c=%d %c\n", c, c); //debug */ @@ -523,6 +527,7 @@ API int pkgmgr_installer_set_uid(pkgmgr_installer *pi, uid_t uid) return -1; pi->target_uid = uid; + g_target_uid = pi->target_uid; return 0; } @@ -620,3 +625,10 @@ API int pkgmgr_installer_delete_certinfo(const char *pkgid) ret = pkgmgrinfo_delete_certinfo(pkgid); return ret; } + +API int pkgmgr_installer_info_get_target_uid(uid_t *uid) +{ + *uid = g_target_uid; + + return 0; +} diff --git a/installer/pkgmgr_installer_info.h b/installer/pkgmgr_installer_info.h new file mode 100644 index 0000000..0f29f6e --- /dev/null +++ b/installer/pkgmgr_installer_info.h @@ -0,0 +1,58 @@ +/* + * slp-pkgmgr + * + * Copyright (c) 2016 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 __PKGMGR_INSTALLER_INFO_H__ +#define __PKGMGR_INSTALLER_INFO_H__ + +/** + * @file pkgmgr_installer_info.h + * @brief This file declares API for getting information of pkgmgr_installer + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Get target_uid for pkg to be installed path + * @pre None + * @post None + * @param[out] uid user id + * @return 0 if success, else retrun < 0 + * @code + #include + int main() + { + uid_t uid; + if (pkgmgr_installer_info_get_target_uid(&uid) < 0) { + printf("failed to get target uid\n"); + } + printf("uid = %d\n", uid); + } + * @endcode + */ +int pkgmgr_installer_info_get_target_uid(uid_t *uid); + +#ifdef __cplusplus +} +#endif + +#endif /* __PKGMGR_INSTALLER_INFO_H__ */ + diff --git a/packaging/pkgmgr.spec b/packaging/pkgmgr.spec index 6439c13..3dfcbb7 100644 --- a/packaging/pkgmgr.spec +++ b/packaging/pkgmgr.spec @@ -165,7 +165,7 @@ HOME="$saveHOME" %manifest %{name}-installer-devel.manifest %defattr(-,root,root,-) %dir %{_includedir}/pkgmgr -%{_includedir}/pkgmgr/pkgmgr_installer.h +%{_includedir}/pkgmgr/*.h %{_libdir}/pkgconfig/pkgmgr-installer.pc %{_libdir}/libpkgmgr_installer.so