Open atarijookie opened 7 years ago
If Linux ce_conf works the same way the Atari version does (i.e. sending 'alive' pings to the CE), you'll get this for free in #73. I have it implemented since a couple of weeks ago.
But I'm not sure what are you trying to prevent? So if I have a text editor open on Atari and I run CE_CONF in Linux, you don't want to see moving down in the text editor if I'm moving down in the menu?
But I'm not sure what are you trying to prevent?
Currently: Open a text editor / e-mail editor / game, and you - for some magical reasons - want to write a readme.txt / some e-mail / your geek name containing 'rm -rf /' and bam - you just unknowingly deleted your RPi linux files, while you were typing something on Atari through USB keyboard. The same goes for 'shutdown', 'reboot' and so on.
New behavior: Until you press the magical combination, you can type on Atari 'rm -rf /' and not delete your whole linux in CE.
PS: replying to this was difficult: https://www.youtube.com/watch?v=_TwCIxy1ExE
Incidently I just observed a similar issue: I rebooted my CE during some tests by accident just by pressing CTRL-ALT-DEL via USB during boot :) So if say, someone is waiting eagerly for CE to boot (cough @mikrosk cough ;-) ), he might reboot the CE while rebooting his ST via keyboard...
And: if ce_main is needed to activate console input via keyboard, troubleshooting a device might get problematic...
I rebooted my CE during some tests by accident just by pressing CTRL-ALT-DEL via USB during boot :)
Does that Raspbian / Yocto react to Ctrl-Alt-Del? I didn't know that :)
And: if ce_main is needed to activate console input via keyboard, troubleshooting a device might get problematic...
Only for the troubleshooting on TV + USB keyboard - the ssh to device shouldn't be affected. If ce_main would be running, then even switching the for linux on and off shouldn't be a problem, the only case would be a problem when the ce_main refuses to run for some reason (or keeps terminating, when HW doesn't respond).
Does that Raspbian / Yocto react to Ctrl-Alt-Del? I didn't know that :)
Yeah, surprising news to me, too :) Yocto isn't affected by this.
Only for the troubleshooting on TV + USB keyboard - the ssh to device shouldn't be affected.
Yeah, I know. But that's (HDMI/Kbd) exactly the thing that people w/o network or with borked up CE/network config might need to unbrick their device. No idea for a better solution atm, though :/
Hehe, this is a fascinating problem, had no idea at all. I use Atari keyboard for my IKBD stuff (with occasional testing for its USB counterpart but never for typing), wow.
Well, if you says that you're actually typing in command line, the problem lies elsewhere, not in CE_CONF. You must first disable autologin (as you say) plus you must somehow prevent even having login prompt at all. And frankly, I have no clue how to achieve this.
After some thinking -- we need that autologin because of "F8" functionality (i.e. switching to bash from Atari's CE_CONF)? If so, this is perhaps fixable with asking for login/password instead of skipping directly to command line.
But about disabling login prompt after boot... no clue. We could perhaps autostart an app in the foreground (!) which would eat all input (which could be possible to terminate via CTRL+C on HDMI) ? (with this hack we perhaps wouldn't need to disable autologin, just open another terminal on F8).
We need that autologin because of "F8" functionality (i.e. switching to bash from Atari's CE_CONF)?
NO, that is done through fork() and exec(), that HDMI console is not needed, unless you want to try to resolve some issue with CE on TV.
I wouldn't disable login prompt, I for now I would just hope nobody writes 'root[enter]ce[enter]' on USB keyboard while doing something on Atari ;)
Btw., if I remember correctly, the typical login program could be replaced with something else, which would just wait for a special key combination (e.g. Ctrl - Shift - F8) and that one would exec then the typical login prompt...
But I guess leaving it at login prompt would be probably just fine most of the time.
What about that idea of yours, the magic hotkey? Can't we replace /bin/login with a program which listens for LCTRL+LALT+RCTRL+RALT+DEL (impossible to do on Atari keyboard) and then show the login prompt? And if you reboot/power cycle the device, you're again in the fake login.
F11 or F12 are good magic hotkeys too ;)
F11 or F12 are good magic hotkeys too ;)
Not really, they are mapped to UNDO/HELP (not in master but in my branch for #73)
why not map Page Up / Page Down to Undo/help ? It is what hatari does
Historically I remember it from Eiffel that way -- PU/PD was mapped to SHIFT+UP/SHIFT+DOWN (something I plan to do after #73, it requires multi mapping from one code to many).
What about that idea of yours, the magic hotkey? Can't we replace /bin/login...
Yeah, that could be done, too, but it seems like too much work, and might behave differently on Yocto and Raspbian, while no one (yet) has complained about this not-blocked USB keyboard. So I would just go with no-autologin and no-ctrl-alt-del for now, and later the rest...
I'm still having trouble with #100
@atarijookie: sounds reasonable although now I will be much more cautious when using USB keyboards. :D
Disabling ctrl-alt-del:
sudo rm /lib/systemd/system/ctrl-alt-del.target
sudo ln -s /dev/null /lib/systemd/system/ctrl-alt-del.target
sudo systemctl daemon-reload
Disable auto-login:
ln -fs /lib/systemd/system/getty@.service
/etc/systemd/system/getty.target.wants/getty@tty1.service
I'm just thinking, is there a way for the ce_main_app to grab exclusive access of the usb keyboard ? The magic key would then be to release that exclusive access :)
I'm just thinking, is there a way for the ce_main_app to grab exclusive access of the usb keyboard ?
I'm not sure, in theory yes, but didn't see / try that... But good idea :+1:
ioctl(fd, EVIOCGRAB, (void)1); // grab exclusive .. ioctl(fd, EVIOCGRAB, (void)0); // release
Wow, nice, thanks ;) If @mikrosk adds another magical keyboard shortcut, adding this one would be easy ;) Or even MiKRO could then add it while he's doing his IKBD enhancements...
Disabling C-A-D and grab all input via ce_main sounds good! There should probably be some text on the console above the login explaining the keystroke to unlock the keyboard.
I've added disabling Ctrl-Alt-Del and disabling auto-login into shellscripts/copynewscripts.sh
There should probably be some text on the console above the login explaining the keystroke to unlock the keyboard.
Agree, I would just add it into /etc/motd which currently shows 'Raspbian Jessie running on CosmosEx device.'
@mikrosk - Will you do this improvement while you're playing with magical key strokes, or should I do it?
EDIT: deleted, I'm an idiot. ;)
Sure, I can take a look. So just to verify we understand each other:
ctrl-alt-del.target
stuff)Correct?
Correct?
No :)
Ah, right. I've mistaken CE_CONF for ce_main_app, assuming that it can't run in background the whole time (I'm tired :-P).
It's a good concept, this could really work nicely.
EDIT: that being said, I fail to see why do we need these:
at all?
Ctrl+Alt+Del sequence for reboot will be disabled (done in the script, applied with next update)
I think that even in the above scenario the user could reboot the CE by accident while ce_main isn't running - we don't know yet if ce_main starts early enough to prevent that.
That accidental reboot probably happened to to users already (but probably unbeknown to them).
I think that even in the above scenario the user could reboot the CE by accident while ce_main isn't running - we don't know yet if ce_main starts early enough to prevent that.
So the assumption is that the systemd flag kicks in earlier?
And why do we need to disable autologin?
I think that even in the above scenario the user could reboot the CE by accident while ce_main isn't running - we don't know yet if ce_main starts early enough to prevent that.
No no, by executing this (in the script):
ln -fs /dev/null /lib/systemd/system/ctrl-alt-del.target
It will disable ctrl-alt-del reboot forever (until changed back), so after that even when linux is booting and ce_main_app is not running, it will not reboot RPi.
And why do we need to disable autologin?
In case you still would be typing in console, while your keyboard grabbing feature is still not available ;)
while your keyboard grabbing feature is still not available ;)
Why it wouldn't be available?
Le 10.01.2017 à 10:31, Miro Kropacek a écrit :
while your keyboard grabbing feature is still not available ;)
Why it wouldn't be available?
until the ce_main_app is launched I guess...
while your keyboard grabbing feature is still not available ;) Why it wouldn't be available?
Because you haven't done it, commited it and pushed it to master branch? :)
until the ce_main_app is launched I guess...
No, it's a linux system setting - once you set it, it's there, independent of ce_main_app running or not.
It will disable ctrl-alt-del reboot forever (until changed back), so after that even when linux is booting and ce_main_app is not running, it will not reboot RPi.
@atarijookie: I know, I was just trying to paint a picture that might happen if we don't do this :) Edit: In that comment I was replying to Mikro, but did that poorly, sorry.
the ce_main_app will be grabbing the keyboard. But until it is runing, the USB keyboard events still goes to the system console. That's why it is needed to disable CTRL-ALT-DEL and disable autologin : the user can be logged a few seconds before ce_main_app is launched. Except if you can make sure autologin happens AFTER ce_main_app is able to grab USB keyboard exclusivity
I can code USB Keyboard grabbing, but I have no HDMI screen to test ;)
@miniupnp I don't have HDMI either. :-P IMO that autologin off is not needed (yes jookie, after I commit it ;)). My memory is vague here but from what I remember login happens at a certain init level so we just have to make sure to run ce_main_app on a lower one (what is the case right now, I believe).
@mikrosk: on raspbian ce_main starts directly after mountall. @miniupnp: I can test that (via dvi adapter).
@tin-nl : could you test my branch https://github.com/miniupnp/ce-atari/tree/ikbd ? only grabbing is implemented :)
Cool, sure :) I'll test yocto & raspbian.
@miniupnp; works fine on Raspbian - takes keyboard as soon as ce_main runs (faaaar before login), no input possible, input is routed to ST nicely. I can finally reboot my STe via keyboard w/o reboot the CE by accident ;-)
Could you shoot me a yocto binary? I can't cross compile to yocto ATM as it seems...
@miniupnp: Thanks a lot - works on yocto, too :) Couldn't check IKBD forwarding aka if ce_main still gets events (I see no reason why it shouldn't).
I also can confirm that ce_main releases USB on SIGINT/KILL (ce_stop.sh). Dunno what happens if it's crashing, though.
@tin-nl well it would be a linux kernel bug if the process keep exclusive access after exit, whatever the reason of the exit (crash, SIGTERM/SIGKILL/etc)
@atarijookie / @mikrosk : should I merge that code right away, or wait for the "magic key" to be implemented for release ? I can implement it if you tell me which magic key combination you want
@miniupnp: go ahead, I wont be able to do it earlier than during the weekend and it's possible the last pending tasks for #73 will eat my all time.
I don't have a preference on Magic Key Combination, so maybe MiKRO should tell ;)
I've implemented it with LCTRL+LALT+RCTRL+RALT if you're OK, I merge
I'm fine with it, and how about @mikrosk ?
@mikrosk is fine with that as well. So what's left to be implemented, if anything?
I swear to flying spaghetti monster that I've created this one, but I can't find it. If it's here somewhere, we can link them and close this one.
When using USB keyboard through CE, the input not only goes to ST, but also to linux console on RPi, which is auto-logged in in Raspbian.
Things to do: 1) disable auto login, so user won't be logged in automatically (seen through HDMI) 2) disable linux console input from USB, add some switching between linux console and Atari IKDB
@mikrosk - do you have any idea how to solve 2), or at least do the preparation for switching that keyboard, like you're currently doing for your IKBD fake joysticks switching?