From 09392be06900a1c11dfee71c137c53bcb9180a6d Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sat, 8 Jul 2017 23:50:47 +0800 Subject: [PATCH] Cleanup file descriptors and add info --- su.c | 4 ++-- su_socket.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/su.c b/su.c index 6c27a7e60..2f62f9d41 100644 --- a/su.c +++ b/su.c @@ -35,7 +35,7 @@ static void usage(int status) { FILE *stream = (status == EXIT_SUCCESS) ? stdout : stderr; fprintf(stream, - "MagiskSU v" xstr(MAGISK_VERSION) "\n\n" + "MagiskSU v" xstr(MAGISK_VERSION) "(" xstr(MAGISK_VER_CODE) ")\n\n" "Usage: su [options] [--] [-] [LOGIN] [--] [args...]\n\n" "Options:\n" " -c, --command COMMAND pass COMMAND to the invoked shell\n" @@ -50,7 +50,7 @@ static void usage(int status) { " this is used almost exclusively by Superuser.apk\n" " -mm, -M,\n" " --mount-master run in the global mount namespace,\n" - " use if you need to publicly apply mounts"); + " use if you need to publicly apply mounts\n"); exit2(status); } diff --git a/su_socket.c b/su_socket.c index 35a21a0e3..99c2a3e75 100644 --- a/su_socket.c +++ b/su_socket.c @@ -22,7 +22,7 @@ int socket_create_temp(char *path, size_t len) { int fd; struct sockaddr_un sun; - fd = xsocket(AF_LOCAL, SOCK_STREAM, 0); + fd = xsocket(AF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0); if (fcntl(fd, F_SETFD, FD_CLOEXEC)) { PLOGE("fcntl FD_CLOEXEC"); } @@ -65,7 +65,7 @@ int socket_accept(int serv_fd) { PLOGE("select"); } - return xaccept(serv_fd, NULL, NULL); + return xaccept4(serv_fd, NULL, NULL, SOCK_CLOEXEC); } #define write_data(fd, data, data_len) \