about summary refs log tree commit diff
path: root/modules/programs
diff options
context:
space:
mode:
authoraszlig <aszlig@redmoonstudios.org>2016-04-03 19:59:14 +0200
committeraszlig <aszlig@redmoonstudios.org>2016-04-04 12:42:31 +0200
commit11e6c261e8a0bd19378b5f2a3f5ac4277d748a94 (patch)
tree870865eaa8fec6fd831860cf3f8df56a858f4821 /modules/programs
parent3e09d459e34e8a8859a4c6e63ebd0725fbe3f520 (diff)
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 <aszlig@redmoonstudios.org>
Diffstat (limited to 'modules/programs')
-rw-r--r--modules/programs/gpg-agent/agent-wrapper.c18
1 files changed, 9 insertions, 9 deletions
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 <sys/un.h>
 #include <systemd/sd-daemon.h>
 
-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