def configure_paranoidguestmode_before_calling_lxdm( password, direct, spoof, camouflage ): ''' Greeter calls me before it calls lxdm. This is my chance to set up the XP look, enable MAC spoofing, etc. ''' # Set password, if appropriate logme( 'configure_para....() - password=%s, direct=%s, spoof=%s, camouflage=%s' % ( str( password ), str( direct ), str( spoof ), str( camouflage ) ) ) distro = load_distro_record() logme( 'At present, windo manager = %s' % ( distro.lxdm_settings['window manager'] ) ) if password in ( None, '' ): disable_root_password( '/' ) else: set_user_password( 'root', password ) # Enable MAC spoofing, if appropriate if spoof: # https://wiki.archlinux.org/index.php/MAC_Address_Spoofing write_spoof_script_file( '/etc/NetworkManager/dispatcher.d/99spoofmymac.sh' ) # NetworkManager will run it, automatically, as soon as network goes up/down system_or_die( '''macchanger -r `ifconfig | grep lan0 | cut -d':' -f1 | head -n1`''' ) else: os.system( 'rm -f /etc/NetworkManager/dispatcher.d/99spoofmymac.sh' ) if camouflage: distro.lxdm_settings['window manager'] = '/usr/bin/mate-session' else: distro.lxdm_settings['window manager'] = distro.lxdm_settings['default wm'] distro.lxdm_settings['internet directly'] = direct save_distro_record( distro ) os.system( 'echo "configure_paranoid... - part E --- BTW, wm is now %s" >> /tmp/log.txt' % ( distro.lxdm_settings['window manager'] ) ) assert( camouflage is False or ( camouflage is True and 0 == os.system( 'cat /etc/lxdm/lxdm.conf | fgrep mate-session' ) ) ) os.system( 'cp /etc/lxdm/lxdm.conf /etc/lxdm/lxdm.conf.doin-the-doo' ) os.system( 'sync;sync;sync' )
def btnApplyAppChangesClicked( self ): # if not self.changes_made: # logme( 'No changes were made. Therefore, I have nothing to do. Cool...' ) # else: reply = QtGui.QMessageBox.question( self, "Make Changes", "This may take me a while to do. Are you sure you want to do this?", QtGui.QMessageBox.Yes, QtGui.QMessageBox.No ) if reply == QtGui.QMessageBox.Yes: self.saveLxdmSettingsToMyDistroRecord() save_distro_record( self.distro ) self.setChangesMadeFalse() self.populateMainTabWidget()
def closeEvent( self, event ): if not self.changes_made: sys.exit( 0 ) else: reply = QtGui.QMessageBox.question( self, "Quit?", "Are you sure to quit?", QtGui.QMessageBox.Yes, QtGui.QMessageBox.No ) if reply == QtGui.QMessageBox.Yes: save_distro_record( self.distro ) event.accept() sys.exit( 0 ) else: event.ignore()
def btnApplyAppChangesClicked(self): # if not self.changes_made: # logme( 'No changes were made. Therefore, I have nothing to do. Cool...' ) # else: reply = QtGui.QMessageBox.question( self, "Make Changes", "This may take me a while to do. Are you sure you want to do this?", QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) if reply == QtGui.QMessageBox.Yes: self.saveLxdmSettingsToMyDistroRecord() save_distro_record(self.distro) self.setChangesMadeFalse() self.populateMainTabWidget()
def closeEvent(self, event): if not self.changes_made: sys.exit(0) else: reply = QtGui.QMessageBox.question(self, "Quit?", "Are you sure to quit?", QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) if reply == QtGui.QMessageBox.Yes: save_distro_record(self.distro) event.accept() sys.exit(0) else: event.ignore()
def configure_paranoidguestmode_before_calling_lxdm(password, direct, spoof, camouflage): ''' Greeter calls me before it calls lxdm. This is my chance to set up the XP look, enable MAC spoofing, etc. ''' # Set password, if appropriate logme( 'configure_para....() - password=%s, direct=%s, spoof=%s, camouflage=%s' % (str(password), str(direct), str(spoof), str(camouflage))) distro = load_distro_record() logme('At present, windo manager = %s' % (distro.lxdm_settings['window manager'])) if password in (None, ''): disable_root_password('/') else: set_user_password('root', password) # Enable MAC spoofing, if appropriate if spoof: # https://wiki.archlinux.org/index.php/MAC_Address_Spoofing write_spoof_script_file( '/etc/NetworkManager/dispatcher.d/99spoofmymac.sh' ) # NetworkManager will run it, automatically, as soon as network goes up/down system_or_die( '''macchanger -r `ifconfig | grep lan0 | cut -d':' -f1 | head -n1`''' ) else: os.system('rm -f /etc/NetworkManager/dispatcher.d/99spoofmymac.sh') if camouflage: distro.lxdm_settings['window manager'] = '/usr/bin/mate-session' else: distro.lxdm_settings['window manager'] = distro.lxdm_settings[ 'default wm'] distro.lxdm_settings['internet directly'] = direct save_distro_record(distro) os.system( 'echo "configure_paranoid... - part E --- BTW, wm is now %s" >> /tmp/log.txt' % (distro.lxdm_settings['window manager'])) assert (camouflage is False or (camouflage is True and 0 == os.system('cat /etc/lxdm/lxdm.conf | fgrep mate-session'))) os.system('cp /etc/lxdm/lxdm.conf /etc/lxdm/lxdm.conf.doin-the-doo') os.system('sync;sync;sync')
def migrate_to_obfuscated_filesystem(distro): failed('migrate_to_obfuscated_filesystem() -- nefarious porpoises') os.system('clear') if distro.status_lst not in (None, []) and len(distro.status_lst) > 1: distro.status_lst = distro.status_lst[-1:] distro.update_status_with_newline('*** %s ***' % (distro.hewwo)) distro.update_status_with_newline('Welcome back!') distro.update_status_with_newline( '****************************************************************************************' ) distro.update_status_with_newline( 'Migrating from a temporary system to an encrypted, permanent system...' ) distro.pheasants = True # HOWEVER, we don't want to modify the sources! If we do that, we lose our existing magic#. distro.kthx = True # HOWEVER....., we don't want to modify the sources! If we do that, we lose our existing magic#. distro.initrd_rebuild_required = True assert (os.path.exists('%s/etc/.randomized_serno' % (distro.mountpoint))) system_or_die('rm -f %s%s/core/chromeos-3.4/arch/arm/boot/vmlinux.uimg' % (distro.mountpoint, distro.kernel_src_basedir)) for cmd in ('mkdir -p %s' % (distro.sources_basedir), 'mkdir -p /tmp/shoopwhoop', 'mount %s /tmp/shoopwhoop' % (distro.root_dev), 'tar -Jxf /tmp/shoopwhoop/.mkfs.tar.xz -C /', 'umount /tmp/shoopwhoop', ''' FSTYPE="blah" while [ "$FSTYPE" != "ext4" ] && [ "$FSTYPE" != "btrfs" ] && [ "$FSTYPE" != "xfs" ] && [ "$FSTYPE" != "jfs" ] ; do echo -en "Your filesystem may use ext4, xfs, jfs, or btrfs. (btrfs=best!) Please choose. => " read FSTYPE done echo $FSTYPE > %s/.cryptofstype ''' % (distro.mountpoint)): chroot_this(distro.mountpoint, cmd, on_fail='Failed to run %s' % (cmd)) distro.crypto_filesystem_format = read_oneliner_file('%s/.cryptofstype' % (distro.mountpoint)) new_mtpt = '/tmp/_enc_root' distro.set_root_password() distro.configure_guestmode_prior_to_migration() # NOOO! system_or_die( 'rm -f /.squashfs.sqfs %s/.squashfs.sqfs' % ( distro.mountpoint ) ) # NOOO! What if we're RUNNING LIVE?! distro.lxdm_settings['use greeter gui'] = False chrubix.save_distro_record(distro_rec=distro, mountpoint=distro.mountpoint) distro.migrate_all_data(new_mtpt) # also mounts new_mtpt and rejigs kernel mount_sys_tmp_proc_n_dev(new_mtpt, force=True) # distro.mountpoint = new_mtpt distro.update_status('PKGBUILDs') for cmd in ( 'mkdir -p %s' % (distro.sources_basedir), 'mkdir -p /tmp/whoopshoop', 'mount %s /tmp/whoopshoop' % (distro.root_dev), # FIXME comment out the next line & see what happens 'tar -Jxf /tmp/whoopshoop/.PKGBUILDs.tar.xz -C %s' % (distro.ryo_tempdir), 'tar -Jxf /tmp/whoopshoop/.PKGBUILDs.additional.tar.xz -C %s' % (distro.ryo_tempdir), # FIXME comment out the next 19 lines & see what happens ''' cd %s errors=0 for ddd in `find *fs* -maxdepth 1 -mindepth 1 -type d | grep fs`; do echo ddd=$ddd >> /tmp/chrubix.log cd $ddd if [ -e "Makefile" ] ; then if make ; then if make install ; then echo $ddd=OK >> /tmp/chrubix.log else errors=$(($errors+10)) fi else errors=$(($errors+1)) fi fi cd ../.. done exit $errors ''' % (distro.sources_basedir), 'cp -f /tmp/whoopshoop/.*gz /tmp/', 'cp -f /tmp/whoopshoop/.*gz /'): chroot_this(new_mtpt, cmd, on_fail='Failed to run %s' % (cmd), status_lst=distro.status_lst, title_str=distro.title_str, attempts=1) distro.update_status('.') # Were the binaries installed? for looking_for_cmd in ('mkfs.xfs', 'jfs_mkfs', 'mkfs.btrfs'): if 0 != os.system('which %s 2> /dev/null' % (looking_for_cmd), attempts=1): failed( 'Unable to locate %s in current filesystem, even though I rebuilt it a moment ago.' % (looking_for_cmd)) system_or_die('cp -f %s/tmp/whoopshoop/.*gz /tmp/' % (new_mtpt)) distro.redo_mbr_for_encrypted_root(new_mtpt) chrubix.save_distro_record( distro_rec=distro, mountpoint=new_mtpt ) # save distro record to new disk (not old mountpoint) distro.update_status_with_newline('5. Reboot!') try: os.system('umount %s/%s/tmp/whoopshoop' % (distro.mountpoint, new_mtpt)) unmount_sys_tmp_proc_n_dev(new_mtpt) os.system('umount %s/%s' % (distro.mountpoint, new_mtpt)) if distro.mountpoint != '/': unmount_sys_tmp_proc_n_dev(distro.mountpoint) except (SystemError, SyntaxError): pass os.system('cryptsetup luksClose %s' % (os.path.basename(distro.crypto_rootdev))) os.system('clear; echo "Press ENTER and reboot.; read line') failed('Reboot now.') os.system('sync;sync;sync; reboot')
def migrate_to_obfuscated_filesystem( distro ): failed( 'migrate_to_obfuscated_filesystem() -- nefarious porpoises' ) os.system( 'clear' ) if distro.status_lst not in ( None, [] ) and len( distro.status_lst ) > 1: distro.status_lst = distro.status_lst[-1:] distro.update_status_with_newline( '*** %s ***' % ( distro.hewwo ) ) distro.update_status_with_newline( 'Welcome back!' ) distro.update_status_with_newline( '****************************************************************************************' ) distro.update_status_with_newline( 'Migrating from a temporary system to an encrypted, permanent system...' ) distro.pheasants = True # HOWEVER, we don't want to modify the sources! If we do that, we lose our existing magic#. distro.kthx = True # HOWEVER....., we don't want to modify the sources! If we do that, we lose our existing magic#. distro.initrd_rebuild_required = True assert( os.path.exists( '%s/etc/.randomized_serno' % ( distro.mountpoint ) ) ) system_or_die( 'rm -f %s%s/core/chromeos-3.4/arch/arm/boot/vmlinux.uimg' % ( distro.mountpoint, distro.kernel_src_basedir ) ) for cmd in ( 'mkdir -p %s' % ( distro.sources_basedir ), 'mkdir -p /tmp/shoopwhoop', 'mount %s /tmp/shoopwhoop' % ( distro.root_dev ), 'tar -Jxf /tmp/shoopwhoop/.mkfs.tar.xz -C /', 'umount /tmp/shoopwhoop', ''' FSTYPE="blah" while [ "$FSTYPE" != "ext4" ] && [ "$FSTYPE" != "btrfs" ] && [ "$FSTYPE" != "xfs" ] && [ "$FSTYPE" != "jfs" ] ; do echo -en "Your filesystem may use ext4, xfs, jfs, or btrfs. (btrfs=best!) Please choose. => " read FSTYPE done echo $FSTYPE > %s/.cryptofstype ''' % ( distro.mountpoint ) ): chroot_this( distro.mountpoint, cmd, on_fail = 'Failed to run %s' % ( cmd ) ) distro.crypto_filesystem_format = read_oneliner_file( '%s/.cryptofstype' % ( distro.mountpoint ) ) new_mtpt = '/tmp/_enc_root' distro.set_root_password() distro.configure_guestmode_prior_to_migration() # NOOO! system_or_die( 'rm -f /.squashfs.sqfs %s/.squashfs.sqfs' % ( distro.mountpoint ) ) # NOOO! What if we're RUNNING LIVE?! distro.lxdm_settings['use greeter gui'] = False chrubix.save_distro_record( distro_rec = distro, mountpoint = distro.mountpoint ) distro.migrate_all_data( new_mtpt ) # also mounts new_mtpt and rejigs kernel mount_sys_tmp_proc_n_dev( new_mtpt, force = True ) # distro.mountpoint = new_mtpt distro.update_status( 'PKGBUILDs' ) for cmd in ( 'mkdir -p %s' % ( distro.sources_basedir ), 'mkdir -p /tmp/whoopshoop', 'mount %s /tmp/whoopshoop' % ( distro.root_dev ), # FIXME comment out the next line & see what happens 'tar -Jxf /tmp/whoopshoop/.PKGBUILDs.tar.xz -C %s' % ( distro.ryo_tempdir ), 'tar -Jxf /tmp/whoopshoop/.PKGBUILDs.additional.tar.xz -C %s' % ( distro.ryo_tempdir ), # FIXME comment out the next 19 lines & see what happens ''' cd %s errors=0 for ddd in `find *fs* -maxdepth 1 -mindepth 1 -type d | grep fs`; do echo ddd=$ddd >> /tmp/chrubix.log cd $ddd if [ -e "Makefile" ] ; then if make ; then if make install ; then echo $ddd=OK >> /tmp/chrubix.log else errors=$(($errors+10)) fi else errors=$(($errors+1)) fi fi cd ../.. done exit $errors ''' % ( distro.sources_basedir ), 'cp -f /tmp/whoopshoop/.*gz /tmp/', 'cp -f /tmp/whoopshoop/.*gz /' ): chroot_this( new_mtpt, cmd, on_fail = 'Failed to run %s' % ( cmd ), status_lst = distro.status_lst, title_str = distro.title_str, attempts = 1 ) distro.update_status( '.' ) # Were the binaries installed? for looking_for_cmd in ( 'mkfs.xfs', 'jfs_mkfs', 'mkfs.btrfs' ): if 0 != os.system( 'which %s 2> /dev/null' % ( looking_for_cmd ), attempts = 1 ): failed( 'Unable to locate %s in current filesystem, even though I rebuilt it a moment ago.' % ( looking_for_cmd ) ) system_or_die( 'cp -f %s/tmp/whoopshoop/.*gz /tmp/' % ( new_mtpt ) ) distro.redo_mbr_for_encrypted_root( new_mtpt ) chrubix.save_distro_record( distro_rec = distro, mountpoint = new_mtpt ) # save distro record to new disk (not old mountpoint) distro.update_status_with_newline( '5. Reboot!' ) try: os.system( 'umount %s/%s/tmp/whoopshoop' % ( distro.mountpoint, new_mtpt ) ) unmount_sys_tmp_proc_n_dev( new_mtpt ) os.system( 'umount %s/%s' % ( distro.mountpoint, new_mtpt ) ) if distro.mountpoint != '/': unmount_sys_tmp_proc_n_dev( distro.mountpoint ) except ( SystemError, SyntaxError ): pass os.system( 'cryptsetup luksClose %s' % ( os.path.basename( distro.crypto_rootdev ) ) ) os.system( 'clear; echo "Press ENTER and reboot.; read line' ) failed( 'Reboot now.' ) os.system( 'sync;sync;sync; reboot' )