~costales/gui-ufw/renamed_object

« back to all changes in this revision

Viewing changes to gufw/gufw/instance.py

  • Committer: costales
  • Date: 2019-05-08 17:29:23 UTC
  • Revision ID: costales.marcos@gmail.com-20190508172923-1sm4j7vsp1ri42vp
Don't allow to run with /etc writable

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
# information.
17
17
 
18
18
import os, sys
19
 
 
 
19
from stat import *
20
20
 
21
21
class Instance:
22
22
    def __init__(self):
23
23
        self.pid_file = '/tmp/gufw.pid'
24
24
        self._check_is_root()
 
25
        self._check_etc_writable()
25
26
        self._check_instance()
26
27
        self._start_application()
27
28
    
34
35
            dialog.destroy()
35
36
            exit(0)
36
37
    
 
38
    def _check_etc_writable(self):
 
39
        if bin(os.stat("/etc")[ST_MODE])[-5] == '0' and bin(os.stat("/etc")[ST_MODE])[-2] == '0': # get chmod /etc
 
40
            return
 
41
        
 
42
        from gi.repository import Gtk
 
43
        import gettext
 
44
        from gettext import gettext as _
 
45
        gettext.textdomain('gufw')
 
46
        
 
47
        dialog = Gtk.MessageDialog(None, 0, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, _("Error: /etc is writable"))
 
48
        dialog.format_secondary_text(_("Your /etc directory is writable.\nFix it running from Terminal:") + "\n\nsudo chmod 755 /etc")
 
49
        dialog.run()
 
50
        dialog.destroy()
 
51
        exit(0)
 
52
 
37
53
    def _check_instance(self):
38
54
        if not os.path.isfile(self.pid_file):
39
55
            return