When the open() or setns() calls fails pasta exits early and prints an error. However it did not include the errno so it was impossible to know why the syscall failed. Signed-off-by: Paul Holzinger <pholzing(a)redhat.com> --- pasta.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pasta.c b/pasta.c index 13ab18b..27809d2 100644 --- a/pasta.c +++ b/pasta.c @@ -136,14 +136,14 @@ void pasta_open_ns(struct ctx *c, const char *netns) nfd = open(netns, O_RDONLY | O_CLOEXEC); if (nfd < 0) - die("Couldn't open network namespace %s", netns); + die("Couldn't open network namespace %s: %s", netns, strerror(errno)); c->pasta_netns_fd = nfd; NS_CALL(ns_check, c); if (c->pasta_netns_fd < 0) - die("Couldn't switch to pasta namespaces"); + die("Couldn't switch to pasta namespaces: %s", strerror(errno)); if (!c->no_netns_quit) { char buf[PATH_MAX] = { 0 }; @@ -261,7 +261,7 @@ void pasta_start_ns(struct ctx *c, uid_t uid, gid_t gid, NS_CALL(pasta_wait_for_ns, c); if (c->pasta_netns_fd < 0) - die("Failed to join network namespace"); + die("Failed to join network namespace: %s", strerror(errno)); } /** -- 2.41.0
On Fri, Jun 23, 2023 at 12:23:50PM +0200, Paul Holzinger wrote:When the open() or setns() calls fails pasta exits early and prints an error. However it did not include the errno so it was impossible to know why the syscall failed. Signed-off-by: Paul Holzinger <pholzing(a)redhat.com>Reviewed-by: David Gibson <david(a)gibson.dropbear.id.au>--- pasta.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pasta.c b/pasta.c index 13ab18b..27809d2 100644 --- a/pasta.c +++ b/pasta.c @@ -136,14 +136,14 @@ void pasta_open_ns(struct ctx *c, const char *netns) nfd = open(netns, O_RDONLY | O_CLOEXEC); if (nfd < 0) - die("Couldn't open network namespace %s", netns); + die("Couldn't open network namespace %s: %s", netns, strerror(errno)); c->pasta_netns_fd = nfd; NS_CALL(ns_check, c); if (c->pasta_netns_fd < 0) - die("Couldn't switch to pasta namespaces"); + die("Couldn't switch to pasta namespaces: %s", strerror(errno)); if (!c->no_netns_quit) { char buf[PATH_MAX] = { 0 }; @@ -261,7 +261,7 @@ void pasta_start_ns(struct ctx *c, uid_t uid, gid_t gid, NS_CALL(pasta_wait_for_ns, c); if (c->pasta_netns_fd < 0) - die("Failed to join network namespace"); + die("Failed to join network namespace: %s", strerror(errno)); } /**-- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
On Fri, 23 Jun 2023 12:23:50 +0200 Paul Holzinger <pholzing(a)redhat.com> wrote:When the open() or setns() calls fails pasta exits early and prints an error. However it did not include the errno so it was impossible to know why the syscall failed. Signed-off-by: Paul Holzinger <pholzing(a)redhat.com>Applied. -- Stefano