python: Harden more tools agains "rogue" modules
PATCH 1/1 python: Harden more tools agains "rogue" modules
Python scripts present in the same directory as the tool override regular modules.
Fixes:
#cat > /usr/bin/signal.py <<EOF
import sys
print("BAD GUY!", file=sys.stderr)
sys.exit(1)
EOF
#sandbox date
BAD GUY!Signed-off-by Vit Mojzis <[email protected]>
--- dbus/selinux_server.py | 2 +- gui/polgengui.py | 2 +- gui/system-config-selinux.py | 6 +++--- sandbox/sandbox | 2 +- sandbox/start | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-)
dbus/selinux_server.py +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/python3 -EsI import dbus import dbus.service
gui/polgengui.py +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/python3 -Es +#!/usr/bin/python3 -EsI # # polgengui.py - GUI for SELinux Config tool in system-config-selinux #
gui/system-config-selinux.py +3 -3
@@ -1,4 +1,4 @@ -#!/usr/bin/python3 -Es +#!/usr/bin/python3 -EsI # # system-config-selinux.py - GUI for SELinux Config tool in system-config-selinux #
@@ -32,6 +32,8 @@ except RuntimeError as e: print("This is a graphical application and requires DISPLAY to be set.") sys.exit(1) +sys.path.append('/usr/share/system-config-selinux') + from gi.repository import GObject import statusPage import booleansPage
@@ -66,8 +68,6 @@ except: version = "1.0" -sys.path.append('/usr/share/system-config-selinux') - ## ## Pull in the Glade file
sandbox/sandbox +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/python3 -Es +#!/usr/bin/python3 -EsI # Authors: Dan Walsh <[email protected]> # Authors: Thomas Liu <[email protected]> # Authors: Josh Cogliati
sandbox/start +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/python3 -Es +#!/usr/bin/python3 -EsI try: from subprocess import getstatusoutput except ImportError:
Signature · 1 line
2.41.0
Quoted 13 lines · Vit Mojzis
Python scripts present in the same directory as the tool override regular modules.
Fixes:
#cat > /usr/bin/signal.py <<EOF import sys print("BAD GUY!", file=sys.stderr) sys.exit(1) EOF #sandbox date BAD GUY!
Quoted 1 line
Signed-off-by Vit Mojzis <[email protected]>
Acked-by James Carter <[email protected]>
Quoted 80 lines
--- dbus/selinux_server.py | 2 +- gui/polgengui.py | 2 +- gui/system-config-selinux.py | 6 +++--- sandbox/sandbox | 2 +- sandbox/start | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-)dbus/selinux_server.py +1
-1@@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/python3 -EsI import dbus import dbus.servicegui/polgengui.py +1
-1@@ -1,4 +1,4 @@ -#!/usr/bin/python3 -Es +#!/usr/bin/python3 -EsI # # polgengui.py - GUI for SELinux Config tool in system-config-selinux #gui/system-config-selinux.py +3
-3@@ -1,4 +1,4 @@ -#!/usr/bin/python3 -Es +#!/usr/bin/python3 -EsI # # system-config-selinux.py - GUI for SELinux Config tool in system-config-selinux #@@ -32,6 +32,8 @@ except RuntimeError as e: print("This is a graphical application and requires DISPLAY to be set.") sys.exit(1) +sys.path.append('/usr/share/system-config-selinux') + from gi.repository import GObject import statusPage import booleansPage@@ -66,8 +68,6 @@ except: version = "1.0" -sys.path.append('/usr/share/system-config-selinux') - ## ## Pull in the Glade filesandbox/sandbox +1
-1@@ -1,4 +1,4 @@ -#!/usr/bin/python3 -Es +#!/usr/bin/python3 -EsI # Authors: Dan Walsh <[email protected]> # Authors: Thomas Liu <[email protected]> # Authors: Josh Cogliatisandbox/start +1
-2@@ -1,4 +1,4 @@ -#!/usr/bin/python3 -Es +#!/usr/bin/python3 -EsI try: from subprocess import getstatusoutput except ImportError: --2.41.0
Quoted 15 lines · James Carter
Quoted 13 lines · Vit Mojzis
Python scripts present in the same directory as the tool override regular modules.
Fixes:
#cat > /usr/bin/signal.py <<EOF import sys print("BAD GUY!", file=sys.stderr) sys.exit(1) EOF #sandbox date BAD GUY!
Quoted 4 lines
Quoted 1 line
Signed-off-by Vit Mojzis <[email protected]>Acked-by James Carter <[email protected]>
Merged.
Thanks,
Jim
Quoted 80 lines
Quoted 80 lines
--- dbus/selinux_server.py | 2 +- gui/polgengui.py | 2 +- gui/system-config-selinux.py | 6 +++--- sandbox/sandbox | 2 +- sandbox/start | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-)dbus/selinux_server.py +1
-1@@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/python3 -EsI import dbus import dbus.servicegui/polgengui.py +1
-1@@ -1,4 +1,4 @@ -#!/usr/bin/python3 -Es +#!/usr/bin/python3 -EsI # # polgengui.py - GUI for SELinux Config tool in system-config-selinux #gui/system-config-selinux.py +3
-3@@ -1,4 +1,4 @@ -#!/usr/bin/python3 -Es +#!/usr/bin/python3 -EsI # # system-config-selinux.py - GUI for SELinux Config tool in system-config-selinux #@@ -32,6 +32,8 @@ except RuntimeError as e: print("This is a graphical application and requires DISPLAY to be set.") sys.exit(1) +sys.path.append('/usr/share/system-config-selinux') + from gi.repository import GObject import statusPage import booleansPage@@ -66,8 +68,6 @@ except: version = "1.0" -sys.path.append('/usr/share/system-config-selinux') - ## ## Pull in the Glade filesandbox/sandbox +1
-1@@ -1,4 +1,4 @@ -#!/usr/bin/python3 -Es +#!/usr/bin/python3 -EsI # Authors: Dan Walsh <[email protected]> # Authors: Thomas Liu <[email protected]> # Authors: Josh Cogliatisandbox/start +1
-2@@ -1,4 +1,4 @@ -#!/usr/bin/python3 -Es +#!/usr/bin/python3 -EsI try: from subprocess import getstatusoutput except ImportError: --2.41.0