Tiny Core Linux

Tiny Core Base => TCB Tips & Tricks => Topic started by: ipmeel on October 03, 2016, 01:39:10 AM

Title: Preventing user to switch to CLI (consoul/shell) from GUI.
Post by: ipmeel on October 03, 2016, 01:39:10 AM
Is it possible to prevent use to switch to CLI (consoul/shell) from GUI?
How to disable "CTL+ALT+Backspace" and "CTL+ALT+F1", that kills GUI?
How to disable or remove "Exit to Prompt" option in "TC Exit Options" (see attached image)?
Title: Re: Preventing user to switch to CLI (consoul/shell) from GUI.
Post by: ipmeel on October 06, 2016, 11:28:42 PM
Customised 'exittc': removed 'Exit to Prompt' option (see attached image).
On ubuntu system, installed FLTK library and dependencies.
downloaded 'exittc.fl' file from https://github.com/tinycorelinux/fltk_projects/blob/master/exittc/exittc.fl (https://github.com/tinycorelinux/fltk_projects/blob/master/exittc/exittc.fl).
Compiled ‘exittc.fl’ with following command, it created 2 files ('exittc.cxx', 'exittc.h')
Code: [Select]
fluid -c exittc.flExecuted following command to create 'exittc' (an executable file)..
Code: [Select]
fltk-config --compile exittc.cxxReplaced the existing 'exittc' file with new one (Location: "TinyCore.iso>cde>optional>Xprogs.tcz>usr>local>bin>exittc")
It is working file, now there is no option for 'Exit to Prompt'.
(http://forum.tinycorelinux.net/index.php?action=dlattach;topic=20388.0;attach=4694)

The only issue is that size of new file is about 500KiB, but the size of original was just about 8KiB!!! (any recommendations)
Title: Re: Preventing user to switch to CLI (consoul/shell) from GUI.
Post by: Juanito on October 07, 2016, 12:08:09 AM
You could use the Makefile in git to ensure exittc is compiled with the tinycore cxxflags and dynamically linked.

..and compile it on tinycore

Edit: alternatively:
Code: [Select]
$ g++ -flto -fuse-linker-plugin -march=i486 -mtune=i686 -Os -pipe -fno-exceptions -fno-rtti -fpic -lfltk -o exittc exittc.cxx
Title: Re: Preventing user to switch to CLI (consoul/shell) from GUI.
Post by: ipmeel on October 07, 2016, 02:37:21 AM
Hi Juanito,
Thank you for the suggestions.
I don't have  much experience with Linux and C++.
May I ask if you could make it from attached files.
Kind regards.
Title: Re: Preventing user to switch to CLI (consoul/shell) from GUI.
Post by: Juanito on October 07, 2016, 04:09:19 AM
see attached.

You can achieve the same thing yourself with:
Code: [Select]
$ tce-load -i compiletc fltk-1.3-dev sstrip

$ cd exittc

$ g++ -flto -fuse-linker-plugin -march=i486 -mtune=i686 -Os -pipe -fno-exceptions -fno-rtti -fpic -lfltk -o exittc exittc.cxx

$ sstrip exittc
Title: Re: Preventing user to switch to CLI (consoul/shell) from GUI.
Post by: nitram on October 07, 2016, 04:43:33 AM
Is it possible to prevent use to switch to CLI (consoul/shell) from GUI?
How to disable "CTL+ALT+Backspace" and "CTL+ALT+F1", that kills GUI?
How to disable or remove "Exit to Prompt" option in "TC Exit Options" (see attached image)?

Hi ipmeel. Just curious why? You are going through a lot of effort, so i'm thinking security related? If so modifying exittc to block TTY access will not suffice. A user with virtual terminal access can run  killall Xorg  and it will return to TTY. System Tools -> Run Program accepts the  killall Xorg  command. Running  sudo openvt  creates an additional TTY on the fly as root, so sudo should be password protected. Physical access to the machine or power supply may allow reboot, so the boot manager (text bootcode) and Tiny Core user login should be password protected. Didn't test CTL+ALT+Backspace and CTL+ALT+F1 so i could finish this post, may be Window Manager dependent. Regardless, ensure the Window Manager does not have additional keyboard shortcuts to exit, open terminal, etc. Probably other methods, fun to brainstorm. If the purpose of your  exittc  modification is not security related please ignore this post.
Title: Re: Preventing user to switch to CLI (consoul/shell) from GUI.
Post by: ipmeel on October 07, 2016, 07:32:16 AM
@Juanito,
Many-many thanks, it worked like charm.
---
@nitram,
Our users don't have physical access to systems.
All icons are excluded from wBar, except 'Exit' and 'Remote Desktop Connection'. The mouse click-context-menu is also disabled. Now 'TC Exit option' is modified. I think there are only remaining possibilities to access 'terminal' or TTY is using 'CTL+ALT+Backspace' and 'CTL+ALT+F1'.
I am not familiar with window manager, I will explore it.
Thanks for your comments.
Title: Re: Preventing user to switch to CLI (consoul/shell) from GUI.
Post by: Rich on October 07, 2016, 07:39:40 AM
Hi ipmeel
To disable  CTL+ALT+F1  try commenting out the  tty1  line in  /etc/inittab. This would need to be done in the  initrd
file (rootfs.gz).
For  CTL+ALT+Backspace, try Googling  linux nozap.
Title: Re: Preventing user to switch to CLI (consoul/shell) from GUI.
Post by: nitram on October 07, 2016, 08:53:01 AM
Alt-SysRq REISUB is also enabled by default, entering  Alt-SysRq+R+ E  will get TTY:
https://en.wikipedia.org/wiki/Magic_SysRq_key
/proc/sys/kernel/sysrq
Title: Re: Preventing user to switch to CLI (consoul/shell) from GUI.
Post by: ipmeel on October 07, 2016, 10:45:11 AM
Hi Rich,
I commented out the tty1 line in 'tinycore-current.iso>/boot/>core.gz>/etc/inittab'.
But, while booting from ISO file, the boot screen hangs at 'Setting hostname to Box Done'.

I try to extract and packed 'core.gz' by two methods...
(1) using 'core-remaster.tcz' and
(2) by following steps mentioned at http://wiki.tinycorelinux.net/wiki:remastering (http://wiki.tinycorelinux.net/wiki:remastering).

Title: Re: Preventing user to switch to CLI (consoul/shell) from GUI.
Post by: ipmeel on October 09, 2016, 07:21:30 AM
Resolved!!!
(1) Installed 'Xorg-7.X.tcz' and removed 'Xvesa.tcz' from 'onboot.lst'. It disabled 'CTRL+ALT+Backspace', don't know how?
(2) Put a file ‘xorg.conf’ in ‘Xorg-7.7-bin.tcz’>/etc/X11/ with following content...
Code: [Select]
Section “ServerFlags”
  Option “DontVTSwitch” “yes”
  Option “DontZap” “yes”
EndSection
It disabled  'CTRL+ALT+Fn'.
Title: Re: Preventing user to switch to CLI (consoul/shell) from GUI.
Post by: Misalf on October 09, 2016, 10:43:18 AM
Quote
It disabled 'CTRL+ALT+Backspace', don't know how?
For Xorg, it would need
Code: [Select]
Section "InputClass"
Option           "XkbOptions"  "terminate:ctrl_alt_bksp"
EndSection

Title: Re: Preventing user to switch to CLI (consoul/shell) from GUI.
Post by: ipmeel on October 09, 2016, 05:47:22 PM
Code: [Select]
Section "InputClass"
Option           "XkbOptions"  "terminate:ctrl_alt_bksp"
EndSection
Is it should be in ‘xorg.conf’ ?