Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 134620 - portage does not uninstall files that have been modified by paxctl or chpax
Summary: portage does not uninstall files that have been modified by paxctl or chpax
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
: 187769 (view as bug list)
Depends on:
Blocks: 193766 181949
  Show dependency tree
 
Reported: 2006-05-28 05:08 UTC by Alex Efros
Modified: 2007-09-25 17:02 UTC (History)
5 users (show)

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 Alex Efros 2006-05-28 05:08:28 UTC
After unmerging wine-0.9.8-r1 these files was not removed:
/usr/bin/wine
/usr/bin/wineserver
/usr/bin/winebuild
/usr/bin/wine-pthread
/usr/bin/wine-kthread
/usr/bin/winedump
/usr/bin/wineg++
/usr/bin/winecpp
/usr/bin/winegcc
/usr/bin/wine-preloader
/usr/share/fonts/wine
/usr/share/fonts/wine/fonts.scale
/usr/share/fonts/wine/fonts.dir
/usr/share/fonts/wine/encodings.dir
/usr/share/fonts/wine/fonts.cache-1
... and maybe other files too.

This also has side effect in revdep-rebuild messages:
  broken /usr/bin/wine (requires  libwine.so.1)
  broken /usr/bin/wineserver (requires  libwine.so.1 libwine_unicode.so.1)
  broken /usr/bin/wmc (requires  libwine_unicode.so.1)
  broken /usr/bin/wrc (requires  libwine_unicode.so.1)
Comment 1 SpanKY gentoo-dev 2006-06-05 09:13:04 UTC
highly doubt this is a wine bug
Comment 2 Zac Medico gentoo-dev 2006-06-05 09:42:41 UTC
Portage doesn't unmerge files if their timestamp or md5 digest doesn't match the value recorded when the files were installed.  One thing that can cause this is if the files are prelinked and then prelink is uninstalled without undoing the prelink first.  Please post the output of `emerge --info`.
Comment 3 Alex Efros 2006-06-05 15:28:43 UTC
I don't use prelinking - AFAIK it's incompatible with hardened.

Portage 2.0.54-r2 (hardened/x86/2.6, gcc-3.4.6, glibc-2.3.6-r3, 2.6.14-hardened-r8 i686)
=================================================================
System uname: 2.6.14-hardened-r8 i686 AMD Athlon(tm) XP 3000+
Gentoo Base System version 1.6.14
dev-lang/python:     2.3.5-r2, 2.4.2
dev-python/pycrypto: [Not Present]
dev-util/ccache:     [Not Present]
dev-util/confcache:  [Not Present]
sys-apps/sandbox:    1.2.17
sys-devel/autoconf:  2.13, 2.59-r7
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r1
sys-devel/binutils:  2.16.1-r2
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.11-r2
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O2 -march=athlon-xp -pipe -ftracer -fprefetch-loop-arrays"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /service /usr/kde/3.4/env /usr/kde/3.4/share/config /usr/kde/3.4/shutdown /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/lib/X11/xkb /usr/share/config /var/qmail/alias /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-O2 -march=athlon-xp -pipe -ftracer -fprefetch-loop-arrays"
DISTDIR="/usr/portage-distfiles"
FEATURES="autoconfig distlocks sandbox sfperms strict userpriv usersandbox"
GENTOO_MIRRORS="http://pandemonium.tiscali.de/pub/gentoo/ http://130.59.10.34/mirror/gentoo/ http://gentoo.zie.pg.gda.pl"
LANG="ru_RU.KOI8-R"
LINGUAS="en ru"
PKGDIR="/usr/portage-packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage /usr/local/portage-power /usr/local/portage-rusxmms"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="3dnow 3dnowext X Xaw3d aac acpi aim alsa apache2 arts asf audiofile avi bash-completion berkdb bitmap-fonts bzip2 cdr crypt cscope curl dga divx4linux dlloader dts dvd dvdr dvdread encode esd ethereal exif expat fam ffmpeg flac flash gd gdbm gif glut gnutls gtk gtk2 guile hardened icq idn imagemagick imap imlib irc jabber javascript jpeg kdeenablefinal lcms lirc lm_sensors lzo mad mailbox mbox mmx mmxext mng motif mp3 mpeg msn mysql ncurses nls nptl nptlonly ogg opengl oss pam pcre perl pic png pwdb python qt quicktime rcc readline rss rtc samba sdl silc slang spell sse ssl svg sysfs tcltk tcpd tiff truetype truetype-fonts type1-fonts udev userlocales vorbis win32codecs x86 xine xinetd xml xml2 xmms xv xvid yahoo zlib linguas_en linguas_ru userland_GNU kernel_linux elibc_glibc"
Unset:  CTARGET, INSTALL_MASK, LC_ALL, LDFLAGS, MAKEOPTS, PORTAGE_RSYNC_EXTRA_OPTS, PORTAGE_RSYNC_OPTS
Comment 4 Zac Medico gentoo-dev 2006-06-05 16:31:47 UTC
Are you able to reproduce this problem if you remerge wine and unmerge it again?
Comment 5 Alex Efros 2006-06-05 17:07:07 UTC
Ohh, it need much time to compile it... :( and I don't sure I've found all files not removed by emerge -C wine.

Ok, if you need it, I'll manually remove these files, run emerge wine when I'll go to sleep and tomorrow try to use wine a little and then emerge -C it again.
Comment 6 Zac Medico gentoo-dev 2006-06-05 17:57:38 UTC
You don't have to manually remove the files.  When you reinstall, they will be overwritten anyway.  Also, before you uninstall, you can use quickpkg to make a backup binary package in case it's needed for further testing.  If you have extra disk space, it a good idea to enable FEATURES="buildpkg" in make.conf so that portage creates binary packages of everything automatically.
Comment 7 Alex Efros 2006-06-05 18:04:18 UTC
(In reply to comment #2)
> Portage doesn't unmerge files if their timestamp or md5 digest doesn't match
> the value recorded when the files were installed.

I've found reason why /usr/bin/wine* files wasn't unmerged: it's because their md5 was changed after executing paxctl (I'm using hardened, as you can see in my emerge --info).

About files in /usr/share/fonts/wine/ - I suppose these files was autogenerated and doesn't belong to wine package.

So, probably this bug can be closed, but I'm not happy with this idea: portage will not delete files changed by paxctl/chpax!! If some package require paxctl/chpax then this package is weak place in hardened protection... and, finally, when I decide to unmerge that package -- portage will leave binaries with disabled PaX protection on my hard drive without any notice... all hackers should applause here! :-(
Comment 8 Zac Medico gentoo-dev 2006-06-05 18:49:29 UTC
Is there some way to reverse the changes that are made by paxctl/chpax?  For prelinked files, portage uses `prelink --undo <filename>` in order to ensure that the checksums match.
Comment 9 Alex Efros 2006-06-06 02:45:13 UTC
I think best workaround should be: if emerge detect 'hardened' environment, then apply paxctl/chpax while emerging, at 'install' stage, using rules from /etc/conf.d/chpax. This way:

1) installed binary will already have modified pax flags, so recorded by emerge md5 will not be changed at unmerging unless user manually change PaX flags (I've no idea why user may need this)

2) package will be ready-to-use just after emerge, without need to running /etc/init.d/chpax (or reboot) first - just like all other packages which doesn't require changing PaX flags to work

3) running /etc/init.d/chpax at system startup will not be needed anymore, so /etc/init.d/chpax and /etc/conf.d/chpax can be replaced, for example, by simple script /etc/set_pax:
---cut---
  #!/bin/sh
  chpax  -pemrxs    /opt/*-{j{,2s}dk-*/{,jre/},jre-*/}bin/*
  chpax  -pemrxs /opt/skype/skype.bin
  paxctl -pemrxs /usr/bin/Xorg
  paxctl -pems   /usr/bin/{g,}mplayer
  paxctl -pems   /usr/bin/{g,}xine
  paxctl -m  /usr/bin/xmms
  paxctl -pems   /usr/bin/{wine{,build,clipsrv,dump,gcc,server,wrap,-{k,p}thread},w{mc,rc,idl}}
---cut---
and emerge will just execute this script if it exists - there even no need to detect hardened environment.
Comment 10 solar (RETIRED) gentoo-dev 2006-06-06 03:41:26 UTC
(In reply to comment #9)
> I think best workaround should be: if emerge detect 'hardened' environment,
> then apply paxctl/chpax while emerging, at 'install' stage, using rules from
> /etc/conf.d/chpax. 

No this has been talked about before and we decided a long time ago that we 
do not want to lower peoples security for them. Changing PaX flags from 
the default would do such a thing. Second old chpax style flags are not 
strip safe so it has to be done postint.


(In reply to comment #8)
> Is there some way to reverse the changes that are made by paxctl/chpax?  For
> prelinked files, portage uses `prelink --undo <filename>` in order to ensure
> that the checksums match.

The default PT_PAX_FLAGS can be restored using paxctl -zxe however if a maintainer elected to use a compile time flag such as -Wl,-z,--execheap 
then setting -zxe would be wrong.

One way this could be accomplished however would be to record the paxelf 
settings in the vdb and restore them prior to unmerge if they differ from 
the recorded ones. (we could revisit this >=2.1.1)
Comment 11 Alex Efros 2006-06-06 05:18:05 UTC
(In reply to comment #10)
> No this has been talked about before and we decided a long time ago that we 
> do not want to lower peoples security for them. Changing PaX flags from 
> the default would do such a thing. Second old chpax style flags are not 
> strip safe so it has to be done postint.

I agree it isn't good idea to lower security 'by default'. But if user configured his own /etc/set_pax script (or config), then executing it at postinst isn't bad idea. Anyway, we've /etc/init.d/chpax executed on each boot and change pax flags for many binaries 'by default'!!

And, lowering security is bad idea, but if user emerge, for example, xmms or java - then he probably wanna use them! But without changing pax flags it's currently impossible to use them, so we force user to run /etc/init.d/chpax anyway, no matter is he wanna lower security or not. So, what's the difference between changing pax flags in postinst (with printing fat big warning to user about lowering security) and manual execution of /etc/init.d/chpax if user has NO CHOICE ANYWAY if he wanna use these packages?

> One way this could be accomplished however would be to record the paxelf 
> settings in the vdb and restore them prior to unmerge if they differ from 
> the recorded ones. (we could revisit this >=2.1.1)
 
Yep, this solve issue... but this solution is complex (compared to my proposition) and will slowdown already-not-very-fast emerge. :(
Comment 12 Kevin F. Quinn (RETIRED) gentoo-dev 2006-06-06 06:06:10 UTC
(In reply to comment #11)
> And, lowering security is bad idea, but if user emerge, for example, xmms or
> java - then he probably wanna use them!

But perhaps the user (i.e. sysadmin) doesn't realise that PaX will be weakened for the apps; if the ebuilds do it all by magic

However ideally PaX should be managed by a MAC (e.g. RBAC, RSBAC, SELinux(?)), not by the file contents.  The init.d/chpax running on boot is sort of trying to do the same thing; keeping policy for PaX flags as a system configuration.  If a MAC is in play, it doesn't matter what the executable is marked with, and the markings give the sysadmin an easy way to find out what the application itself thinks it needs.

I did play with a portage hook for setting flags according to a system configuration file; perhaps it's worth looking at again.  It's all the more complex because some stuff won't take paxctl (although that situation has improved significantly), and different kernel configurations pay attention to different types of PaX marking.  Alternatively we could save/restore chpax flags around the stripping that portage does, which should simplify things dramatically.

Perhaps this would be better discussed on the hardened mailing list.
Comment 13 Zac Medico gentoo-dev 2006-06-06 07:46:55 UTC
(In reply to comment #10)
> One way this could be accomplished however would be to record the paxelf 
> settings in the vdb and restore them prior to unmerge if they differ from 
> the recorded ones. (we could revisit this >=2.1.1)

Rather than include specialized support for things like this (chpax, prelink, etc...) in portage, I think it would be cleaner and more worthwhile to implement global reference counting for the unmerge phase.  Tools such as qfile (from portage-utils) show that contents lookups can be done quickly even with flat CONTENTS files (as opposed to a real database).
Comment 14 solar (RETIRED) gentoo-dev 2006-06-14 11:16:16 UTC
(In reply to comment #11)
> Anyway, we've /etc/init.d/chpax executed on each boot
> and change pax flags for many binaries 'by default'!!

This statement is incorrect/false. The user has to rc-update add chpax <level> 
to make that happen. It is in no way enabled per default and never will be.
Comment 15 Zac Medico gentoo-dev 2006-09-12 09:53:30 UTC

*** This bug has been marked as a duplicate of 16162 ***
Comment 16 Zac Medico gentoo-dev 2007-06-13 07:32:54 UTC
In svn r6830 I've added support for FEATURES=unmerge-orphans which causes unmerge to remove files more aggressively.  If a file is not claimed by another package in the same slot and it is not protected by CONFIG_PROTECT, unmerge it even if the modification time or checksum differs from the file that was originally installed.
Comment 17 Zac Medico gentoo-dev 2007-06-15 03:24:10 UTC
This has been released in 2.1.3_rc1.
Comment 18 Zac Medico gentoo-dev 2007-08-05 07:40:42 UTC
*** Bug 187769 has been marked as a duplicate of this bug. ***