Don't assume setuid() cannot fail for suid root applications.

This commit is contained in:
Michael Nottebrock 2006-06-09 16:07:01 +00:00
parent ce1c89634d
commit 869f68a326
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=164914
3 changed files with 38 additions and 0 deletions

View File

@ -8,6 +8,7 @@
PORTNAME= arts
PORTVERSION= 1.5.3
PORTREVISION= 1
PORTEPOCH= 1
CATEGORIES= audio kde
MASTER_SITES= ${MASTER_SITE_KDE}

View File

@ -0,0 +1,33 @@
Index: soundserver/artswrapper.c
===================================================================
--- soundserver/artswrapper.c (revision 546970)
+++ soundserver/artswrapper.c (working copy)
@@ -95,6 +95,10 @@ int main(int argc, char **argv)
#else
setreuid(-1, getuid());
#endif
+ if (geteuid() != getuid()) {
+ perror("setuid()");
+ return 2;
+ }
}
if(argc == 0)
Index: soundserver/crashhandler.cc
===================================================================
--- soundserver/crashhandler.cc (revision 546970)
+++ soundserver/crashhandler.cc (working copy)
@@ -196,7 +196,12 @@ CrashHandler::defaultCrashHandler (int s
argv[i++] = NULL;
setgid(getgid());
- setuid(getuid());
+ if (getuid() != geteuid())
+ setuid(getuid());
+ if (getuid() != geteuid()) {
+ perror("setuid()");
+ exit(255);
+ }
execvp(crashApp, argv);

View File

@ -93,6 +93,10 @@ int main(int argc, char **argv)
#else
setreuid(-1, getuid());
#endif
if (geteuid() != getuid()) {
perror("setuid()");
return 2;
}
}
if(argc == 0)