From: Joshua Kwan Date: Fri, 2 Jan 2004 20:47:53 +0000 (+0000) Subject: works X-Git-Tag: v1.6.1-roc-dev~655 X-Git-Url: https://skyeroc.xyz/gitweb/?a=commitdiff_plain;h=3a2b0a7b0d8eed3d7198adcccb87d089b9a394f1;p=dgamelaunch works git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@43 db0b04b0-f4d1-0310-9a6d-de3e77497b0e --- diff --git a/Makefile b/Makefile index dd7c568..5c96a25 100644 --- a/Makefile +++ b/Makefile @@ -8,11 +8,11 @@ endif CC = gcc LDFLAGS = -CFLAGS = -g3 $(optimize) -Wall -W -Wno-unused-parameter $(DEFS) +CFLAGS = -g3 $(optimize) -Wall -W $(DEFS) DEFS = -DVERSION=\"$(VERSION)\" SRCS = virus.c ttyrec.c dgamelaunch.c io.c ttyplay.c stripgfx.c OBJS = $(SRCS:.c=.o) -LIBS = -lncurses -lcrypt +LIBS = -lncurses -lcrypt -lutil all: $(NAME) diff --git a/dgamelaunch.c b/dgamelaunch.c index 466d0ca..eaff799 100644 --- a/dgamelaunch.c +++ b/dgamelaunch.c @@ -46,17 +46,24 @@ #include #include -#include #include #include /* for flock() */ +#include + +#ifndef __FreeBSD__ +# include +#else +# include +#endif + +#include #include #include /* ttyrec */ #include -#include #include #include #include -#include +#include #include #include #include @@ -91,10 +98,12 @@ ttyrec_getmaster () { (void) tcgetattr (0, &tt); (void) ioctl (0, TIOCGWINSZ, (char *) &win); +#ifdef USE_OPENPTY + if (openpty(&master, &slave, NULL, &tt, &win) == -1) +#else if ((master = open ("/dev/ptmx", O_RDWR)) < 0) - { +#endif exit (62); - } } /* ************************************************************* */ @@ -1050,12 +1059,14 @@ main (void) /* get master tty just before chroot (lives in /dev) */ ttyrec_getmaster (); +#ifndef USE_OPENPTY grantpt (master); unlockpt (master); if ((slave = open ((const char *) ptsname (master), O_RDWR)) < 0) { exit (65); } +#endif /* chroot */ @@ -1078,13 +1089,13 @@ main (void) exit(1); } - if (setgid (1, newgid) == -1) + if (setgid (newgid) == -1) { perror("setgid"); exit(1); } - if (setuid (1, newuid) == -1) + if (setuid (newuid) == -1) { perror("setuid"); exit(1); diff --git a/dgamelaunch.h b/dgamelaunch.h index af5697a..9163210 100644 --- a/dgamelaunch.h +++ b/dgamelaunch.h @@ -5,6 +5,10 @@ #include +/* Default - should work everywhere */ +#define USE_OPENPTY +#define NOSTREAMS + struct dg_user { char *username;