[Box Backup-commit] COMMIT r1348 - box/chris/general/lib/common

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Sun Mar 4 20:58:23 GMT 2007


Author: chris
Date: 2007-03-04 20:58:23 +0000 (Sun, 04 Mar 2007)
New Revision: 1348

Modified:
   box/chris/general/lib/common/UnixUser.cpp
Log:
Minimise #ifdeffed out code on win32.


Modified: box/chris/general/lib/common/UnixUser.cpp
===================================================================
--- box/chris/general/lib/common/UnixUser.cpp	2007-03-04 20:57:33 UTC (rev 1347)
+++ box/chris/general/lib/common/UnixUser.cpp	2007-03-04 20:58:23 UTC (rev 1348)
@@ -75,17 +75,18 @@
 // --------------------------------------------------------------------------
 UnixUser::~UnixUser()
 {
-#ifndef WIN32
 	if(mRevertOnDestruction)
 	{
 		// Revert to "real" user and group id of the process
-		if(::setegid(::getgid()) != 0
-			|| ::seteuid(::getuid()) != 0)
+		#ifdef WIN32
+		if(0)
+		#else
+		if(::setegid(::getgid()) != 0 || ::seteuid(::getuid()) != 0)
+		#endif
 		{
 			THROW_EXCEPTION(CommonException, CouldNotRestoreProcessUser)
 		}
 	}
-#endif
 }
 
 
@@ -100,12 +101,14 @@
 // --------------------------------------------------------------------------
 void UnixUser::ChangeProcessUser(bool Temporary)
 {
-#ifndef WIN32
 	if(Temporary)
 	{
 		// Change temporarily (change effective only)
-		if(::setegid(mGID) != 0
-			|| ::seteuid(mUID) != 0)
+		#ifdef WIN32
+		if(0)
+		#else
+		if(::setegid(mGID) != 0 || ::seteuid(mUID) != 0)
+		#endif
 		{
 			THROW_EXCEPTION(CommonException, CouldNotChangeProcessUser)
 		}
@@ -115,14 +118,16 @@
 	}
 	else
 	{
-		// Change perminantely (change all UIDs and GIDs)
-		if(::setgid(mGID) != 0
-			|| ::setuid(mUID) != 0)
+		// Change permanently (change all UIDs and GIDs)
+		#ifdef WIN32
+		if(0)
+		#else
+		if(::setgid(mGID) != 0 || ::setuid(mUID) != 0)
+		#endif
 		{
 			THROW_EXCEPTION(CommonException, CouldNotChangeProcessUser)
 		}
 	}
-#endif
 }
 
 




More information about the Boxbackup-commit mailing list