Ejemplo n.º 1
0
        static int Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                string assemblyname = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
                Console.WriteLine("{0} <setting> <encryptthis> [GUID]", assemblyname);
                Console.ResetColor();
                Console.WriteLine("   {0} SearchPW \"my p@asswor&\" 0f52390b-c781-43ae-bd62-553c77fa4cf7", assemblyname);
                Console.WriteLine("      add setting SearchPW and assign \"my p@asswor&\" to pluging 0f523...f7", assemblyname);
                Console.WriteLine("   {0} SearchPW \"my p@asswor&\"", assemblyname);
                Console.WriteLine("      add setting SearchPW and assign \"my p@asswor&\" to pgina config", assemblyname);
                return(3);
            }

            if (args.Length > 2 && !String.IsNullOrEmpty(args[2]))
            {
                try
                {
                    Guid GUID = Guid.Parse(args[2]);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("can't parse GUID:{0}", ex.Message);
                    return(4);
                }
            }

            try
            {
                if (args.Length > 2 && !String.IsNullOrEmpty(args[2]))
                {
                    m_settings = new pGina.Shared.Settings.pGinaDynamicSettings(Guid.Parse(args[2]));
                }
                else
                {
                    m_settings = new pGina.Shared.Settings.pGinaDynamicSettings();
                }

                m_settings.SetEncryptedSetting(args[0], args[1]);
                Abstractions.Settings.DynamicSettings setting = m_settings;

                if (!setting.GetEncryptedSetting(args[0]).Equals(args[1]))
                {
                    return(1);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception:{0}", ex.Message);
                return(2);
            }

            return(0);
        }
Ejemplo n.º 2
0
        private void getSettings()
        {
            try
            {
                Abstractions.Settings.DynamicSettings settings = new Abstractions.Settings.DynamicSettings(pGina.Plugin.pgSMB2.PluginImpl.PluginUuid, "global");
                Dictionary <string, string>           set      = settings.GetSettings(new string[] {});
                foreach (string text in set["MaxStoreText"].Split('\0'))
                {
                    string name  = text.Split(new char[] { '\t' }, 2).First();
                    string value = text.Split(new char[] { '\t' }, 2).Last();

                    switch (name)
                    {
                    case "MaxStoreUserprofile":
                        over_max_userprofile = value.Trim();
                        break;

                    case "MaxStorefree":
                        over_max_free = value.Trim();
                        break;

                    case "MaxStoreExceeded":
                        over_max_exceeded = value.Trim();
                        break;

                    case "MaxStoreWarningTitle":
                        over_max_warning_title = value.Trim();
                        break;

                    case "MaxStoreErrorTitle":
                        over_max_error_title = value.Trim();
                        break;

                    case "MaxStoreErrorText":
                        over_max_error_text = value.Trim();
                        break;

                    case "MaxStoreCalculateText":
                        over_max_calculate_text = value.Trim();
                        break;
                    }
                }
                exclude_dir = set["MaxStoreExclude"];

                top = new System.Windows.Forms.Form();
                msg = new Thread(() => MsgBox("is not null", "init"));
            }
            catch (Exception ex)
            {
                Program.Log(String.Format("Error in getSettings():{0}", ex.ToString()), EventLogEntryType.Error);
                Application.Exit();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get an encryted string containing a value of the pgina registry
        /// key.
        /// </summary>
        /// <returns></returns>
        public static string DecryptSetting(string subKey, string name)
        {
            try
            {
                dynamic s_settings = new Abstractions.Settings.DynamicSettings(subKey);
                return(s_settings.GetEncryptedSetting(name));
            }
            catch (Exception ex)
            {
                Abstractions.Logging.LibraryLogging.Error("DecryptSetting({0}, {1}) failed:{2}", subKey, name, ex.Message);
            }

            return(null);
        }
Ejemplo n.º 4
0
        private void ServerThread()
        {
            PipeSecurity security = new PipeSecurity();

            using (WindowsIdentity myself = WindowsIdentity.GetCurrent())
            {
                try
                {
                    // Anyone can talk to us
                    LibraryLogging.Debug("Setting PipeAccess R/W for world: {0}", Abstractions.Windows.Security.GetWellknownSID(WellKnownSidType.WorldSid));
                    security.AddAccessRule(new PipeAccessRule(Abstractions.Windows.Security.GetWellknownSID(WellKnownSidType.WorldSid), PipeAccessRights.ReadWrite, AccessControlType.Allow));

                    // But only we have full control (including the 'create' right, which allows us to be the server side of this equation)
                    LibraryLogging.Debug("Setting PipeAccess FullControl for myself: {0}", WindowsIdentity.GetCurrent().Name);
                    security.AddAccessRule(new PipeAccessRule(WindowsIdentity.GetCurrent().Owner, PipeAccessRights.FullControl, AccessControlType.Allow));
                }
                catch (Exception e)
                {
                    LibraryLogging.Error("Unable to set all pipe access rules, the security of the pGina service pipe is in an unknown state!: {0}", e);
                }
            }

            while (Running)
            {
                try
                {
                    using (NamedPipeServerStream pipeServer = new NamedPipeServerStream(Name, PipeDirection.InOut, MaxClients,
                                                                                        PipeTransmissionMode.Byte, PipeOptions.WriteThrough, 0, 0, security, HandleInheritability.None))
                    {
                        try
                        {
                            pipeServer.WaitForConnection();
                        }
                        catch (Exception e)
                        {
                            LibraryLogging.Error("Error in server connection handler: {0}", e);
                            continue;
                        }

                        // Handle this connection, note that we always expect client to initiate the
                        //  flow of messages, so we do not include an initial message
                        using (BinaryReader reader = new BinaryReader(pipeServer, Encoding.Unicode /*, true*/))
                        {
                            using (BinaryWriter writer = new BinaryWriter(pipeServer, Encoding.Unicode /*, true*/))
                            {
                                HandlePipeConnection(reader, writer, null);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    LibraryLogging.Error("Error while trying to open pipe server: {0}", e);
                    if (Running)
                    {
                        dynamic s_settings = new Abstractions.Settings.DynamicSettings();
                        Abstractions.Windows.Networking.sendMail(s_settings.GetSettings(new string[] { "notify_pass" }), "", "", String.Format("pGina: PipeServer error {0}", Environment.MachineName), e.ToString());
                    }
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Get a dictionary containing all values of the pgina registry
        /// key.  The Dictionary key is the sub-key name, the value is a pGinaDynamicSettings object
        /// corresponding to the sub-key.
        /// </summary>
        /// <returns></returns>
        public static Dictionary <string, string> GetSettings(string subKey, string[] encypted)
        {
            dynamic s_settings = new Abstractions.Settings.DynamicSettings(subKey);

            return(s_settings.GetSettings(encypted));
        }
Ejemplo n.º 6
0
        private void getSettings()
        {
            try
            {
                Abstractions.Settings.DynamicSettings settings = new Abstractions.Settings.DynamicSettings(pGina.Plugin.pgSMB2.PluginImpl.PluginUuid, "global");
                Dictionary<string,string> set = settings.GetSettings(new string[] {});
                foreach (string text in set["MaxStoreText"].Split('\0'))
                {
                    string name = text.Split(new char[] { '\t' }, 2).First();
                    string value = text.Split(new char[] { '\t' }, 2).Last();

                    switch (name)
                    {
                        case "MaxStoreUserprofile":
                            over_max_userprofile = value.Trim();
                            break;
                        case "MaxStorefree":
                            over_max_free = value.Trim();
                            break;
                        case "MaxStoreExceeded":
                            over_max_exceeded = value.Trim();
                            break;
                        case "MaxStoreWarningTitle":
                            over_max_warning_title = value.Trim();
                            break;
                        case "MaxStoreErrorTitle":
                            over_max_error_title = value.Trim();
                            break;
                        case "MaxStoreErrorText":
                            over_max_error_text = value.Trim();
                            break;
                        case "MaxStoreCalculateText":
                            over_max_calculate_text = value.Trim();
                            break;
                    }
                }
                exclude_dir = set["MaxStoreExclude"];

                top = new System.Windows.Forms.Form();
                msg = new Thread(() => MsgBox("is not null", "init"));
            }
            catch (Exception ex)
            {
                Program.Log(String.Format("Error in getSettings():{0}", ex.ToString()), EventLogEntryType.Error);
                Application.Exit();
            }
        }
Ejemplo n.º 7
0
        private void ServerThread()
        {
            PipeSecurity security = new PipeSecurity();

            using (WindowsIdentity myself = WindowsIdentity.GetCurrent())
            {
                try
                {
                    // Anyone can talk to us
                    LibraryLogging.Debug("Setting PipeAccess R/W for world: {0}", Abstractions.Windows.Security.GetWellknownSID(WellKnownSidType.WorldSid));
                    security.AddAccessRule(new PipeAccessRule(Abstractions.Windows.Security.GetWellknownSID(WellKnownSidType.WorldSid), PipeAccessRights.ReadWrite, AccessControlType.Allow));

                    // But only we have full control (including the 'create' right, which allows us to be the server side of this equation)
                    LibraryLogging.Debug("Setting PipeAccess FullControl for myself: {0}", WindowsIdentity.GetCurrent().Name);
                    security.AddAccessRule(new PipeAccessRule(WindowsIdentity.GetCurrent().Owner, PipeAccessRights.FullControl, AccessControlType.Allow));
                }
                catch (Exception e)
                {
                    LibraryLogging.Error("Unable to set all pipe access rules, the security of the pGina service pipe is in an unknown state!: {0}", e);
                }
            }

            while (Running)
            {
                try
                {
                    using (NamedPipeServerStream pipeServer = new NamedPipeServerStream(Name, PipeDirection.InOut, MaxClients,
                            PipeTransmissionMode.Byte, PipeOptions.WriteThrough, 0, 0, security, HandleInheritability.None))
                    {
                        try
                        {
                            pipeServer.WaitForConnection();
                        }
                        catch (Exception e)
                        {
                            LibraryLogging.Error("Error in server connection handler: {0}", e);
                            continue;
                        }

                        // Handle this connection, note that we always expect client to initiate the
                        //  flow of messages, so we do not include an initial message
                        using (BinaryReader reader = new BinaryReader(pipeServer, Encoding.Unicode/*, true*/))
                        {
                            using (BinaryWriter writer = new BinaryWriter(pipeServer, Encoding.Unicode/*, true*/))
                            {
                                HandlePipeConnection(reader, writer, null);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    LibraryLogging.Error("Error while trying to open pipe server: {0}", e);
                    if (Running)
                    {
                        dynamic s_settings = new Abstractions.Settings.DynamicSettings();
                        Abstractions.Windows.Networking.sendMail(s_settings.GetSettings(new string[] { "notify_pass" }), "", "", String.Format("pGina: PipeServer error {0}", Environment.MachineName), e.ToString());
                    }
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Get an encryted string containing a value of the pgina registry
        /// key.
        /// </summary>
        /// <returns></returns>
        public static string DecryptSetting(string subKey, string name)
        {
            try
            {
                dynamic s_settings = new Abstractions.Settings.DynamicSettings(subKey);
                return s_settings.GetEncryptedSetting(name);
            }
            catch (Exception ex)
            {
                Abstractions.Logging.LibraryLogging.Error("DecryptSetting({0}, {1}) failed:{2}", subKey, name, ex.Message);
            }

            return null;
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Get a dictionary containing all values of the pgina registry
 /// key.  The Dictionary key is the sub-key name, the value is a pGinaDynamicSettings object
 /// corresponding to the sub-key.
 /// </summary>
 /// <returns></returns>
 public static Dictionary<string, string> GetSettings(string subKey, string[] encypted)
 {
     dynamic s_settings = new Abstractions.Settings.DynamicSettings(subKey);
     return s_settings.GetSettings(encypted);
 }