dnschneid / crouton

Chromium OS Universal Chroot Environment
https://goo.gl/fd3zc?si=1
BSD 3-Clause "New" or "Revised" License
8.57k stars 1.24k forks source link

Crosh to/from Chroot(s) with a mouse click ? #708

Closed DennisLfromGA closed 9 years ago

DennisLfromGA commented 10 years ago

This question was originally posted in the Google+ 'Crouton Users' community by Amith F. and I'm simply posting it here for more visibility - and hopefully some input.

Is there a way to toggle XFCE and ChromeOs with just a mouseclick? (for instance by clicking on a button). 

divx118 commented 10 years ago

IMHO it sounds to me that if that was possible you should have a security issue on chromeos. The command would need to run as root as it is now.

DennisLfromGA commented 10 years ago

I think this kind of falls into the same category as the new Multi-profile feature - once you're in, you're in...

divx118 commented 10 years ago

Hmm, no there shouldn't be a way now when I am in chromeos, to run a root command accept from opening a cross window myself and go to the shell. That is what I like about chromeos. Running a command as root shouldn't be possible from some kind of chrome app. This doesn't mean there is no way, maybe a background app that adds an overlay button to chromeos. However that would still mean you need to start it manually on a reboot from the commandline. So "once you're in, you're in..." is not correct in my opinion.

dnschneid commented 10 years ago

Well, if you've already started the chroot and it's running in the background, switching between the two doesn't require root. This is actually what I implemented on the extensioncycle branch, but it's waiting for smartcycle to get merged. Basically, the crouton extension lists the running chroots and you can switch to them with a mouse click.

DennisLfromGA commented 10 years ago

I've been using the 'smartcycle' branch on my new chroots of late because I like it so much. I haven't tried the 'extensioncycle' branch, frankly, because I was unclear of it's purpose. You've piqued my curiosity now though with the description of switching with a mouse click, I'll try it next...

I'm testing @drinkcat's 'separate_partition' branch right now and it's awesome! No fear of powerwashes anymore... :)

dnschneid commented 10 years ago

Rebased that branch.

DennisLfromGA commented 10 years ago

Thank you.

divx118 commented 10 years ago

@dnschneid Nice. I assumed you also needed root to switch between screens, because if I use chvt on the command line I need to run it as root to let it work.

DennisLfromGA commented 10 years ago

It looks like in my chroots the setuid permission is set on 'chvt' - -rwsr-xr-x 1 root root 5516 Apr 29 2012 /var/crouton/chroots/wheezy-cb/bin/chvt but not in crosh - -rwxr-xr-x 1 root root 11K Mar 12 00:29 /usr/sbin/chvt*

drinkcat commented 10 years ago

Nice. I assumed you also needed root to switch between screens, because if I use chvt on the command line I need to run it as root to let it work.

The trick here is that the extension asks the websocket server (running in the chroot) to switch VT. And as Dennis pointed out, chvt is SUID inside the chroot.

divx118 commented 10 years ago

@drinkcat thanks for the explanation.

fbreitwieser commented 10 years ago

It's naturally no complete solution, but I'm quite happy with it. I start the following script in a ssh/crosh chrooted shell, and when i want to switch to the XFCE session, I go to the window using Alt-tab or the mouse, and press any key.

#!/usr/bin/perl

use strict;
use warnings;
use Term::ReadKey;
ReadMode 3;

print "

  █╗  ██╗███████╗ ██████╗███████╗
  ╚██╗██╔╝██╔════╝██╔════╝██╔════╝
   ╚███╔╝ █████╗  ██║     █████╗  
   ██╔██╗ ██╔══╝  ██║     ██╔══╝  
  ██╔╝ ██╗██║     ╚██████╗███████╗
  ╚═╝  ╚═╝╚═╝      ╚═════╝╚══════╝

### Press any key to switch to XFCE ";
while (my $char = getc()) {
  `croutoncycle next`;
}
dnschneid commented 9 years ago

This now exists alongside the xiwi stuff.