Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Genkernel runs as root?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
awdas
n00b
n00b


Joined: 20 Dec 2016
Posts: 4

PostPosted: Tue Dec 20, 2016 2:28 am    Post subject: Genkernel runs as root? Reply with quote

Hello, I have a question concerning genkernel, does it run as root?

Is there any known way to build the kernel via portage? I'd love to use the sandbox it provides (and unprivileged user).
Back to top
View user's profile Send private message
The Doctor
Moderator
Moderator


Joined: 27 Jul 2010
Posts: 2546

PostPosted: Tue Dec 20, 2016 4:03 am    Post subject: Reply with quote

Yes, genkernel is designed to run as root. So does portage.

If you really want to build the kernel as a user you can do so. You will either have to download the sources yourself or chown the portage installed sources (at your own risk). There is no way for portage to build the kernel by itself because it has no way of knowing what features you want. Genkernel can't because it requires root privileges to install the kernel.
_________________
First things first, but not necessarily in that order.

Apologies if I take a while to respond. I'm currently working on the dematerialization circuit for my blue box.
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 6960
Location: Saint Amant, Acadiana

PostPosted: Tue Dec 20, 2016 4:26 am    Post subject: Reply with quote

Actually portage runs as portage, although initiated by root it drops the rights for fetching and building.
_________________
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6276

PostPosted: Tue Dec 20, 2016 7:47 am    Post subject: Reply with quote

The Doctor wrote:
build the kernel as a user [...] You will either have to download the sources yourself or chown the portage installed sources (at your own risk).

Neither is necessary: You just have to define an output directory which belongs to portage:portage and set KBUILD_OUTPUT to that directory. Set KERNEL_DIR to /usr/src/linux.
Then you can compile as portage. There is a kernel script (can be installed over portage from the mv overlay) which does this if the above variables are set up:
It must be called as root, but will drop permissions for compilation to "portage"; then it restores root permissions for installation and setting symlinks.
It is written to match my personal kernel management, but if you prefer a different one and write patches to the script which support both, I will gladly extend the script...
Back to top
View user's profile Send private message
awdas
n00b
n00b


Joined: 20 Dec 2016
Posts: 4

PostPosted: Tue Dec 20, 2016 11:35 pm    Post subject: Reply with quote

mv wrote:
The Doctor wrote:
build the kernel as a user [...] You will either have to download the sources yourself or chown the portage installed sources (at your own risk).

Neither is necessary: You just have to define an output directory which belongs to portage:portage and set KBUILD_OUTPUT to that directory. Set KERNEL_DIR to /usr/src/linux.
Then you can compile as portage. There is a kernel script (can be installed over portage from the mv overlay) which does this if the above variables are set up:
It must be called as root, but will drop permissions for compilation to "portage"; then it restores root permissions for installation and setting symlinks.
It is written to match my personal kernel management, but if you prefer a different one and write patches to the script which support both, I will gladly extend the script...


This is what I was looking for, thanks! I'll look at it, and might send some push request if I have time.

I also thought about making an ebuild for hardened-sources that calls portage's make functions with USE flags to determine the configuration mechanism (ex USE=menuconfig), I'll see if that feasible.
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6276

PostPosted: Wed Dec 21, 2016 12:19 am    Post subject: Reply with quote

awdas wrote:
I also thought about making an ebuild for hardened-sources that calls portage's make functions with USE flags to determine the configuration mechanism (ex USE=menuconfig), I'll see if that feasible.

I prefer a separate script, because reconfiguring/recompiling the kernel and installing the sources are two separate things and the latter does not always have to be repeated before the former. Also note that an interactive ebuild is usually always a bad idea. Yet another argument against it: A script is somewhat distribution independent (though the mentioned kernel scripts supports many gentoo-specific features [like using the portage user by default], these features are optional).
Back to top
View user's profile Send private message
awdas
n00b
n00b


Joined: 20 Dec 2016
Posts: 4

PostPosted: Wed Dec 21, 2016 1:32 am    Post subject: Reply with quote

mv wrote:
awdas wrote:
I also thought about making an ebuild for hardened-sources that calls portage's make functions with USE flags to determine the configuration mechanism (ex USE=menuconfig), I'll see if that feasible.

I prefer a separate script, because reconfiguring/recompiling the kernel and installing the sources are two separate things and the latter does not always have to be repeated before the former. Also note that an interactive ebuild is usually always a bad idea. Yet another argument against it: A script is somewhat distribution independent (though the mentioned kernel scripts supports many gentoo-specific features [like using the portage user by default], these features are optional).


Hmm, I think you're right, portage doesn't even seem to support interactive ebuild.
I don't know if it's a bug, but it won't redirect your input to the config utilities, probably because of a combination of sandbox + chroot?.

Although a script is fun because it's distribution independent, a full integration of the kernel building and initramfs building into portage would be awesome.
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1717

PostPosted: Wed Dec 21, 2016 9:08 pm    Post subject: Reply with quote

Quote:
portage doesn't even seem to support interactive ebuild.

It does.
I recall there are some ebuilds for games that require you to copy data files into some specific location. You could probably use it to let the user know it's time for menuconfig (or set USE=savedconfig and try building new kernel with config stored in /etc - non-interactively)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum