[lxc-devel] [lxd/master] forkproxy: non-functional changes
brauner on Github
lxc-bot at linuxcontainers.org
Tue Apr 16 20:49:02 UTC 2019
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 364 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190416/9e70a642/attachment.bin>
-------------- next part --------------
From f331346b0b6673a20679f016c04ca37813a7c25d Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Tue, 16 Apr 2019 22:37:50 +0200
Subject: [PATCH 1/4] forkproxy: make helpers static
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
lxd/main_forkproxy.go | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/lxd/main_forkproxy.go b/lxd/main_forkproxy.go
index fb2213a548..834fa1de05 100644
--- a/lxd/main_forkproxy.go
+++ b/lxd/main_forkproxy.go
@@ -44,7 +44,7 @@ int whoami = -ESRCH;
#define FORKPROXY_PARENT 0
#define FORKPROXY_UDS_SOCK_FD_NUM 200
-int switch_uid_gid(uint32_t uid, uint32_t gid)
+static int switch_uid_gid(uint32_t uid, uint32_t gid)
{
if (setgid((gid_t)gid) < 0)
return -1;
@@ -55,7 +55,7 @@ int switch_uid_gid(uint32_t uid, uint32_t gid)
return 0;
}
-int wait_for_pid(pid_t pid)
+static int wait_for_pid(pid_t pid)
{
int status, ret;
@@ -73,7 +73,8 @@ again:
return 0;
}
-int lxc_epoll_wait_nointr(int epfd, struct epoll_event* events, int maxevents, int timeout)
+static int lxc_epoll_wait_nointr(int epfd, struct epoll_event* events,
+ int maxevents, int timeout)
{
int ret;
again:
From ae50a7a82e3bd97a9afba4dae270273aabd879af Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Tue, 16 Apr 2019 22:38:40 +0200
Subject: [PATCH 2/4] forkproxy: make logfile close on exec
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
lxd/main_forkproxy.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lxd/main_forkproxy.go b/lxd/main_forkproxy.go
index 834fa1de05..6205da30df 100644
--- a/lxd/main_forkproxy.go
+++ b/lxd/main_forkproxy.go
@@ -120,7 +120,7 @@ void forkproxy()
if (ret < 0)
_exit(EXIT_FAILURE);
- pid_file = fopen(pid_path, "w+");
+ pid_file = fopen(pid_path, "we+");
if (!pid_file) {
fprintf(stderr,
"%s - Failed to create pid file for proxy daemon\n",
From 2566b869d648de04efbdfc9efa10a47e4d14ac15 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Tue, 16 Apr 2019 22:39:51 +0200
Subject: [PATCH 3/4] forkproxy: don't wrap string literal
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
lxd/main_forkproxy.go | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/lxd/main_forkproxy.go b/lxd/main_forkproxy.go
index 6205da30df..4d7a7a4e43 100644
--- a/lxd/main_forkproxy.go
+++ b/lxd/main_forkproxy.go
@@ -130,8 +130,7 @@ void forkproxy()
if (strncmp(listen_addr, "udp:", sizeof("udp:") - 1) == 0 &&
strncmp(connect_addr, "udp:", sizeof("udp:") - 1) != 0) {
- fprintf(stderr, "Error: Proxying from udp to non-udp "
- "protocol is not supported\n");
+ fprintf(stderr, "Error: Proxying from udp to non-udp protocol is not supported\n");
_exit(EXIT_FAILURE);
}
From f30a22c134d02fb747b807bfcdd2e32e4c4669d3 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Tue, 16 Apr 2019 22:45:10 +0200
Subject: [PATCH 4/4] forkproxy: use standard macros on exit
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
lxd/main_forkproxy.go | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lxd/main_forkproxy.go b/lxd/main_forkproxy.go
index 4d7a7a4e43..208e361ebd 100644
--- a/lxd/main_forkproxy.go
+++ b/lxd/main_forkproxy.go
@@ -182,7 +182,7 @@ void forkproxy()
fprintf(stderr,
"%s - Failed to duplicate fd %d to fd 200\n",
strerror(errno), sk_fds[1]);
- _exit(1);
+ _exit(EXIT_FAILURE);
}
ret = close(sk_fds[1]);
@@ -221,7 +221,7 @@ void forkproxy()
fprintf(stderr,
"%s - Failed to duplicate fd %d to fd 200\n",
strerror(errno), sk_fds[1]);
- _exit(1);
+ _exit(EXIT_FAILURE);
}
ret = close(sk_fds[0]);
More information about the lxc-devel
mailing list