Don't restart kodi when exiting to terminal

Hi everyone,

I need to access my Vero locally through its terminal. So far so good, in order to do that I exited Kodi and pressed ESC (also tried ALT+F3), the command line appears. Unfortunately, being security aware, my password is rather long and requires some time for typing. So during typing Kodi starts up again and the console disappears (which is expected with restart=always in the service file, I guess). Is it possible to

  • Make the command line permanent, not allowing Kodi to overlap it or
  • change the osmc user password within Kodi?

The background: I was playing around with installing a firewall (I know, it’s not supported…) and somehow I managed to lock myself out after a routine Vero reboot (must have something to do with making ip-tables permanent). So SSH or any other access via network is not possible.

Thanks,
Chris

I’ve solved this in my own, not so secure, way. Creating two “home made addons”.

Root-shell on TV

Password restore

Improvements could be made to both addons, like setting a reading friendly resolution in root-shell and change the password restore to restore or ask for a new password to be reset.

Anyway since you seem to have some Linux experience, take a look at these rather simple scripts, and modify them the way that you feel fits your setup. PR’s are welcome =)

1 Like

Thank you very very much for linking to your addons :slight_smile: This seems to be exactly what I was looking for. I will try them right away tomorrow…

Chris

I’ve been caught out by this. The proper answer is to modify mediacenter which shouldn’t be too difficult.

Yes, I agree, but in my case not possible since there is no access via SSH…

You can use a systemd local ‘drop-in’ and override the Restart parameter. This would be persistent across updates.

I’m suggesting it’s something we should do. If you are still stuck, you could boot from SD or USB with an image we are testing. Let us know if you want access to those.

I haven’t found the time to change the password using @joakim_s script, so yeah, still stuck. I’d like to try that. So you mean booting from SD/USB and modifying the mediacenter service file of the main installation?

I’ve sent you an invite to a testing thread. You can boot from that image, mount /dev/vero-nand/root and maybe sort out your firewall from there. Or as Sam says, edit out the restart from the mediacenter service file.

Edit: I just checked - we give you 30 seconds to type your username and password. If that’s not enough, change it in line 206 of /usr/bin/mediacenter.

Thank you very much @grahamh!

I was able to boot from the image and increased the time following your suggestion. This helped me logging in (cursing myself for the long password), correcting iptables and gaining access again. I wonder if it’s easy/feasable/worth considering to add an option to Kodi/My OSMC for disabling mediacenter restart.

Thanks again from a very happy OSMC user :slight_smile:

Glad you cracked it. I’ve had a look at stopping the timeout as soon as a username is typed, but the bash is defeating me and it’s not a problem we get very often tbh.

While the the USB image is named the same, it’s still another os. Configured differently, perhaps newer bins etc. So in my mind, writing an image to USB, boot on it in order to mount your “normal file system” in another OS and do the repair…

I might be crazy but I do think, booting a whole other OS to correct a “broken password” or to gain root access. Seems like overkill when you got a running Kodi in OSMC, and can download a few “allthough not SAFE for average Joe”-addons. Say you download to another computer. Chose to write to a usb-stick or put it on an accessible network share, and use Kodi filemanager to add a source and install the downloaded zip.

True I could put some work into those addons to be better/safer. But they have been my “emergency” rescue kit from time to time.

Anyway I’m glad everything is resolved for @zerog

Sorry, I didn’t mean your solution was not a ‘proper answer’ to solve the immediate problem. I meant we should be looking at modifying mediacenter permanently to make typing a long password possible.

And tbh I didn’t realise how simple your solution could be. I don’t spend a lot of time messing with addons.

Agreed, along with some other system management. But I’m “trying to put something together”, that probably needs some “polishing and refining”.

Yes, I agree, your addons are a solution way easier than booting from a “different” OS. I have reviewed your code and I do find it very useful. If I find some time I may contribute. I do have a pythonic background but wasn’t aware of addons being written in Python. Anyway, I changed the solution to your answer.

I do think so. When I was meddling with iptables, I haven’t thought about local access being a problem. I have no intend of starting a discussion on having no firewall configured, but following a “never trust anything/deny all, but…” policy such situation are quite common to me…

First, thanks for those warm words.

As you see in the addons, they are just a python wrappers for running some bash commands. I would love to do it more pythonic, but my python experience (or lack there of) is not worth mentioning. I usually read other peoples solutions and like a script-kiddie “copy & paste” multiple parts together to “make something” that works for me.

Any input is appreciated, be it PR’s, comments here on the forum or even a PM or two here. I really like other peoples input, since I often stare blindly on my “creations”.