예제 #1
0
        public void Lockdown(PrisonConfiguration rules)
        {
            if (rules == null)
            {
                throw new ArgumentNullException("rules");
            }

            if (!Prison.wasInitialized)
            {
                throw new InvalidOperationException("Prison environment has not been initialized. Call Prison.Init to initialize.");
            }

            if (this.IsLocked)
            {
                throw new InvalidOperationException("This prison is already locked.");
            }

            Logger.Debug("Locking down prison {0}", this.Id);

            this.Configuration = rules;

            Directory.CreateDirectory(this.PrisonHomePath);

            if (rules.Rules != RuleTypes.None)
            {
                foreach (Type cellType in ruleTypes)
                {
                    Rule cell = (Rule)cellType.GetConstructor(Type.EmptyTypes).Invoke(null);
                    if (this.RuleEnabled(cell.RuleType))
                    {
                        this.prisonCells.Add(cell);
                    }
                }
            }

            // Create the Windows User
            this.User = new PrisonUser(this.Tag);
            this.User.Create();

            // InitializeSystemVirtualAddressSpaceQuotas();

            this.InitializeJobObject();

            // Lock all cells
            foreach (Rule cell in this.prisonCells)
            {
                if (cell.RuleType != RuleTypes.WindowStation)
                {
                    cell.Apply(this);
                }
            }

            this.User.Profile.CreateUserProfile();
            string customProfilePath = Path.Combine(this.PrisonHomePath, "profile");
            this.User.Profile.ChangeProfilePath(customProfilePath);

            // TODO: is guard supposed to run?
            // RunGuard();

            this.IsLocked = true;

            this.Save();
        }
예제 #2
0
        public void Lockdown(PrisonConfiguration rules)
        {
            if (rules == null)
            {
                throw new ArgumentNullException("rules");
            }

            if (!Prison.wasInitialized)
            {
                throw new InvalidOperationException("Prison environment has not been initialized. Call Prison.Init to initialize.");
            }

            if (this.IsLocked)
            {
                throw new InvalidOperationException("This prison is already locked.");
            }

            Logger.Debug("Locking down prison {0}", this.Id);

            this.Configuration = rules;

            Directory.CreateDirectory(this.PrisonHomePath);

            if (rules.Rules != RuleTypes.None)
            {
                foreach (Type cellType in ruleTypes)
                {
                    Rule cell = (Rule)cellType.GetConstructor(Type.EmptyTypes).Invoke(null);
                    if (this.RuleEnabled(cell.RuleType))
                    {
                        this.prisonCells.Add(cell);
                    }
                }
            }

            // Create the Windows User
            this.User = new PrisonUser(this.Tag);
            this.User.Create();

            // InitializeSystemVirtualAddressSpaceQuotas();

            this.InitializeJobObject();

            // Lock all cells
            foreach (Rule cell in this.prisonCells)
            {
                if (cell.RuleType != RuleTypes.WindowStation)
                {
                    cell.Apply(this);
                }
            }

            this.User.Profile.CreateUserProfile();
            string customProfilePath = Path.Combine(this.PrisonHomePath, "profile");

            this.User.Profile.ChangeProfilePath(customProfilePath);

            // TODO: is guard supposed to run?
            // RunGuard();

            this.IsLocked = true;

            this.Save();
        }