From 43ff9535028fd224b79dec5d2859eb4a82d8a4af Mon Sep 17 00:00:00 2001 From: Vivian Fang Date: Sat, 20 Feb 2016 12:46:45 -0800 Subject: [PATCH] adding windows user check --- notebook/notebookapp.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/notebook/notebookapp.py b/notebook/notebookapp.py index 96646cbe6..fa6724c4b 100644 --- a/notebook/notebookapp.py +++ b/notebook/notebookapp.py @@ -1110,11 +1110,13 @@ class NotebookApp(JupyterApp): This method takes no arguments so all configuration and initialization must be done prior to calling this method.""" try: - if os.geteuid() == 0 and not self.allow_root: - self.log.critical("Running as root is forbidden. Use --allow-root to bypass.") - self.exit(1) + is_root = os.geteuid() == 0 except AttributeError as e: - pass #need to add Windows + import ctypes + is_root = ctypes.windll.shell32.IsUserAnAdmin() == 1 + if is_root and not self.allow_root: + self.log.critical("Running as root is forbidden. Use --allow-root to bypass.") + self.exit(1) super(NotebookApp, self).start()