Skip to contentSkip to conversation

DISCUSSION Sky Autumn 3 participants 4 messages Aug 22, 2017 SELinux security module

lore
Share & tools
lore

Sky Autumn

author
#0 lore raw

Hello, everyone.=C2=A0There's my problem. When = I try to set label on directory with russian letters in name with policy = module, the following error occur:=C2=A0=C2=A0/etc/selinux/fin= al/targeted/contexts/files/file_contexts: =C2=A0line 5206 error due to: N= on-ASCII characters found=C2=A0On other machine it = works fine. libselinux version on first machine 2.5-6, on second 2.2.2-6.= Can I somehow install such policy on first machine without renaming dire= ctory? Thank you.

#1 lore raw

Re: file_contexts non-ascii error

Quoted 9 lines · Sky Autumn

Hello, everyone.
There's my problem. When I try to set label on directory with russian letters in name with policy module, the following error occur:
 /etc/selinux/final/targeted/contexts/files/file_contexts:  line 5206 error due to: Non-ASCII characters found

On other machine it works fine. libselinux version on first machine 2.5-6, on second 2.2.2-6. Can I somehow install such policy on first machine without renaming directory? Thank you.

The check for non-ASCII characters was introduced by the following commit:

commit 2981e0ba3a869d12ed6f376581277847421db2e7
Author: William Roberts <[email protected]> Date:   Tue Feb 9 13:59:46 2016 -0800

    read_spec_entry: fail on non-ascii

    Inserting non-ascii characters into the following files:
     * file_contexts
     * property_contexts
     * service_contexts
    can cause a failure on labeling but still result in a successful build.

    Hard error on non-ascii characters with:
    <path>:  line 229 error due to: Non-ASCII characters found

Even before that change, the code did not truly support unicode strings, so you could have inserted the module but restorecon or other commands could easily have mislabeled the directory. I guess the question is what exactly would need to change to truly support unicode strings in the libselinux label code; at the least, we'd need to pass additional flags to pcre_compile().

As a workaround, I would think you could use regex meta characters e.g. .* or .+ to match the portion of the pathname that contains unicode characters, as long as that doesn't cause other directories/files to become mislabeled.

author
#2 lore raw

Re: file_contexts non-ascii error

PGRpdj5UaGFuayB5b3UsIFN0ZXBoZW4sIEkgd291bGQga2VlcCBpdCBpbiBtaW5kLjwvZGl2Pjxk aXY+PGJyIC8+PC9kaXY+PGRpdj48YnIgLz48L2Rpdj48ZGl2PjIyLjA4LjIwMTcsI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F1b3RlPg==

#3 lore raw

Re: file_contexts non-ascii error

In reply to Stephen Smalley
Quoted 30 lines · Stephen Smalley
Quoted 9 lines · Sky Autumn

Hello, everyone.
There's my problem. When I try to set label on directory with russian letters in name with policy module, the following error occur:
/etc/selinux/final/targeted/contexts/files/file_contexts: line 5206
error due to: Non-ASCII characters found

On other machine it works fine. libselinux version on first machine 2.5-6, on second 2.2.2-6. Can I somehow install such policy on first machine without renaming directory? Thank you.

The check for non-ASCII characters was introduced by the following commit:

commit 2981e0ba3a869d12ed6f376581277847421db2e7

Author: William Roberts <[email protected]>
Date:   Tue Feb 9 13:59:46 2016 -0800

read_spec_entry: fail on non-ascii

Inserting non-ascii characters into the following files:
* file_contexts
* property_contexts
* service_contexts
can cause a failure on labeling but still result in a successful build.

Hard error on non-ascii characters with:
<path>: line 229 error due to: Non-ASCII characters found

Quoted 8 lines

Even before that change, the code did not truly support unicode strings, so you could have inserted the module but restorecon or other commands could easily have mislabeled the directory. I guess the question is what exactly would need to change to truly support unicode strings in the libselinux label code; at the least, we'd need to pass additional flags to pcre_compile().

We actually had weird behavior with things not working when unicode characters were accidentally slipped into the files and since it was unsupported, I wanted it to fail loudly. Since I don't do anything out of the ASCII set, I felt I was a poor candidate to properly add UTF support.

I would assume all folks would want is UTF8, and that should be fairly straightforward to add (I'm not doing it).

Quoted 6 lines

As a workaround, I would think you could use regex meta characters e.g. .* or .+ to match the portion of the pathname that contains unicode characters, as long as that doesn't cause other directories/files to become mislabeled.

Signature · 3 lines
Respectfully,

William C Roberts