Index: command.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/ppp/command.c,v retrieving revision 1.5.4.3 retrieving revision 1.5.4.4 diff -u -r1.5.4.3 -r1.5.4.4 --- command.c 1996/02/05 17:02:52 1.5.4.3 +++ command.c 1996/06/10 09:41:49 1.5.4.4 @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: SA-96:15.ppp.21X,v 1.1.1.1 1998/03/16 07:07:34 kato Exp $ + * $Id: SA-96:15.ppp.21X,v 1.1.1.1 1998/03/16 07:07:34 kato Exp $ * */ #include @@ -187,9 +187,14 @@ * We are running setuid, we should change to * real user for avoiding security problems. */ - setgid( getgid() ); - setuid( getuid() ); - + if (setgid(getgid()) < 0) { + perror("setgid"); + exit(1); + } + if (setuid(getuid()) < 0) { + perror("setuid"); + exit(1); + } TtyOldMode(); if(argc > 0) execvp(argv[0], argv); Index: chat.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/ppp/chat.c,v retrieving revision 1.4.4.1 retrieving revision 1.4.4.2 diff -u -r1.4.4.1 -r1.4.4.2 --- chat.c 1995/10/06 11:24:31 1.4.4.1 +++ chat.c 1996/06/10 09:41:45 1.4.4.2 @@ -18,7 +18,7 @@ * Columbus, OH 43221 * (614)451-1883 * - * $Id: SA-96:15.ppp.21X,v 1.1.1.1 1998/03/16 07:07:34 kato Exp $ + * $Id: SA-96:15.ppp.21X,v 1.1.1.1 1998/03/16 07:07:34 kato Exp $ * * TODO: * o Support more UUCP compatible control sequences. @@ -331,6 +331,15 @@ nb = open("/dev/tty", O_RDWR); dup2(nb, 0); LogPrintf(LOG_CHAT, "exec: %s\n", command); + /* switch back to original privileges */ + if (setgid(getgid()) < 0) { + LogPrintf(LOG_CHAT, "setgid: %s\n", strerror(errno)); + exit(1); + } + if (setuid(getuid()) < 0) { + LogPrintf(LOG_CHAT, "setuid: %s\n", strerror(errno)); + exit(1); + } pid = execvp(command, vector); LogPrintf(LOG_CHAT, "execvp failed for (%d/%d): %s\n", pid, errno, command); exit(127);