From 11e6c261e8a0bd19378b5f2a3f5ac4277d748a94 Mon Sep 17 00:00:00 2001 From: aszlig Date: Sun, 3 Apr 2016 19:59:14 +0200 Subject: modules/gpg-agent: Hide internals of preloader First of all, let's inline the first_fork variable, because we don't want this variable to be exposed as a symbol, even though it doesn't hurt (except maybe for a very very very tiny improvement in RTLD lookup performance). And apart from the first_fork variable, there were a few other symbols we don't want to propagate to the RTLD chain as well: 0000000000001465 T accept 000000000000130b T bind 000000000000153e T execv 0000000000001610 T _fini 00000000000013b8 T fork 0000000000000fe0 T get_sd_fd_for 0000000000001420 T get_socket_pid 0000000000000d80 T _init 00000000000012fa T listen 00000000000012b8 T record_sockfd So in the end we're down to: 00000000000011fb T accept 00000000000010a1 T bind 00000000000012c8 T execv 0000000000001390 T _fini 000000000000114e T fork 0000000000000b68 T _init 0000000000001090 T listen ... which is a lot more clean and even though our staff doesn't collide with existing libraries in the chain it's better to be safe than sorry. Signed-off-by: aszlig --- modules/programs/gpg-agent/agent-wrapper.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'modules/programs') diff --git a/modules/programs/gpg-agent/agent-wrapper.c b/modules/programs/gpg-agent/agent-wrapper.c index e969e85b..84b4f80b 100644 --- a/modules/programs/gpg-agent/agent-wrapper.c +++ b/modules/programs/gpg-agent/agent-wrapper.c @@ -11,14 +11,14 @@ #include #include -int main_fd = 0; -int ssh_fd = 0; -int scdaemon_fd = 0; +static int main_fd = 0; +static int ssh_fd = 0; +static int scdaemon_fd = 0; /* Get the systemd file descriptor for a particular socket file. * Returns -1 if there is an error or -2 if it is an unnamed socket. */ -int get_sd_fd_for(const struct sockaddr_un *addr) +static int get_sd_fd_for(const struct sockaddr_un *addr) { if (main_fd == 0 && ssh_fd == 0 && scdaemon_fd == 0) { int num_fds; @@ -75,7 +75,7 @@ int get_sd_fd_for(const struct sockaddr_un *addr) /* Replace the systemd-provided socket FD with the one that is used by the * agent, so that we can later look it up in our accept() wrapper. */ -void record_sockfd(int sysd_fd, int redir_fd) +static void record_sockfd(int sysd_fd, int redir_fd) { if (sysd_fd == main_fd) main_fd = redir_fd; @@ -122,10 +122,10 @@ int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen) /* Avoid forking for the first time so we can properly track the agent using a * systemd service (without the need to set Type="forking"). */ -int first_fork = 1; - pid_t fork(void) { + static int first_fork = 1; + static pid_t (*_fork)(void) = NULL; if (_fork == NULL) _fork = dlsym(RTLD_NEXT, "fork"); @@ -143,7 +143,7 @@ pid_t fork(void) } /* Get the PID of the client connected to the given socket FD. */ -pid_t get_socket_pid(int sockfd) +static pid_t get_socket_pid(int sockfd) { struct ucred pcred; socklen_t pcred_len = sizeof(pcred); @@ -154,7 +154,7 @@ pid_t get_socket_pid(int sockfd) return pcred.pid; } -pid_t last_pid = 0; +static pid_t last_pid = 0; /* For the pinentry to work correctly with SSH, we need to record the process ID * of the process communicating with the agent. That way we can get more -- cgit 1.4.1