Commits

Konstantine Rybnikov committed 19b7725

firstboot from fedora13. Now need to upgrade it to version with libuser

Comments (0)

Files changed (1)

 #
 # Authors: Russian Fedora Team. http://russianfedora.ru
 #
+# This is a good example of impossible programing on python
+
 import gtk
 
 from firstboot.config import *
 class moduleClass(Module):
     def __init__(self):
         Module.__init__(self)
-        self.priority = 0
+        self.priority = 101
         # self.priority = 99
         self.sidebarTitle = N_("RFRemix configure")
         self.title = N_("RFRemix configure")
         self.icon = "workstation.png"
 
     def apply(self, interface, testing=False):
+        print '======================================='
+        for key, val in self.ACTIONS_MAP.iteritems():
+            print "%s -> %s" % (key, val)
+        print '======================================='
         if self.ch1.get_property('sensitive') and self.ch1.state == 1:
             os.system('/usr/bin/gconftool-2 --direct --config-source=xml:readwrite:/etc/gconf/gconf.xml.defaults -s -t bool /apps/nautilus/preferences/always_use_browser true')
         if self.ch2.get_property('sensitive') and self.ch2.state == 1:
-            os.system('/usr/bin/gconftool-2 --direct --config-source=xml:readwrite:/etc/gconf/gconf.xml.defaults -s -t bool /desktop/gnome/interface/menu_have_icons true')
+            os.system('/usr/bin/gconftool-2 --direct --config-source=xml:readwrite:/etc/gconf/gconf.xml.defaults -s -t bool /desktop/gnome/interface/menus_have_icons true')
         if self.ch3.get_property('sensitive') and self.ch3.state == 1:
             os.system('/usr/bin/gconftool-2 --direct --config-source=xml:readwrite:/etc/gconf/gconf.xml.defaults -s -t bool /desktop/gnome/interface/buttons_have_icons true')
         if self.ch5.get_property('sensitive') and self.ch5.state == 1:
         print '======================================='
         
         if 'kdm_gdm' in self.ACTIONS_MAP:
-            # let's write it only for kdm
-            if self.ACTIONS_MAP['kdm_gdm'] == 'kdm':
+            if self.ACTIONS_MAP['kdm_gdm'] == 'gdm':
+                os.system(r"""echo "DISPLAYMANAGER=\"GNOME\"" > /etc/sysconfig/desktop""")
+            else:
                 os.system(r"""echo "DISPLAYMANAGER=\"KDE\"" > /etc/sysconfig/desktop""")
         
-        if 'disable_ipv6' in self.ACTIONS_MAP:
-            pass
-        
         if 'sudo_users' in self.ACTIONS_MAP:
             for user in self.ACTIONS_MAP['sudo_users']:
                 os.system("cat >> /etc/sudoers.d/%(username)s << FOE\n"
                     user = self.ACTIONS_MAP['autologin_user']
                     os.system("cat >> /etc/gdm/custom.conf << FOE\n"
                               "[daemon]\n"
+                              "AutomaticLoginEnable=true\n"
+                              "AutomaticLogin=%(username)s\n"
                               "TimedLoginEnable=true\n"
                               "TimedLogin=%(username)s\n"
                               "TimedLoginDelay=10\n"
                     os.system(r"sed -i 's/#AutoLoginUser=fred/AutoLoginUser=%(username)s/' /etc/kde/kdm/kdmrc" % dict(username=user))
         
         if 'c_m_backspace' in self.ACTIONS_MAP:
-            pass
-        
+            os.system("grep 'terminate:ctrl_alt_bksp' /etc/sysconfig/keyboard > /dev/null || sed -i 's!OPTIONS=\"!OPTIONS=\"terminate:ctrl_alt_bksp,!g' /etc/sysconfig/keyboard")
+
+        if 'disable_ipv6' in self.ACTIONS_MAP:
+            os.system("echo \"install ipv6 /bin/true blacklist ipv6\" > /etc/modprobe.d/blacklist-ipv6.conf")
+            os.system("/sbin/service ip6tables stop && /sbin/chkconfig ip6tables off")
+            os.system("grep 'NETWORKING_IPV6=no' /etc/sysconfig/network || echo \"NETWORKING_IPV6=no\" >> /etc/sysconfig/network")
+
+        if 'permissive_selinux' in self.ACTIONS_MAP:
+            os.system("sed -i 's!SELINUX=enforcing!SELINUX=permissive!g' /etc/selinux/config")
+
         return RESULT_SUCCESS
     
     def callb_radio(self, widget, data=None):
         self.ACTIONS_MAP = {}
         self.vbox = gtk.VBox()
         
-        label = gtk.Label(_("Now your can enable some parameters, which are disabled in original\n"
-                            "Fedora, such as fonts style, icons, encoding autodetection and others.\n"
+        label = gtk.Label(_("Now your can enable some parameters, which are disabled in original "
+                            "Fedora, such as fonts style, icons, encoding autodetection and others. "
                             "These are global parameter, they will be enabled for all users."))
         label.set_line_wrap(True)
         label.set_alignment(0.0, 0.5)
         
         first_tab_vbox.pack_start(box2, False, True, 0)
         
-        notebook.append_page(first_tab_vbox, gtk.Label(_("first tab")))
+        notebook.append_page(first_tab_vbox, gtk.Label(_("Desktop Preferences")))
         
         ## Here goes second tab of notebook
         second_tab_vbox = gtk.VBox()
-        notebook.append_page(second_tab_vbox, gtk.Label(_("second tab")))
+        notebook.append_page(second_tab_vbox, gtk.Label(_("System Preferences")))
         
-        label = gtk.Label(_("Choose window manager"))
+        label = gtk.Label(_("<b>Select login manager:</b>"))
+        label.set_use_markup(True)
+        label.set_line_wrap(True)
         label.set_alignment(0.0, 0.5)
-        second_tab_vbox.pack_start(label, False, True, 0)
+        label.set_size_request(500, -1)
+        second_tab_vbox.pack_start(label, False, True, 10)
         
         box = gtk.VBox()
-        self.wmanager_button = gtk.RadioButton(None, _("GDM (default)"))
+        self.wmanager_button = gtk.RadioButton(None, _("KDE Display Manager"))
         self.wmanager_button.set_active(True)
-        if not os.path.exists('/usr/bin/gdm'):
+        if not os.path.exists('/usr/bin/kdm'):
+            self.wmanager_button.set_sensitive(False)
+        else:
+            self.ACTIONS_MAP['kdm_gdm'] = 'kdm'
+        
+        self.wmanager_button.connect("toggled", self.callb_radio, dict(key='kdm_gdm', val='kdm'))
+        
+        box.pack_start(self.wmanager_button)
+        self.wmanager_button = gtk.RadioButton(self.wmanager_button, _("GNOME Display Manager"))
+        self.wmanager_button.set_active(True)
+        if not os.path.exists('/usr/sbin/gdm'):
             self.wmanager_button.set_sensitive(False)
         else:
             self.ACTIONS_MAP['kdm_gdm'] = 'gdm'
         self.wmanager_button.connect("toggled", self.callb_radio, dict(key='kdm_gdm', val='gdm'))
         
         box.pack_start(self.wmanager_button)
-        self.wmanager_button = gtk.RadioButton(self.wmanager_button, _("KDM"))
-        self.wmanager_button.set_active(True)
-        if not os.path.exists('/usr/bin/kdm'):
-            self.wmanager_button.set_sensitive(False)
-        else:
-            if 'kdm_gdm' not in self.ACTIONS_MAP:
-                self.ACTIONS_MAP['kdm_gdm'] = 'kdm'
         
-        self.wmanager_button.connect("toggled", self.callb_radio, dict(key='kdm_gdm', val='kdm'))
-        
-        box.pack_start(self.wmanager_button)
-        
-        second_tab_vbox.pack_start(box, False, True, 0)
+        second_tab_vbox.pack_start(box, False, True, 0)    
+
+        label = gtk.Label(_("<b>Advanced system settings</b>"))
+        label.set_use_markup(True)
+        label.set_line_wrap(True)
+        label.set_alignment(0.0, 0.5)
+        label.set_size_request(500, -1)
+        label.set_alignment(0.0, 0.5)
+        second_tab_vbox.pack_start(label, False, True, 10)
 
         #
         # C-M-Backspace option
         c_m_checkbox.connect("toggled", self.callb_checkbox, dict(key='c_m_backspace', val=True))
         box.pack_start(c_m_checkbox, False, True, 0)
         second_tab_vbox.pack_start(box, False, True, 0)
+
+        #
+        # IPv6 settings
+        #
+        box = gtk.VBox()
+        ipv6_checkbox = gtk.CheckButton(label=_("Disable IPv6 support"))
+        ipv6_checkbox.connect("toggled", self.callb_checkbox, dict(key="disable_ipv6", val=True))
+        box.pack_start(ipv6_checkbox, False, True, 0)
+        second_tab_vbox.pack_start(box, False, True, 0)
+
+        #
+        # SELinux switcher
+        #
+        box = gtk.VBox()
+        selinux_checkbox = gtk.CheckButton(label=_("Switch SELinux to Permissive (Reboot required)"))
+        selinux_checkbox.connect("toggled", self.callb_checkbox, dict(key="permissive_selinux", val=True))
+        box.pack_start(selinux_checkbox, False, True, 0)
+        second_tab_vbox.pack_start(box, False, True, 0)
+        
+        self.vbox.pack_start(notebook)
         
         # user_opt = gtk.combo_box_new_text()
-        # user_opt.append_text(_('Choose user:'))
+        # user_opt.append_text(_('Select user:'))
         # user_opt.append_text('kost')
         # user_opt.append_text('most')
         # user_opt.append_text('dost')
         # hbox.pack_start(user_opt)
         # add_sudo_checkbox = gtk.CheckButton(label=_('use SUDO for this user'))
 
-        import grp, pwd
-        users = [grp.getgrgid(user[3])[0] for user in pwd.getpwall() if grp.getgrgid(user[3])[2] >= 500]
+        ##import grp, pwd
+        ##users = [grp.getgrgid(user[3])[0] for user in pwd.getpwall() if grp.getgrgid(user[3])[2] <= 65535 and grp.getgrgid(user[3])[2] >= 500 ]
         
-        box = gtk.VBox()
-        hbox = gtk.HBox()
-        #
-        # Autologin
-        #
-        #self.ACTIONS_MAP['autologin_user'] = None
+        ##box = gtk.VBox()
+        ##hbox = gtk.HBox()
+        ###
+        ### Autologin
+        ###
+        ###self.ACTIONS_MAP['autologin_user'] = None
         
-        # def autologin_callb(widget, data=None):
-        #     return autologin_and_sudo_callb(self.ACTIONS_MAP['autologin_user'], widget, data)
+        ### def autologin_callb(widget, data=None):
+        ###     return autologin_and_sudo_callb(self.ACTIONS_MAP['autologin_user'], widget, data)
         
-        autologin_box = gtk.VBox()
-        autologin_box.pack_start(gtk.Label(_("Autologin user:")))
+        ##autologin_box = gtk.VBox()
+        ### autologin_box.pack_start(gtk.Label(_("Autologin user:")))
         
-        def change_autologin_user(widget):
-            def get_active_text(combobox):
-                model = combobox.get_model()
-                active = combobox.get_active()
-                if active < 0:
-                    return None
-                return model[active][0]
+        ##def change_autologin_user(widget):
+        ##    def get_active_text(combobox):
+        ##        model = combobox.get_model()
+        ##        active = combobox.get_active()
+        ##        if active < 0:
+        ##            return None
+        ##        return model[active][0]
             
-            if widget.get_active() > 0:
-                self.ACTIONS_MAP['autologin_user'] = get_active_text(widget)
-            else:
-                if 'autologin_user' in self.ACTIONS_MAP:
-                    del self.ACTIONS_MAP['autologin_user']
+        ##    if widget.get_active() > 0:
+        ##        self.ACTIONS_MAP['autologin_user'] = get_active_text(widget)
+        ##    else:
+        ##        if 'autologin_user' in self.ACTIONS_MAP:
+        ##            del self.ACTIONS_MAP['autologin_user']
+
+        ##label = gtk.Label(_("<b>Select user for autologin:</b>"))
+        ##label.set_use_markup(True)
+        ##label.set_line_wrap(True)
+        ##label.set_alignment(0.0, 0.5)
+        ##label.set_size_request(500, -1)
+        ##label.set_alignment(0.0, 0.5)
+        ##second_tab_vbox.pack_start(label, False, True, 10)
         
-        alog_opt = gtk.combo_box_new_text()
-        alog_opt.append_text(_('Choose user:'))
-        for user in users:
-            alog_opt.append_text(user)
-        alog_opt.connect('changed', change_autologin_user)
-        alog_opt.set_active(0)
+        ##alog_opt = gtk.combo_box_new_text()
+        ##alog_opt.append_text(_(' '))
+        ##for user in users:
+        ##    alog_opt.append_text(user)
+        ##alog_opt.connect('changed', change_autologin_user)
+        ##alog_opt.set_active(0)
         
-        autologin_box.pack_start(alog_opt)
-        hbox.pack_start(autologin_box)
+        ##autologin_box.pack_start(alog_opt)
+        ##hbox.pack_start(autologin_box)
+
+        ##box.pack_start(hbox, False, True, 0)
+        ##second_tab_vbox.pack_start(box, False, True, 0)
         
-        #
-        # Sudo
-        #
-        self.ACTIONS_MAP['sudo_users'] = []
+        ###
+        ### Sudo
+        ###
+        ##self.ACTIONS_MAP['sudo_users'] = []
         
-        def autologin_and_sudo_callb(var, widget, data=None):
-            if widget.get_active():
-                if data['user'] not in var:
-                    var.append(data['user'])
-            else:
-                if data['user'] in var:
-                    del var[var.index(data['user'])]
+        ##def autologin_and_sudo_callb(var, widget, data=None):
+        ##    if widget.get_active():
+        ##        if data['user'] not in var:
+        ##            var.append(data['user'])
+        ##    else:
+        ##        if data['user'] in var:
+        ##            del var[var.index(data['user'])]
         
-        def sudo_callb(widget, data=None):
-            return autologin_and_sudo_callb(self.ACTIONS_MAP['sudo_users'], widget, data)
+        ##def sudo_callb(widget, data=None):
+        ##    return autologin_and_sudo_callb(self.ACTIONS_MAP['sudo_users'], widget, data)
+
+
+        ##label = gtk.Label(_("<b>Allow sudo for users:</b>"))
+        ##label.set_use_markup(True)
+        ##label.set_line_wrap(True)
+        ##label.set_alignment(0.0, 0.5)
+        ##label.set_size_request(500, -1)
+        ##label.set_alignment(0.0, 0.5)
+        ##second_tab_vbox.pack_start(label, False, True, 10)
+
+     
+        ##box = gtk.VBox()
+        ##hbox = gtk.HBox()
+
+        ##sudo_box = gtk.VBox()
+
+        ##for user in users:
+        ##    checkbox = gtk.CheckButton(label=user)
+        ##    sudo_box.pack_start(checkbox)
+        ##    checkbox.connect("toggled", sudo_callb, {'user': user})
+        ##hbox.pack_start(sudo_box)
         
-        sudo_box = gtk.VBox()
-        sudo_box.pack_start(gtk.Label(_("Allow sudo for users:")))
-        for user in users:
-            checkbox = gtk.CheckButton(label=user)
-            sudo_box.pack_start(checkbox)
-            checkbox.connect("toggled", sudo_callb, {'user': user})
-        hbox.pack_start(sudo_box)
+        ##box.pack_start(hbox, False, True, 0)
+        ##second_tab_vbox.pack_start(box, False, True, 0)
         
-        box.pack_start(hbox, False, True, 0)
-        second_tab_vbox.pack_start(box, False, True, 0)
-        
-        #
-        # IPv6 settings
-        #
-        box = gtk.VBox()
-        checkbox = gtk.CheckButton(label=_("Disable IPv6 support"))
-        checkbox.connect("toggled", self.callb_checkbox, dict(key="disable_ipv6", val=True))
-        box.pack_start(checkbox)
-        second_tab_vbox.pack_start(box, False, True, 0)
-        
-        self.vbox.pack_start(notebook)
         
     def initializeUI(self):
         pass