From patchwork Fri Aug 20 16:39:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 1519112 X-Patchwork-Delegate: zajec5@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=PaVIqM6g; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=nCZerpcz; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GrnW71txtz9sRf for ; Sat, 21 Aug 2021 02:42:58 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=ZJzRhAynMDCpFbGul3urVpMfDUTDTp60LrGLpxe5nEI=; b=PaVIqM6gHhYzML zYcCWVo/CJkqonGjwr/L34I1WdknLwYRaOUKssz8Yf33kQExcKv47fLv5QOZzOnqmFkCA0wDEFYMl 3vDwYrQbBuoI3k+wew8d+VF49dLGVIbH00IgE6VaYhvGkmLZUHqeK1JuhbnucjmlYk7TjRabqtXNL 1vfczgaufcYirLqEFjrzHkv8xnMV6TJ614OahPiR3vOYkklthW8ovcYVRoxY60vzmfuUNJ3jbIkgz NdMzhCuYc1B4nhFkjogWJdusWkYYpeB+mto7CGiwUT5VfQs8hpSWe2p0DCEY0Acv8+Qzqqe17QaYy hSiDyYvegxInhylInhVg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mH7Ym-00BelH-ED; Fri, 20 Aug 2021 16:40:00 +0000 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mH7Yi-00BekJ-CX for openwrt-devel@lists.openwrt.org; Fri, 20 Aug 2021 16:39:58 +0000 Received: by mail-lj1-x230.google.com with SMTP id h9so18200674ljq.8 for ; Fri, 20 Aug 2021 09:39:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=KDFvhKFr7mEk4WncRPn/w0bKcyQ9saP6MjRoSQUARic=; b=nCZerpczBE8qigi/qAn7yyKfAFyWrHiAlp+EwZSyAyfLvX5O/96gq+6ej6HvXAeM3r Vww6RL2/bbAn8z55d17w1QXEKxFhj0NdMmx0Rc842Xm/O4ORYYtjClHIL2l2tQCx8ls4 a17+NEu4s4G831ujfpzjEJeMs+EqNxObd4Bg2WAvh40HM4Nk2hW02OJVNvvgveuRXwpv TX4JKrhxz0Izu1W7Emw56HIUruMJVM+QrYEkyZh+PGJZbO5KxivDxGGPh2C8NxXRNVee 1XnmrB/zs+dfuBTZVBAAwAlBOTsAqZZTk3/glNafKyu556FuM4S7NqZCyTdKtRnX1CX6 /5PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=KDFvhKFr7mEk4WncRPn/w0bKcyQ9saP6MjRoSQUARic=; b=Io6D8FHy2HFctPPvSkEPRFe0R9/Z1gJNYUHoSwvFSxb7YNOYPk/1h/lFI5qqb9XH5l czRYNO81dJlOUrxkF+EGc2Z/svTCUqlWDMPqhHwIUxbM3FXnAzos02X0H9r4zZ6jl11h y9NmQZG73cu9i1jKWr7MPTmR8gThpUDMce91xp62axfHHsBZzyZvldKKR3hXboCaHBtY 35/uKBBfBsv//LFucLmD+qK92irY1jNvnl6lyPAAaq0k0nhZOJcnH84u11gcXs4G9E0u cNSdS38vXM5fcWeE9UFaChMXRxxRTE7OOJQuOQ7+xa2/w225CDT97RN8t37iE95Shm2Z yQ2Q== X-Gm-Message-State: AOAM530hikJTkYGeJYsg98V/6zx0Ga5CvWx+CDYU+tQ3e8RrrqS5vFvu ExrGZELE3uPyB6tU147YzloCUxAGN4wQ+Q== X-Google-Smtp-Source: ABdhPJwt71jKJr+DZa2mgbFiAFmXUwyLDmG0X9VU11b6IAcc2ROgvnYWt/sQRo0xcgqTr2J5RLQ05Q== X-Received: by 2002:a2e:9901:: with SMTP id v1mr16596523lji.205.1629477593836; Fri, 20 Aug 2021 09:39:53 -0700 (PDT) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id j14sm241782lfe.203.2021.08.20.09.39.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Aug 2021 09:39:53 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: openwrt-devel@lists.openwrt.org Cc: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH ubus] ubusd: log ACL init errors Date: Fri, 20 Aug 2021 18:39:46 +0200 Message-Id: <20210820163946.21341-1-zajec5@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210820_093956_532885_DA1D3E07 X-CRM114-Status: GOOD ( 12.57 ) X-Spam-Score: 0.1 (/) X-Spam-Report: =?unknown-8bit?q?Spam_detection_software=2C_running_on_the_sy?= =?unknown-8bit?q?stem_=22bombadil=2Einfradead=2Eorg=22=2C?= =?unknown-8bit?q?_has_NOT_identified_this_incoming_email_as_spam=2E__The_ori?= =?unknown-8bit?q?ginal?= =?unknown-8bit?q?_message_has_been_attached_to_this_so_you_can_view_it_or_la?= =?unknown-8bit?q?bel?= =?unknown-8bit?q?_similar_future_email=2E__If_you_have_any_questions=2C_see?= =?unknown-8bit?q?_the_administrator_of_that_system_for_details=2E?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_preview=3A__From=3A_Rafa=C5=82_Mi=C5=82ecki_This_m?= =?unknown-8bit?q?akes_it_easier_to_notice_ubusd?= =?unknown-8bit?q?_=28and_so_often_a_system=29_failing_to_start_properly=2E_S?= =?unknown-8bit?q?ome_users_reported_procd?= =?unknown-8bit?q?_failing_to_initialize_fully_without_a_clear_error_with_fau?= =?unknown-8bit?q?lty_/etc/passwd=2E?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_analysis_details=3A___=280=2E1_points=2C_5=2E0_req?= =?unknown-8bit?q?uired=29?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_pts_rule_name______________description?= =?unknown-8bit?q?_----_----------------------_------------------------------?= =?unknown-8bit?q?--------------------?= =?unknown-8bit?q?_-0=2E0_RCVD=5FIN=5FDNSWL=5FNONE_____RBL=3A_Sender_listed_a?= =?unknown-8bit?q?t_https=3A//www=2Ednswl=2Eorg/=2C?= =?unknown-8bit?q?_no_trust?= =?unknown-8bit?b?IFsyYTAwOjE0NTA6NDg2NDoyMDowOjA6MDoyMzAgbGlzdGVkIGluXQ==?= =?unknown-8bit?b?IFtsaXN0LmRuc3dsLm9yZ10=?= =?unknown-8bit?q?_-0=2E0_SPF=5FPASS_______________SPF=3A_sender_matches_SPF_?= =?unknown-8bit?q?record?= =?unknown-8bit?q?_0=2E0_SPF=5FHELO=5FNONE__________SPF=3A_HELO_does_not_publ?= =?unknown-8bit?q?ish_an_SPF_Record?= =?unknown-8bit?q?_0=2E0_FREEMAIL=5FFROM__________Sender_email_is_commonly_ab?= =?unknown-8bit?q?used_enduser_mail?= =?unknown-8bit?q?_provider?= =?unknown-8bit?q?_=5Bzajec5=5Bat=5Dgmail=2Ecom=5D?= =?unknown-8bit?q?_0=2E2_FREEMAIL=5FENVFROM=5FEND=5FDIGIT_Envelope-from_freem?= =?unknown-8bit?q?ail_username_ends?= =?unknown-8bit?q?_in_digit?= =?unknown-8bit?q?_=5Bzajec5=5Bat=5Dgmail=2Ecom=5D?= =?unknown-8bit?q?_-0=2E1_DKIM=5FVALID=5FAU__________Message_has_a_valid_DKIM?= =?unknown-8bit?q?_or_DK_signature_from?= =?unknown-8bit?q?_author=27s_domain?= =?unknown-8bit?q?_-0=2E1_DKIM=5FVALID_____________Message_has_at_least_one_v?= =?unknown-8bit?q?alid_DKIM_or_DK_signature?= =?unknown-8bit?q?_0=2E1_DKIM=5FSIGNED____________Message_has_a_DKIM_or_DK_si?= =?unknown-8bit?q?gnature=2C_not_necessarily?= =?unknown-8bit?q?_valid?= =?unknown-8bit?q?_-0=2E1_DKIM=5FVALID=5FEF__________Message_has_a_valid_DKIM?= =?unknown-8bit?q?_or_DK_signature_from?= =?unknown-8bit?q?_envelope-from_domain?= X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Rafał Miłecki This makes it easier to notice ubusd (and so often a system) failing to start properly. Some users reported procd failing to initialize fully without a clear error with faulty /etc/passwd. Signed-off-by: Rafał Miłecki Acked-by: John Crispin --- ubusd_acl.c | 13 ++++++++++--- ubusd_main.c | 3 +++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ubusd_acl.c b/ubusd_acl.c index e050e2c..352c581 100644 --- a/ubusd_acl.c +++ b/ubusd_acl.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "ubusd.h" @@ -175,19 +176,25 @@ ubusd_acl_init_client(struct ubus_client *cl, int fd) #ifdef SO_PEERCRED unsigned int len = sizeof(struct ucred); - if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cred, &len) == -1) + if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cred, &len) == -1) { + ULOG_ERR("Failed getsockopt(): %m\n"); return -1; + } #else memset(&cred, 0, sizeof(cred)); #endif pwd = getpwuid(cred.uid); - if (!pwd) + if (!pwd) { + ULOG_ERR("Failed getpwuid(): %m\n"); return -1; + } group = getgrgid(cred.gid); - if (!group) + if (!group) { + ULOG_ERR("Failed getgrgid(): %m\n"); return -1; + } cl->uid = cred.uid; cl->gid = cred.gid; diff --git a/ubusd_main.c b/ubusd_main.c index d454b1a..6b132ce 100644 --- a/ubusd_main.c +++ b/ubusd_main.c @@ -233,6 +233,8 @@ static void mkdir_sockdir() free(ubus_sock_dir); } +#include + int main(int argc, char **argv) { const char *ubus_socket = UBUS_UNIX_SOCKET; @@ -242,6 +244,7 @@ int main(int argc, char **argv) signal(SIGPIPE, SIG_IGN); signal(SIGHUP, sighup_handler); + ulog_open(ULOG_KMSG | ULOG_SYSLOG, LOG_DAEMON, "ubusd"); openlog("ubusd", LOG_PID, LOG_DAEMON); uloop_init();