Skip to content

Instantly share code, notes, and snippets.

@CoolElectronics
Last active April 29, 2024 14:50
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save CoolElectronics/a5088c9ade6ec4d35435b9826b45d7a3 to your computer and use it in GitHub Desktop.
Save CoolElectronics/a5088c9ade6ec4d35435b9826b45d7a3 to your computer and use it in GitHub Desktop.
Re-Enable sudo from crosh on R117+ Chrome OS without recompiling

Short guide on how to bypass this:

image

If you haven't disabled rootfs verification, switch to vt-2 and run /usr/libexec/debugd/helpers/dev_features_rootfs_verification. Then reboot.

Inside crostini, download minioverride.c and compile it with gcc minioverride.c -o minioverride.so -shared (make sure gcc is installed)

In the files app, move minioverride.so into your downloads folder.

Switch to vt2, and in the root terminal, not crostini, run these commands

mkdir -p /usr/local/bin
mv /home/chronos/user/Downloads/minioverride.so /usr/local/bin/
chmod +x /usr/local/bin/minioverride.so
sed -i '1s/^/env LD_PRELOAD=\/usr\/local\/bin\/minioverride.so\n/' /etc/init/ui.conf 
reboot

After rebooting you should be able to use sudo inside crosh as you would normally before updating to 117. It will display the warning, but sudo should work regardless.

NOTE: When you update chrome os versions, this will stop working. You don't need to redo the whole thing, just run /usr/libexec/debugd/helpers/dev_features_rootfs_verification, reboot and run sed -i '1s/^/env LD_PRELOAD=\/usr\/local\/bin\/minioverride.so\n/' /etc/init/ui.conf and reboot again.

1/29 - added fix for landlock policy (fixes permission denied writing to disk) restart the entire process with the updated c code if you want to fix it

int minijail_no_new_privs(){
return 0;
}
int minijail_add_fs_restriction_rx(){
return 0;
}
int minijail_add_fs_restriction_advanced_rw(){
return 0;
}
int minijail_set_enable_profile_fs_restrictions(){
return 0;
}
int minijail_enable_default_fs_restrictions(){
return 0;
}
@Gorvetco
Copy link

Gorvetco commented Nov 20, 2023

Awesome!!

Thank you so much.

Now I'm able to use the terminal as root once again while maintaining the ever so important contents of my screen without switching the entire screen back and forth. (Yay! from all the lazy ppl 🙃)

But more importantly, being able to conveniently utilize the copy and paste (ctl+c & ctl+v) shortcut makes this guy (Points Thumbs At Self) a very happy Chromebook user, indeed.

Thanks again my friend!

If no one told you yet today... Your doing a great job, you beautiful person you! 😁

@eritain
Copy link

eritain commented Dec 2, 2023

Can you confirm that you're talking about Crostini, not Crouton here?

I was planning on getting rid of this problem by finally making the switch from Crouton to Crostini, but if that still means I have to go through spooky gyrations ... ugh.

@CoolElectronics
Copy link
Author

@eritain i am talking about crostini, but if you know how to move around the files you can do the compile step in crouton or another linux pc. the instructions are just written for crostini to make it simpler

@eritain
Copy link

eritain commented Dec 3, 2023

Thanks very much!

I'll probably end up switching to Crostini regardless, but it'll be nice to prepare for the transition from a competent crosh window.

@philippesic
Copy link

philippesic commented Dec 12, 2023

After using a sudo in crosh command following these steps, sudo asks for a password, but it doesn't seem to be the root pass or the user pass?

Anyone know what to do?
IMG_4837

@philippesic
Copy link

After using a sudo in crosh command following these steps, sudo asks for a password, but it doesn't seem to be the root pass or the user pass?

Anyone know what to do? IMG_4837

I powerwashed my machine and relogged as root without debug tools. Works like a charm!

@CoolElectronics
Copy link
Author

in vt-2, yes

@therealSpamton-G-Spamton
Copy link

therealSpamton-G-Spamton commented Dec 13, 2023

In crostinni it says cc1: fatal error: minioverride.c: No such file or directory
compilation terminated.
but i downloaded minioverride.c

@CoolElectronics
Copy link
Author

you have to put the minioverride.c file you made in the same directory where you're running the gcc command, the home directory of crostini

@FergooseWC
Copy link

How do you copy the sed module over to vt2, my chromebook doesn't have a backwards slash and just comes up with a question mark, then the command doesn't run properly.

@marcsadler
Copy link

I think this workaround breaks on the latest 120 update. The desktop interface doesn't get loaded and the screen hangs on the startup logo. Commenting out the override in /etc/init/ui.conf does make the desktop interface work again. I'll do some more testing by rolling back to 119, but I think we've come to the end of the road.

@CoolElectronics
Copy link
Author

@marcsadler these same steps still work on version 120.0.6099.203 for me. perhaps you typed in the last command wrong?

@marcsadler
Copy link

@marcsadler these same steps still work on version 120.0.6099.203 for me. perhaps you typed in the last command wrong?

Thank you for your reply. I'm on 120.0.6099.235, although like you said I must have done one of the steps wrong because it works again now after reinstalling ChromeOS from recovery. Sorry to have wasted your time.

@CoolElectronics
Copy link
Author

CoolElectronics commented Jan 29, 2024

1/29 - added fix for landlock policy (fixes permission denied writing to disk)
restart the entire process with the updated c code if you want to fix it

@da-moon
Copy link

da-moon commented Feb 15, 2024

You are a lifesaver. Thank you so much

@supechicken
Copy link

supechicken commented Mar 6, 2024

Interesting approach using the LD_PRELOAD hack, it is way smarter than my current workaround on this (disable Landlock LSM with kernel parameter + redirect sudo calls to VT2)

@DennisLfromGA
Copy link

DennisLfromGA commented Mar 8, 2024

It's interesting that I'm no longer getting the 'Sudo commands will not succeed by default.' message on beta channel 15753.36.0 / 122.0.6261.98 when entering 'shell' now. 🤔

Screenshot 2024-03-08 11 32 45 AM

@CoolElectronics
Copy link
Author

CoolElectronics commented Mar 8, 2024

yeah saw this too, change was made here
wonder why that wasn't there from the beginning

@DennisLfromGA
Copy link

@CoolElectronics,

I don't understand the code enough to know but is the 'no-new-privs warning' still shown on those without the 'minioverride' bypass?

@CoolElectronics
Copy link
Author

@DennisLfromGA
Copy link

Ah, got it, makes sense now.
I guess that's one way to know if the minioverride bypass is working or not.

@Arfonium
Copy link

@DennisLfromGA
Copy link

@Arfonium,

That's the first step listed in the instructions above.

DennyL

@YeesterPlus
Copy link

you can also do chromebrew and uninstall crew-sudo!

@DennisLfromGA
Copy link

@YeesterPlus,

I think you mean you can also use chromebrew and install crew-sudo!
However with crew-sudo v1.1 you don't need chromebrew.

~DennyL

@DragonFire1024
Copy link

of you can't compile minioverride.so, you can just download it from here. Tested and works on my Dell Chromebook 5190.

@ianhill00
Copy link

1/29 - added fix for landlock policy (fixes permission denied writing to disk) restart the entire process with the updated c code if you want to fix

Thank you very much for this, I have been pulling my hair out (what's left) trying to get use to VT2.
If a future update stops this from working, is there a way to stop VT2 scrolling or pause when using certain commands.
Once again, thank you so much

@YeesterPlus
Copy link

no, no crew-sudo, it has issues, instead use this allower

@NipunEranda
Copy link

You are a lifesaver. Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment