Bug 1000815

Summary: semanage throws an exception because of a syntax error
Product: [Fedora] Fedora Reporter: Nicolas Iooss <nicolas.iooss.2010_redhat>
Component: policycoreutilsAssignee: Daniel Walsh <dwalsh>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: rawhideCC: dwalsh, mgrepl
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-05-15 11:59:46 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Nicolas Iooss 2013-08-25 15:27:29 UTC
Description of problem:

There is a syntax error in seobject.py file on line 92. http://userspace.selinuxproject.org/trac/browser/policycoreutils/semanage/seobject.py?rev=da867f68b2f7c94cbc6a455ba7033871e2e536f9#L92 contains: message += " %s name=%s" % (msg, name). As variable "message" is undefined here, Python raises an UnboundLocalError error. Changing += to = would fix this bug.


How reproducible: always


Steps to Reproduce:
1. Run "semanage login -a -s staff_u userlogin" where userlogin is a valid Unix user.
2.
3.

Actual results:

Traceback (most recent call last):
  File "/usr/sbin/semanage", line 569, in <module>
    process_args(sys.argv[1:])
  File "/usr/sbin/semanage", line 411, in process_args
    OBJECT.add(target, seuser, serange)
  File "/usr/lib/python2.7/dist-packages/seobject.py", line 536, in add
    self.__add(name, sename, serange)
  File "/usr/lib/python2.7/dist-packages/seobject.py", line 531, in __add
    self.mylog.log("login", name, sename=sename, serange=serange, serole=",".join(serole), oldserole=",".join(oldserole), oldsename=self.oldsename, oldserange=self.oldserange);
  File "/usr/lib/python2.7/dist-packages/seobject.py", line 90, in log
    message += " %s name=%s" % (msg, name)
UnboundLocalError: local variable 'message' referenced before assignment

Expected results:
No exception

Additional info:
I'm experiencing this issue on a Debian sid system. Gentoo seems to have a patch to fix its package.

Comment 1 Nicolas Iooss 2013-08-28 16:02:34 UTC
This patch seems to fix this bug: http://comments.gmane.org/gmane.comp.security.selinux/19129

Comment 2 Daniel Walsh 2013-08-28 20:03:34 UTC
policycoreutils-2.1.14-75.fc20.x86_64 already looks like this is fixed.

It is still broken in F19 though.