1.1 --- a/OpenSecurity.iss Wed Jun 04 16:42:37 2014 +0100
1.2 +++ b/OpenSecurity.iss Thu Jun 05 14:49:21 2014 +0200
1.3 @@ -12,6 +12,12 @@
1.4 ArchitecturesInstallIn64BitMode=x64
1.5 DefaultDirName={pf}\OpenSecurity
1.6 DefaultGroupName=OpenSecurity
1.7 +; DisableDirPage=yes
1.8 +; DisableFinishedPage=yes
1.9 +; DisableProgramGroupPage=yes
1.10 +; DisableReadyMemo=yes
1.11 +; DisableReadyPage=yes
1.12 +; DisableWelcomePage=yes
1.13 OutputDir="."
1.14 OutputBaseFilename="OpenSecurity Setup V0.2.6"
1.15 OutputManifestFile=OpenSecurity-Setup-Manifest.txt
1.16 @@ -38,6 +44,7 @@
1.17 ; Registry entries to set
1.18 Root: HKCU; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueName: "OpenSecurity Tray Icon"; ValueType: string; ValueData: "{app}\python27\pythonw.exe ""{app}\bin\opensecurity_tray.pyw"""; Flags: uninsdeletevalue
1.19 Root: HKLM; Subkey: "SOFTWARE\OpenSecurity"; ValueName: "LogServerUrl"; ValueType: string; ValueData: "http://extern.x-net.at/opensecurity/log"; Flags: uninsdeletevalue
1.20 +Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\services\USBSTOR"; ValueName: "Start"; ValueType: dword; ValueData: 4;
1.21
1.22 [Icons]
1.23 ; Program Icons in start menu
2.1 --- a/OpenSecurity/bin/opensecurity_client_restful_server.py Wed Jun 04 16:42:37 2014 +0100
2.2 +++ b/OpenSecurity/bin/opensecurity_client_restful_server.py Thu Jun 05 14:49:21 2014 +0200
2.3 @@ -53,6 +53,7 @@
2.4 import win32api
2.5 import win32con
2.6 import win32wnet
2.7 +import win32netcon
2.8 import itertools
2.9 import ctypes
2.10
2.11 @@ -205,6 +206,9 @@
2.12 This is called on GET /notification?msgtype=TYPE&text=TEXT.
2.13 This will pop up an OpenSecurity notifcation window
2.14 """
2.15 +
2.16 + def POST(self):
2.17 + return self.GET()
2.18
2.19 def GET(self):
2.20
2.21 @@ -290,7 +294,23 @@
2.22 if path in network_path:
2.23 return drive
2.24 return None
2.25 -
2.26 +
2.27 +def mapDrive(drive, networkPath, user, password):
2.28 + print networkPath
2.29 + if (os.path.exists(networkPath)):
2.30 + print networkPath, " is found..."
2.31 + print "Trying to map ", networkPath, " on to ", drive, " ....."
2.32 + try:
2.33 + win32wnet.WNetAddConnection2(win32netcon.RESOURCETYPE_DISK, drive, networkPath, None, user, password)
2.34 + except:
2.35 + print "Unexpected error..."
2.36 + return 1
2.37 + print "Mapping successful"
2.38 + return 0
2.39 + else:
2.40 + print "Network path unreachable..."
2.41 + return 1
2.42 +
2.43 # handles netumount request
2.44 class MountNetworkDriveHandler(threading.Thread):
2.45 networkPath = None
2.46 @@ -313,21 +333,15 @@
2.47 return 1
2.48
2.49 #Check for network resource availability
2.50 - retry = 5
2.51 + retry = 20
2.52 while not os.path.exists(self.networkPath):
2.53 + if retry == 0:
2.54 + break
2.55 + logger.info("Path not accessible: " + self.networkPath + " retrying")
2.56 time.sleep(1)
2.57 - if retry == 0:
2.58 - return 1
2.59 - logger.info("Path not accessible: " + self.networkPath + " retrying")
2.60 retry-=1
2.61 -
2.62 - command = 'USE ' + drive + ' ' + self.networkPath + ' /PERSISTENT:NO'
2.63 -
2.64 - result = Cygwin.checkResult(Cygwin.execute('C:\\Windows\\system32\\NET', command))
2.65 - if string.find(result[1], 'successfully',) == -1:
2.66 - logger.error("Failed: NET " + command)
2.67 - return 1
2.68 - return 0
2.69 +
2.70 + return mapDrive(drive, self.networkPath, "", "")
2.71
2.72 class os_netmount:
2.73
2.74 @@ -345,7 +359,20 @@
2.75 driveHandler.start()
2.76 driveHandler.join(None)
2.77 return 'Ok'
2.78 -
2.79 +
2.80 +def unmapDrive(drive, force=0):
2.81 + print "drive in use, trying to unmap..."
2.82 + if force == 0:
2.83 + print "Executing un-forced call..."
2.84 +
2.85 + try:
2.86 + win32wnet.WNetCancelConnection2(drive, 1, force)
2.87 + print drive, "successfully unmapped..."
2.88 + return 0
2.89 + except:
2.90 + print "Unmap failed, try again..."
2.91 + return 1
2.92 +
2.93 # handles netumount request
2.94 class UmountNetworkDriveHandler(threading.Thread):
2.95 networkPath = None
2.96 @@ -364,10 +391,8 @@
2.97 else:
2.98 drive = drive+':'
2.99 logger.info("Unmounting drive " + drive + " for " + self.networkPath)
2.100 - command = 'USE ' + drive + ' /DELETE /YES'
2.101 - result = Cygwin.checkResult(Cygwin.execute('C:\\Windows\\system32\\net.exe', command))
2.102 - if string.find(str(result[1]), 'successfully',) == -1:
2.103 - logger.error(result[2])
2.104 + result = unmapDrive(drive, force=1)
2.105 + if result != 0:
2.106 continue
2.107
2.108