summaryrefslogtreecommitdiffstats
path: root/games/adventure
diff options
context:
space:
mode:
authoreivind <eivind@FreeBSD.org>1997-09-01 00:34:51 +0000
committereivind <eivind@FreeBSD.org>1997-09-01 00:34:51 +0000
commitd8e95d8c1a6a0918fc9dda2ca247833ad222696d (patch)
tree42fed91af49ba9290d473dbe68d13f3f33e7545c /games/adventure
parentff4b4c1d18cef70a372542d0a1a7a48e6543cf9e (diff)
downloadFreeBSD-src-d8e95d8c1a6a0918fc9dda2ca247833ad222696d.zip
FreeBSD-src-d8e95d8c1a6a0918fc9dda2ca247833ad222696d.tar.gz
Change games from setuid games to setgid games.
Reviewed by: maybe@yes.no Obtained from: OpenBSD (mostly deraadt@openbsd.org)
Diffstat (limited to 'games/adventure')
-rw-r--r--games/adventure/hdr.h5
-rw-r--r--games/adventure/main.c7
-rw-r--r--games/adventure/save.c22
-rw-r--r--games/adventure/vocab.c8
4 files changed, 22 insertions, 20 deletions
diff --git a/games/adventure/hdr.h b/games/adventure/hdr.h
index c77663a..6c8a1fd 100644
--- a/games/adventure/hdr.h
+++ b/games/adventure/hdr.h
@@ -52,6 +52,7 @@
*/
/* hdr.h: included by c advent files */
+#include <sys/types.h>
int datfd; /* message file descriptor */
int delhit;
@@ -128,7 +129,7 @@ int hntmax;
int hints[20][5]; /* info on hints */
int hinted[20],hintlc[20];
-int place[101], prop[101],link[201];
+int place[101], prop[101],linkx[201];
int abb[LOCSIZ];
int maxtrs,tally,tally2; /* treasure values */
@@ -161,3 +162,5 @@ unsigned long crc();
/* We need to get a little tricky to avoid strings */
#define DECR(a,b,c,d,e) decr('a'+'+','b'+'-','c'+'#','d'+'&','e'+'%')
+
+gid_t egid;
diff --git a/games/adventure/main.c b/games/adventure/main.c
index 89629df..3d7fb9a 100644
--- a/games/adventure/main.c
+++ b/games/adventure/main.c
@@ -64,6 +64,9 @@ char **argv;
struct text *kk;
extern trapdel();
+ egid = getegid();
+ setegid(getgid());
+
init(); /* Initialize everything */
signal(2,trapdel);
@@ -117,7 +120,7 @@ char **argv;
if (loc==33 && pct(25)&&!closng) rspeak(8);
if (!dark(0))
{ abb[loc]++;
- for (i=atloc[loc]; i!=0; i=link[i]) /*2004 */
+ for (i=atloc[loc]; i!=0; i=linkx[i]) /*2004 */
{ obj=i;
if (obj>100) obj -= 100;
if (obj==steps && toting(nugget)) continue;
@@ -261,7 +264,7 @@ char **argv;
l4080:
switch(verb)
{ case 1: /* take = 8010 */
- if (atloc[loc]==0||link[atloc[loc]]!=0) goto l8000;
+ if (atloc[loc]==0||linkx[atloc[loc]]!=0) goto l8000;
for (i=1; i<=5; i++)
if (dloc[i]==loc&&dflag>=2) goto l8000;
obj=atloc[loc];
diff --git a/games/adventure/save.c b/games/adventure/save.c
index 6784fef..763e56b 100644
--- a/games/adventure/save.c
+++ b/games/adventure/save.c
@@ -108,7 +108,7 @@ struct savestruct save_array[] =
dseen, sizeof(dseen),
fixed, sizeof(fixed),
hinted, sizeof(hinted),
- link, sizeof(link),
+ linkx, sizeof(linkx),
odloc, sizeof(odloc),
place, sizeof(place),
prop, sizeof(prop),
@@ -125,24 +125,23 @@ char *outfile; /* to output the data using checksum to start random #s */
char *s;
long sum;
int i;
- uid_t euid_save;
crc_start();
for (p = save_array; p->address != NULL; p++)
sum = crc(p->address, p->width);
srandom((int) sum);
- euid_save = geteuid();
- seteuid(getuid());
-
+ setegid(egid);
if ((out = fopen(outfile, "wb")) == NULL)
{
fprintf(stderr,
"Hmm. The name \"%s\" appears to be magically blocked.\n",
outfile);
- seteuid(euid_save);
+ setegid(getgid());
return 1;
}
+ setegid(getgid());
+
fwrite(&sum, sizeof(sum), 1, out); /* Here's the random() key */
for (p = save_array; p->address != NULL; p++)
{
@@ -151,7 +150,6 @@ char *outfile; /* to output the data using checksum to start random #s */
fwrite(p->address, p->width, 1, out);
}
fclose(out);
- seteuid(euid_save);
return 0;
}
@@ -163,19 +161,18 @@ char *infile;
char *s;
long sum, cksum;
int i;
- uid_t euid_save;
-
- euid_save = geteuid();
- seteuid(euid_save);
+ setegid(egid);
if ((in = fopen(infile, "rb")) == NULL)
{
fprintf(stderr,
"Hmm. The file \"%s\" appears to be magically blocked.\n",
infile);
- seteuid(euid_save);
+ setegid(getgid());
return 1;
}
+ setegid(getgid());
+
fread(&sum, sizeof(sum), 1, in); /* Get the seed */
srandom((int) sum);
for (p = save_array; p->address != NULL; p++)
@@ -185,7 +182,6 @@ char *infile;
*s = (*s ^ random()) & 0xFF; /* Lightly decrypt */
}
fclose(in);
- seteuid(euid_save);
crc_start(); /* See if she cheated */
for (p = save_array; p->address != NULL; p++)
diff --git a/games/adventure/vocab.c b/games/adventure/vocab.c
index b34b42e..357e238 100644
--- a/games/adventure/vocab.c
+++ b/games/adventure/vocab.c
@@ -91,11 +91,11 @@ int object,where;
holdng++;
}
if (atloc[where]==object)
- { atloc[where]=link[object];
+ { atloc[where]=linkx[object];
return;
}
- for (temp=atloc[where]; link[temp]!=object; temp=link[temp]);
- link[temp]=link[object];
+ for (temp=atloc[where]; linkx[temp]!=object; temp=linkx[temp]);
+ linkx[temp]=linkx[object];
}
@@ -107,7 +107,7 @@ int object,where;
place[object]=where;
}
if (where<=0) return;
- link[object]=atloc[where];
+ linkx[object]=atloc[where];
atloc[where]=object;
}
OpenPOWER on IntegriCloud