From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTP id 039305A026D for ; Fri, 23 Jun 2023 12:24:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687515844; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=W4ETvKXHXsqEyPc0syzSsl0dcttR3otpHjn9HkuomAw=; b=M/PF2c1zUppWiTqidOXfbt5v8iY7EPoYywRK9HlVrXE0MTFD9wa8cUokSRxeERKaTMnJ/w rVtty74izC2j/VO1FWC8pqRcgbCPeBir3CjPUI2kLVl1MaasasZfFABPHc5RRd6tJT3C+O bb1vMUbtyS4H7Ujoi1d23FM9E8f2qvY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-645-v4hqzVXMMByjthKfA3F0Gg-1; Fri, 23 Jun 2023 06:24:03 -0400 X-MC-Unique: v4hqzVXMMByjthKfA3F0Gg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4ED398CC207 for ; Fri, 23 Jun 2023 10:24:03 +0000 (UTC) Received: from pholzing-fedora.redhat.com (unknown [10.39.192.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id B93AEC1ED97; Fri, 23 Jun 2023 10:24:02 +0000 (UTC) From: Paul Holzinger To: passt-dev@passt.top Subject: [PATCH] pasta: include errno in error message Date: Fri, 23 Jun 2023 12:23:50 +0200 Message-ID: <20230623102350.106830-1-pholzing@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: RNVTT7CX5XS3MARQYROGTAIMA5FVTII7 X-Message-ID-Hash: RNVTT7CX5XS3MARQYROGTAIMA5FVTII7 X-MailFrom: pholzing@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Paul Holzinger X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- 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