- Logs->Log("STARTUP", DEFAULT, "Startup complete as '%s'[%s], %d max open sockets", Config->ServerName,Config->GetSID().c_str(), SE->GetMaxFds());
+ Logs->Log("STARTUP", DEFAULT, "Startup complete as '%s'[%s], %d max open sockets", Config->ServerName.c_str(),Config->GetSID().c_str(), SE->GetMaxFds());
+
+#ifndef WIN32
+ if (!Config->SetGroup.empty())
+ {
+ int ret;
+
+ // setgroups
+ ret = setgroups(0, NULL);
+
+ if (ret == -1)
+ {
+ this->Logs->Log("SETGROUPS", DEFAULT, "setgroups() failed (wtf?): %s", strerror(errno));
+ this->QuickExit(0);
+ }
+
+ // setgid
+ struct group *g;
+
+ errno = 0;
+ g = getgrnam(this->Config->SetGroup.c_str());
+
+ if (!g)
+ {
+ this->Logs->Log("SETGUID", DEFAULT, "getgrnam() failed (bad user?): %s", strerror(errno));
+ this->QuickExit(0);
+ }
+
+ ret = setgid(g->gr_gid);
+
+ if (ret == -1)
+ {
+ this->Logs->Log("SETGUID", DEFAULT, "setgid() failed (bad user?): %s", strerror(errno));
+ this->QuickExit(0);
+ }
+ }
+
+ if (!Config->SetUser.empty())
+ {
+ // setuid
+ struct passwd *u;
+
+ errno = 0;
+ u = getpwnam(this->Config->SetUser.c_str());
+
+ if (!u)
+ {
+ this->Logs->Log("SETGUID", DEFAULT, "getpwnam() failed (bad user?): %s", strerror(errno));
+ this->QuickExit(0);
+ }
+
+ int ret = setuid(u->pw_uid);
+
+ if (ret == -1)
+ {
+ this->Logs->Log("SETGUID", DEFAULT, "setuid() failed (bad user?): %s", strerror(errno));
+ this->QuickExit(0);
+ }
+ }
+#endif