From ded9814c4f952e6fe700736034ff85482771a01d Mon Sep 17 00:00:00 2001 From: TerrorByte Date: Tue, 5 Feb 2013 23:12:31 -0700 Subject: [PATCH] Fixed posix environmental variables getting pulled from os.environ to ctypes to allow for use before init and in specific sudo environments. --- droopy | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/droopy b/droopy index 016ca25..6deee9b 100755 --- a/droopy +++ b/droopy @@ -68,6 +68,7 @@ import tempfile import socket import locale import urllib +from ctypes import CDLL, c_char_p LOGO = '''\ _____ @@ -816,8 +817,10 @@ class ThreadedHTTPServer(SocketServer.ThreadingMixIn, def configfile(): appname = 'droopy' # os.name is 'posix', 'nt', 'os2', 'mac', 'ce' or 'riscos' - if os.name == 'posix': - filename = "%s/.%s" % (os.environ["HOME"], appname) + if os.name == 'posix' + getenv = CDLL("libc.so.6").getenv + getenv.restype = c_char_p + filename = "%s/.%s" % (getenv("HOME"), appname) elif os.name == 'mac': filename = ("%s/Library/Application Support/%s" %