Admin mode is not working/buggy [FIXED]

Questions, glitches, bugs and crashes
Locked
JayB
Posts: 192
Joined: Sun Jan 08, 2017 4:38 pm

Admin mode is not working/buggy [FIXED]

Post by JayB » Sun Jan 29, 2017 7:54 pm

There seems to be a problem with admin mode. I'm not able to delete root privileged files/folders, even though SIP is disabled. Just tried to do it on a service bundle in /Library/Services, but I always got an error message. NC tells me that it can't delete the .service bundle, because the folder isn't empty, which is weird, because I can delete folders, bundles etc. without problems in the $HOME space, i.e. recursing is fine. (Tried CMD-BACKSPACE, "move to trash", delete permanently etc., and yes, I tried reloading the directory and navigating out and back in.) So I believe it's a problem with admin mode. I ran my own Services script (sudo rm -rf) on the bundle, and everything worked fine, just not with the native NC functions.

Question: might the reason be that I need to open a completely new tab for admin mode to work in a directory that's already open?

Another (possible) bug I noticed a couple of weeks ago, is that Admin Mode is disabled after some time, which is a good thing (!), but the menu item Nimble Commander > Disable Admin Mode doesn't change back to "Enable Admin Mode". (At least that's what I noticed.)

User avatar
mike
Posts: 1060
Joined: Thu Jul 16, 2015 5:35 am
Location: Exeter, UK

Re: Admin mode is not working/buggy

Post by mike » Mon Jan 30, 2017 4:08 am

JayB,
I've just checked deleting of items owned by root via Admin Mode, and it works.
(haven't tested removing of system components though, can't see a point of doing it)
JayB wrote:
Sun Jan 29, 2017 7:54 pm
NC tells me that it can't delete the .service bundle, because the folder isn't empty, which is weird
Well..
This might happen if you've asked to NC to move folder to trash (*) and after a failure have tried to remove the entry completely(**).
(* which is basically a syscall for single entry, and it can't be routed into root-level service since I can't imagine what ~/Trash/ would mean for root user, so it is executed with current user's rights)
(** at this moment there's no re-scanning and recursive deleting of entries inside a directory after choosing to delete instead of moving to trash )
I can simply disable moving to trash when Admin Mode is toggled, this might solve an issue.
JayB wrote:
Sun Jan 29, 2017 7:54 pm
Question: might the reason be that I need to open a completely new tab for admin mode to work in a directory that's already open?
Nope, Admin Mode is application-wide, there're no relations with tabs nor windows.
JayB wrote:
Sun Jan 29, 2017 7:54 pm
Another (possible) bug I noticed a couple of weeks ago, is that Admin Mode is disabled after some time, which is a good thing (!), but the menu item Nimble Commander > Disable Admin Mode doesn't change back to "Enable Admin Mode". (At least that's what I noticed.)
This is quite odd, as there's no automatic disabling on Admin Mode.

JayB
Posts: 192
Joined: Sun Jan 08, 2017 4:38 pm

Re: Admin mode is not working/buggy

Post by JayB » Mon Jan 30, 2017 12:24 pm

mike wrote:
Mon Jan 30, 2017 4:08 am
This might happen if you've asked to NC to move folder to trash (*) and after a failure have tried to remove the entry completely(**).
(* which is basically a syscall for single entry, and it can't be routed into root-level service since I can't imagine what ~/Trash/ would mean for root user, so it is executed with current user's rights)
(** at this moment there's no re-scanning and recursive deleting of entries inside a directory after choosing to delete instead of moving to trash )
I can simply disable moving to trash when Admin Mode is toggled, this might solve an issue.
This was probably the reason. I recreacted the situation, and going directly for "delete permanently" instead of "move to trash" or hitting CMD-BACKSPACE was successful. BTW: I was not deleting system files, which you're right one shouldn't do, unless you've hacked a replacement copy, but a third-party .service that the developer wants to have installed in the Services directory of the global library, not the user library. So there are situations when users do need to delete files from the global or even the system library. (For example, a couple of weeks ago I hacked a macOS GPU kext in /System/Library/Extensions to alter some frame rate values etc.; while I may not be a "standard" macOS user, there are people like me around, who like to fumble with things. ;) )

"Move to trash" with root privileges could in principle move a file or folder to /private/var/root/.Trash … not in Finder, though… there it goes into the .Trash of the logged user, which is the standard user like admin. You'd have to switch into the actual root account (move on console), but that only works if you have that root user account enabled. (Most people don't even know it exists.) Then the Finder would surely put it in /private/var/root/.Trash. I don't know what would happen in NC, if the admin hasn't activated the root user account. Standard behavior should be that a file should be moved into the trash of the logged user. So if a staff group user like admin elevates himself to root, but stays logged in as admin, then all root-privileged files should be moved to the .Trash directory of the user, not into /private/var/root/.Trash, for one thing because that directory (i.e. that root userspace) might not even exist, because it was never enabled.

So a good solution might be to leave "Move to Trash" even in admin mode, but always move the files/folders to the .Trash folder of the logged-in user, and completely ignore /private/var/root/.Trash, unless the logged-in user is actually root. The latter would mean that if I actually log in as root, not as admin, and then start Nimble Commander, "Move to Trash" should put files in /private/var/root/.Trash
JayB wrote:
Sun Jan 29, 2017 7:54 pm
Another (possible) bug I noticed a couple of weeks ago, is that Admin Mode is disabled after some time, which is a good thing (!), but the menu item Nimble Commander > Disable Admin Mode doesn't change back to "Enable Admin Mode". (At least that's what I noticed.)
This is quite odd, as there's no automatic disabling on Admin Mode.
Weird. Then it must be something that I did, and I didn't realize it. I'll try to recreate it, but I can't promise.

Come to think of it, wouldn't it be a security enhancement to add a timeout to the admin mode in Nimble Commander, similar to the timeout of sudo in the shell? You could even have a user setting in Preferences to set the time out: 15, 30, 45 minutes, 1/2/3/4 hours, and "forever" (i.e. until Quit).

User avatar
mike
Posts: 1060
Joined: Thu Jul 16, 2015 5:35 am
Location: Exeter, UK

Re: Admin mode is not working/buggy

Post by mike » Sat Jul 08, 2017 3:09 am

Some additions regarding an items deletion under Admin Mode:
Now the Delete operation can re-scan directories after being asked to "Delete Permanently" while doing a "Move to Trash".

Locked