From patchwork Thu Feb 11 13:07:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 581880 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6CCBB140BA5 for ; Fri, 12 Feb 2016 00:07:40 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=Qv8tMdzZ; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:from:subject:message-id:date:mime-version :content-type; q=dns; s=default; b=P6kFu7N3cSZtSvzCIuFWjQpWlBBLb dNFH4m3P7dBP23k02yYx7hAquFloIVGbvpjl/0zgRK8QuePqZ9fjs05E8lftENqz DFDDzbV0jLDmq2h8DSmGfM0m87LAt1HWFl/0kHPuNMLeTbOqkWgGViAIQDAMd7uD dvlMb9YoEJsTJg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:from:subject:message-id:date:mime-version :content-type; s=default; bh=hGV1xeEtP7FEjZ0v1HRZp+G88zA=; b=Qv8 tMdzZUOfiQYaypXThyz9CMQJShzxE6uNyuTHnFK4nhlxIF2CTm+qWb6pr0AfkNZm 8xKy7uAJq2i0h0qDVl5yk1gbEZRL/S/KVvfOAtwB7INiwDOd/auTq6QdFKK7q9LR tk4I8oTIDvEaddQSkjbjYMrJ3w/qN3iT46DL9aJg= Received: (qmail 127589 invoked by alias); 11 Feb 2016 13:07:33 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 127576 invoked by uid 89); 11 Feb 2016 13:07:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=conf X-HELO: mx1.redhat.com To: GNU C Library From: Florian Weimer Subject: [PATCH] ldconfig: Do not remove stale symbolic links with -X [BZ #19610] Message-ID: <56BC8790.1080400@redhat.com> Date: Thu, 11 Feb 2016 14:07:28 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 I think this change makes ldconfig match user expectations. Florian 2016-02-11 Florian Weimer [BZ #19610] * elf/ldconfig.c (search_dir): Unlink stale symbolic link only if updating symbolic links. (options): Update help string for option -X. * elf/bug19610.sh: New file. * elf/Makefile (tests-special): Add bug19610.out. (bug19610.out): New rule to run bug19610.sh. diff --git a/elf/Makefile b/elf/Makefile index 63a5355..4655033 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -163,7 +163,8 @@ endif endif ifeq ($(run-built-tests),yes) tests-special += $(objpfx)tst-leaks1-mem.out \ - $(objpfx)tst-leaks1-static-mem.out $(objpfx)noload-mem.out + $(objpfx)tst-leaks1-static-mem.out $(objpfx)noload-mem.out \ + $(objpfx)bug19610.out endif tlsmod17a-suffixes = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 tlsmod18a-suffixes = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 @@ -1252,3 +1253,7 @@ $(objpfx)tst-prelink-cmp.out: tst-prelink.exp \ $(objpfx)tst-prelink-conflict.out cmp $^ > $@; \ $(evaluate-test) + +$(objpfx)bug19610.out : bug19610.sh $(objpfx)ldconfig + $(SHELL) $< '$(common-objpfx)' '$(test-wrapper)' '$(test-wrapper-env)' > $@; \ + $(evaluate-test) diff --git a/elf/bug19610.sh b/elf/bug19610.sh new file mode 100644 index 0000000..f125bc1 --- /dev/null +++ b/elf/bug19610.sh @@ -0,0 +1,60 @@ +#!/bin/sh +# Test that ldconfig -X does not remove stale symbolic links. +# Copyright (C) 2000-2016 Free Software Foundation, Inc. +# This file is part of the GNU C Library. + +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. + +# The GNU C Library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. + +# You should have received a copy of the GNU Lesser General Public +# License along with the GNU C Library; if not, see +# . + +set -ex + +common_objpfx=$1 +test_wrapper_env=$2 +run_program_env=$3 + +testroot="${common_objpfx}elf/bug19610-test-directory" +cleanup () { + rm -rf "$testroot" +} +trap cleanup 0 + +rm -rf "$testroot" +mkdir -p $testroot/lib $testroot/etc + +ln -s libdoesnotexist.so.1.1 $testroot/lib/libdoesnotexist.so.1 +ln -s /opt/sw/lib/libdoesnotexist2.so.1.1 $testroot/lib/ + +errors=0 +check_files () { + for name in libdoesnotexist.so.1 libdoesnotexist2.so.1.1 ; do + path="$testroot/lib/$name" + if test ! -h $path ; then + echo "error: missing file: $path" + errors=1 + fi + done +} + +check_files + +${test_wrapper_env} \ +${run_program_env} \ +${common_objpfx}elf/ldconfig -X -f /dev/null \ + -C $testroot/etc/ld.so.cache \ + $testroot/lib + +check_files + +exit $errors + diff --git a/elf/ldconfig.c b/elf/ldconfig.c index 9c6f2ba..5890322 100644 --- a/elf/ldconfig.c +++ b/elf/ldconfig.c @@ -141,7 +141,7 @@ static const struct argp_option options[] = { "print-cache", 'p', NULL, 0, N_("Print cache"), 0}, { "verbose", 'v', NULL, 0, N_("Generate verbose messages"), 0}, { NULL, 'N', NULL, 0, N_("Don't build cache"), 0}, - { NULL, 'X', NULL, 0, N_("Don't generate links"), 0}, + { NULL, 'X', NULL, 0, N_("Don't update symbolic links"), 0}, { NULL, 'r', N_("ROOT"), 0, N_("Change to and use ROOT as root directory"), 0}, { NULL, 'C', N_("CACHE"), 0, N_("Use CACHE as cache file"), 0}, { NULL, 'f', N_("CONF"), 0, N_("Use CONF as configuration file"), 0}, @@ -800,7 +800,7 @@ search_dir (const struct dir_entry *entry) error (0, errno, _("Cannot stat %s"), file_name); /* Remove stale symlinks. */ - if (strstr (direntry->d_name, ".so.")) + if (opt_link && strstr (direntry->d_name, ".so.")) unlink (real_file_name); continue; }