From nobody Sun Nov 03 16:48:10 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XhLBf4TjYz5cRGQ; Sun, 03 Nov 2024 16:48:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XhLBf1QWRz4XTt; Sun, 3 Nov 2024 16:48:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730652490; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=TWGDpvWmfNH7NbXe6rI0ikJvLil5rwh6Cd+qnAI1sVk=; b=rVqHWE3rJnVTUGJ6U+z/eMJcsBo/+eviZcqMFP+9XYxXfz0p3xNSzE7WLnUG5kWtzQEQ8E OameIucOLLKIGBidJU7pbdNtskdG0m5OKAfZ/wAfOwYrW4QZM5KmfVohG/O+RByDlhN4Q0 WJH3RjAGFMB40+mLqw0hMgE26EHdGbEG2OFF29Ig6GpLH413cdBjQbMJ1CFShIYWkwJJsz WvIZCNrCsHKvI8Y7GzSkxPE7PYPUbSFXTEYI8F+DXfX07lP2j3zX1ZPsvBjuL0c6t0CoEa 03+2zI6Twlq1g6t9Mp+gzMPsZeM0k2sVisn+uBfZIVI43rfsTf9fPRa6EQ4pmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730652490; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=TWGDpvWmfNH7NbXe6rI0ikJvLil5rwh6Cd+qnAI1sVk=; b=mgDVgXwu/0y6ARpoB44KOJnX7YcHluREhtQbtObGWq4+z0OyzJZZa8lKge6EJMzGUGn09o 7OfdZwIMDsQVrW6fvkXAVM/M7KLJ6MlavYGKWV81SGDAVccZfnCPNnWMml182u4nwu5/2S iASPWvHXd5Mj+tdqNv/Y9r97gpdJ3dt0YRwQpnnbJyOpdVJq7N+kXlmqOJqkkUIs1NIKck gJMAKBRsJVhsyzbT6xXof9Epa0EetGjVQ8c8/nKQNXHgSQvglEh8S7G8DEzCK8Fz5qbhFS rq6+CJUPouZczyT6iqd/bJbRqpvXkK/BnqB7qLut4nPLIL7sZF62ubjxFoBTqw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730652490; a=rsa-sha256; cv=none; b=A4nAyu5lRFt+cqdFhIa7nxgHKjOTMXN8EXKuZJ09hTtVIQ63s1N4Iuql0gsSahOlrXDGjM y5F/kH/fBKdpEh/WiJfYXAR3mgDhZz2LfNpD37+qFlxx7on/AYqgUMOVcprXxi3PJOFD3/ J4vzqBXsmALBB/u8Opqf74eYDzgOd9xmyVceY3QczkCa8mZUQ/PTAb4Lek4J6I25Vc0jIh wq0XXh68rPNgdeMKqMgVqDa9MJAWQlccuxRmXdbZaaa4mNsAdc4O8woa9H2JoQOlO3G32Q S/V5eRHneEj6UKPLJJ2069x2FN9SI6QDFq444HvCYX6yvwxjsWTUsOMdYzUqVg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XhLBf11yFzwt4; Sun, 3 Nov 2024 16:48:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4A3GmAC9092302; Sun, 3 Nov 2024 16:48:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4A3GmAfJ092299; Sun, 3 Nov 2024 16:48:10 GMT (envelope-from git) Date: Sun, 3 Nov 2024 16:48:10 GMT Message-Id: <202411031648.4A3GmAfJ092299@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 2b8c3a05e0a6 - main - syslogd: Set unix socket modes atomically List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2b8c3a05e0a63f3ffd6ba0eeca08a97578ec3a38 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=2b8c3a05e0a63f3ffd6ba0eeca08a97578ec3a38 commit 2b8c3a05e0a63f3ffd6ba0eeca08a97578ec3a38 Author: Mark Johnston AuthorDate: 2024-11-03 14:41:15 +0000 Commit: Mark Johnston CommitDate: 2024-11-03 16:46:53 +0000 syslogd: Set unix socket modes atomically Take advantage of the ability to atomically set unix socket modes to ensure that /var/run/logpriv always has mode 0600. MFC after: 1 month --- usr.sbin/syslogd/syslogd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index 12fa61b01bad..98ddb5d9158f 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -3721,6 +3721,11 @@ socksetup(struct addrinfo *ai, const char *name, mode_t mode) if (ai->ai_family == AF_LOCAL) unlink(name); if (ai->ai_family == AF_LOCAL || NoBind == 0 || name != NULL) { + if (ai->ai_family == AF_LOCAL && fchmod(s, mode) < 0) { + dprintf("fchmod %s: %s\n", name, strerror(errno)); + close(s); + return (NULL); + } if (bind(s, ai->ai_addr, ai->ai_addrlen) < 0) { logerror("bind"); close(s); @@ -3729,11 +3734,6 @@ socksetup(struct addrinfo *ai, const char *name, mode_t mode) if (ai->ai_family == AF_LOCAL || SecureMode == 0) increase_rcvbuf(s); } - if (ai->ai_family == AF_LOCAL && chmod(name, mode) < 0) { - dprintf("chmod %s: %s\n", name, strerror(errno)); - close(s); - return (NULL); - } dprintf("new socket fd is %d\n", s); sl_recv = socklist_recv_sock; #if defined(INET) || defined(INET6)