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.133.124]) by passt.top (Postfix) with ESMTP id 8AD185A026D for ; Thu, 17 Aug 2023 12:55:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692269716; 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: in-reply-to:in-reply-to:references:references; bh=sbXZaxQ/O7nmolOxr7r5thOcIvwWZvSYIG3DT1OnnpQ=; b=KCf6urcnPyBdOLfvnBOicqWRfKg3z0rx6/49bmzXP6eYeZ9FVTyzqPXD2qfR6lIxZOPB7Y H6YxUIU2ORVKHXVMgXf0pTEP+pq7erqh+aS61ddkDR0RJgro5/u/QgAn360l6/s3hV85kX 91lBSXxXybgLeqa1qsuw35tyXA9VcdI= Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-678-S88AzMfRO3yWpxGtnTxEag-1; Thu, 17 Aug 2023 06:55:15 -0400 X-MC-Unique: S88AzMfRO3yWpxGtnTxEag-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D80673C0FC93 for ; Thu, 17 Aug 2023 10:55:14 +0000 (UTC) Received: from elisabeth (unknown [10.39.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2DF0E492C13; Thu, 17 Aug 2023 10:55:14 +0000 (UTC) Date: Thu, 17 Aug 2023 12:53:10 +0200 From: Stefano Brivio To: "Richard W.M. Jones" Subject: Re: [PATCH v2 1/7] fedora: Install pasta as hard link to ensure SELinux file context match Message-ID: <20230817125232.6480cccf@elisabeth> In-Reply-To: <20230817075355.GL7636@redhat.com> References: <20230816181730.2165306-1-sbrivio@redhat.com> <20230816181730.2165306-2-sbrivio@redhat.com> <20230817075355.GL7636@redhat.com> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: DMXTXXN5JJCD565GX4MRSIK6LK5FV7F5 X-Message-ID-Hash: DMXTXXN5JJCD565GX4MRSIK6LK5FV7F5 X-MailFrom: sbrivio@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: passt-dev@passt.top 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: On Thu, 17 Aug 2023 08:53:55 +0100 "Richard W.M. Jones" wrote: > On Wed, Aug 16, 2023 at 08:17:24PM +0200, Stefano Brivio wrote: > > The Makefile installs symbolic links by default, which actually > > worked at some point (not by design) with SELinux, but at least on > > recent kernel versions it doesn't anymore: override pasta (and > > pasta.avx2) with hard links. > > > > Otherwise, even if the links are labeled as pasta_exec_t, SELinux > > will "resolve" them to passt_exec_t, and we'll have pasta running as > > passt_t instead of pasta_t. > > > > Signed-off-by: Stefano Brivio > > --- > > contrib/fedora/passt.spec | 7 +++++++ > > 1 file changed, 7 insertions(+) > > > > diff --git a/contrib/fedora/passt.spec b/contrib/fedora/passt.spec > > index 8d28ef6..d0c6895 100644 > > --- a/contrib/fedora/passt.spec > > +++ b/contrib/fedora/passt.spec > > @@ -54,10 +54,17 @@ This package adds SELinux enforcement to passt(1) and pasta(1). > > %make_build VERSION="%{version}-%{release}.%{_arch}" > > > > %install > > + > > %make_install DESTDIR=%{buildroot} prefix=%{_prefix} bindir=%{_bindir} mandir=%{_mandir} docdir=%{_docdir}/%{name} > > +# The Makefile creates symbolic links for pasta, but we need hard links for > > +# SELinux file contexts to work as intended. Same with pasta.avx2 if present. > > +ln -f %{buildroot}%{_bindir}/passt %{buildroot}%{_bindir}/pasta > > %ifarch x86_64 > > +ln -f %{buildroot}%{_bindir}/passt.avx2 %{buildroot}%{_bindir}/pasta.avx2 > > + > > ln -sr %{buildroot}%{_mandir}/man1/passt.1 %{buildroot}%{_mandir}/man1/passt.avx2.1 > > ln -sr %{buildroot}%{_mandir}/man1/pasta.1 %{buildroot}%{_mandir}/man1/pasta.avx2.1 > > +install -p -m 755 %{buildroot}%{_bindir}/passt.avx2 %{buildroot}%{_bindir}/pasta.avx2 > > %endif > > Acked-by: Richard W.M. Jones > > ... although why not change the Makefile install rule instead so > everyone gets this change? Because that's only needed for SELinux "based" distributions. I have the feeling that symlinks are in general more desirable -- at least personally I find them less confusing. Also, David pointed out that hard links are not supported by a number of filesystems, and we probably don't want to mess this up for embedded environments. On the other hand, I didn't check yet if AppArmor would also benefit from this -- there we have at the moment a single profile for passt and pasta (the symlink behaviour is documented)... if it does, I guess it might make sense to switch to hard links in the Makefile (assuming there are no issues with other distributions), and perhaps export a Makefile variable to have symlinks instead. -- Stefano