protected static string getPartitionId(string driveLetter)
        {
            string            command = getDCCon() + @" -enum";
            ExecuteParameters eparams = new ExecuteParameters(command, "DC enum");
            string            output  = ProcessControl.CommandOutputSync(eparams);

            string[] lines = output.Split('\n');
            foreach (string line in lines)
            {
                if (line.Contains("reboot you system"))
                {
                    return(null);
                }

                if (line.Contains("is not compatible with the version of Windows"))
                {
                    return(null);
                }

                string[] parts = line.Split('|');
                if (parts.Length != 4)
                {
                    continue;
                }
                string drivePart = parts[1];
                if (drivePart.Contains(" " + driveLetter + ": "))
                {
                    string partitionIdPart = parts[0];
                    return(partitionIdPart.Trim());
                }
            }
            return(null);
        }
        protected static void installDC()
        {
            string            command = getDCInst() + @" -setup";
            ExecuteParameters eparams = new ExecuteParameters(command, "DC install");

            ProcessControl.CommandOutputSync(eparams);
        }
        protected static void deconfigureDC()
        {
            string            command = getDCCon() + @" -deconfig-mydlp";
            ExecuteParameters eparams = new ExecuteParameters(command, "DC deconfig mydlp");

            ProcessControl.CommandOutputSync(eparams);
        }
        protected static void unmountPartition(string partitionId)
        {
            string            command = getDCCon() + @" -unmount " + partitionId + " -f";
            ExecuteParameters eparams = new ExecuteParameters(command, "DC unmount");

            ProcessControl.CommandOutputSync(eparams);
        }
        protected static void unmountAllEncryptedPartitions()
        {
            string            command = getDCCon() + @" -unmountall -f";
            ExecuteParameters eparams = new ExecuteParameters(command, "DC unmountall");

            ProcessControl.CommandOutputSync(eparams);
        }
        protected static void cleanupMemory()
        {
            string            command = getDCCon() + @" -clean";
            ExecuteParameters eparams = new ExecuteParameters(command, "DC clean");

            ProcessControl.CommandOutputSync(eparams);
        }
        protected static void mountAllEncryptedPartitions()
        {
            string keyfile = Engine.GetShortPath(SeapClient.GetKeyfile());

            if (File.Exists(keyfile))
            {
                string            command = getDCCon() + @" -mountall -p mydlp -kf " + keyfile;
                ExecuteParameters eparams = new ExecuteParameters(command, "DC mountall");
                ProcessControl.CommandOutputSync(eparams);
                File.Delete(keyfile);
            }
        }
        protected static void formatPartition(string partitionId, string fsType)
        {
            string keyfile = Engine.GetShortPath(SeapClient.GetKeyfile());

            if (File.Exists(keyfile))
            {
                string            command = getDCCon() + @" -format " + partitionId + " -q -" + fsType + " -a -p mydlp -kf " + keyfile;
                ExecuteParameters eparams = new ExecuteParameters(command, "DC format");
                ProcessControl.CommandOutputSync(eparams);
                File.Delete(keyfile);
            }
        }
        protected static bool isEncrypted(string partitionId)
        {
            string            command = getDCCon() + @" -info " + partitionId;
            ExecuteParameters eparams = new ExecuteParameters(command, "DC isEncrypted");
            string            output  = ProcessControl.CommandOutputSync(eparams);

            string[] lines = output.Split('\n');
            foreach (string line in lines)
            {
                if (line.StartsWith("Cipher:"))
                {
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 10
0
        protected static bool doesNeedFormatting(string partitionId)
        {
            string            command = getDCCon() + @" -info " + partitionId;
            ExecuteParameters eparams = new ExecuteParameters(command, "DC doesNeedFormatting");
            string            output  = ProcessControl.CommandOutputSync(eparams);

            string[] lines = output.Split('\n');
            foreach (string line in lines)
            {
                if (line.StartsWith("Status:") &&
                    (line.Contains("boot") || line.Contains("system"))
                    )
                {
                    return(false);
                }

                if (line.StartsWith("Device:") && line.Contains(@"\\Device\CdRom"))
                {
                    return(false);
                }


                if (line.StartsWith("Cipher:"))
                {
                    return(false);
                }

                if (line.Contains("reboot you system"))
                {
                    return(false);
                }

                if (line.Contains("is not compatible with the version of Windows"))
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 11
0
        public static void Start()
        {
            javaStartCmd           = @"cd " + Configuration.JavaBackendPath + " && Run.bat";
            erlStartCmd            = @"cd " + Configuration.ErlangPath + " && Run.bat";
            erlInstallCmd          = @"cd " + Configuration.ErlangPath + " && RegisterService.bat";
            erlStartInteractiveCmd = @"cd " + Configuration.ErlangPath + " && InteractiveRun.bat";

            DelPids();

            KillProcByName("erl");
            KillProcByName("werl");
            KillProcByName("java");

            EnvVar[] erlEnv = new EnvVar[] {
                new EnvVar("MYDLP_CONF", GetShortPath(Configuration.MydlpConfPath).Replace(@"\", @"/")),
                new EnvVar("MYDLPBEAMDIR", GetShortPath(Configuration.ErlangPath)),
                new EnvVar("MYDLP_APPDIR", GetShortPath(Configuration.AppPath)),
                new EnvVar("ERLANG_HOME", GetShortPath(Configuration.ErlangHome))
            };

            int phyMemory  = GetPhysicalMemory();
            int javaMemory = 256;

            if (phyMemory < 300)
            {
                Logger.GetInstance().Error("Not enough memory, MyDLP Engine can not function under 300 MB memory");
                Engine.Stop();
                return;
            }

            else if (phyMemory < 600)
            {
                javaMemory = 256;
            }

            else
            {
                javaMemory = 256 + ((phyMemory - 600) / 4);

                if (javaMemory > xmx32BitLimit)
                {
                    javaMemory = xmx32BitLimit;
                }
            }

            Logger.GetInstance().Info("Setting Java memory: " + javaMemory);


            EnvVar[] javaEnv = new EnvVar[] {
                new EnvVar("JRE_BIN_DIR", GetShortPath(Configuration.JavaBinPaths)),
                new EnvVar("BACKEND_DIR", GetShortPath(Configuration.JavaPath)),
                new EnvVar("MYDLP_APPDIR", GetShortPath(Configuration.AppPath)),
                new EnvVar("JAVAXMX", javaMemory.ToString())
            };


            if (!System.Environment.UserInteractive && SvcController.IsServiceInstalled("mydlpengine"))
            {
                if (SvcController.IsServiceRunning("mydlpengine"))
                {
                    SvcController.StopService("mydlpengine", 5000);
                }

                ProcessControl.ExecuteCommandSync(new ExecuteParameters("sc delete mydlpengine", "SC", erlEnv));
            }

            try
            {
                using (RegistryKey key = Registry.LocalMachine.OpenSubKey("Software\\Ericsson\\Erlang", true))
                {
                    key.DeleteSubKeyTree("ErlSrv");
                }
            }
            catch
            {
                //Logger.GetInstance().Info("Unable to delete uneccessary keys or keys do not exists");
            }

            Logger.GetInstance().Info("Starting Java Backend");


            ProcessControl.ExecuteCommandAsync(javaStartCmd, "JAVA:", javaEnv);

            Configuration.SetErlConf();

            Logger.GetInstance().Info("Starting Erlang Backend");
            if (System.Environment.UserInteractive)
            {
                ProcessControl.ExecuteCommandAsync(erlStartInteractiveCmd, "WERL", erlEnv);
            }
            else
            {
                ProcessControl.ExecuteCommandAsync(erlStartCmd, "ERL", erlEnv);
            }
        }
Esempio n. 12
0
        public static void Stop()
        {
            Logger.GetInstance().Info("Stopping Erlang Backend");

            /*
             * Logger.GetInstance().Debug("Kill erlang by pid:" + Configuration.ErlPid);
             * if (Configuration.ErlPid != 0)
             * {
             *  try
             *  {
             *      Process p = Process.GetProcessById(Configuration.ErlPid);
             *      p.Kill();
             *  }
             *  catch
             *  {
             *      Logger.GetInstance().Debug("Kill erlang by pid failed:" + Configuration.ErlPid);
             *  }
             * }*/

            if (System.Environment.UserInteractive)
            {
                KillProcByName("werl");
            }
            else
            {
                KillProcByName("erl");
            }
            KillProcByName("epmd");

            Logger.GetInstance().Info("Stopping Java Backend");

            /*
             * Logger.GetInstance().Debug("Kill java by pid:" + Configuration.JavaPid);
             * if (Configuration.JavaPid != 0)
             * {
             *  try
             *  {
             *      Process p = Process.GetProcessById(Configuration.JavaPid);
             *      p.Kill();
             *  }
             *  catch
             *  {
             *      Logger.GetInstance().Debug("Kill java by pid failed:" + Configuration.JavaPid);
             *  }
             * }*/

            KillProcByName("java");


            if (!System.Environment.UserInteractive && SvcController.IsServiceInstalled("mydlpengine"))
            {
                if (SvcController.IsServiceRunning("mydlpengine"))
                {
                    SvcController.StopService("mydlpengine", 5000);
                }


                EnvVar[] erlEnv = new EnvVar[] {
                    new EnvVar("MYDLP_CONF", GetShortPath(Configuration.MydlpConfPath).Replace(@"\", @"/")),
                    new EnvVar("MYDLPBEAMDIR", GetShortPath(Configuration.ErlangPath)),
                    new EnvVar("MYDLP_APPDIR", GetShortPath(Configuration.AppPath)),
                    new EnvVar("ERLANG_HOME", GetShortPath(Configuration.ErlangHome))
                };

                ProcessControl.ExecuteCommandSync(new ExecuteParameters("sc delete mydlpengine", "SC", erlEnv));
            }

            DelPids();

            try
            {
                using (RegistryKey key = Registry.LocalMachine.OpenSubKey("Software\\Ericsson\\Erlang", true))
                {
                    key.DeleteSubKeyTree("ErlSrv");
                }
            }
            catch
            {
                //Logger.GetInstance().Info("Unable to delete uneccessary keys or keys do not exists");
            }
        }