condition: fix reversed tests if path does not exist at all

CONDITION_PATH_IS_DIRECTORY, CONDITION_PATH_IS_SYMBOLIC_LINK and
CONDITION_FILE_IS_EXECUTABLE gave reversed results when the path
did not exist at all.
This commit is contained in:
Michal Schmidt
2011-09-23 02:10:00 +02:00
parent f8440af5fe
commit 1f8fef5a44
+3 -3
View File
@@ -163,7 +163,7 @@ bool condition_test(Condition *c) {
struct stat st;
if (stat(c->parameter, &st) < 0)
return !c->negate;
return c->negate;
return S_ISDIR(st.st_mode) == !c->negate;
}
@@ -171,7 +171,7 @@ bool condition_test(Condition *c) {
struct stat st;
if (lstat(c->parameter, &st) < 0)
return !c->negate;
return c->negate;
return S_ISLNK(st.st_mode) == !c->negate;
}
@@ -189,7 +189,7 @@ bool condition_test(Condition *c) {
struct stat st;
if (stat(c->parameter, &st) < 0)
return !c->negate;
return c->negate;
return (S_ISREG(st.st_mode) && (st.st_mode & 0111)) == !c->negate;
}