From patchwork Thu Nov 22 15:37:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 1001853 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4313Wy3r9tz9s0t for ; Fri, 23 Nov 2018 02:39:10 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 876C1D62; Thu, 22 Nov 2018 15:38:06 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 12681D60 for ; Thu, 22 Nov 2018 15:38:06 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 6807D5E2 for ; Thu, 22 Nov 2018 15:38:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F41E8C064276 for ; Thu, 22 Nov 2018 15:38:04 +0000 (UTC) Received: from dmarchan.remote.csb (ovpn-117-158.ams2.redhat.com [10.36.117.158]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C4B81868C for ; Thu, 22 Nov 2018 15:38:04 +0000 (UTC) From: David Marchand To: dev@openvswitch.org Date: Thu, 22 Nov 2018 16:37:57 +0100 Message-Id: <1542901077-7567-1-git-send-email-david.marchand@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 22 Nov 2018 15:38:05 +0000 (UTC) X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH] ovs-ctl: fix system-id.conf owner X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org As far as RPMs are concerned, system-id.conf file is declared as being owned by openvswitch. At the first ovs startup, ovs-ctl creates this file if none exists without ensuring this. We end up with an inconsistency: $ rpm -V openvswitch .....UG.. c /etc/openvswitch/system-id.conf Fix this when ovs-ctl is the one who creates the file. Note: this issue ends up being hidden after a RPM upgrade, since the openvswitch user is enforced on the whole /etc/openvswitch directory as a %post operation. Signed-off-by: David Marchand Acked-by: Flavio Leitner Acked-by: Timothy Redaelli --- utilities/ovs-ctl.in | 2 ++ utilities/ovs-lib.in | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in index e42f0f1..3bd8a6d 100644 --- a/utilities/ovs-ctl.in +++ b/utilities/ovs-ctl.in @@ -61,8 +61,10 @@ set_system_ids () { # Migrate from old file name. . "$uuid_file" SYSTEM_ID=$INSTALLATION_UUID + run_as_ovsuser touch "$id_file" echo "$SYSTEM_ID" > "$id_file" elif SYSTEM_ID=`uuidgen`; then + run_as_ovsuser touch "$id_file" echo "$SYSTEM_ID" > "$id_file" else log_failure_msg "missing uuidgen, could not generate system ID" diff --git a/utilities/ovs-lib.in b/utilities/ovs-lib.in index 7df672c..9a0af2e 100644 --- a/utilities/ovs-lib.in +++ b/utilities/ovs-lib.in @@ -387,17 +387,21 @@ move_ip_routes () { done } -ovsdb_tool () { +run_as_ovsuser() { if [ "$OVS_USER" != "" ]; then local uid=$(id -u "${OVS_USER%:*}") local gid=$(id -g "${OVS_USER%:*}") local groups=$(id -G "${OVS_USER%:*}" | tr ' ' ',') - setpriv --reuid "$uid" --regid "$gid" --groups "$groups" ovsdb-tool -vconsole:off "$@" + setpriv --reuid "$uid" --regid "$gid" --groups "$groups" "$@" else - ovsdb-tool -vconsole:off "$@" + "$@" fi } +ovsdb_tool () { + run_as_ovsuser ovsdb-tool -vconsole:off "$@" +} + create_db () { DB_FILE="$1" DB_SCHEMA="$2"