The following commit has been merged in the master branch:
commit bf9cefeb7abd4bb0445b3a39a74d5594e247cd8e
Author: Raphaël Hertzog <[email protected]>
Date:   Mon Sep 12 10:20:05 2011 +0200

    update-alternatives: use alternative_path_classify() more extensively
    
    Constructs like “lstat(foo, &st) == 0 && S_ISLNK(st.st_mode)” do not
    fail when lstat() fails and they should really fail except when
    the failure is due to a missing foo (ENOENT).
    
    Using alternative_path_classify() achieves this.

diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index 3b3bad5..2ac02e4 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -2094,7 +2094,7 @@ alternative_evolve(struct alternative *a, struct 
alternative *b,
        struct slave_link *sl;
        struct stat st;
 
-       bool is_link = (lstat(a->master_link, &st) == 0 && S_ISLNK(st.st_mode));
+       bool is_link = (alternative_path_classify(a->master_link) == 
ALT_PATH_SYMLINK);
        if (is_link && strcmp(a->master_link, b->master_link) != 0) {
                info(_("renaming %s link from %s to %s."), b->master_name,
                     a->master_link, b->master_link);
@@ -2124,8 +2124,8 @@ alternative_evolve(struct alternative *a, struct 
alternative *b,
                        new_file = areadlink(lnk);
                        free(lnk);
                }
-               if (strcmp(old, new) != 0 && lstat(old, &st) == 0 &&
-                   S_ISLNK(st.st_mode)) {
+               if (strcmp(old, new) != 0 &&
+                   alternative_path_classify(old) == ALT_PATH_SYMLINK) {
                        if (new_file && stat(new_file, &st) == 0) {
                                info(_("renaming %s slave link from %s to %s."),
                                     sl->name, old, new);

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to