From patchwork Fri Feb 19 14:23:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vit Mojzis X-Patchwork-Id: 12095451 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC01FC433E0 for ; Fri, 19 Feb 2021 14:24:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9432D64DDA for ; Fri, 19 Feb 2021 14:24:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230091AbhBSOYt (ORCPT ); Fri, 19 Feb 2021 09:24:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:33402 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229553AbhBSOYs (ORCPT ); Fri, 19 Feb 2021 09:24:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613744601; 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=sol4uAMeNxmhZrGuEiBTThlfmZrkIIfaYGP2a+7fjn8=; b=fAprDYi0dgwlPK+Tq2f1V0UwC5fQxAH98+rrKFmag21MVS5N6KY4TTOnybmHaVQ7t1Eu8L 32J4ikCSMjUnXA3LKe3NWI8Zo/KfcM7WE6TJftk6gUw/gLpnMN+IYWzdJLsxKrk6643LGL +2djigmyAaEEnjuo1lttPF3gNDeAOTw= 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-508-P0jTiXXZOpaLP5acCHfU8A-1; Fri, 19 Feb 2021 09:23:19 -0500 X-MC-Unique: P0jTiXXZOpaLP5acCHfU8A-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 7E80E1005501 for ; Fri, 19 Feb 2021 14:23:18 +0000 (UTC) Received: from thinkpad-work.redhat.com (unknown [10.40.193.138]) by smtp.corp.redhat.com (Postfix) with ESMTP id E70A51002391 for ; Fri, 19 Feb 2021 14:23:17 +0000 (UTC) From: Vit Mojzis To: selinux@vger.kernel.org Subject: [PATCH v2] gui: fix "file type" selection in fcontextPage Date: Fri, 19 Feb 2021 15:23:14 +0100 Message-Id: <20210219142314.1962469-1-vmojzis@redhat.com> In-Reply-To: References: 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 A change in seobject.py file_type_str_to_option made the "file type" list not compatible with items in this ComboBox. See: 317743bbe2a235a5c68f1066b4153e0726a3118f Avoid this in the future by populating the ComboBox using keys from file_type_str_to_option. This change disables translations on the file types, but those cause other issues (adding file context fails the same way as with 'socket file' since the translated strings differ form file_type_str_to_option.keys, 'properties' of a file context entry shows no file type for the same reason). Fixes: Traceback (most recent call last): File "/usr/share/system-config-selinux/system-config-selinux.py", line 136, in add self.tabs[self.notebook.get_current_page()].addDialog() File "/usr/share/system-config-selinux/semanagePage.py", line 143, in addDialog if self.add() is False: File "/usr/share/system-config-selinux/fcontextPage.py", line 195, in add (rc, out) = getstatusoutput("semanage fcontext -a -t %s -r %s -f '%s' '%s'" % (type, mls, seobject.file_type_str_to_option[ftype], fspec)) KeyError: 'socket file' Signed-off-by: Vit Mojzis Acked-by: Petr Lautrbach --- Add missing "Signed-off-by". gui/fcontextPage.py | 7 +++++++ gui/system-config-selinux.ui | 26 -------------------------- 2 files changed, 7 insertions(+), 26 deletions(-) diff --git a/gui/fcontextPage.py b/gui/fcontextPage.py index 370bbee4..d26aa1b4 100644 --- a/gui/fcontextPage.py +++ b/gui/fcontextPage.py @@ -102,6 +102,13 @@ class fcontextPage(semanagePage): self.load() self.fcontextEntry = xml.get_object("fcontextEntry") self.fcontextFileTypeCombo = xml.get_object("fcontextFileTypeCombo") + # Populate file type combo_box + liststore = self.fcontextFileTypeCombo.get_model() + for ftype in seobject.file_type_str_to_option.keys(): + iter = liststore.append() + liststore.set_value(iter, 0, ftype) + iter = liststore.get_iter_first() + self.fcontextFileTypeCombo.set_active_iter(iter) self.fcontextTypeEntry = xml.get_object("fcontextTypeEntry") self.fcontextMLSEntry = xml.get_object("fcontextMLSEntry") diff --git a/gui/system-config-selinux.ui b/gui/system-config-selinux.ui index 7cc1cc53..e7b84a64 100644 --- a/gui/system-config-selinux.ui +++ b/gui/system-config-selinux.ui @@ -401,32 +401,6 @@ Level - - - all files - - - regular file - - - directory - - - character device - - - block device - - - socket file - - - symbolic link - - - named pipe - - False