Index: command.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/ppp/command.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- command.c 1996/05/11 20:48:22 1.17 +++ command.c 1996/06/09 20:40:58 1.18 @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: command.c,v 1.17 1996/05/11 20:48:22 phk Exp $ + * $Id: command.c,v 1.18 1996/06/09 20:40:58 ache Exp $ * */ #include @@ -190,9 +190,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.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- chat.c 1996/05/11 20:48:20 1.10 +++ chat.c 1996/06/09 20:40:56 1.11 @@ -18,7 +18,7 @@ * Columbus, OH 43221 * (614)451-1883 * - * $Id: chat.c,v 1.10 1996/05/11 20:48:20 phk Exp $ + * $Id: chat.c,v 1.11 1996/06/09 20:40:56 ache Exp $ * * TODO: * o Support more UUCP compatible control sequences. @@ -393,6 +393,15 @@ nb = open("/dev/tty", O_RDWR); dup2(nb, 0); LogPrintf(LOG_CHAT_BIT, "exec: %s\n", command); + /* switch back to original privileges */ + if (setgid(getgid()) < 0) { + LogPrintf(LOG_CHAT_BIT, "setgid: %s\n", strerror(errno)); + exit(1); + } + if (setuid(getuid()) < 0) { + LogPrintf(LOG_CHAT_BIT, "setuid: %s\n", strerror(errno)); + exit(1); + } pid = execvp(command, vector); LogPrintf(LOG_CHAT_BIT, "execvp failed for (%d/%d): %s\n", pid, errno, command); exit(127);