- (dtucker) [platform.c platform.h session.c] Move the Cygwin special-case
check into platform.c
diff --git a/platform.c b/platform.c
index b4fb88e..f2cf11f 100644
--- a/platform.c
+++ b/platform.c
@@ -1,4 +1,4 @@
-/* $Id: platform.c,v 1.13 2010/11/05 02:32:53 dtucker Exp $ */
+/* $Id: platform.c,v 1.14 2010/11/05 03:47:01 dtucker Exp $ */
/*
* Copyright (c) 2006 Darren Tucker. All rights reserved.
@@ -17,6 +17,10 @@
*/
#include "config.h"
+
+#include <sys/types.h>
+#include <unistd.h>
+
#include "platform.h"
#include "openbsd-compat/openbsd-compat.h"
@@ -59,6 +63,18 @@
#endif
}
+/* return 1 if we are running with privilege to swap UIDs, 0 otherwise */
+int
+platform_privileged_uidswap(void)
+{
+#ifdef HAVE_CYGWIN
+ /* uid 0 is not special on Cygwin so always try */
+ return 1;
+#else
+ return (getuid() == 0 || geteuid() == 0);
+#endif
+}
+
/*
* This gets called before switching UIDs, and is called even when sshd is
* not running as root.