Skip to content

Commit

Permalink
bus: Do not mkdir abstract unix socket
Browse files Browse the repository at this point in the history
IBus ran mkdir for unix abstract sockets for --address=unix:abstract
but should not need to mkdir.

BUG=#2363
  • Loading branch information
fujiwarat committed Feb 3, 2022
1 parent 787b564 commit dfd3fbf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions bus/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,15 @@ bus_server_init (void)
const char *unix_path = socket_address + strlen (prefix); \
unix_dir = g_path_get_dirname (unix_path); \
}
#define IF_GET_UNIX_DIR_FROM_ABSTRACT(prefix) \
if (g_str_has_prefix (socket_address, (prefix))) {}


IF_GET_UNIX_DIR_FROM_DIR (IBUS_UNIX_TMPDIR)
else
IF_GET_UNIX_DIR_FROM_PATH (IBUS_UNIX_PATH)
else
IF_GET_UNIX_DIR_FROM_PATH (IBUS_UNIX_ABSTRACT)
IF_GET_UNIX_DIR_FROM_ABSTRACT (IBUS_UNIX_ABSTRACT)
else
IF_GET_UNIX_DIR_FROM_DIR (IBUS_UNIX_DIR)
else {
Expand All @@ -281,7 +283,8 @@ bus_server_init (void)
IBUS_UNIX_ABSTRACT "FILE, " IBUS_UNIX_DIR "DIR.",
socket_address);
}
if (!g_file_test (unix_dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
if (unix_dir &&
!g_file_test (unix_dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
/* Require mkdir for BSD system.
* The mode 0700 can eliminate malicious users change the mode.
* `chmod` runs for the last directory only not to change the modes
Expand Down Expand Up @@ -337,6 +340,7 @@ bus_server_init (void)

#undef IF_GET_UNIX_DIR_FROM_DIR
#undef IF_GET_UNIX_DIR_FROM_PATH
#undef IF_GET_UNIX_DIR_FROM_ABSTRACT
#undef IBUS_UNIX_TMPDIR
#undef IBUS_UNIX_PATH
#undef IBUS_UNIX_ABSTRACT
Expand Down

0 comments on commit dfd3fbf

Please sign in to comment.