chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
kmsg-syslogd: pass facility value into kmsg
[elogind.git]
/
src
/
condition.c
diff --git
a/src/condition.c
b/src/condition.c
index 1dce276c00575004f48ecde1ff40de576a8ed771..b404b49c925eba8c92a6a97420d0829c148c6c3a 100644
(file)
--- a/
src/condition.c
+++ b/
src/condition.c
@@
-30,7
+30,9
@@
Condition* condition_new(ConditionType type, const char *parameter, bool trigger, bool negate) {
Condition *c;
Condition* condition_new(ConditionType type, const char *parameter, bool trigger, bool negate) {
Condition *c;
- c = new0(Condition, 1);
+ if (!(c = new0(Condition, 1)))
+ return NULL;
+
c->type = type;
c->trigger = trigger;
c->negate = negate;
c->type = type;
c->trigger = trigger;
c->negate = negate;
@@
-134,6
+136,14
@@
bool condition_test(Condition *c) {
case CONDITION_PATH_EXISTS:
return (access(c->parameter, F_OK) >= 0) == !c->negate;
case CONDITION_PATH_EXISTS:
return (access(c->parameter, F_OK) >= 0) == !c->negate;
+ case CONDITION_PATH_IS_DIRECTORY: {
+ struct stat st;
+
+ if (lstat(c->parameter, &st) < 0)
+ return !c->negate;
+ return S_ISDIR(st.st_mode) == !c->negate;
+ }
+
case CONDITION_DIRECTORY_NOT_EMPTY: {
int k;
case CONDITION_DIRECTORY_NOT_EMPTY: {
int k;