瀏覽代碼

u-a: Do not check if linknames can be updated if --force is in use

The action is going to proceed in any case, no point wasting resources
doing the checks. Also this removes a possible point of non-overridable
failure.
Guillem Jover 15 年之前
父節點
當前提交
81412e6445
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      utils/update-alternatives.c

+ 4 - 1
utils/update-alternatives.c

@@ -1629,6 +1629,9 @@ alternative_can_replace_path(const char *linkname)
 	struct stat st;
 	bool replace_link;
 
+	if (opt_force)
+		return true;
+
 	errno = 0;
 	if (lstat(linkname, &st) == -1) {
 		if (errno != ENOENT)
@@ -1638,7 +1641,7 @@ alternative_can_replace_path(const char *linkname)
 		replace_link = S_ISLNK(st.st_mode);
 	}
 
-	return (replace_link || opt_force);
+	return replace_link;
 }
 
 static void