Check setreuid() return value to eliminate warnings. Update makefile
This commit is contained in:
parent
ee01f9eefd
commit
5a83ea113c
7
makefile
7
makefile
@ -9,25 +9,26 @@ ifeq ($(OPSYS),Darwin)
|
||||
# mac: UNIX comms model, but on MACOSX
|
||||
OPTIONS = -DMACOSX
|
||||
LFLAGS = -lpthread
|
||||
BINDIR = /usr/local/bin
|
||||
else ifeq ($(OPSYS:CYGWIN%=CYGWIN),CYGWIN)
|
||||
# win: WINDOWS comms model under CYGWIN (any version)
|
||||
OPTIONS = -DCYGWIN -DWINCOMM
|
||||
LFLAGS = -lpthread -lrt
|
||||
BINDIR = /cygdrive/e/DEC/tools/exe
|
||||
else ifeq ($(OPSYS),Linux)
|
||||
# unix: UNIX comms model under LINUX, use PARMRK serial mode
|
||||
OPTIONS = -DLINUX -DUSE_PARMRK
|
||||
LFLAGS = -lpthread -lrt
|
||||
BINDIR = /usr/local/bin
|
||||
else # unknown environment
|
||||
OPTIONS =
|
||||
LFLAGS = -lpthread -lrt
|
||||
BINDIR = /usr/local/bin
|
||||
endif
|
||||
|
||||
# default program name, redefine PROG=xxx on command line if wanted
|
||||
PROG = tu58em
|
||||
|
||||
# put your binary installation directory here...
|
||||
BINDIR = /cygdrive/e/DEC/tools/exe
|
||||
|
||||
# compiler flags and libraries
|
||||
CC = gcc
|
||||
CFLAGS = -I. -O3 -Wall -c $(OPTIONS)
|
||||
|
||||
4
serial.c
4
serial.c
@ -586,10 +586,10 @@ void devinit (char *port,
|
||||
// open serial port
|
||||
int32_t euid = geteuid();
|
||||
int32_t uid = getuid();
|
||||
setreuid(euid, -1);
|
||||
if (setreuid(euid, -1)) fatal("setreuid(euid,-1) failed");
|
||||
if (sscanf(port, "%u", &n) == 1) sprintf(name, "/dev/ttyS%u", n-1); else strcpy(name, port);
|
||||
if ((device = open(name, O_RDWR|O_NDELAY|O_NOCTTY)) < 0) fatal("no serial line [%s]", name);
|
||||
setreuid(uid, euid);
|
||||
if (setreuid(uid, euid)) fatal("setreuid(uid,euid) failed");
|
||||
|
||||
// get current line params, error if not a serial port
|
||||
if (tcgetattr(device, &lineSave)) fatal("not a serial device [%s]", name);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user