- use termios
- enable setgid games - enable savedir
This commit is contained in:
parent
ec609ce1aa
commit
6ecf74c0f6
@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile,v 1.2 2020/11/10 08:49:08 kamil Exp $
|
||||
# $NetBSD: Makefile,v 1.3 2020/11/11 17:11:19 christos Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
@ -18,6 +18,9 @@ HIDEGAME=hidegame
|
||||
SETGIDGAME=yes
|
||||
MAN= warp.6
|
||||
|
||||
BINGRP= games
|
||||
BINMODE=2555
|
||||
|
||||
warp.6:
|
||||
${_MKTARGET_CREATE}
|
||||
cat ${.CURDIR}/warp.man > ${.TARGET}
|
||||
|
@ -20,12 +20,12 @@
|
||||
*/
|
||||
#define SIGNEDCHAR /**/
|
||||
|
||||
/* TERMIO:
|
||||
/* TERMIOS:
|
||||
* This symbol, if defined, indicates that the program should include
|
||||
* termio.h rather than sgtty.h. There are also differences in the
|
||||
* ioctl() calls that depend on the value of this symbol.
|
||||
*/
|
||||
#undef TERMIO /**/
|
||||
#define TERMIOS /**/
|
||||
|
||||
/* USENDIR:
|
||||
* This symbol, if defined, indicates that the program should compile
|
||||
|
@ -568,7 +568,7 @@ getrealname(uid_t uid)
|
||||
if (fork())
|
||||
wait(0);
|
||||
else {
|
||||
setuid(getuid());
|
||||
setgid(getgid());
|
||||
if ((tmpfp = fopen(filexp(FULLNAMEFILE),"w")) == NULL)
|
||||
exit(1);
|
||||
fprintf(tmpfp, "%s\n", buf);
|
||||
|
@ -35,20 +35,18 @@ score_init(void)
|
||||
int i;
|
||||
FILE *savfil;
|
||||
|
||||
#if 0
|
||||
if (stat(SAVEDIR,&filestat)) {
|
||||
printf("Cannot access %s\r\n",SAVEDIR);
|
||||
finalize(1);
|
||||
}
|
||||
if (filestat.st_uid != geteuid()) {
|
||||
printf("Warp will not run right without being setuid.\r\n");
|
||||
if (filestat.st_gid != getegid()) {
|
||||
printf("Warp will not run right without being setgid.\r\n");
|
||||
finalize(1);
|
||||
}
|
||||
if ((filestat.st_mode & 0605) != 0605) {
|
||||
printf("%s is not protected correctly (must be u+rw o+rx).\r\n",SAVEDIR);
|
||||
finalize(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SCOREFULL
|
||||
interp(longlognam, sizeof longlognam, "%N");
|
||||
@ -241,9 +239,7 @@ wscore(void)
|
||||
printf("WHO SCORE DF CDF E B WV FLAGS\r\n");
|
||||
resetty();
|
||||
snprintf(spbuf, sizeof(spbuf), "/bin/cat %ssave.*",SAVEDIR);
|
||||
#ifndef lint
|
||||
execl("/bin/sh", "sh", "-c", spbuf, NULL);
|
||||
#endif
|
||||
finalize(1);
|
||||
}
|
||||
|
||||
@ -421,10 +417,8 @@ wavescore(void)
|
||||
snprintf(spbuf, sizeof(spbuf), "Star save ratio: %1.8f (%d/%d)",
|
||||
starscore, numstars, inumstars);
|
||||
mvaddstr( 6,5, spbuf);
|
||||
#ifndef lint
|
||||
bonuses += tmp = (long) (((double)curscore / possiblescore) *
|
||||
(starscore*starscore) * smarts * 20);
|
||||
#endif
|
||||
snprintf(spbuf, sizeof(spbuf), "%6ld", tmp);
|
||||
mvaddstr( 6, 68, spbuf);
|
||||
row = 7;
|
||||
|
@ -69,8 +69,8 @@ term_init(void)
|
||||
{
|
||||
savetty(); /* remember current tty state */
|
||||
|
||||
#ifdef TERMIO
|
||||
ospeed = _tty.c_cflag & CBAUD; /* for tputs() */
|
||||
#if defined(TERMIO) || defined(TERMIOS)
|
||||
ospeed = cfgetospeed(&_tty);
|
||||
ERASECH = _tty.c_cc[VERASE]; /* for finish_command() */
|
||||
KILLCH = _tty.c_cc[VKILL]; /* for finish_command() */
|
||||
#else
|
||||
@ -265,19 +265,19 @@ term_set(char *tcbuf) /* temp area for "uncompiled" termcap entry */
|
||||
for (p=filler+(sizeof filler)-1;!*p;--p)
|
||||
*p = PC;
|
||||
}
|
||||
charsperhalfsec = ospeed >= B9600 ? 480 :
|
||||
ospeed == B4800 ? 240 :
|
||||
ospeed == B2400 ? 120 :
|
||||
ospeed == B1200 ? 60 :
|
||||
ospeed == B600 ? 30 :
|
||||
/* speed is 300 (?) */ 15;
|
||||
charsperhalfsec = (speed_t)ospeed >= B9600 ? (speed_t)480 :
|
||||
(speed_t)ospeed == B4800 ? (speed_t)240 :
|
||||
(speed_t)ospeed == B2400 ? (speed_t)120 :
|
||||
(speed_t)ospeed == B1200 ? (speed_t)60 :
|
||||
(speed_t)ospeed == B600 ? (speed_t)30 :
|
||||
/* speed is 300 (?) */ (speed_t)15;
|
||||
|
||||
gfillen = ospeed >= B9600 ? (int /*XXX: speed_t*/)(sizeof filler) :
|
||||
ospeed == B4800 ? 13 :
|
||||
ospeed == B2400 ? 7 :
|
||||
ospeed == B1200 ? 4 :
|
||||
(1+BCsize);
|
||||
if (ospeed < B2400)
|
||||
gfillen = (speed_t)ospeed >= B9600 ? (speed_t)(sizeof filler) :
|
||||
(speed_t)ospeed == B4800 ? (speed_t)13 :
|
||||
(speed_t)ospeed == B2400 ? (speed_t)7 :
|
||||
(speed_t)ospeed == B1200 ? (speed_t)4 :
|
||||
(speed_t)(1+BCsize);
|
||||
if ((speed_t)ospeed < B2400)
|
||||
lowspeed = true;
|
||||
|
||||
strcpy(term,ttyname(2));
|
||||
@ -767,7 +767,7 @@ tryagain:
|
||||
}
|
||||
|
||||
got_canonical:
|
||||
#ifndef TERMIO
|
||||
#if !defined(TERMIO) && !defined(TERMIOS)
|
||||
if (*whatbuf == '\r')
|
||||
*whatbuf = '\n';
|
||||
#endif
|
||||
|
@ -181,9 +181,16 @@ EXT char INTRCH INIT('\03');
|
||||
|
||||
/* stuff wanted by terminal mode diddling routines */
|
||||
|
||||
#ifdef TERMIO
|
||||
#ifdef TERMIOS
|
||||
EXT struct termios _tty, _oldtty;
|
||||
#elif defined(TERMIO)
|
||||
typedef int speed_t;
|
||||
EXT struct termio _tty, _oldtty;
|
||||
#define tcsetattr(fd, how, ti) ioctl(fd, how, ti)
|
||||
#define tcgetattr(fd, ti) ioctl(fd, TCGETA, ti)
|
||||
#define cfgetospeed(ti) ((ti)->c_cflag & CBAUD)
|
||||
#else
|
||||
typedef int speed_t;
|
||||
EXT struct sgttyb _tty;
|
||||
EXT int _res_flg INIT(0);
|
||||
#endif
|
||||
@ -193,18 +200,18 @@ EXT bool bizarre INIT(false); /* do we need to restore terminal? */
|
||||
|
||||
/* terminal mode diddling routines */
|
||||
|
||||
#ifdef TERMIO
|
||||
#if defined(TERMIO) || defined(TERMIOS)
|
||||
|
||||
#define raw() ((bizarre=1),_tty.c_lflag &=~ISIG,_tty.c_cc[VMIN] = 1,ioctl(_tty_ch,TCSETAF,&_tty))
|
||||
#define noraw() ((bizarre=1),_tty.c_lflag |= ISIG,_tty.c_cc[VEOF] = CEOF,ioctl(_tty_ch,TCSETAF,&_tty))
|
||||
#define crmode() ((bizarre=1),_tty.c_lflag &=~ICANON,_tty.c_cc[VMIN] = 1,ioctl(_tty_ch,TCSETAF,&_tty))
|
||||
#define nocrmode() ((bizarre=1),_tty.c_lflag |= ICANON,_tty.c_cc[VEOF] = CEOF,ioctl(_tty_ch,TCSETAF,&_tty))
|
||||
#define echo() ((bizarre=1),_tty.c_lflag |= ECHO, ioctl(_tty_ch, TCSETAW, &_tty))
|
||||
#define noecho() ((bizarre=1),_tty.c_lflag &=~ECHO, ioctl(_tty_ch, TCSETAW, &_tty))
|
||||
#define nl() ((bizarre=1),_tty.c_iflag |= ICRNL,_tty.c_oflag |= ONLCR,ioctl(_tty_ch, TCSETAW, &_tty))
|
||||
#define nonl() ((bizarre=1),_tty.c_iflag &=~ICRNL,_tty.c_oflag &=~ONLCR,ioctl(_tty_ch, TCSETAW, &_tty))
|
||||
#define savetty() (ioctl(_tty_ch, TCGETA, &_oldtty),ioctl(_tty_ch, TCGETA, &_tty))
|
||||
#define resetty() ((bizarre=0),ioctl(_tty_ch, TCSETAF, &_oldtty))
|
||||
#define raw() ((bizarre=1),_tty.c_lflag &=~ISIG,_tty.c_cc[VMIN] = 1,tcsetattr(_tty_ch,TCSAFLUSH,&_tty))
|
||||
#define noraw() ((bizarre=1),_tty.c_lflag |= ISIG,_tty.c_cc[VEOF] = CEOF,tcsetattr(_tty_ch,TCSAFLUSH,&_tty))
|
||||
#define crmode() ((bizarre=1),_tty.c_lflag &=~ICANON,_tty.c_cc[VMIN] = 1,tcsetattr(_tty_ch,TCSAFLUSH,&_tty))
|
||||
#define nocrmode() ((bizarre=1),_tty.c_lflag |= ICANON,_tty.c_cc[VEOF] = CEOF,tcsetattr(_tty_ch,TCSAFLUSH,&_tty))
|
||||
#define echo() ((bizarre=1),_tty.c_lflag |= ECHO, tcsetattr(_tty_ch, TCSANOW, &_tty))
|
||||
#define noecho() ((bizarre=1),_tty.c_lflag &=~ECHO, tcsetattr(_tty_ch, TCSANOW, &_tty))
|
||||
#define nl() ((bizarre=1),_tty.c_iflag |= ICRNL,_tty.c_oflag |= ONLCR,tcsetattr(_tty_ch, TCSANOW, &_tty))
|
||||
#define nonl() ((bizarre=1),_tty.c_iflag &=~ICRNL,_tty.c_oflag &=~ONLCR,tcsetattr(_tty_ch, TCSANOW, &_tty))
|
||||
#define savetty() (tcgetattr(_tty_ch, &_oldtty),tcgetattr(_tty_ch, &_tty))
|
||||
#define resetty() ((bizarre=0),tcsetattr(_tty_ch, TCSAFLUSH, &_oldtty))
|
||||
#define unflush_output()
|
||||
|
||||
#else
|
||||
|
@ -43,7 +43,7 @@
|
||||
* access.)
|
||||
*/
|
||||
|
||||
#define SAVEDIR "/var/games"
|
||||
#define SAVEDIR "/var/games/warp"
|
||||
#define NEWSFILE "warp.news"
|
||||
#define HELPFILE "warp.doc"
|
||||
#define LOCKFILE ".warp.lock"
|
||||
|
Loading…
Reference in New Issue
Block a user