summaryrefslogtreecommitdiff
path: root/platform.c
diff options
context:
space:
mode:
authordtucker <dtucker>2010-11-05 03:47:01 +0000
committerdtucker <dtucker>2010-11-05 03:47:01 +0000
commite309d72a1dfc5a2c3c3e6bb43fbd66d65b0a02b2 (patch)
tree777f6857fd23e7bef5085ddf5d9fc303921d60d8 /platform.c
parent7ae36c743f1e078e458a8caa0e58ab306807fbfb (diff)
downloadopenssh-e309d72a1dfc5a2c3c3e6bb43fbd66d65b0a02b2.tar.gz
- (dtucker) [platform.c platform.h session.c] Move the Cygwin special-case
check into platform.c
Diffstat (limited to 'platform.c')
-rw-r--r--platform.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/platform.c b/platform.c
index b4fb88e5..f2cf11f5 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 @@ platform_post_fork_child(void)
#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.