{
Utility::srandom();
- int newgid=0;
- if(!::arg()["setgid"].empty())
- newgid=Utility::makeGidNumeric(::arg()["setgid"]);
- int newuid=0;
- if(!::arg()["setuid"].empty())
- newuid=Utility::makeUidNumeric(::arg()["setuid"]);
+ gid_t newgid = 0;
+ if(!::arg()["setgid"].empty())
+ newgid=Utility::makeGidNumeric(::arg()["setgid"]);
+ uid_t newuid = 0;
+ if(!::arg()["setuid"].empty())
+ newuid=Utility::makeUidNumeric(::arg()["setuid"]);
g_anyToTcp = ::arg().mustDo("any-to-tcp");
g_8bitDNS = ::arg().mustDo("8bit-dns");
// Drops the program's group privileges.
-void Utility::dropGroupPrivs( int uid, int gid )
+void Utility::dropGroupPrivs( uid_t uid, gid_t gid )
{
if(gid) {
if(setgid(gid)<0) {
// Drops the program's user privileges.
-void Utility::dropUserPrivs( int uid )
+void Utility::dropUserPrivs( uid_t uid )
{
if(uid) {
if(setuid(uid)<0) {
// Retrieves a gid using a groupname.
-int Utility::makeGidNumeric(const string &group)
+gid_t Utility::makeGidNumeric(const string &group)
{
- int newgid;
+ gid_t newgid;
if(!(newgid=atoi(group.c_str()))) {
errno=0;
struct group *gr=getgrnam(group.c_str());
// Retrieves an uid using a username.
-int Utility::makeUidNumeric(const string &username)
+uid_t Utility::makeUidNumeric(const string &username)
{
- int newuid;
+ uid_t newuid;
if(!(newuid=atoi(username.c_str()))) {
struct passwd *pw=getpwnam(username.c_str());
if(!pw) {
static const char *inet_ntop( int af, const char *src, char *dst, size_t size );
//! Retrieves a gid using a groupname.
- static int makeGidNumeric( const string & group );
+ static gid_t makeGidNumeric( const string & group );
//! Retrieves an uid using an username.
- static int makeUidNumeric( const string & username );
+ static uid_t makeUidNumeric( const string & username );
//! Writes a vector.
static int writev( Utility::sock_t socket, const iovec *vector, size_t count );
static void srandom(void);
//! Drops the program's group privileges.
- static void dropGroupPrivs( int uid, int gid );
+ static void dropGroupPrivs( uid_t uid, gid_t gid );
//! Drops the program's user privileges.
- static void dropUserPrivs( int uid );
+ static void dropUserPrivs( uid_t uid );
//! Sets the socket into Bind-any mode
static void setBindAny ( int af, Utility::sock_t socket );