Module: kamailio
Branch: master
Commit: 241ac2813d30792c713dd6e585bae3c1d6e76f47
URL:
https://github.com/kamailio/kamailio/commit/241ac2813d30792c713dd6e585bae3c…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2015-01-02T11:16:28+01:00
core: don't do setuid() if started by same user as -u
- closing FS#473
---
Modified: daemonize.c
---
Diff:
https://github.com/kamailio/kamailio/commit/241ac2813d30792c713dd6e585bae3c…
Patch:
https://github.com/kamailio/kamailio/commit/241ac2813d30792c713dd6e585bae3c…
---
diff --git a/daemonize.c b/daemonize.c
index ef8a46c..63d96be 100644
--- a/daemonize.c
+++ b/daemonize.c
@@ -452,9 +452,11 @@ int do_suid()
struct passwd *pw;
if (gid){
- if(setgid(gid)<0){
- LM_CRIT("cannot change gid to %d: %s\n", gid, strerror(errno));
- goto error;
+ if(gid!=getgid()) {
+ if(setgid(gid)<0){
+ LM_CRIT("cannot change gid to %d: %s\n", gid, strerror(errno));
+ goto error;
+ }
}
}
@@ -468,9 +470,11 @@ int do_suid()
strerror(errno));
goto error;
}
- if(setuid(uid)<0){
- LM_CRIT("cannot change uid to %d: %s\n", uid, strerror(errno));
- goto error;
+ if(uid!=getuid()) {
+ if(setuid(uid)<0){
+ LM_CRIT("cannot change uid to %d: %s\n", uid, strerror(errno));
+ goto error;
+ }
}
}