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() && geteuid() != 0) {
+ 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");
if (scorespec)
wscore();
- snprintf(savefilename, sizeof(savefilename), "save.%s", logname);
+ snprintf(savefilename, sizeof(savefilename), "%s/save.%s",
+ SAVEDIR, logname);
savfil = experimenting ? NULL : fopen(savefilename,"r");
if (savfil != NULL && fgets(spbuf,100,savfil) != NULL) {
tmpbuf[strlen(tmpbuf)-1] = '\0';
printf("You seem to have left a game %s.\r\n",tmpbuf+9);
- s = index(tmpbuf+9, ',');
+ s = strchr(tmpbuf+9, ',');
*s = '\0';
processnum = atoi(s+11);
if (kill(processnum, SIGINT)) {
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);
}
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;
eat_typeahead();
do {
getcmd(&tmp);
- } while (tmp != INTRCH && tmp != BREAKCH && !index(" rqQ",tmp));
- if (index("qQr",tmp)) {
+ } while (tmp != INTRCH && tmp != BREAKCH && !strchr(" rqQ",tmp));
+ if (strchr("qQr",tmp)) {
justonemoretime = (tmp == 'r');
if (logfd != NULL)
fclose(logfd);
eat_typeahead();
do {
getcmd(&tmp);
- } while (tmp != INTRCH && tmp != BREAKCH && !index("nNyY \n\r",tmp));
+ } while (tmp != INTRCH && tmp != BREAKCH && !strchr("nNyY \n\r",tmp));
if (tmp == 'n' || tmp == 'N' || tmp == INTRCH || tmp == BREAKCH)
justonemoretime = false;
}
if (experimenting)
return;
if ((savfil = fopen(savefilename,"w")) == NULL) {
+ int e = errno;
resetty();
- printf("Cannot save game\r\n");
+ printf("Cannot save game in %s (%s)\r\n", savefilename, strerror(e));
finalize(1);
}
fprintf(savfil, "%-8s %10ld, %2d,%5d,%2d,%2d,%3d %c%c%c%c%c%c%c%c%c\n",