Re: accidentally changed the owner of sudo

David Ledger <[email protected]>
Newsgroups gmane.comp.tools.sudo.user
Message-ID <[email protected]>
On 1 Sep 2017, at 20:11, Galen Johnson wrote:

> "chown -R <user> /" is _almost_ as bad as 'rm -rf /'.  This happened to me once due to  an unguarded condition in a script.  A restore was the only option.  Of course, if you have a similar system and root, you could always compare ownerships and fix it.  Either way, you're in for a long day.
> 
> =G=
> 
> ________________________________________
> From: sudo-users <[email protected]> on behalf of Shawn McMahon <[email protected]>

This is one of the few cases where "Restore Permissions" would be useful. If you have another Mac that this could be mounted on, copying permissions across could be scripted. I'd do (as a broad outline) :

	find (on the bad volume) | A loop reading the filename {
		if same dir/file doesn't exist on master, log it and continue
		extract owner, group and permissions from an ls -l of the good objct
		apply it to the bad object
	}
	Manually check the log and fix. Much will be achieved with wildcards once you get here.




> EXTERNAL
> 
> The "chown" command you typed cannot have changed file permissions, but
> would (if left uninterrupted) have changed file ownership throughout the
> system. The error you received suggests file permissions changed, and the
> "ll" output shows permissions wrong but ownership correct (possibly,
> depending on distribution). Therefore, more has happened here than you've
> provided.

Changing the owner (or group) of a file usually unsets any SUID (or SGID) bit.

David


> You'll have to be root to fix the sudo permissions, either by using "su" to
> become root (requires the root password), logging directly into the system
> as root (requires the root password), or booting into single user mode.
> However, depending on how long you let that "chown -R" run, and what other
> commands you ran that you've left out, it may be the least of your
> problems. Restoring a backup may be necessary.
> 
> 
> On Thu, Aug 31, 2017 at 10:46 AM, Tingyu Lu <[email protected]> wrote:
> 
>> Hello,
>> I accidentally typed " *sudo chown -R <MyUserName> /*"
>> when I type "*ls -l*", I got:
>> 
>> total 80
>> drwxrwxr-x  6 heat heat 4096 2017-08-15 16:16 build
>> drwxr-xr-x  2 heat heat 4096 2017-04-12 15:36 Desktop
>> drwxr-xr-x  2 heat heat 4096 2017-04-12 15:36 Documents
>> drwxr-xr-x  3 heat heat 4096 2017-05-18 23:44 Downloads
>> drwxrwxr-x  3 heat heat 4096 2017-04-21 01:03 espresso
>> -rw-r--r--  1 heat heat  179 2017-04-12 15:33 examples.desktop
>> drwxrwxr-x  2 heat heat 4096 2017-06-07 02:50 jhe17
>> drwxrwxr-x  2 heat heat 4096 2017-05-16 11:44 jliu38
>> drwxrwxr-x  3 heat heat 4096 2017-05-30 17:26 kkim15
>> drwxrwxr-x  5 heat heat 4096 2017-04-21 00:05 lammps
>> drwxrwxr-x  3 heat heat 4096 2017-08-31 10:50 lammps11-Aug2017
>> drwxrwxr-x  3 heat heat 4096 2017-08-28 20:52 lammps_cpu
>> drwxr-xr-x  2 heat heat 4096 2017-04-12 15:36 Music
>> drwxr-xr-x  2 heat heat 4096 2017-04-12 15:36 Pictures
>> drwxr-xr-x  2 heat heat 4096 2017-04-12 15:36 Public
>> *-rw-rw-r--  1 heat heat   38 2017-04-25 15:22 sudo*
>> drwxr-xr-x  2 heat heat 4096 2017-04-12 15:36 Templates
>> drwxrwxr-x 13 heat heat 4096 2017-08-28 20:40 tlu3
>> drwxr-xr-x  2 heat heat 4096 2017-04-12 15:36 Videos
>> drwxrwxr-x  2 heat heat 4096 2017-04-21 11:49 wzhang42
>> 
>> Here, "heat" is my username.
>> 
>> When I type *"ll /usr/bin/sudo"*, I got* "-rwxr-xr-x 2 root root 168768
>> 2013-02-27 15:54 /usr/bin/sudo*"*
>> 
>> When I type "*sudo*", I got *"sudo: must be setuid root"*
>> 
>> *Could you please kindly help me with the problem?*
>> 
>> Thanks,
>> Tingyu
>> 
>> --
>> Best Regards,
>> Tingyu Lu
>> Mechanical and Aerospace Engineering
>> 911 Oval Dr. - 3404 EBIII
>> North Carolina State University
>> Raleigh, NC 27695
>> ____________________________________________________________
>> sudo-users mailing list <[email protected]>
>> For list information, options, or to unsubscribe, visit:
>> https://www.sudo.ws/mailman/listinfo/sudo-users
>> 
> ____________________________________________________________
> sudo-users mailing list <[email protected]>
> For list information, options, or to unsubscribe, visit:
> https://www.sudo.ws/mailman/listinfo/sudo-users
> ____________________________________________________________
> sudo-users mailing list <[email protected]>
> For list information, options, or to unsubscribe, visit:
> https://www.sudo.ws/mailman/listinfo/sudo-users

____________________________________________________________
sudo-users mailing list <[email protected]>
For list information, options, or to unsubscribe, visit:
https://www.sudo.ws/mailman/listinfo/sudo-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.