/* $OpenBSD: setgid_none.c,v 1.1 2014/08/27 07:36:14 blambert Exp $ */ /* * Written by Bret Stephen Lambert 2014 * Public Domain. */ #include #include #include #include #include #include #include #include #include #include #include "setuid_regress.h" int main(int argc, const char *argv[]) { struct kinfo_proc kproc; gid_t gid; gid = getgid(); checkgids(gid, gid, gid, "checkgid"); /* should only respond to setgid upon exec */ if (issetugid()) errx(1, "process incorrectly marked as issetugid()"); if (read_kproc_pid(&kproc, getpid()) == -1) err(1, "kproc read failed"); if (kproc.p_psflags & PS_SUGID) errx(1, "PS_SUGID incorrectly set"); if (kproc.p_psflags & PS_SUGIDEXEC) errx(1, "PS_SUGIDEXEC incorrectly set"); exit(0); }