Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 390043 - On SELinux, emerging packages fails with "OSError: [Errno 22] Invalid argument" when done through a terminal emulator
Summary: On SELinux, emerging packages fails with "OSError: [Errno 22] Invalid argumen...
Status: VERIFIED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Hardened (show other bugs)
Hardware: AMD64 Linux
: Normal minor (vote)
Assignee: SE Linux Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-10 00:25 UTC by bleedingsamurai
Modified: 2011-12-26 12:29 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description bleedingsamurai 2011-11-10 00:25:35 UTC
Whenever I emerge packages through a terminal emulator such as Konsole or Yakuake the emerge fails right after checking the SHA1 sum on the tarball of the package. However if I switch to a virtual console (pressing ctrl + alt + F5) I can emerge the exact same package and it will build and install just fine.

Reproducible: Always

Steps to Reproduce:
1.open a terminal emulator such as Konsole or Yakuake
2.run ~$ emerge <packagename>
3.

It is important to note that this only started happening after I switched my system profile from default/linux/amd64/10.0/desktop/kde to hardened/linux/amd64/selinux
Actual Results:  
alex@Hitomi ~ $ sudo emerge wget
Calculating dependencies... done!

>>> Verifying ebuild manifests

>>> Emerging (1 of 1) net-misc/wget-1.12-r3
 * wget-1.12.tar.bz2 RMD160 SHA1 SHA256 size ;-) ...                                                                                                                                                          [ ok ]
Traceback (most recent call last):
  File "/usr/bin/emerge", line 43, in <module>
    retval = emerge_main()
  File "/usr/lib64/portage/pym/_emerge/main.py", line 1906, in emerge_main
    myopts, myaction, myfiles, spinner)
  File "/usr/lib64/portage/pym/_emerge/actions.py", line 437, in action_build
    retval = mergetask.merge()
  File "/usr/lib64/portage/pym/_emerge/Scheduler.py", line 1073, in merge
    rval = self._merge()
  File "/usr/lib64/portage/pym/_emerge/Scheduler.py", line 1423, in _merge
    self._main_loop()
  File "/usr/lib64/portage/pym/_emerge/Scheduler.py", line 1573, in _main_loop
    self._poll_loop()
  File "/usr/lib64/portage/pym/_emerge/PollScheduler.py", line 193, in _poll_loop
    handler(f, event)
  File "/usr/lib64/portage/pym/_emerge/EbuildIpcDaemon.py", line 85, in _input_handler
    reply_hook()
  File "/usr/lib64/portage/pym/_emerge/AbstractEbuildProcess.py", line 146, in _exit_command_callback
    self.scheduler.schedule(self._reg_id, timeout=self._exit_timeout)
  File "/usr/lib64/portage/pym/_emerge/PollScheduler.py", line 291, in _schedule_wait
    handler(f, event)
  File "/usr/lib64/portage/pym/_emerge/SpawnProcess.py", line 215, in _output_handler
    self._unregister_if_appropriate(event)
  File "/usr/lib64/portage/pym/_emerge/AbstractPollTask.py", line 61, in _unregister_if_appropriate
    self.wait()
  File "/usr/lib64/portage/pym/_emerge/AsynchronousTask.py", line 46, in wait
    self._wait_hook()
  File "/usr/lib64/portage/pym/_emerge/AsynchronousTask.py", line 128, in _wait_hook
    self._exit_listener_stack.pop()(self)
  File "/usr/lib64/portage/pym/_emerge/EbuildPhase.py", line 238, in _ebuild_exit
    self.wait()
  File "/usr/lib64/portage/pym/_emerge/AsynchronousTask.py", line 46, in wait
    self._wait_hook()
  File "/usr/lib64/portage/pym/_emerge/AsynchronousTask.py", line 128, in _wait_hook
    self._exit_listener_stack.pop()(self)
  File "/usr/lib64/portage/pym/_emerge/EbuildExecuter.py", line 76, in _setup_exit
    self._start_task(unpack_phase, self._unpack_exit)
  File "/usr/lib64/portage/pym/_emerge/CompositeTask.py", line 146, in _start_task
    task.start()
  File "/usr/lib64/portage/pym/_emerge/AsynchronousTask.py", line 24, in start
    self._start()
  File "/usr/lib64/portage/pym/_emerge/EbuildPhase.py", line 120, in _start
    self._start_lock()
  File "/usr/lib64/portage/pym/_emerge/EbuildPhase.py", line 140, in _start_lock
    self._start_ebuild()
  File "/usr/lib64/portage/pym/_emerge/EbuildPhase.py", line 169, in _start_ebuild
    self._start_task(ebuild_process, self._ebuild_exit)
  File "/usr/lib64/portage/pym/_emerge/CompositeTask.py", line 146, in _start_task
    task.start()
  File "/usr/lib64/portage/pym/_emerge/AsynchronousTask.py", line 24, in start
    self._start()
  File "/usr/lib64/portage/pym/_emerge/AbstractEbuildProcess.py", line 95, in _start
    SpawnProcess._start(self)
  File "/usr/lib64/portage/pym/_emerge/SpawnProcess.py", line 123, in _start
    retval = self._spawn(self.args, **kwargs)
  File "/usr/lib64/portage/pym/_emerge/EbuildProcess.py", line 21, in _spawn
    actionmap=actionmap, **kwargs)
  File "/usr/lib64/portage/pym/portage/package/ebuild/doebuild.py", line 104, in _doebuild_spawn
    return spawn(cmd, settings, **kwargs)
  File "/usr/lib64/portage/pym/portage/package/ebuild/doebuild.py", line 1255, in spawn
    return spawn_func(mystring, env=mysettings.environ(), **keywords)
  File "/usr/lib64/portage/pym/portage/_selinux.py", line 105, in wrapper_func
    setexec(con)
  File "/usr/lib64/portage/pym/portage/_selinux.py", line 79, in setexec
    if selinux.setexeccon(ctx) < 0:
OSError: [Errno 22] Invalid argument


Expected Results:  
I should have had my package emerge.

It doesn't matter what package I emerge, I always get the same error.
It doesn't matter if I use sudo or su -c or just su right into root, as long as I'm running through Konsole or Yakuake I will get this error.
I have SELinux set to passive.

I can switch to a virtual console and emerge my packages just fine, so this isn't a serious, major issue. More of a pain in the butt.
Comment 1 Sven Vermeulen (RETIRED) gentoo-dev 2011-12-11 08:43:36 UTC
It means that the context in which you were sitting when you launched portage wasn't sysadm_t. Portage itself checks for a proper context but if it isn't in portage_t (which can only be transitioned to from sysadm_t) it b0rks like that.

You can temporarily disable that with FEATURES="-selinux", but be aware that that means SELinux support in Portage is disabled (including labeling the files it installs). Better is to focus on why the context of your root account isn't "sysadm_t".

I'll see to it that this error is documented in the troubleshooting section of the handbook or in the FAQ.
Comment 2 Sven Vermeulen (RETIRED) gentoo-dev 2011-12-11 14:39:49 UTC
In hardened-docs overlay
Comment 3 Sven Vermeulen (RETIRED) gentoo-dev 2011-12-26 12:29:42 UTC
Pushed to main site