summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorRaphaël Hertzog <hertzog@debian.org>2011-09-12 10:20:05 +0200
committerRaphaël Hertzog <hertzog@debian.org>2011-09-12 10:20:05 +0200
commitbf9cefeb7abd4bb0445b3a39a74d5594e247cd8e (patch)
treeb13cf48128fc682f71d4f02488e0d20cefa5ee3e /utils
parent9dcb50a59414e1fe0e6a8a4c8ee9f59d10706396 (diff)
downloaddpkg-bf9cefeb7abd4bb0445b3a39a74d5594e247cd8e.tar.gz
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.
Diffstat (limited to 'utils')
-rw-r--r--utils/update-alternatives.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index 3b3bad5ad..2ac02e4d9 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);