Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Mounted var as noexec, portage fails to compile packages
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
hjkl
Apprentice
Apprentice


Joined: 22 Apr 2021
Posts: 198
Location: Somewhere in Europe

PostPosted: Thu Jun 24, 2021 11:54 am    Post subject: Mounted var as noexec, portage fails to compile packages Reply with quote

Hi,


I just mounted my /var onto a seperate disk with the
Code:
noexec
flag.


I did the same for /var/tmp/portage except added the
Code:
exec
flag.


Compiling doesn't work when I tried it that way however.


My /var/tmp/portage :

Code:
 tmpfs           /var/tmp/portage                tmpfs   size=20G,uid=portage,gid=portage,mode=775,nos
   uid,noatime,nodev,exec 0 0




My /var :

Code:
/dev/sdc11  /var ext4 nosuid,nodev,relatime,noexec      0       2


Cheers!


EDIT:

Code:
tmpfs /var/tmp/portage tmpfs rw,nosuid,noatime,nodev,size=20G,mode=775,uid=portage,gid=portage,x-mount.mkdir=775 0 0
didn't help either.
_________________
Having problems compiling since 2021 :(
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


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

PostPosted: Thu Jun 24, 2021 12:30 pm    Post subject: Reply with quote

Mount options which are not supported or available will be ignored, see mount command output for actual mount options in force.
_________________
My Gentoo installation notes.
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
hjkl
Apprentice
Apprentice


Joined: 22 Apr 2021
Posts: 198
Location: Somewhere in Europe

PostPosted: Thu Jun 24, 2021 1:32 pm    Post subject: Reply with quote

Jaglover wrote:
Mount options which are not supported or available will be ignored, see mount command output for actual mount options in force.


So
Code:
exec
isn't a valid mount option.

What other options do I have then other than to remove
Code:
noexec
from /var ?
_________________
Having problems compiling since 2021 :(
Back to top
View user's profile Send private message
Ralphred
Guru
Guru


Joined: 31 Dec 2013
Posts: 501

PostPosted: Thu Jun 24, 2021 1:41 pm    Post subject: Reply with quote

You can set a non-default PORTAGE_TMPDIR= in /etc/portage/make.conf and move it off of /var entirely.
Back to top
View user's profile Send private message
hjkl
Apprentice
Apprentice


Joined: 22 Apr 2021
Posts: 198
Location: Somewhere in Europe

PostPosted: Thu Jun 24, 2021 2:00 pm    Post subject: Reply with quote

Ralphred wrote:
You can set a non-default PORTAGE_TMPDIR= in /etc/portage/make.conf and move it off of /var entirely.


Thank you!!!
_________________
Having problems compiling since 2021 :(
Back to top
View user's profile Send private message
Naib
Watchman
Watchman


Joined: 21 May 2004
Posts: 6051
Location: Removed by Neddy

PostPosted: Thu Jun 24, 2021 2:26 pm    Post subject: Reply with quote

The reason why this failed is the vast majority of configure scripts compile testcode to check the consistency of the available toolchain. These testprogs are executed to confirm.

Then there are those applications that bootstrap themselves... GCC for instance is compiled something like 3 times and it is the intermediate built GCC that is used.


So in these cases if a generated executable cannot be executed, aspects of the build will fail
_________________
Quote:
Removed by Chiitoo
Back to top
View user's profile Send private message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3922
Location: Hamburg

PostPosted: Thu Jun 24, 2021 2:33 pm    Post subject: Reply with quote

fullbyte wrote:
So
Code:
exec
isn't a valid mount option.

It is a valid mount option, see "man mount".
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


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

PostPosted: Thu Jun 24, 2021 2:41 pm    Post subject: Reply with quote

exec is not mentioned in man tmpfs.
_________________
My Gentoo installation notes.
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21633

PostPosted: Thu Jun 24, 2021 4:11 pm    Post subject: Reply with quote

fullbyte wrote:
Compiling doesn't work when I tried it that way however.
That setup works for me. Please show how it fails, and the output of emerge --info.
fullbyte wrote:
So
Code:
exec
isn't a valid mount option.
It is, but it should also be unnecessary, unless an option earlier in the line set or implied noexec.
fullbyte wrote:
What other options do I have then other than to remove
Code:
noexec
from /var ?
You cannot have noexec on the filesystem where Portage builds. If that filesystem is /var, then remove noexec from /var or move Portage to another filesystem. As Ralphred mentions, you can change this. However, I would expect that the defaults would already work for you, since you said you made /var/tmp/portage a tmpfs that allows exec.
Jaglover wrote:
exec is not mentioned in man tmpfs.
It is a filesystem-independent option, so it is in man mount. Even if it is invalid for tmpfs, that should mean that neither exec nor noexec work, and execution is always allowed.
Back to top
View user's profile Send private message
hjkl
Apprentice
Apprentice


Joined: 22 Apr 2021
Posts: 198
Location: Somewhere in Europe

PostPosted: Thu Jun 24, 2021 7:35 pm    Post subject: Reply with quote

Hu wrote:
fullbyte wrote:
Compiling doesn't work when I tried it that way however.
That setup works for me. Please show how it fails, and the output of emerge --info.
fullbyte wrote:
So
Code:
exec
isn't a valid mount option.
It is, but it should also be unnecessary, unless an option earlier in the line set or implied noexec.
fullbyte wrote:
What other options do I have then other than to remove
Code:
noexec
from /var ?
You cannot have noexec on the filesystem where Portage builds. If that filesystem is /var, then remove noexec from /var or move Portage to another filesystem. As Ralphred mentions, you can change this. However, I would expect that the defaults would already work for you, since you said you made /var/tmp/portage a tmpfs that allows exec.
Jaglover wrote:
exec is not mentioned in man tmpfs.
It is a filesystem-independent option, so it is in man mount. Even if it is invalid for tmpfs, that should mean that neither exec nor noexec work, and execution is always allowed.


I probably misworded what I meant;

Basically, /var/tmp/portage still doesn't work and i just resorted to creating a new directory called
Code:
/portage
and putting the tmpfs there.


Code:

❯ emerge bubblewrap
Calculating dependencies... done!

>>> Verifying ebuild manifests

>>> Emerging (1 of 1) sys-apps/bubblewrap-0.4.1::gentoo
Can not execute files in /var/tmp/portage
Likely cause is that you've mounted it with one of the
following mount options: 'noexec', 'user', 'users'

Please make sure that portage can execute files in this directory.

>>> Failed to emerge sys-apps/bubblewrap-0.4.1


emerge --info: https://gist.github.com/7c0bdfcb1b85190a58ef373510c011be

Cheers![/quote]
_________________
Having problems compiling since 2021 :(
Back to top
View user's profile Send private message
hjkl
Apprentice
Apprentice


Joined: 22 Apr 2021
Posts: 198
Location: Somewhere in Europe

PostPosted: Thu Jun 24, 2021 7:37 pm    Post subject: Reply with quote

toralf wrote:
fullbyte wrote:
So
Code:
exec
isn't a valid mount option.

It is a valid mount option, see "man mount".


Well oddly enough whenever I set that as option it never shows up when i run


Code:
mount

_________________
Having problems compiling since 2021 :(
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21633

PostPosted: Thu Jun 24, 2021 7:56 pm    Post subject: Reply with quote

What is the output of cat /proc/self/mountinfo? If you create a trivial shell script in /var/tmp/portage and make it executable, can you run it as /var/tmp/portage/test-script.sh?

It is normal not to see exec as a mount option, since exec is assumed if noexec is absent.
Back to top
View user's profile Send private message
hjkl
Apprentice
Apprentice


Joined: 22 Apr 2021
Posts: 198
Location: Somewhere in Europe

PostPosted: Thu Jun 24, 2021 8:03 pm    Post subject: Reply with quote

Hu wrote:
What is the output of cat /proc/self/mountinfo? If you create a trivial shell script in /var/tmp/portage and make it executable, can you run it as /var/tmp/portage/test-script.sh?

It is normal not to see exec as a mount option, since exec is assumed if noexec is absent.



Code:

21 1 8:18 / / rw,relatime - ext4 /dev/root rw
22 21 0:5 / /dev rw,nosuid,relatime - devtmpfs devtmpfs rw,size=10240k,nr_inodes=3067501,mode=755,inode64
23 21 0:20 / /proc rw,nosuid,nodev,noexec,relatime - proc proc rw,gid=102,hidepid=invisible
24 21 0:21 / /run rw,nodev,relatime - tmpfs tmpfs rw,size=2454692k,mode=755,inode64
25 21 0:22 / /sys rw,nosuid,nodev,noexec,relatime - sysfs sysfs rw
26 25 0:23 / /sys/kernel/security rw,nosuid,nodev,noexec,relatime - securityfs securityfs rw
27 25 0:6 / /sys/kernel/debug rw,nosuid,nodev,noexec,relatime - debugfs debugfs rw
28 25 0:24 / /sys/kernel/config rw,nosuid,nodev,noexec,relatime - configfs configfs rw
29 25 0:25 / /sys/fs/pstore rw,nosuid,nodev,noexec,relatime - pstore pstore rw
30 25 0:26 / /sys/firmware/efi/efivars rw,nosuid,nodev,noexec,relatime - efivarfs efivarfs rw
31 25 0:27 / /sys/fs/cgroup rw,nosuid,nodev,noexec,relatime - tmpfs cgroup_root rw,size=10240k,mode=755,inode64
32 31 0:28 / /sys/fs/cgroup/openrc rw,nosuid,nodev,noexec,relatime - cgroup openrc rw,release_agent=/lib/rc/sh/cgroup-release-agent.sh,name=openrc
33 31 0:29 / /sys/fs/cgroup/unified rw,nosuid,nodev,noexec,relatime - cgroup2 none rw,nsdelegate
34 31 0:30 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime - cgroup cpuset rw,cpuset
35 31 0:31 / /sys/fs/cgroup/cpu rw,nosuid,nodev,noexec,relatime - cgroup cpu rw,cpu
36 31 0:32 / /sys/fs/cgroup/cpuacct rw,nosuid,nodev,noexec,relatime - cgroup cpuacct rw,cpuacct
37 31 0:33 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime - cgroup blkio rw,blkio
38 31 0:34 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime - cgroup memory rw,memory
39 31 0:35 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime - cgroup devices rw,devices
40 31 0:36 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime - cgroup freezer rw,freezer
41 31 0:37 / /sys/fs/cgroup/net_cls rw,nosuid,nodev,noexec,relatime - cgroup net_cls rw,net_cls
42 31 0:38 / /sys/fs/cgroup/perf_event rw,nosuid,nodev,noexec,relatime - cgroup perf_event rw,perf_event
43 31 0:39 / /sys/fs/cgroup/net_prio rw,nosuid,nodev,noexec,relatime - cgroup net_prio rw,net_prio
44 31 0:40 / /sys/fs/cgroup/hugetlb rw,nosuid,nodev,noexec,relatime - cgroup hugetlb rw,hugetlb
45 31 0:41 / /sys/fs/cgroup/pids rw,nosuid,nodev,noexec,relatime - cgroup pids rw,pids
46 22 0:19 / /dev/mqueue rw,nosuid,nodev,noexec,relatime - mqueue mqueue rw
47 22 0:42 / /dev/pts rw,nosuid,noexec,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=000
48 22 0:43 / /dev/shm rw,nosuid,nodev,noexec,relatime - tmpfs shm rw,inode64
49 23 0:44 / /proc/sys/fs/binfmt_misc rw,nosuid,nodev,noexec,relatime - binfmt_misc binfmt_misc rw
51 21 8:1 / /home rw,nosuid,nodev,relatime - ext4 /dev/sda1 rw
52 21 8:17 / /boot rw,nosuid,nodev,noexec,relatime - vfat /dev/sdb1 rw,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro
54 21 0:46 / /tmp rw,nosuid,nodev,noexec,noatime - tmpfs tmpfs rw,size=2097152k,inode64
55 21 0:47 / /portage rw,nosuid,nodev,noatime - tmpfs tmpfs rw,size=20971520k,mode=775,uid=250,gid=250,inode64
56 21 8:43 / /var rw,nosuid,nodev,noexec,relatime - ext4 /dev/sdc11 rw
57 24 0:48 / /run/user/1000 rw,nosuid,nodev,relatime - tmpfs tmpfs rw,size=2454688k,nr_inodes=613672,mode=700,uid=1000,gid=1000,inode64


Code:

❯ chmod +x test-script.sh
❯ ./test-script.sh
zsh: permission denied: ./test-script.sh

_________________
Having problems compiling since 2021 :(
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21633

PostPosted: Thu Jun 24, 2021 8:34 pm    Post subject: Reply with quote

It looks like you do not have /var/tmp/portage mounted as a tmpfs, so the file, and the options, are part of /var, which we know will disallow execution. You said in the opening post that you mounted an exec-enabled tmpfs on /var/tmp/portage.
Back to top
View user's profile Send private message
hjkl
Apprentice
Apprentice


Joined: 22 Apr 2021
Posts: 198
Location: Somewhere in Europe

PostPosted: Fri Jun 25, 2021 7:48 am    Post subject: Reply with quote

Hu wrote:
It looks like you do not have /var/tmp/portage mounted as a tmpfs, so the file, and the options, are part of /var, which we know will disallow execution. You said in the opening post that you mounted an exec-enabled tmpfs on /var/tmp/portage.


Well I had it mounted as that before and then just remounted my /portage as tmpfs.

Apologies

Anyways:


Code:

❯ cat /proc/self/mountinfo | grep -i portage
55 21 0:47 / /var/tmp/portage rw,nosuid,nodev,noatime - tmpfs tmpfs rw,size=20971520k,mode=775,uid=250,gid=250,inode64


However, in my fstab it's different?

Code:

tmpfs          /var/tmp/portage               tmpfs   size=20G,uid=portage,gid=portage,mode=775,nosuid,noatime,nodev,exec 0 0

_________________
Having problems compiling since 2021 :(
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21633

PostPosted: Fri Jun 25, 2021 4:43 pm    Post subject: Reply with quote

fullbyte wrote:
Code:
❯ cat /proc/self/mountinfo | grep -i portage
55 21 0:47 / /var/tmp/portage rw,nosuid,nodev,noatime - tmpfs tmpfs rw,size=20971520k,mode=775,uid=250,gid=250,inode64
That could be rewritten as grep portage /proc/self/mountinfo
fullbyte wrote:
Code:
tmpfs          /var/tmp/portage               tmpfs   size=20G,uid=portage,gid=portage,mode=775,nosuid,noatime,nodev,exec 0 0
That looks fine to me.

This is confusing. First you show output stating that /var/tmp/portage is not a mountpoint, and that exec fails. That failure seems correct, since it fell through to /var, which is noexec. Then more recently, you show output stating that /var/tmp/portage is a mountpoint, and has the correct options. You don't re-show the test with the mount set correctly. Based on your output so far, everything looks to be as expected.
  • You cannot build on a noexec filesystem.
  • Your test for executability was correctly denied on a noexec filesystem.
  • You have /var/tmp/portage configured properly now, but no output shows you running any executability tests with it configured properly.
Back to top
View user's profile Send private message
hjkl
Apprentice
Apprentice


Joined: 22 Apr 2021
Posts: 198
Location: Somewhere in Europe

PostPosted: Tue Jun 29, 2021 6:44 pm    Post subject: Reply with quote

Hu wrote:
fullbyte wrote:
Code:
❯ cat /proc/self/mountinfo | grep -i portage
55 21 0:47 / /var/tmp/portage rw,nosuid,nodev,noatime - tmpfs tmpfs rw,size=20971520k,mode=775,uid=250,gid=250,inode64
That could be rewritten as grep portage /proc/self/mountinfo
fullbyte wrote:
Code:
tmpfs          /var/tmp/portage               tmpfs   size=20G,uid=portage,gid=portage,mode=775,nosuid,noatime,nodev,exec 0 0
That looks fine to me.

This is confusing. First you show output stating that /var/tmp/portage is not a mountpoint, and that exec fails. That failure seems correct, since it fell through to /var, which is noexec. Then more recently, you show output stating that /var/tmp/portage is a mountpoint, and has the correct options. You don't re-show the test with the mount set correctly. Based on your output so far, everything looks to be as expected.
  • You cannot build on a noexec filesystem.
  • Your test for executability was correctly denied on a noexec filesystem.
  • You have /var/tmp/portage configured properly now, but no output shows you running any executability tests with it configured properly.



I think i'm giving up on this as I am also getting confused.

Sorry about the late reply.
_________________
Having problems compiling since 2021 :(
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21633

PostPosted: Wed Jun 30, 2021 2:02 am    Post subject: Reply with quote

No need to apologize. I watch for recent thread activity, and return when you do. If you want to take a week off from a thread, we'll be here when you get back. ;)

If you decide you want to try this again later, start from the beginning. Show us the exact failure, the output of emerge --info, and the mount configuration (from /proc/self/mountinfo) in effect at that time.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo 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