From patchwork Mon Jul 1 17:18:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allan Oepping X-Patchwork-Id: 13718489 X-Patchwork-Delegate: plautrba@redhat.com Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE17D14B947 for ; Mon, 1 Jul 2024 17:19:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719854344; cv=none; b=QQjSVvhBZb2pm9dGe4H5HYC9jPCxicFE+DUN0+qOKHxKp83Gjdz8Wy7a72oYeNwVZghZPVHzdrlJ/3Y46PkSGLI7tIzFA9fa/rpHLCIFclVfgAArQ92DwF4684yJgdkNW+X9/l5kt7/mcJ4fQYTg4nUXBZnCqJAOBXwAKqQqxMQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719854344; c=relaxed/simple; bh=vYH337oh5Ja4sJ66CBMB4rmmaqTJTwE7/DPy9ywLQBM=; h=MIME-Version:From:Date:Message-ID:Subject:To:Content-Type; b=KEAHY3tgDAed+WdfvW3wD2ecYgUk4smcLfuhADkM/UIH6XKiPXTBbLpfwYMJBWBomjaNePZJztpea0FP/Kg1joUnQxgbcn+4MWmbFnhfdi/h5hgtLZ7WxHKArpq0ZaCh27650NH9CJpGaO7b1Df9BMlYSL5t/Bzj7pd4cvHidpo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intellipay.com; spf=pass smtp.mailfrom=intellipay.com; dkim=pass (2048-bit key) header.d=intellipay-com.20230601.gappssmtp.com header.i=@intellipay-com.20230601.gappssmtp.com header.b=fP8+soUM; arc=none smtp.client-ip=209.85.208.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intellipay.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intellipay.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intellipay-com.20230601.gappssmtp.com header.i=@intellipay-com.20230601.gappssmtp.com header.b="fP8+soUM" Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2eaea28868dso46346301fa.3 for ; Mon, 01 Jul 2024 10:19:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intellipay-com.20230601.gappssmtp.com; s=20230601; t=1719854339; x=1720459139; darn=vger.kernel.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=Gpv1pLYI2DjtEFy23jnYK926DeN1I0IOXpi8FuvzjHc=; b=fP8+soUMXXHFcp+OQQN99MCu30DkjQj6P8D6iN85gH5b2QM332avkDnAIuc0do4Zno KwguDt2t3GuxAQOxCYQDs5cCjo3MQv69CqZCgiKb3YnFwHx0mZM9U1ClN8jYAsNooU5a K+regbop+XNJk+YnGQ3E1IFz4sCNLgQ/yUKzJzS+Ki3sTpcqw8uOQR/hoFYmvBbuGA3O gQxfsos/a424jc8eSXS1a2MXuT28JzDZtI+tYpYr+aGeV33tITRkIa83wyYl1A6TlttS D4V4YFCBrh+HVAfkI4+BnQ1T+2Edd/lOe/1aZmM5DUk85fChEPtQDbmtdyiJWhOvPX4U xwvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719854339; x=1720459139; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Gpv1pLYI2DjtEFy23jnYK926DeN1I0IOXpi8FuvzjHc=; b=aduRvQAp3Ee1om1EAfVxGWo1AEIPRzLMPl0+iKoXp74P40labUnoDEnzwwHDAKGLqe vs9m6/Kh0VWIZebelQUQUZQXFtWAKbnk5mgpf1aFnVXDIjMFAaEg7HskIasDAVsqsiXz 7DAkhwOT9pDqBqJMcQlcEys+ecuVC71WXB61IvkayKNCpkxguc7g/XXpqN3UO03Fzy2Z 185WoHv5Qeuu+/oXQyt5PLCIrL/vxvHFY0tC4Ga+LoaIe72hiZ+0fOQodPDKKEwd3Eme AL9grCuzlYKlaumdrJ4Rb0mMoJIANIY9j2hmq9fNEIzaLTMsJKcdAvGoi7LcTf2zoui7 2Gpw== X-Gm-Message-State: AOJu0Yzx7Cak1ltJtPNCankG+iIUP96/b+BF6SCa2dmSrTfqH5YJFoxW sOTL1daZP9/laa0V5VNEoKt+T7EyLLqGE0UX9PzyuNsj99AjV1F3Gwe39gUjNjFkEO0PB0dAxxX QkB5KO2+Vf9BjCP0FZQ7raMCXAyf9HGUH2ERJfbrSTMMqGOuIRAoypg== X-Google-Smtp-Source: AGHT+IFbL9dNy+TiySFOv1VYSrF2fJ9XbmN65yYc7/DmLcsrOtoy3/Y8lDNL1Cw9qETit9Fq16NO2AuzO9z56qTn8pc= X-Received: by 2002:a2e:90d3:0:b0:2ec:5645:7deb with SMTP id 38308e7fff4ca-2ee5e380020mr53538091fa.5.1719854339158; Mon, 01 Jul 2024 10:18:59 -0700 (PDT) Precedence: bulk X-Mailing-List: selinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Allan Oepping Date: Mon, 1 Jul 2024 11:18:47 -0600 Message-ID: Subject: UnicodeDecodeError: utf-8 on python semanage -i import To: selinux@vger.kernel.org Importing a .pp file with the python semanage -i option generates a "UnicodeDecodeError: utf-8" on an up to date Rocky 9 distribution. packages: policycoreutils-python-utils-3.6-2.1.el9.noarch python-unversioned-command-3.9.18-3.el9.noarch The open() in SetImportFile needs the binary "b" option to open the file in binary mode, as the .pp file is not in utf-8 format: patch also attached. Thanks, Allan Oepping --- /semanage~ 2024-07-01 10:29:20.000000000 -0600 +++ /semanage 2024-07-01 10:54:30.520312298 -0600 @@ -122,11 +122,11 @@ class SetImportFile(argparse.Action): def __call__(self, parser, namespace, values, option_string=None): if values and values != "-": try: - sys.stdin = open(values, 'r') + sys.stdin = open(values, 'rb') except IOError as e: sys.stderr.write("%s: %s\n" % (e.__class__.__name__, str(e))) sys.exit(1) setattr(namespace, self.dest, values)