diff --git a/README.md b/README.md index cfdd83e..4a60c4c 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # prelink +ELF prelinking utility to speed up dynamic linking. + diff --git a/prelink.conf b/prelink.conf new file mode 100644 index 0000000..7ee80de --- /dev/null +++ b/prelink.conf @@ -0,0 +1,32 @@ +# This config file contains a list of directories both with binaries +# and libraries prelink should consider by default. +# If a directory name is prefixed with `-l ', the directory hierarchy +# will be walked as long as filesystem boundaries are not crossed. +# If a directory name is prefixed with `-h ', symbolic links in a +# directory hierarchy are followed. +# Directories or files with `-b ' prefix will be blacklisted. +# `-c ' is used to source additional config file snippets. +-c /etc/prelink.conf.d/*.conf +-b *.la +-b *.png +-b *.py +-b *.pl +-b *.pm +-b *.sh +-b *.xml +-b *.xslt +-b *.a +-b *.js +-b /lib/modules +-b /usr/lib/locale +-l /bin +-l /usr/bin +-l /sbin +-l /usr/sbin +-l /usr/kerberos/bin +-l /usr/games +-l /usr/libexec +-l /var/ftp/bin +-l /lib{,64} +-l /usr/lib{,64} +-l /var/ftp/lib{,64} diff --git a/prelink.cron b/prelink.cron new file mode 100644 index 0000000..86d5f53 --- /dev/null +++ b/prelink.cron @@ -0,0 +1,51 @@ +#!/bin/bash + +. /etc/sysconfig/prelink + +renice +19 -p $$ >/dev/null 2>&1 + +if [ "$PRELINKING" != yes ]; then + if [ -f /etc/prelink.cache ]; then + echo /usr/sbin/prelink -uav > /var/log/prelink/prelink.log + /usr/sbin/prelink -uav >> /var/log/prelink/prelink.log 2>&1 \ + || echo Prelink failed with return value $? >> /var/log/prelink/prelink.log + rm -f /etc/prelink.cache + # Restart init if needed + [ -n "$(find `ldd /sbin/init | awk 'NF == 4 { print $3 }'` /sbin/init -ctime -1 2>/dev/null )" ] && /sbin/telinit u + fi + exit 0 +fi + +if [ ! -f /etc/prelink.cache -o -f /var/lib/prelink/force ] \ + || grep -q '^prelink-ELF0.[0-2]' /etc/prelink.cache; then + # If cache does not exist or is from older prelink versions or + # if we were asked to explicitely, force full prelinking + rm -f /etc/prelink.cache /var/lib/prelink/force + PRELINK_OPTS="$PRELINK_OPTS -f" + date > /var/lib/prelink/full + cp -a /var/lib/prelink/{full,quick} +elif [ -n "$PRELINK_FULL_TIME_INTERVAL" \ + -a "`find /var/lib/prelink/full -mtime -${PRELINK_FULL_TIME_INTERVAL} 2>/dev/null`" \ + = /var/lib/prelink/full ]; then + # If no more than PRELINK_NONRPM_CHECK_INTERVAL days elapsed from last prelink + # (be it full or quick) and no packages have been upgraded via rpm since then, + # don't do anything. + [ "`find /var/lib/prelink/quick -mtime -${PRELINK_NONRPM_CHECK_INTERVAL:-7} 2>/dev/null`" \ + -a -f /var/lib/rpm/Packages \ + -a /var/lib/rpm/Packages -ot /var/lib/prelink/quick ] && exit 0 + date > /var/lib/prelink/quick + # If prelink without -q has been run in the last + # PRELINK_FULL_TIME_INTERVAL days, just use quick mode + PRELINK_OPTS="$PRELINK_OPTS -q" +else + date > /var/lib/prelink/full + cp -a /var/lib/prelink/{full,quick} +fi + +echo /usr/sbin/prelink -av $PRELINK_OPTS > /var/log/prelink/prelink.log +/usr/sbin/prelink -av $PRELINK_OPTS >> /var/log/prelink/prelink.log 2>&1 \ + || echo Prelink failed with return value $? >> /var/log/prelink/prelink.log +# Restart init if needed +[ -n "$(find `ldd /sbin/init | awk 'NF == 4 { print $3 }'` /sbin/init -ctime -1 2>/dev/null )" ] && /sbin/telinit u + +exit 0 diff --git a/prelink.spec b/prelink.spec new file mode 100644 index 0000000..044ed7f --- /dev/null +++ b/prelink.spec @@ -0,0 +1,129 @@ +Name: prelink +Version: 20130503 +Release: 1mamba +Summary: ELF prelinking utility to speed up dynamic linking +Group: System/Tools +Vendor: openmamba +Distribution: openmamba +Packager: Silvan Calarco +URL: ftp://people.redhat.com/jakub/prelink/ +Source0: http://people.redhat.com/jakub/prelink/prelink-%{version}.tar.bz2 +# SOURCE1: see doc/prelink.conf +Source1: prelink.conf +Source2: prelink.cron +Source3: prelink.sysconfig +License: GPL +BuildRequires: libelf-devel +BuildRequires: libselinux-devel +BuildRequires: transfig +BuildRequires: tetex +BuildRequires: tetex-latex +BuildRoot: %{_tmppath}/%{name}-%{version}-root + +%description +ELF prelinking utility to speed up dynamic linking. + +%package doc +Summary: Documentation for the prelink tool +Group: Documentation +Requires: %{name} = %{?epoch:%epoch:}%{version}-%{release} + +%description doc +ELF prelinking utility to speed up dynamic linking. +This package includes pdf documentation for for prelink. + +%prep +%setup -q -n %{name} + +%build +%configure \ + --disable-shared \ + LIBS="-lpthread" + +%make + +#% ifnarch arm +#make -C testsuite check-harder +#make -C testsuite check-cycle +#% endif + +%install +[ "%{buildroot}" != / ] && rm -rf %{buildroot} +%makeinstall + +install -d %{buildroot}%{_sysconfdir}/{cron.daily,sysconfig,prelink.conf.d} +install -m644 %{S:1} %{buildroot}%{_sysconfdir}/prelink.conf +install -m755 %{S:2} %{buildroot}%{_sysconfdir}/cron.daily/prelink +install -m644 %{S:3} %{buildroot}%{_sysconfdir}/sysconfig/prelink + +install -d %{buildroot}/var/lib/prelink +touch %{buildroot}/var/lib/prelink/full +touch %{buildroot}/var/lib/prelink/quick +touch %{buildroot}/var/lib/prelink/force + +install -d %{buildroot}/var/log/prelink +touch %{buildroot}/var/log/prelink/prelink.log + +#install -d %{buildroot}%{_sysconfdir}/rpm +#cat > %{buildroot}%{_sysconfdir}/rpm/macros.prelink <<"EOF" +## rpm-4.1 verifies prelinked libraries using a prelink undo helper. +## Note: The 2nd token is used as argv[0] and "library" is a +## placeholder that will be deleted and replaced with the appropriate +## library file path. +##%%__prelink_undo_cmd /usr/sbin/prelink prelink -y library +#EOF +#chmod 644 %{buildroot}%{_sysconfdir}/rpm/macros.prelink + +%clean +[ "%{buildroot}" != / ] && rm -rf %{buildroot} + +%post +touch /var/lib/prelink/force +exit 0 + +%files +%defattr(-,root,root) +%{_bindir}/execstack +%{_sbindir}/prelink +%config(noreplace) %{_sysconfdir}/prelink.conf +%config(noreplace) %{_sysconfdir}/sysconfig/prelink +%{_sysconfdir}/cron.daily/prelink +#%{_sysconfdir}/rpm/macros.prelink +%dir %attr(0755,root,root) %{_sysconfdir}/prelink.conf.d +%dir /var/lib/prelink +%attr(0644,root,root) %ghost %config(missingok,noreplace) /var/lib/prelink/full +%attr(0644,root,root) %ghost %config(missingok,noreplace) /var/lib/prelink/quick +%attr(0644,root,root) %ghost %config(missingok,noreplace) /var/lib/prelink/force +%dir /var/log/prelink +%attr(0644,root,root) %ghost %config(missingok,noreplace) /var/log/prelink/prelink.log +%{_mandir}/man8/execstack.* +%{_mandir}/man8/prelink.* +%doc AUTHORS COPYING ChangeLog NEWS README THANKS TODO + +%files doc +%defattr(-,root,root) +%doc doc/prelink.pdf + +%changelog +* Wed Jul 24 2013 Automatic Build System 20130503-1mamba +- automatic update by autodist + +* Fri Oct 14 2011 Automatic Build System 20111012-1mamba +- automatic version update by autodist + +* Wed Dec 22 2010 Davide Madrisan 20100106-1mamba +- update to 20100106 +- move files from /var/lib/misc to /var/lib/prelink/ +- own /var/log/prelink + +* Mon Jun 29 2009 Silvan Calarco 20061201-3mamba +- specfile updated and rebuilt + +* Fri Feb 23 2007 Silvan Calarco 20061201-2qilnx +- prelink cron: add support for PRELINK_NOINITCHECK to disable relaunching init + +* Fri Jan 19 2007 Davide Madrisan 20061201-1qilnx +- update to version 20061201 by autospec + +* Fri Dec 23 2005 Davide Madrisan 20050610-1qilnx +- package created by autospec diff --git a/prelink.sysconfig b/prelink.sysconfig new file mode 100644 index 0000000..db8c22f --- /dev/null +++ b/prelink.sysconfig @@ -0,0 +1,37 @@ +# Set this to no to disable prelinking altogether +# (if you change this from yes to no prelink -ua +# will be run next night to undo prelinking) +PRELINKING=yes + +# Options to pass to prelink +# -m Try to conserve virtual memory by allowing overlapping +# assigned virtual memory slots for libraries which +# never appear together in one binary +# -R Randomize virtual memory slot assignments for libraries. +# This makes it slightly harder for various buffer overflow +# attacks, since library addresses will be different on each +# host using -R. +PRELINK_OPTS=-mR + +# How often should full prelink be run (in days) +# Normally, prelink will be run in quick mode, every +# $PRELINK_FULL_TIME_INTERVAL days it will be run +# in normal mode. Comment it out if it should be run +# in normal mode always. +PRELINK_FULL_TIME_INTERVAL=14 + +# How often should prelink run (in days) even if +# no packages have been upgraded via rpm. +# If $PRELINK_FULL_TIME_INTERVAL days have not elapsed +# yet since last normal mode prelinking, last +# quick mode prelinking happened less than +# $PRELINK_NONRPM_CHECK_INTERVAL days ago +# and no packages have been upgraded by rpm +# since last quick mode prelinking, prelink +# will not do anything. +# Change to +# PRELINK_NONRPM_CHECK_INTERVAL=0 +# if you want to disable the rpm database timestamp +# check (especially if you don't use rpm/up2date/yum/apt-rpm +# exclusively to upgrade system libraries and/or binaries). +PRELINK_NONRPM_CHECK_INTERVAL=7