diff options
author | max <max@FreeBSD.org> | 1997-02-01 21:30:50 +0000 |
---|---|---|
committer | max <max@FreeBSD.org> | 1997-02-01 21:30:50 +0000 |
commit | b0c88e4d210ce20c6d868495b891852c3939afa6 (patch) | |
tree | 8e4e8a1158219b1dbb92ab02bfabae6bf34c447f /games | |
parent | e254d33903055e0d44084504fe6ab5f5a6b86ffb (diff) | |
download | FreeBSD-src-b0c88e4d210ce20c6d868495b891852c3939afa6.zip FreeBSD-src-b0c88e4d210ce20c6d868495b891852c3939afa6.tar.gz |
Instead of swapping ruid and euid before and after touching user's file,
simply drop the privilege right after the program is started.
Thanks to bde for giving me good suggestion about this problem.
Diffstat (limited to 'games')
-rw-r--r-- | games/backgammon/backgammon/main.c | 5 | ||||
-rw-r--r-- | games/backgammon/common_source/save.c | 4 | ||||
-rw-r--r-- | games/backgammon/teachgammon/teach.c | 7 |
3 files changed, 12 insertions, 4 deletions
diff --git a/games/backgammon/backgammon/main.c b/games/backgammon/backgammon/main.c index 6d18876..97f0c6a 100644 --- a/games/backgammon/backgammon/main.c +++ b/games/backgammon/backgammon/main.c @@ -104,6 +104,11 @@ char **argv; register int l; /* non-descript index */ register char c; /* non-descript character storage */ long t; /* time for random num generator */ + uid_t uid; + + /*Drop the privilege.*/ + uid = getuid(); + setreuid (uid,uid); /* initialization */ bflag = 2; /* default no board */ diff --git a/games/backgammon/common_source/save.c b/games/backgammon/common_source/save.c index 80030e7..b25e194 100644 --- a/games/backgammon/common_source/save.c +++ b/games/backgammon/common_source/save.c @@ -87,7 +87,6 @@ register int n; writec (*fs++); } *fs = '\0'; - setreuid(geteuid(), getuid()); if ((fdesc = open(fname,2)) == -1 && errno == 2) { if ((fdesc = creat (fname,0700)) != -1) break; @@ -130,7 +129,6 @@ register int n; write (fdesc,&gvalue,sizeof gvalue); write (fdesc,&raflag,sizeof raflag); close (fdesc); - setreuid(geteuid(), getuid()); if (tflag) curmove (18,0); writel (saved); @@ -150,7 +148,6 @@ char *s; register int i; int fdesc; - setreuid(geteuid(), getuid()); if ((fdesc = open (s,0)) == -1) norec (s); read (fdesc,board,sizeof board); @@ -165,7 +162,6 @@ char *s; read (fdesc,&gvalue,sizeof gvalue); read (fdesc,&raflag,sizeof raflag); close (fdesc); - setreuid(geteuid(), getuid()); rflag = 1; } diff --git a/games/backgammon/teachgammon/teach.c b/games/backgammon/teachgammon/teach.c index 7761ee6..bae186c 100644 --- a/games/backgammon/teachgammon/teach.c +++ b/games/backgammon/teachgammon/teach.c @@ -42,6 +42,8 @@ static char sccsid[] = "@(#)teach.c 8.1 (Berkeley) 5/31/93"; #endif /* not lint */ #include <string.h> +#include <sys/types.h> +#include <unistd.h> #include "back.h" char *hello[]; @@ -78,6 +80,11 @@ char **argv; { register int i; + uid_t uid; + + /*Drop the privilege.*/ + uid = getuid(); + setreuid (uid,uid); acnt = 1; signal (2,getout); |