]> git.armaanb.net Git - opendoas.git/commitdiff
Merge doas.c 1.34 from OpenBSD CVS.
authorNathan Holstein <nathan.holstein@gmail.com>
Wed, 5 Aug 2015 15:01:36 +0000 (11:01 -0400)
committerNathan Holstein <nathan.holstein@gmail.com>
Wed, 5 Aug 2015 16:38:09 +0000 (12:38 -0400)
1  2 
doas.c

diff --combined doas.c
index 6fabd7bf1b9887dbf65f1d60f1f8cd906623b455,a7c7be238d3f971eadc504037bf9324b60b688f7..f0cbab295bfb265cc4c03f9bf2e4077c0e68d293
--- 1/doas.c
--- 2/doas.c
+++ b/doas.c
@@@ -1,4 -1,4 +1,4 @@@
- /* $OpenBSD: doas.c,v 1.32 2015/07/29 00:00:31 tedu Exp $ */
+ /* $OpenBSD: doas.c,v 1.33 2015/07/30 17:04:33 tedu Exp $ */
  /*
   * Copyright (c) 2015 Ted Unangst <tedu@openbsd.org>
   *
@@@ -19,6 -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>
@@@ -29,8 -31,6 +29,8 @@@
  #include <syslog.h>
  #include <errno.h>
  
 +#include "openbsd.h"
 +
  #include "doas.h"
  
  static void __dead
@@@ -45,11 -45,9 +45,11 @@@ arraylen(const char **arr
  {
        size_t cnt = 0;
  
 -      while (*arr) {
 -              cnt++;
 -              arr++;
 +      if (arr) {
 +              while (*arr) {
 +                      cnt++;
 +                      arr++;
 +              }
        }
        return cnt;
  }
@@@ -164,7 -162,10 +164,7 @@@ parseconfig(const char *filename, int c
  
        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);
        }
  
   * 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;
@@@ -223,8 -224,8 +223,8 @@@ copyenv(const char **oldenvp, struct ru
        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);
@@@ -332,6 -333,7 +332,7 @@@ main(int argc, char **argv, char **envp
        int nflag = 0;
  
        uid = getuid();
        while ((ch = getopt(argc, argv, "C:nsu:")) != -1) {
                switch (ch) {
                case 'C':
        } else if ((!sflag && !argc) || (sflag && argc))
                usage();
  
-       uid = getuid();
        pw = getpwuid(uid);
        if (!pw)
                err(1, "getpwuid failed");