policy.c, yaid.c: Silently ignore missing user policy files.
[yaid] / policy.c
index 32a4550..57ce979 100644 (file)
--- a/policy.c
+++ b/policy.c
@@ -443,13 +443,15 @@ fail:
  * formatting error messages for the log.
  */
 int open_policy_file(struct policy_file *pf, const char *name,
-                    const char *what, const struct query *q)
+                    const char *what, const struct query *q, unsigned f)
 {
   struct stat st;
 
   if ((pf->fp = fopen(name, "r")) == 0) {
-    logmsg(q, LOG_ERR, "failed to open %s `%s': %s",
-          what, name, strerror(errno));
+    if (errno != ENOENT || !(f & OPF_NOENTOK)) {
+      logmsg(q, LOG_ERR, "failed to open %s `%s': %s",
+            what, name, strerror(errno));
+    }
     goto err_0;
   }
 
@@ -529,7 +531,7 @@ int load_policy_file(const char *file, policy_v *pv)
   struct policy_file pf;
   policy_v v = DA_INIT;
 
-  if (open_policy_file(&pf, file, "policy file", 0))
+  if (open_policy_file(&pf, file, "policy file", 0, 0))
     return (-1);
   while (!read_policy_file(&pf)) {
     DA_PUSH(&v, pf.p);