-/* $OpenBSD: kern_pledge.c,v 1.278 2022/01/20 03:43:30 jsg Exp $ */
+/* $OpenBSD: kern_pledge.c,v 1.279 2022/02/04 17:50:28 tedu Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
break;
case SYS_stat:
- /* DNS needs /etc/resolv.conf. */
+ /* DNS needs /etc/{resolv.conf,hosts}. */
if ((ni->ni_pledge == PLEDGE_RPATH) &&
- (pledge & PLEDGE_DNS) &&
- strcmp(path, "/etc/resolv.conf") == 0) {
- ni->ni_cnd.cn_flags |= BYPASSUNVEIL;
- return (0);
+ (pledge & PLEDGE_DNS)) {
+ if (strcmp(path, "/etc/resolv.conf") == 0) {
+ ni->ni_cnd.cn_flags |= BYPASSUNVEIL;
+ return (0);
+ }
+ if (strcmp(path, "/etc/hosts") == 0) {
+ ni->ni_cnd.cn_flags |= BYPASSUNVEIL;
+ return (0);
+ }
}
break;
}