- /* $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>
*
#include <sys/stat.h>
#include <limits.h>
-#include <login_cap.h>
-#include <bsd_auth.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>
#include <errno.h>
+#include "openbsd.h"
+
#include "doas.h"
static void __dead
{
size_t cnt = 0;
- while (*arr) {
- cnt++;
- arr++;
+ if (arr) {
+ while (*arr) {
+ cnt++;
+ arr++;
+ }
}
return cnt;
}
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;
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);
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");