<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://bugs.gentoo.org/bugzilla.dtd">

<bugzilla version="2.22.7"
          urlbase="http://bugs.gentoo.org/"
          maintainer="bugzilla@gentoo.org"
>

    <bug>
          <bug_id>91141</bug_id>
          
          <creation_ts>2005-05-02 02:53 0000</creation_ts>
          <short_desc>Sed filter in init.d/xmail fails to copy ld-linux.so.2 causing XMail to segfault</short_desc>
          <delta_ts>2005-06-06 06:24:03 0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Gentoo Linux</product>
          <component>Applications</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          
          <priority>P2</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>39817</blocked>
          
          <everconfirmed>1</everconfirmed>
          <reporter>quinox_san_@hotmail.com</reporter>
          <assigned_to>net-mail@gentoo.org</assigned_to>
          

      

      
          <long_desc isprivate="0">
            <who>quinox_san_@hotmail.com</who>
            <bug_when>2005-05-02 02:53:52 0000</bug_when>
            <thetext>Hi, there is a problem with the /etc/init.d/xmail file, it fails to copy lib files if they are listed in a specific way. I found this out after upgrading my glibc version and xmail segfaulting. I traced it down to an outdated ld-linux.so.2 in my /chroot/xmail/lib . This is caused by the sed filter from the init file that fails to copy the file. The output of ldd /var/MailRoot/bin/XMail:

        linux-gate.so.1 =&gt;  (0xffffe000)
        libdl.so.2 =&gt; /lib/libdl.so.2 (0xb7fd0000)
        libpthread.so.0 =&gt; /lib/libpthread.so.0 (0xb7f7d000)
        libstdc++.so.5 =&gt; /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5-20050130/libstdc++.so.5 (0xb7eb1000)
        libm.so.6 =&gt; /lib/libm.so.6 (0xb7e8c000)
        libgcc_s.so.1 =&gt; /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5-20050130/libgcc_s.so.1 (0xb7e83000)
        libc.so.6 =&gt; /lib/libc.so.6 (0xb7d57000)
        /lib/ld-linux.so.2 (0xb7fea000)

After applying the sed filter -n &apos;s/[[:blank:]]*[^=]*=&gt;\([^(]*\).*/\1/p&apos;, these files be copied to the chrooted lib directory:

 /lib/libdl.so.2
 /lib/libpthread.so.0
 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5-20050130/libstdc++.so.5
 /lib/libm.so.6
 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5-20050130/libgcc_s.so.1
 /lib/libc.so.6

Clearly the ld-linux.so.2 library is missing. This is caused by the requirement that a line should contain a =&gt;. This problem is solvable by using a slightly modified sed filter. Using  sed -n &apos;s/[[:blank:]]*\([^=]*\=&gt;\)\? \([^(]*\)
.*/\2/p;&apos; the output will be:

/lib/libdl.so.2
/lib/libpthread.so.0
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5-20050130/libstdc++.so.5
/lib/libm.so.6
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.5-20050130/libgcc_s.so.1
/lib/libc.so.6
/lib/ld-linux.so.2

which is correct for my system. This script might break things if the ldd output lines without a =&gt; can contain weird stuff, I can&apos;t say because I&apos;m no ldd expert.

Reproducible: Always
Steps to Reproduce:
1. Upgrading glibc
2. starting the chrooted version of xmail using /etc/init.d/xmail start

Actual Results:  
XMail will not start because of a segmentation fault

Expected Results:  
XMail should have started

Fix supplied, needs verification concerning the ldd output</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>quinox_san_@hotmail.com</who>
            <bug_when>2005-05-02 02:59:35 0000</bug_when>
            <thetext>The fixed sed filter shouldn&apos;t contain a newline in it. 

Patchfile (-Naur) for the fixed init.d/xmail file:

--- /usr/portage/mail-mta/xmail/files/xmail.initd       2004-07-15 01:05:55.000000000 +0200
+++ /etc/init.d/xmail   2005-05-02 11:58:11.000000000 +0200
@@ -70,7 +70,7 @@
        chown -R xmail:xmail ${CHROOT}
 
        cp `ldd ${CHROOT}${MAIL_ROOT}/bin/XMail |\
-       sed -n &apos;s/[[:blank:]]*[^=]*=&gt;\([^(]*\).*/\1/p&apos;` ${CHROOT}/lib/
+       sed -n &apos;s/[[:blank:]]*\([^=]*\=&gt;\)\? \([^(]*\).*/\2/p;&apos;` ${CHROOT}/lib/
        start-stop-daemon --start -c xmail -r ${CHROOT} \
                --startas ${MAIL_EXEC} --pidfile=${MAIL_PID} -- \
                ${MAIL_CMD_LINE} 
</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>ticho@gentoo.org</who>
            <bug_when>2005-06-06 06:24:03 0000</bug_when>
            <thetext>Fixed, thanks. Sorry it took a while, it&apos;s just no one here is using xmail. :/</thetext>
          </long_desc>
      
    </bug>

</bugzilla>