From: Jiwan Kim Date: Thu, 2 Jul 2015 05:27:21 +0000 (+0900) Subject: Code sync from tizen_2.4 X-Git-Tag: accepted/tizen/mobile/20150708.015034~1 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Ftelephony%2Ftelephony-daemon.git;a=commitdiff_plain;h=19262d06a85436f94c3b5851d5c2a8efb99369c1 Code sync from tizen_2.4 Change-Id: I3af42c7aa5b3453cdb5fe5555049e29d284f8a2f --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d85725..9f85b49 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,9 +16,11 @@ ENDFOREACH(flag) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/) -SET(ADDITIONAL_CFLAGS "-Wno-array-bounds -Wno-empty-body -Wno-ignored-qualifiers -Wshadow -Wwrite-strings -Wswitch-default -Wno-unused-but-set-parameter -Wno-unused-but-set-variable") -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Werror -Wextra -Wall -Wdeclaration-after-statement -Wmissing-declarations -Wredundant-decls -Wcast-align -Wcast-qual") -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ADDITIONAL_CFLAGS}") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Werror -Wextra -Wall -Wdeclaration-after-statement -Wmissing-declarations -Wredundant-decls -Wcast-align -Wcast-qual -Wno-array-bounds -Wno-empty-body -Wno-ignored-qualifiers -Wshadow -Wwrite-strings -Wswitch-default -Wno-unused-but-set-parameter -Wno-unused-but-set-variable") + +##Address-Space Layout Randomization +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIE") +SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") ADD_DEFINITIONS("-DFEATURE_TLOG_DEBUG") ADD_DEFINITIONS("-DTCORE_LOG_TAG=\"DAEMON\"") diff --git a/packaging/telephony-daemon.service b/packaging/telephony-daemon.service index 24a81d1..043dce4 100644 --- a/packaging/telephony-daemon.service +++ b/packaging/telephony-daemon.service @@ -1,10 +1,11 @@ [Unit] Description=Telephony daemon -Requires=dbus.socket -After=factory-reset.service secure-storage.service dlog_logger.service shutdown.target +After=secure-storage.service [Service] -Type=simple +User=system +Group=system +SmackProcessLabel=telephony_framework ExecStart=/usr/bin/telephony-daemon Restart=always RestartSec=0 diff --git a/packaging/telephony-daemon.spec b/packaging/telephony-daemon.spec index 4e2555a..49313b5 100644 --- a/packaging/telephony-daemon.spec +++ b/packaging/telephony-daemon.spec @@ -1,11 +1,11 @@ %define major 1 %define minor 3 -%define patchlevel 24 +%define patchlevel 33 Name: telephony-daemon Version: %{major}.%{minor}.%{patchlevel} Release: 1 -License: Apache +License: Apache-2.0 Summary: Telephony Daemon Group: System/Telephony Source0: %{name}-%{version}.tar.gz @@ -39,8 +39,8 @@ ln -s %{_libdir}/systemd/system/telephony-daemon.service %{buildroot}%{_libdir}/ %files %manifest telephony-daemon.manifest -%defattr(-,root,root,-) -%{_bindir}/telephony-daemon -%attr(644,root,root) %{_libdir}/systemd/system/telephony-daemon.service -%attr(644,root,root) %{_libdir}/systemd/system/multi-user.target.wants/telephony-daemon.service +%defattr(644,system,system,-) +%caps(cap_mac_override,cap_dac_override,cap_net_admin=eip) %attr(755,system,system) %{_bindir}/telephony-daemon +%{_libdir}/systemd/system/telephony-daemon.service +%{_libdir}/systemd/system/multi-user.target.wants/telephony-daemon.service %{_datadir}/license/telephony-daemon diff --git a/src/main.c b/src/main.c index e04dc9f..77a1329 100644 --- a/src/main.c +++ b/src/main.c @@ -48,34 +48,35 @@ #endif #define NOTUSED(var) (var = var) +#define BUFFER_SIZE 1024 static Server *_server = NULL; static void __usage_info(const char *exec) { - printf("Usage: %s [OPTION]... [PLUGIN_PATH]\n", exec); - printf("\n"); - printf(" -T, --testload\t run with plugin load test mode and exit\n"); - printf(" -h, --help\t\t display this help and exit\n"); - printf("\n"); + info("Usage: %s [OPTION]... [PLUGIN_PATH]\n", exec); + info("\n"); + info(" -T, --testload\t run with plugin load test mode and exit\n"); + info(" -h, --help\t\t display this help and exit\n"); + info("\n"); } void tcore_log(enum tcore_log_type type, enum tcore_log_priority priority, const char *tag, const char *fmt, ...) { va_list ap; - char buf[1024]; + char buf[BUFFER_SIZE]; switch (type) { case TCORE_LOG_TYPE_RADIO: { if (priority >= TCORE_LOG_INFO) { va_start(ap, fmt); - vsnprintf(buf, 1023, fmt, ap); + vsnprintf(buf, BUFFER_SIZE-1, fmt, ap); va_end(ap); __dlog_print(LOG_ID_RADIO, priority, tag, buf); } else { #ifdef TIZEN_DEBUG_ENABLE va_start(ap, fmt); - vsnprintf(buf, 1023, fmt, ap); + vsnprintf(buf, BUFFER_SIZE-1, fmt, ap); va_end(ap); __dlog_print(LOG_ID_RADIO, priority, tag, buf); #endif @@ -89,14 +90,14 @@ void tcore_log(enum tcore_log_type type, enum tcore_log_priority priority, const FILE *fp = fopen("/proc/uptime", "r"); g_return_if_fail(NULL != fp); - if(fscanf(fp, "%f %f", &a, &b)){}; + if (fscanf(fp, "%f %f", &a, &b)) ; fclose(fp); - next = sprintf(buf, "[UPTIME] %f ", a); + next = snprintf(buf, BUFFER_SIZE, "[UPTIME] %f ", a); if (next < 0) return; va_start(ap, fmt); - vsnprintf(buf + next, 1023 - next, fmt, ap); + vsnprintf(buf + next, (BUFFER_SIZE-1) - next, fmt, ap); va_end(ap); __dlog_print(LOG_ID_RADIO, priority, tag, buf); #endif @@ -141,6 +142,26 @@ static void telephony_signal_handler(int signo) } #endif +#if defined(TIZEN_PROFILE_TV) && !defined(TIZEN_DEBUG_ENABLE) +static void telephony_signal_handler(int signo) +{ + if (!_server) + return; + + switch (signo) { + case SIGHUP: { + warn("*~*~*~* Ignore Signal: [SIGHUP] *~*~*~*"); + } break; + + default: { + warn("*~*~*~* Unhandled Signal: [%d] *~*~*~*", signo); + } break; + } /* end switch */ + + return; +} +#endif + static void __log_uptime() { float a = 0.00, b = 0.00; @@ -283,7 +304,7 @@ static gboolean load_plugins(Server *s, const char *path, gboolean flag_test_loa int main(int argc, char *argv[]) { -#ifdef TIZEN_DEBUG_ENABLE +#if defined(TIZEN_DEBUG_ENABLE) || defined(TIZEN_PROFILE_TV) struct sigaction sigact; #endif Server *s = NULL; @@ -314,9 +335,9 @@ int main(int argc, char *argv[]) info("glib version: %u.%u.%u", glib_major_version, glib_minor_version, glib_micro_version); /* Telephony reset handling*/ - vconf_get_int(VCONFKEY_TELEPHONY_DAEMON_LOAD_COUNT,&daemon_load_count); + vconf_get_int(VCONFKEY_TELEPHONY_DAEMON_LOAD_COUNT, &daemon_load_count); daemon_load_count++; - vconf_set_int(VCONFKEY_TELEPHONY_DAEMON_LOAD_COUNT,daemon_load_count); + vconf_set_int(VCONFKEY_TELEPHONY_DAEMON_LOAD_COUNT, daemon_load_count); dbg("daemon load count = [%d]", daemon_load_count); #ifdef TIZEN_DEBUG_ENABLE @@ -328,6 +349,21 @@ int main(int argc, char *argv[]) warn("sigaction(SIGTERM) failed."); if (sigaction(SIGUSR1, &sigact, NULL) < 0) warn("sigaction(SIGUSR1) failed."); +#ifdef TIZEN_PROFILE_TV + /* SIGHUP should be ignored because cellular dongle ejection makes this signal */ + if (sigaction(SIGHUP, &sigact, NULL) < 0) + warn("sigaction(SIGHUP) failed."); +#endif +#endif + +#if defined(TIZEN_PROFILE_TV) && !defined(TIZEN_DEBUG_ENABLE) + /* Signal Registration */ + sigact.sa_handler = telephony_signal_handler; + sigemptyset(&sigact.sa_mask); + sigact.sa_flags = 0; + /* SIGHUP should be ignored because cellular dongle ejection makes this signal */ + if (sigaction(SIGHUP, &sigact, NULL) < 0) + warn("sigaction(SIGHUP) failed."); #endif /* Commandline option parser TODO: Replace with GOptionContext */ diff --git a/src/monitor.c b/src/monitor.c index b65defd..903fb37 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -67,7 +67,7 @@ static void _monitor_core_objects(GSList *list) } list = list->next; - } while(list); + } while (list); } static void _monitor_plugin(Server *s) @@ -108,7 +108,7 @@ static void _monitor_plugin(Server *s) msg(""); list = list->next; - } while(list); + } while (list); } static void _monitor_storage(Server *s) @@ -130,7 +130,7 @@ static void _monitor_storage(Server *s) msg(""); list = list->next; - } while(list); + } while (list); } static void _monitor_communicator(Server *s) @@ -154,7 +154,7 @@ static void _monitor_communicator(Server *s) msg(""); list = list->next; - } while(list); + } while (list); } static void _monitor_hal(Server *s) @@ -208,9 +208,9 @@ static void _monitor_hal(Server *s) pending = g_queue_peek_nth(q->gq, i); ur = tcore_pending_ref_user_request(pending); msg(" [%02d] pending=%p, id=0x%x, ur=%p", i, pending, tcore_pending_get_id(pending), ur); - if (ur) { + if (ur) msg(" ur request command = 0x%x", tcore_user_request_get_command(ur)); - } + data_len = 0; data = tcore_pending_ref_request_data(pending, &data_len); msg(" data=%p, data_len=%d", data, data_len); @@ -219,7 +219,7 @@ static void _monitor_hal(Server *s) msg(""); list = list->next; - } while(list); + } while (list); } void monitor_server_state(Server *s) diff --git a/telephony-daemon.manifest b/telephony-daemon.manifest index aa2d6bc..282062f 100755 --- a/telephony-daemon.manifest +++ b/telephony-daemon.manifest @@ -18,7 +18,6 @@