From patchwork Thu Oct 29 17:28:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vit Mojzis X-Patchwork-Id: 11867043 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2143614B7 for ; Thu, 29 Oct 2020 17:29:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 039C920756 for ; Thu, 29 Oct 2020 17:29:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Zfp1I98S" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725785AbgJ2R3f (ORCPT ); Thu, 29 Oct 2020 13:29:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:38421 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725777AbgJ2R3e (ORCPT ); Thu, 29 Oct 2020 13:29:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603992532; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=V/c4fYWRf+eesp7xf/ciLnS1g575QIYWoSjrNkdpzf0=; b=Zfp1I98SRGRdZoKOTaVP9haTqUew6upH7bROTKCtfyYLcNxhZW6BZ4tuSx59gr25mDlfrh JtsnBXx09cjOUWnwl9ulE4otX+QLh0HjP5aI9wiNJe9MZWoaXtup80T4aDzzkxhjpJERC2 eDzvwcp7vdxnfOivnif4bIq7tjCkSr0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-553-A0fyRGmYPgCSe42lmP2DhQ-1; Thu, 29 Oct 2020 13:28:50 -0400 X-MC-Unique: A0fyRGmYPgCSe42lmP2DhQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 033F51084D70 for ; Thu, 29 Oct 2020 17:28:49 +0000 (UTC) Received: from thinkpad-work.redhat.com (unknown [10.40.194.157]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B64D1002C03 for ; Thu, 29 Oct 2020 17:28:48 +0000 (UTC) From: Vit Mojzis To: selinux@vger.kernel.org Subject: [PATCH] libsemanage/genhomedircon: check usepasswd Date: Thu, 29 Oct 2020 18:28:45 +0100 Message-Id: <20201029172845.1321021-1-vmojzis@redhat.com> In-Reply-To: <20201029104802.GA52464@localhost.localdomain> References: <20201029104802.GA52464@localhost.localdomain> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Only add user homedir contexts when usepasswd = True Resolves: #cat /etc/selinux/semanage.conf | grep usepasswd usepasswd=False #useradd -Z unconfined_u -d /tmp test #matchpathcon /tmp /tmp unconfined_u:object_r:user_home_dir_t:s0 Signed-off-by: Vit Mojzis --- libsemanage/src/genhomedircon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsemanage/src/genhomedircon.c b/libsemanage/src/genhomedircon.c index d08c88de..fc75fa8c 100644 --- a/libsemanage/src/genhomedircon.c +++ b/libsemanage/src/genhomedircon.c @@ -1332,7 +1332,7 @@ static int write_context_file(genhomedircon_settings_t * s, FILE * out) s->fallback->home = NULL; } } - if (user_context_tpl || username_context_tpl) { + if (!(s->usepasswd) && (user_context_tpl || username_context_tpl)) { if (write_username_context(s, out, username_context_tpl, s->fallback) != STATUS_SUCCESS) { retval = STATUS_ERR;