Message ID | xna78awjsl.fsf@greed.delorie.com |
---|---|
State | Not applicable |
Headers |
Received: (qmail 81400 invoked by alias); 2 Dec 2019 20:32:17 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <libc-alpha.sourceware.org> List-Unsubscribe: <mailto:libc-alpha-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:libc-alpha-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 81388 invoked by uid 89); 2 Dec 2019 20:32:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy= X-HELO: us-smtp-delivery-1.mimecast.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575318734; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vUrGE/y2GAVUMdC3HFrIyK0p1d4PcznkA8dtEjUo1Dc=; b=WCHTO2I07hhKHYPaw3EXENmAYkrsy/13g5D8khpGZOMW33D1zmEefrPjDqtbu+0gOVFzsD pxV/IelCXwFbp+PvHTc5OQYfz7Dgs1Rdsqz6H5W1sFcUTdWmJSfm3Af2vH2l8ftHYYUoWw 9R9xOlMKAHOO03L7olKGNlxqWYqrrZc= Date: Mon, 02 Dec 2019 15:32:10 -0500 Message-Id: <xna78awjsl.fsf@greed.delorie.com> From: DJ Delorie <dj@redhat.com> To: mtk.manpages@gmail.com CC: linux-man@vger.kernel.org, libc-alpha@sourceware.org Subject: [patch] ldconfig.8: Document file filter and symlink pattern expectations X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable |
Commit Message
DJ Delorie
Dec. 2, 2019, 8:32 p.m. UTC
Information gleaned from comments in glibc's elf/ldconfig.c
Comments
On 12/2/19 3:32 PM, DJ Delorie wrote: > > Information gleaned from comments in glibc's elf/ldconfig.c > > diff --git a/man8/ldconfig.8 b/man8/ldconfig.8 > index 4f799962c..15585243c 100644 > --- a/man8/ldconfig.8 > +++ b/man8/ldconfig.8 > @@ -93,6 +93,28 @@ option. > .B ldconfig > should normally be run by the superuser as it may require write > permission on some root owned directories and files. > +.PP > +Note that > +.B ldconfig > +will only look at files that are named > +.I lib*.so* > +(for regular shared objects) or > +.I ld-*.so* > +(for the dynamic loader itsef). Other files will be ignored. Also, > +.B ldconfig > +expects a certain pattern to how the symlinks are set up, like this > +example, where the middle file > +.RB ( libfoo.so.1 > +here) is the SONAME for the library: > +.PP > +.in +4n > +.EX > +libfoo.so -> libfoo.so.1 -> libfoo.so.1.12 > +.EE > +.in > +.PP > +Failure to follow this pattern may result in compatibility issues > +after an upgrade. > .SH OPTIONS > .TP > .BR \-c " \fIfmt\fP, " \-\-format=\fIfmt\fP > I wrote the relevant comment in glibc here after a frustrating night of debugging :-) elf/ldconfig.c 884 /* If the path the link points to isn't its soname or it is not 885 the .so symlink for ld(1), we treat it as a normal file. 886 887 You should always do this: 888 889 libfoo.so -> SONAME -> Arbitrary package-chosen name. 890 891 e.g. libfoo.so -> libfoo.so.1 -> libfooimp.so.9.99. 892 Given a SONAME of libfoo.so.1. 893 894 You should *never* do this: 895 896 libfoo.so -> libfooimp.so.9.99 897 898 If you do, and your SONAME is libfoo.so.1, then libfoo.so 899 fails to point at the SONAME. In that case ldconfig may consider 900 libfoo.so as another implementation of SONAME and will create 901 symlinks against it causing problems when you try to upgrade 902 or downgrade. The problems will arise because ldconfig will, 903 depending on directory ordering, creat symlinks against libfoo.so 904 e.g. libfoo.so.1.2 -> libfoo.so, but when libfoo.so is removed 905 (typically by the removal of a development pacakge not required 906 for the runtime) it will break the libfoo.so.1.2 symlink and the 907 application will fail to start. */ Should we be more specific about always doing: libfoo.so -> SONAME -> Arbitrary package-chosen name. Users love having examples of how to do it right :-)
On 12/2/19 9:32 PM, DJ Delorie wrote: > > Information gleaned from comments in glibc's elf/ldconfig.c Thanks, DJ. Patch applied. Cheers, Michael > diff --git a/man8/ldconfig.8 b/man8/ldconfig.8 > index 4f799962c..15585243c 100644 > --- a/man8/ldconfig.8 > +++ b/man8/ldconfig.8 > @@ -93,6 +93,28 @@ option. > .B ldconfig > should normally be run by the superuser as it may require write > permission on some root owned directories and files. > +.PP > +Note that > +.B ldconfig > +will only look at files that are named > +.I lib*.so* > +(for regular shared objects) or > +.I ld-*.so* > +(for the dynamic loader itsef). Other files will be ignored. Also, > +.B ldconfig > +expects a certain pattern to how the symlinks are set up, like this > +example, where the middle file > +.RB ( libfoo.so.1 > +here) is the SONAME for the library: > +.PP > +.in +4n > +.EX > +libfoo.so -> libfoo.so.1 -> libfoo.so.1.12 > +.EE > +.in > +.PP > +Failure to follow this pattern may result in compatibility issues > +after an upgrade. > .SH OPTIONS > .TP > .BR \-c " \fIfmt\fP, " \-\-format=\fIfmt\fP >
Hi Carlis, On 12/2/19 10:41 PM, Carlos O'Donell wrote: > On 12/2/19 3:32 PM, DJ Delorie wrote: >> >> Information gleaned from comments in glibc's elf/ldconfig.c >> >> diff --git a/man8/ldconfig.8 b/man8/ldconfig.8 >> index 4f799962c..15585243c 100644 >> --- a/man8/ldconfig.8 >> +++ b/man8/ldconfig.8 >> @@ -93,6 +93,28 @@ option. >> .B ldconfig >> should normally be run by the superuser as it may require write >> permission on some root owned directories and files. >> +.PP >> +Note that >> +.B ldconfig >> +will only look at files that are named >> +.I lib*.so* >> +(for regular shared objects) or >> +.I ld-*.so* >> +(for the dynamic loader itsef). Other files will be ignored. Also, >> +.B ldconfig >> +expects a certain pattern to how the symlinks are set up, like this >> +example, where the middle file >> +.RB ( libfoo.so.1 >> +here) is the SONAME for the library: >> +.PP >> +.in +4n >> +.EX >> +libfoo.so -> libfoo.so.1 -> libfoo.so.1.12 >> +.EE >> +.in >> +.PP >> +Failure to follow this pattern may result in compatibility issues >> +after an upgrade. >> .SH OPTIONS >> .TP >> .BR \-c " \fIfmt\fP, " \-\-format=\fIfmt\fP >> > > I wrote the relevant comment in glibc here after a frustrating > night of debugging :-) > > elf/ldconfig.c > > 884 /* If the path the link points to isn't its soname or it is not > 885 the .so symlink for ld(1), we treat it as a normal file. > 886 > 887 You should always do this: > 888 > 889 libfoo.so -> SONAME -> Arbitrary package-chosen name. > 890 > 891 e.g. libfoo.so -> libfoo.so.1 -> libfooimp.so.9.99. > 892 Given a SONAME of libfoo.so.1. > 893 > 894 You should *never* do this: > 895 > 896 libfoo.so -> libfooimp.so.9.99 > 897 > 898 If you do, and your SONAME is libfoo.so.1, then libfoo.so > 899 fails to point at the SONAME. In that case ldconfig may consider > 900 libfoo.so as another implementation of SONAME and will create > 901 symlinks against it causing problems when you try to upgrade > 902 or downgrade. The problems will arise because ldconfig will, > 903 depending on directory ordering, creat symlinks against libfoo.so > 904 e.g. libfoo.so.1.2 -> libfoo.so, but when libfoo.so is removed > 905 (typically by the removal of a development pacakge not required > 906 for the runtime) it will break the libfoo.so.1.2 symlink and the > 907 application will fail to start. */ Thanks for that added info. > Should we be more specific about always doing: > > libfoo.so -> SONAME -> Arbitrary package-chosen name. > > Users love having examples of how to do it right :-) Well, I applied DJ's patch. Would you be willing to send a small patch with this extra info? Thanks, Michael
diff --git a/man8/ldconfig.8 b/man8/ldconfig.8 index 4f799962c..15585243c 100644 --- a/man8/ldconfig.8 +++ b/man8/ldconfig.8 @@ -93,6 +93,28 @@ option. .B ldconfig should normally be run by the superuser as it may require write permission on some root owned directories and files. +.PP +Note that +.B ldconfig +will only look at files that are named +.I lib*.so* +(for regular shared objects) or +.I ld-*.so* +(for the dynamic loader itsef). Other files will be ignored. Also, +.B ldconfig +expects a certain pattern to how the symlinks are set up, like this +example, where the middle file +.RB ( libfoo.so.1 +here) is the SONAME for the library: +.PP +.in +4n +.EX +libfoo.so -> libfoo.so.1 -> libfoo.so.1.12 +.EE +.in +.PP +Failure to follow this pattern may result in compatibility issues +after an upgrade. .SH OPTIONS .TP .BR \-c " \fIfmt\fP, " \-\-format=\fIfmt\fP