Bläddra i källkod

Revert "u-a: Use xreadlink() instead of areadlink() in alternative_evolve()"

This reverts commit 6c481e19a532080643e3cf5c76760df8009ea2c7 and
changes the surrounding code to deal correctly with the case where
areadlink() returns NULL.

This part of the code really had to cope with a non-existing
/etc/alternatives/slave.

Reported-by: Sven Joachim <svenjoac@gmx.de>
Raphaël Hertzog 15 år sedan
förälder
incheckning
9dceac005a
1 ändrade filer med 2 tillägg och 2 borttagningar
  1. 2 2
      utils/update-alternatives.c

+ 2 - 2
utils/update-alternatives.c

@@ -2121,12 +2121,12 @@ alternative_evolve(struct alternative *a, struct alternative *b,
 			char *lnk;
 
 			xasprintf(&lnk, "%s/%s", altdir, sl->name);
-			new_file = xreadlink(lnk);
+			new_file = areadlink(lnk);
 			free(lnk);
 		}
 		if (strcmp(old, new) != 0 && lstat(old, &st) == 0 &&
 		    S_ISLNK(st.st_mode)) {
-			if (stat(new_file, &st) == 0) {
+			if (new_file && stat(new_file, &st) == 0) {
 				info(_("renaming %s slave link from %s to %s."),
 				     sl->name, old, new);
 				checked_mv(old, new);