* 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;
}
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);
*/
DRESET(&d);
dstr_putf(&d, "%s/.yaid.policy", pw->pw_dir);
- if (open_policy_file(&pf, d.buf, "user policy file", &c->q))
+ if (open_policy_file(&pf, d.buf, "user policy file", &c->q, OPF_NOENTOK))
continue;
while (!read_policy_file(&pf)) {
* formatting error messages for the log.
*/
extern 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*/);
+#define OPF_NOENTOK 1u /* Don't complain if file missing */
/* Read a policy rule from the file, storing it in PF->p. Return one of the
* T_* codes.