unveil(2) "path" (/dev/audioctl0 by default, or changed via args) with rw
authormestre <mestre@openbsd.org>
Mon, 17 Sep 2018 14:14:39 +0000 (14:14 +0000)
committermestre <mestre@openbsd.org>
Mon, 17 Sep 2018 14:14:39 +0000 (14:14 +0000)
access and disable further calls to unveil(2) with unveil(NULL, NULL).

OK ratchov@

usr.bin/audioctl/audioctl.c

index bbc035a..706df9a 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: audioctl.c,v 1.35 2017/05/31 04:18:58 jsg Exp $       */
+/*     $OpenBSD: audioctl.c,v 1.36 2018/09/17 14:14:39 mestre Exp $    */
 /*
  * Copyright (c) 2016 Alexandre Ratchov <alex@caoua.org>
  *
@@ -217,6 +217,11 @@ main(int argc, char **argv)
        argc -= optind;
        argv += optind;
 
+       if (unveil(path, "rw") == -1)
+               err(1, "unveil");
+       if (unveil(NULL, NULL) == -1)
+               err(1, "unveil");
+
        fd = open(path, O_RDWR);
        if (fd < 0)
                err(1, "%s", path);