]> skyeroc.xyz Git - dgamelaunch/commitdiff
works
authorJoshua Kwan <joshk@triplehelix.org>
Fri, 2 Jan 2004 20:47:53 +0000 (20:47 +0000)
committerJoshua Kwan <joshk@triplehelix.org>
Fri, 2 Jan 2004 20:47:53 +0000 (20:47 +0000)
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@43 db0b04b0-f4d1-0310-9a6d-de3e77497b0e

Makefile
dgamelaunch.c
dgamelaunch.h

index dd7c568479550793dcba55279aa520bb44996581..5c96a2582a30e6bfc262653e7d9e4e13b98c7f43 100644 (file)
--- 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)
 
index 466d0cab0dfebe2e7df50164722167ff6aa8a20e..eaff799443964f038816844e2e9d89105f602922 100644 (file)
 
 #include <stdlib.h>
 #include <curses.h>
-#include <crypt.h>
 #include <sys/types.h>
 #include <sys/file.h>           /* for flock() */
+#include <sys/time.h>
+
+#ifndef __FreeBSD__
+# include <crypt.h>
+#else
+# include <libutil.h>
+#endif
+
+#include <time.h>
 #include <sys/resource.h>
 #include <sys/ioctl.h>          /* ttyrec */
 #include <errno.h>
-#include <time.h>
 #include <dirent.h>
 #include <string.h>
 #include <sys/stat.h>
-#include <sys/signal.h>
+#include <signal.h>
 #include <assert.h>
 #include <ctype.h>
 #include <unistd.h>
@@ -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);
index af5697af50e70e8dd865b4ca32578367abe5250c..916321075657870a4954e2d809a474b2a3d04707 100644 (file)
@@ -5,6 +5,10 @@
 
 #include <time.h>
 
+/* Default - should work everywhere */
+#define USE_OPENPTY
+#define NOSTREAMS
+
 struct dg_user
 {
   char *username;