It could but it's more code to write and maintain, and it needs to be justified.E001754 wrote:Could --depclean become smarter and don't flag for remove the currently used kernel sources ?
Technically it's the correct thing: as genstorm said, you don't need the package installed on your system for anything (it's just been pulled in as part of world.) Each version has its own SLOT, and in portage's eyes, you only need the latest one to satisfy the world dep on whichever source package you went for (so if you did: emerge gentoo-sources, the package is in world, not every SLOT.)Or is there some weird reason for not doing that default on --depclean?
Not sure if it'll get you anywhere: I had the same discussion years ago, and ended up putting the functionality into update -C.* So it protects the running kernel, and the /usr/src/linux linked package if that's not the same: if you have symlink USE flag (iirc it's default, but I turned it off years ago because of this issue), then when you upgrade it updates the link automatically. This can be a pita if you later compile something against the kernel, as it won't be the one you're actually using.Where else shall I post this feature request so that some dev can hear at that?

Code: Select all
emerge --noreplace =gentoo-sources-3.2.1-gentoo-r2Code: Select all
emerge --deselect =gentoo-sources-3.2.1-gentoo-r2
This is one good trick.John R. Graham wrote:I wouldn't object to --depclean being smarter, but there is a simple, effective workaround. You know when you build and test a new kernel. As part of that process, always add it to the world set. For example, in your case:When you're finally done with that kernel (you'll unambiguously know this, too):Code: Select all
emerge --noreplace =gentoo-sources-3.2.1-gentoo-r2I agree with steveL on the symlink USE flag: turn it off.Code: Select all
emerge --deselect =gentoo-sources-3.2.1-gentoo-r2
- John
Yes. Portage will only erase the files it created itself. The products of kernel compilations were not created by portage, nor the files under /boot or /lib/modules (they were created by *you*, using genkernel, make fooo or whatever else). The .config files won't be touched either, which is a very good thing.John R. Graham wrote:Actually, that turns out not to be the case. Emerge will remove any unmodified file that it installed. That means that a --depclean will remove all of the kernel source but none of the work products. All of the build cruft (principally .o files) will be left but the kernel source will be gone. It is true that the installed kernel binaries (in /boot and /lib/modules) will not be touched.
- John
I use gentoo-sources, but I always chown /usr/src/linux to my user before compiling.i92guboj wrote:What I particularly do is to add gentoo-sources to package.provided, then download the latest stable from kernel.org to my home directory, where I can build the kernel without being root (still don't know why would I need to be root just to compile a kernel...).

wouldn't it be a serous security problem if a user could modify the kernel config/compile the kernel? It seems to me that a single user with hostile intent could add a patch or otherwise tamper with the kernel source much more easily than if the kernel source is owned by root.i92guboj wrote:... where I can build the kernel without being root (still don't know why would I need to be root just to compile a kernel...).
Why use chown? Write all build products to a user-owned area and leave the sources in the root-owned /usr/src/linux. This is fully supported via $KBUILD_OUTPUT and friends.piedar wrote:I use gentoo-sources, but I always chown /usr/src/linux to my user before compiling.i92guboj wrote:What I particularly do is to add gentoo-sources to package.provided, then download the latest stable from kernel.org to my home directory, where I can build the kernel without being root (still don't know why would I need to be root just to compile a kernel...).
Could you explain how being able to compile the kernel is a security problem, but being able to compile non-kernel packages by hand, e.g. glibc, is not a security problem? You still need root privilege to install the kernel into the location where the bootloader will use it. You still need root to install the kernel modules, if you built any. You can use a dedicated build user if you are concerned that other processes owned by your user might tamper with the kernel configuration.penguin swordmaster wrote:wouldn't it be a serous security problem if a user could modify the kernel config/compile the kernel? It seems to me that a single user with hostile intent could add a patch or otherwise tamper with the kernel source much more easily than if the kernel source is owned by root.i92guboj wrote:... where I can build the kernel without being root (still don't know why would I need to be root just to compile a kernel...).

I was thinking along the lines of modifying the source so that when it was installed it would be altered or setting up a tainted kernel if bzImage was symlinked to /boot. I suppose this was general if Gentoo was configured to allow user to modify and compile the kernel source wouldn't that be a security risk?Hu wrote:Could you explain how being able to compile the kernel is a security problem, but being able to compile non-kernel packages by hand, e.g. glibc, is not a security problem? You still need root privilege to install the kernel into the location where the bootloader will use it. You still need root to install the kernel modules, if you built any. You can use a dedicated build user if you are concerned that other processes owned by your user might tamper with the kernel configuration.
What? "Yes, it would be a bad idea to execute code of unknown origin as root."penguin swordmaster wrote:I was thinking along the lines of modifying the source so that when it was installed it would be altered or setting up a tainted kernel if bzImage was symlinked to /boot. I suppose this was general if Gentoo was configured to allow user to modify and compile the kernel source wouldn't that be a security risk?Hu wrote:Could you explain how being able to compile the kernel is a security problem, but being able to compile non-kernel packages by hand, e.g. glibc, is not a security problem? You still need root privilege to install the kernel into the location where the bootloader will use it. You still need root to install the kernel modules, if you built any. You can use a dedicated build user if you are concerned that other processes owned by your user might tamper with the kernel configuration.

What I am talking about is if the kernel was designed so that root privileges were NOT required to work with it by default. Basically sidestepping the root user so to speak. My point was that if a file is owned by root it makes it harder to tamper with than a user's file.Hello71 wrote:What? "Yes, it would be a bad idea to execute code of unknown origin as root."penguin swordmaster wrote:....Hu wrote:...

I meant compile and possibly leave in a place were the administrator might install it without realizing that it was unsafe or possibly exploit a symlink to install the kernel directly without gaining root privileges.I think you need to clarify what you mean by "work with it" [the kernel]. Do you mean "work with it" to be "compile and link the kernel" or do you mean it to be "install the kernel in a location that the bootloader will respect?"
I was thinking of a design where, for example, to have a user own /usr/src/linux or allowed users to read/write by default. In such a case wouldn't the a symlinked bzImage be respected even if the original was overwritten? I was simply thinking out loud about what it would mean to change the current system of having the folder owned by root to allow the kernel to be compiled by a user.Hu wrote:You speak of a symlink to bzImage. Do you mean that you think root would create a symlink that points to a user-owned kernel image?
No. You need to be root to install it, to install the modules, and to modify your bootloader. The user can compile as much as he likes on his/her home, but that will only give him the joy of seeing the compilation messages. The user can't run a kernel, or install it, without root permissions.penguin swordmaster wrote:wouldn't it be a serous security problem if a user could modify the kernel config/compile the kernel? It seems to me that a single user with hostile intent could add a patch or otherwise tamper with the kernel source much more easily than if the kernel source is owned by root.i92guboj wrote:... where I can build the kernel without being root (still don't know why would I need to be root just to compile a kernel...).