Bug 965397 - chcat cannot assign level/category in full format for user
chcat cannot assign level/category in full format for user
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: policycoreutils (Show other bugs)
All Linux
medium Severity medium
: rc
: ---
Assigned To: Petr Lautrbach
Milos Malik
Depends On:
Blocks: 1073966
  Show dependency treegraph
Reported: 2013-05-21 03:34 EDT by Michal Trunecka
Modified: 2015-05-27 08:42 EDT (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1073966 (view as bug list)
Last Closed: 2015-05-04 08:52:42 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Michal Trunecka 2013-05-21 03:34:56 EDT
Description of problem:

This works on RHEL5, but doesn't work on RHEL6 (or RHEL7, I'll clone the bug if we decide this is really bug)

# chcat -l s0-s0:c0.c1023 testuser
libsepol.mls_from_string: invalid MLS context s0-s0:s0-s0,c0.c1023 (No such file or directory).
libsepol.mls_from_string: could not construct mls context structure (No such file or directory).
libsemanage.validate_handler: seuser mapping [testuser -> (unconfined_u, s0-s0:s0-s0,c0.c1023)] is invalid (No such file or directory).
libsemanage.dbase_llist_iterate: could not iterate over records (No such file or directory).
/usr/sbin/semanage: Could not commit semanage transaction

Version-Release number of selected component (if applicable):

Expected results:

# chcat -l s0-s0:c0.c1023 testuser
# semanage login -l | grep testuser
testuser                  user_u                    s0-s0:c0.c1023
Comment 1 Daniel Walsh 2013-05-23 10:45:13 EDT
chcat should probably be removed or this functionality removed since mcstransd has moved beyond simple name value pairs.
Comment 3 Petr Lautrbach 2015-02-24 11:22:18 EST
The diff between rhel-5 and rhel-6 seems to be simple enough. So I believe that this issue could be fixed.

--- rhel-5.11/policycoreutils-1.33.12.git/scripts/chcat 2015-02-24 15:25:16.774790332 +0100
+++ rhel-6.7/policycoreutils-2.0.83.git/scripts/chcat   2015-02-23 16:25:46.607444509 +0100
@@ -221,7 +221,7 @@
             add_ind = 1
             user = seusers["__default__"]
         serange = user[1].split("-")
-        new_serange = "%s:%s" % (newcat[0],string.join(newcat[1:], ","))
+        new_serange = "%s-%s:%s" % (serange[0],newcat[0], string.join(newcat[1:], ","))
         if new_serange[-1:] == ":":
             new_serange = new_serange[:-1]
@@ -273,7 +273,7 @@
     return replace_ind
 def isSensitivity(sensitivity):
-    if sensitivity[0] == "s" and sensitivity[1].isdigit() and int(sensitivity[1]) in range(0,16):
+    if sensitivity[0] == "s" and sensitivity[1:].isdigit() and int(sensitivity[1:]) in range(0,16):
         return 1
         return 0
Comment 6 Petr Lautrbach 2015-05-04 08:52:08 EDT
The fix probably broke more than it fixed and it would be hard to preserver the original chcat functionality and fix this issue.

Therefore we've decided to revert it and close this bug as WONTFIX and advice users to use 'semanage login -m -r RANGE LOGIN'

Note You need to log in before you can comment on or make changes to this bug.