]> git.armaanb.net Git - opendoas.git/blobdiff - doas.c
Merge doas.c 1.34 from OpenBSD CVS.
[opendoas.git] / doas.c
diff --git a/doas.c b/doas.c
index a7c7be238d3f971eadc504037bf9324b60b688f7..f0cbab295bfb265cc4c03f9bf2e4077c0e68d293 100644 (file)
--- a/doas.c
+++ b/doas.c
@@ -19,8 +19,6 @@
 #include <sys/stat.h>
 
 #include <limits.h>
-#include <login_cap.h>
-#include <bsd_auth.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -31,6 +29,8 @@
 #include <syslog.h>
 #include <errno.h>
 
+#include "openbsd.h"
+
 #include "doas.h"
 
 static void __dead
@@ -45,9 +45,11 @@ arraylen(const char **arr)
 {
        size_t cnt = 0;
 
-       while (*arr) {
-               cnt++;
-               arr++;
+       if (arr) {
+               while (*arr) {
+                       cnt++;
+                       arr++;
+               }
        }
        return cnt;
 }
@@ -162,10 +164,7 @@ parseconfig(const char *filename, int checkperms)
 
        yyfp = fopen(filename, "r");
        if (!yyfp) {
-               if (checkperms)
-                       fprintf(stderr, "doas is not enabled.\n");
-               else
-                       warn("could not open config file");
+               warn("could not open config file");
                exit(1);
        }
 
@@ -188,10 +187,10 @@ parseconfig(const char *filename, int checkperms)
  * Copy the environment variables in safeset from oldenvp to envp.
  */
 static int
-copyenvhelper(const char **oldenvp, const char **safeset, int nsafe,
+copyenvhelper(const char **oldenvp, const char **safeset, size_t nsafe,
     char **envp, int ei)
 {
-       int i;
+       size_t i;
 
        for (i = 0; i < nsafe; i++) {
                const char **oe = oldenvp;
@@ -224,8 +223,8 @@ copyenv(const char **oldenvp, struct rule *rule)
        char **envp;
        const char **extra;
        int ei;
-       int nsafe, nbad;
-       int nextras = 0;
+       size_t nsafe, nbad;
+       size_t nextras = 0;
 
        /* if there was no envvar whitelist, pass all except badset ones */
        nbad = arraylen(badset);