pacstall / pacstall

An AUR-inspired package manager for Ubuntu
https://pacstall.dev
GNU General Public License v3.0
1.28k stars 45 forks source link

`removescipt`, `postinst` need to be run as root #73

Closed wizard-28 closed 3 years ago

wizard-28 commented 3 years ago

Describe the bug Title

To Reproduce

  1. Remove a pacscript with the removescript function
  2. See error

Expected behavior No errors

Screenshots img

Desktop (please complete the following information):

Additional context None

Elsie19 commented 3 years ago

removescript and postinst should have sudo in the functions itself, the function doesn't need to be run with root, just the commands inside. Just like manually putting in the commands

wizard-28 commented 3 years ago

As a sidenote, in 1.5, we ARE moving every command to a separate file, no writing the commands in the main script /bin/pacstall, as this creates lot of issues, like the onces faced in this issue (If the remove command was a separate file, a simple sudo /usr/share/pacstall/scripts/removescript.sh would work)

Elsie19 commented 3 years ago

it would be in /usr/share/pacstall/scripts/remove.sh instead

wizard-28 commented 3 years ago

removescript and postinst should have sudo in the functions itself, the function doesn't need to be run with root, just the commands inside. Just like manually putting in the commands

Give a reason, why most of the stuff that people do in removescript requires root, so it makes sense to run it with root instead of doing sudo for every command

Elsie19 commented 3 years ago

Because that's how it would manually be done

Elsie19 commented 3 years ago

you don't run sudo su then run post install commands

wizard-28 commented 3 years ago

But it adds redundancy, doing sudo for every command.

I think we should should deviate from the manual way, and have root privileges in the removescript, and postinst.

Plus the syntax would be more closer to the AUR PKGBUILD syntax, so it will be easier for people to port the packages

wizard-28 commented 3 years ago

Plus then after #72 was merged, every pacscript using removescript is actually broken

Except if people run sudo pacstall -R pkg, but that is against the whole idea of #72

Elsie19 commented 3 years ago

You can't run functions with sudo:

function1() {
echo "$USER"
}
henry@twilight ~ % ››› function1
henry
henry@twilight ~ % ››› sudo function1
[sudo] password for henry:
sudo: function1: command not found
henry@twilight ~ % ›››
wizard-28 commented 3 years ago

I know, thats why I proposed it to be in a separate file

wizard-28 commented 3 years ago

So we can sudo it

wizard-28 commented 3 years ago

Or leave, now that I think about it giving granular permission control to the maintainer is a better idea