AppImageUpdate icon indicating copy to clipboard operation
AppImageUpdate copied to clipboard

When run with sudo ... the resulting AppImage has root as its owner

Open probonopd opened this issue 7 years ago • 13 comments

When AppImageUpdate is run with sudo (as I need to do in order to update things in /isodevice (the device Ubuntu mounts the medium on which the Live ISO resides to), then the resulting "new" AppImage has root as its owner, which is not what we want.

Hence, we should run sudo -R $USER $New.AppImage at the end.

probonopd avatar Jan 05 '19 22:01 probonopd

$USER == root if sudo is used.

TheAssassin avatar Jan 06 '19 00:01 TheAssassin

No:

me@host:~$ sudo echo $USER
me

probonopd avatar Jan 06 '19 00:01 probonopd

Try on Debian, and you'll see what I mean.

TheAssassin avatar Jan 06 '19 01:01 TheAssassin

I have tried on Ubuntu. Here sudo chown $USER $New.AppImage would help and on Debian it would not make things worse. So let's just do it

probonopd avatar Jan 06 '19 03:01 probonopd

Please research a bit more on the topic. IIRC there's a variable sudo exports that shows the original user. But this seems quite implicit...

Did you mean to write chown -R ...? (That -R is by the way not necessary)

TheAssassin avatar Jan 06 '19 17:01 TheAssassin

Sure, I meant sudo chown "${USER}" ..., corrected above.

probonopd avatar Jan 06 '19 19:01 probonopd

Shouldn't we just add a flag to copy the old owner and their permissions? Like -p or so? Changing owner would only work properly when you call it with sudo, and it's less implicit than using $SUDO_USER.

Or maybe we should just do that by default? Not a fan, but perhaps this is desirable for some people.

TheAssassin avatar Sep 14 '19 22:09 TheAssassin

Copy the old owner and their permissions Or maybe we should just do that by default?

Yes, absolutely. Copy over owner and permissions from the old to the new file.

probonopd avatar Sep 15 '19 07:09 probonopd

But only if a flag is passed, at least for zsync2, for AppImageUpdate I'd consider adding a pre-checked checkbox to create an opt-out.

TheAssassin avatar Sep 15 '19 13:09 TheAssassin

Yes :+1:

probonopd avatar Sep 15 '19 14:09 probonopd

@TheAssassin $USER == root if sudo is used.

@probonopd No:

me@host:~$ sudo echo $USER
me

Variable substitution is performed by the shell (which is not root) before arguments are passed to the sudo command. Try this instead:

me@host:~$ sudo bash -c 'echo $USER'
root

shoogle avatar Nov 09 '19 18:11 shoogle

Note the ' single quotes, which escape the contents.

TheAssassin avatar Nov 09 '19 18:11 TheAssassin

Indeed, it would not work with " double quotes. (It would return "me" instead of "root".)

shoogle avatar Nov 09 '19 21:11 shoogle