You are not logged in.

#1 2018-01-08 03:39:29

theonlylawislove
Member
Registered: 2015-01-05
Posts: 38

makepkg support for running as root.

I get why it was disabled. You don't want random PKGBUILDs to run on your machine and cause havoc.

However, this leaves me in a weird place when installing Arch via scripts.

Everything is run as root. Only after the machine is finally booted, will the end user add a normal non-root user.

The base image contains some AUR packages.

As it stands, I have to create a temporary user, su to run makepkg, and when install script it completed, delete the temporary user. I don't like doing that. So ugly, that during install, I patch the makepkg script to remove the requirement for root (https://github.com/pauldotknopf/darch-i … epkg.patch).

What do you guys think about having an environment variable that can override the root check, and if running as root, output a "WARNING" text?

Otherwise, I have to create a temporary user, or patch the makepkg script.

Offline

#2 2018-01-08 03:56:17

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: makepkg support for running as root.

Run makepkg as the user "nobody".


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#3 2018-01-08 04:42:40

theonlylawislove
Member
Registered: 2015-01-05
Posts: 38

Re: makepkg support for running as root.

Good idea.

This brings up another issue though.

Let's say I have manually ran makepkg for trizen, to install other packages from the aur.

trizen will prompt for sudo password when doing the installation, allowing you to run the command as a normal user.

For this two work, I need to run trizen as "nobody", but then it will attempt to access sudo. This is a scripted install, so I would have to give sudo access to nobody with nopasswd to work seamlessly with trizen. Giving a user "nobody" sudo access def not a good idea, so there doesn't seem to be a clean way to work with trizen.

So, for me to work with trizen (or any AUR helper), I'd have to do something like:

su nobody -c "trizen -S  some-package --noinstall"
cd /.cache/trizen/some-package && makepkg -i

I'd have to be aware of the dependencies that "some-package" needs from AUR, and be sure to also makepkg -i them as well.

I suppose this method is better than patching makepkg to support root.

Last edited by theonlylawislove (2018-01-08 04:43:26)

Offline

#4 2018-01-08 04:54:23

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: makepkg support for running as root.

pacman -U *.pkg.tar.*


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#5 2018-01-08 05:34:36

theonlylawislove
Member
Registered: 2015-01-05
Posts: 38

Re: makepkg support for running as root.

That doesn't take care of dependency order though, correct?

Offline

#6 2018-01-08 07:18:24

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: makepkg support for running as root.

theonlylawislove wrote:

What do you guys think about having an environment variable that can override the root check, and if running as root, output a "WARNING" text?

Otherwise, I have to create a temporary user, or patch the makepkg script.

Right, we *used* to have that and it was called --asroot. wink

...

If you are doing a scripted install, I see no reason why you should be afraid of giving the "nobody" user access to pacman via NOPASSWD.

Of course, you could also use our official makechrootpkg tool for building packages in a clean chroot, which automates all of this and comes with wrapper flags for e.g. installing dependency packages into the chroot.

aurutils is an AUR helper with seamless native understanding of makechrootpkg.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#7 2018-01-08 07:19:30

ayekat
Member
Registered: 2011-01-17
Posts: 1,591

Re: makepkg support for running as root.

pacman takes care of dependency order when installing packages.

But if it can't find the required packages in any repository, it will fail, yes. It is up to you to build and install the missing packages beforehand in such a case (tip: use --asdeps, to keep things sane).

--edit: oops, ninja'd

Last edited by ayekat (2018-01-08 07:19:45)


pkgshackscfgblag

Offline

#8 2018-01-08 10:29:04

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: makepkg support for running as root.

You could create a custom repo with all of the AUR packages you want to install.


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#9 2019-01-16 16:07:43

es20490446e
Banned
Registered: 2017-12-29
Posts: 46
Website

Re: makepkg support for running as root.

makepkg could automatically detect if it's being run as superuser, and if that was the case spawn a new instance as a non privileged user. Then do its operation.

This way running makepkg or its dependent tools would work safely independently if they are run as root or not. This would save a lot of pain when using these commands along with more complex operations, like scripts or pipes.

Offline

#10 2019-01-16 16:21:20

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: makepkg support for running as root.

es20490446e wrote:

makepkg could automatically detect if it's being run as superuser, and if that was the case spawn a new instance as a non privileged user. Then do its operation.

Which user that may or may not exist on any of the various Linux distributions that pacman supports?

How do we know which user has write permissions for the working directory and/or SRCDEST, PKGDEST, BUILDDIR, etc?

This way running makepkg or its dependent tools would work safely independently if they are run as root or not. This would save a lot of pain when using these commands along with more complex operations, like scripts or pipes.

How exactly is this superior to just using `runuser -u $nonprivilegeduser makepkg` within the script or pipe you're referring to, which is something you can actually control? Why does this trivial-yet-site-specific functionality need to be in makepkg? How would you reliably set SRCDIR, PKGDEST, BUILDDIR, etc. such that the site-specific user has site-specific directories it can write to?

How do you handle -s and -r if makepkg is re-executing as the common "nobody" user that has no permissions, including the lack of permissions represented by sudo?

Because guess what -- I'm fairly sure none of this is ever going to be in makepkg. It is extraordinarily easy to do properly in your script, and much, much, much harder to do in makepkg itself for something that we explicitly refused to support in the first place.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#11 2019-01-16 23:40:43

bluetechgirl
Member
Registered: 2019-01-14
Posts: 18

Re: makepkg support for running as root.

During the install why can't you just make your main user (the one you plan on actually using) and using that account for the build. You do not have to wait until after the install to add it. I do that when installing aur packages during the install. For example after I make my user and installed and set up sudo:

sudo -u [my username] makepkg -si
theonlylawislove wrote:

However, this leaves me in a weird place when installing Arch via scripts.

This is unsupported and not recommended. If this is your own script that you wrote, there is no reason you cannot modify it to add your main user during the install versus after. If this isn't your script I would suggest you stop using it.

Offline

#12 2019-01-16 23:52:13

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,904
Website

Re: makepkg support for running as root.

Please don't necrobump, es20490446e.

Closing.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

Board footer

Powered by FluxBB