From 3bac623571c4d032218dbfbacf2b4c29357e3305 Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Mon, 21 Aug 2017 09:56:12 +0900 Subject: [PATCH] focus-server: Apply umask(0) to change access permissions of its files [Version] 0.11.18 [Issue Type] Enhancement Change-Id: I7a46d3ea7df6cef23301175dccc5d6c4a553fecb Signed-off-by: Sangchul Lee --- focus_server/mm_sound_focus_server.c | 3 +++ focus_server/mm_sound_mgr_focus_socket.c | 14 +++++++++----- packaging/libmm-sound.spec | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/focus_server/mm_sound_focus_server.c b/focus_server/mm_sound_focus_server.c index 42a98c0..6f32348 100644 --- a/focus_server/mm_sound_focus_server.c +++ b/focus_server/mm_sound_focus_server.c @@ -266,6 +266,9 @@ int main(int argc, char **argv) } #endif if (serveropt.startserver) { + /* Change the file mode mask */ + umask(0); + if (MMSoundMgrFocusSocketInit(&socket_fd)) { debug_error("focus_server [%d] terminating, due to the error of socket init.", getpid()); return 0; diff --git a/focus_server/mm_sound_mgr_focus_socket.c b/focus_server/mm_sound_mgr_focus_socket.c index bf12efa..4844106 100644 --- a/focus_server/mm_sound_mgr_focus_socket.c +++ b/focus_server/mm_sound_mgr_focus_socket.c @@ -212,7 +212,7 @@ int MMSoundMgrFocusSocketInit(int *fd) if (socket_fd < 0) { strerror_r(errno, str_error, sizeof(str_error)); debug_error("failed to socket(), err: %s", str_error); - return MM_ERROR_SOUND_INTERNAL; + goto LEAVE; } debug_log("focus server socket fd [%d]", socket_fd); @@ -230,12 +230,10 @@ int MMSoundMgrFocusSocketInit(int *fd) if (bind(socket_fd, (struct sockaddr *)&addr_un, sizeof(addr_un))) { strerror_r(errno, str_error, sizeof(str_error)); debug_error("failed to bind() again, err: %s", str_error); - close(socket_fd); - return MM_ERROR_SOUND_INTERNAL; + goto LEAVE; } } else { - close(socket_fd); - return MM_ERROR_SOUND_INTERNAL; + goto LEAVE; } } @@ -246,6 +244,12 @@ int MMSoundMgrFocusSocketInit(int *fd) debug_leave(); return MM_ERROR_NONE; + +LEAVE: + if (socket_fd >= 0) + close(socket_fd); + + return MM_ERROR_SOUND_INTERNAL; } void MMSoundMgrFocusSocketFini(int fd) diff --git a/packaging/libmm-sound.spec b/packaging/libmm-sound.spec index 58810c2..2744c54 100644 --- a/packaging/libmm-sound.spec +++ b/packaging/libmm-sound.spec @@ -1,6 +1,6 @@ Name: libmm-sound Summary: MMSound Package contains client lib and sound_server binary -Version: 0.11.17 +Version: 0.11.18 Release: 0 Group: System/Libraries License: Apache-2.0 -- 2.7.4