mirror of
https://github.com/slicer69/doas
synced 2024-10-07 00:19:09 +00:00
Avoid echoing stdin when output is piped to doas.
Fix asprintf() compile warning when building on Linux.
This commit is contained in:
parent
fe6d3a342b
commit
c8cb4d999e
3
Makefile
3
Makefile
|
@ -3,12 +3,13 @@ YACC?=yacc
|
|||
BIN=doas
|
||||
PREFIX?=/usr/local
|
||||
OBJECTS=doas.o env.o execvpe.o reallocarray.o y.tab.o
|
||||
CFLAGS+=-DUSE_PAM -DDOAS_CONF=\"${PREFIX}/etc/doas.conf\"
|
||||
CFLAGS+=-DUSE_PAM -DDOAS_CONF=\"${PREFIX}/etc/doas.conf\"
|
||||
LDFLAGS+=-lpam
|
||||
UNAME_S := $(shell uname -s)
|
||||
ifeq ($(UNAME_S),Linux)
|
||||
LDFLAGS+=-lpam_misc
|
||||
OBJECTS+=strlcat.o strlcpy.o
|
||||
CFLAGS+=-D_GNU_SOURCE
|
||||
endif
|
||||
ifeq ($(UNAME_S),FreeBSD)
|
||||
CFLAGS+=-DHAVE_LOGIN_CAP_H
|
||||
|
|
12
doas.c
12
doas.c
|
@ -433,7 +433,7 @@ main(int argc, char **argv)
|
|||
pam_handle_t *pamh = NULL;
|
||||
int pam_err;
|
||||
|
||||
#ifndef linux
|
||||
/* #ifndef linux */
|
||||
int temp_stdin;
|
||||
|
||||
/* openpam_ttyconv checks if stdin is a terminal and
|
||||
|
@ -450,7 +450,7 @@ main(int argc, char **argv)
|
|||
if (temp_stdin == -1)
|
||||
err(1, "dup");
|
||||
close(STDIN_FILENO);
|
||||
#else
|
||||
/* #else */
|
||||
/* force password prompt to display on stderr, not stdout */
|
||||
int temp_stdout = dup(1);
|
||||
if (temp_stdout == -1)
|
||||
|
@ -458,7 +458,7 @@ main(int argc, char **argv)
|
|||
close(1);
|
||||
if (dup2(2, 1) == -1)
|
||||
err(1, "dup2");
|
||||
#endif
|
||||
/* #endif */
|
||||
|
||||
pam_err = pam_start("doas", myname, &pamc, &pamh);
|
||||
if (pam_err != PAM_SUCCESS) {
|
||||
|
@ -510,17 +510,17 @@ main(int argc, char **argv)
|
|||
}
|
||||
pam_end(pamh, pam_err);
|
||||
|
||||
#ifndef linux
|
||||
/* #ifndef linux */
|
||||
/* Re-establish stdin */
|
||||
if (dup2(temp_stdin, STDIN_FILENO) == -1)
|
||||
err(1, "dup2");
|
||||
close(temp_stdin);
|
||||
#else
|
||||
/* #else */
|
||||
/* Re-establish stdout */
|
||||
close(1);
|
||||
if (dup2(temp_stdout, 1) == -1)
|
||||
err(1, "dup2");
|
||||
#endif
|
||||
/* #endif */
|
||||
#else
|
||||
#error No auth module!
|
||||
#endif
|
||||
|
|
4
env.c
4
env.c
|
@ -20,9 +20,9 @@
|
|||
#include <sys/tree.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <err.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
@ -90,7 +90,7 @@ createenv(struct rule *rule)
|
|||
env->count = 0;
|
||||
|
||||
if (rule->options & KEEPENV) {
|
||||
extern const char **environ;
|
||||
/* extern const char **environ; */
|
||||
|
||||
for (i = 0; environ[i] != NULL; i++) {
|
||||
struct envnode *node;
|
||||
|
|
Loading…
Reference in a new issue