Exemple #1
0
        private void AddProcessToGuardJobObject(Process p)
        {
            this.InitializeGuard();

            // Careful to close the Guard Job Object,
            // else it is not guaranteed that the Job Object will not terminate if the Guard exists

            using (var guardJob = JobObject.Attach(this.user.Username + Prison.guardSuffix))
            {
                guardJob.AddProcess(p);
            }

            this.CheckGuard();
        }
Exemple #2
0
        public void Attach(ProcessPrisonCreateInfo createInfo)
        {
            if (createInfo.Id == null)
            {
                throw new ArgumentException("Id from createInfo is null", "createInfo");
            }

            if (createInfo.WindowsPassword == null)
            {
                throw new ArgumentException("WindowsPassword from createInfo is null", "createInfo");
            }

            this.Id = createInfo.Id;

            this.createInfo = createInfo;

            // The Job Object will disapear after a reboot or if all job's processes exit.
            // It is fine if it is created again with the same name id if the Job doesn't exist.

            try
            {
                // try only to attach and fail if it doesn't exist
                this.jobObject = JobObject.Attach(JobObjectNamespace() + this.Id);
            }
            catch (Win32Exception)
            {
                // try to create the job Id;
                this.jobObject = new JobObject(JobObjectNamespace() + this.Id);
            }


            this.WindowsPassword = this.createInfo.WindowsPassword;
            this.WindowsUsername = GenerateDecoratedUsername(this.Id);

            if (this.createInfo.DiskQuotaBytes > -1)
            {
                userQuota = DiskQuotaManager.GetDiskQuotaUser(DiskQuotaManager.GetVolumeRootFromPath(this.createInfo.DiskQuotaPath), this.WindowsUsername);
            }

            this.Created = true;
        }
Exemple #3
0
 private void CheckGuard()
 {
     using (var guardJob = JobObject.Attach(this.user.Username + Prison.guardSuffix))
     {
     }
 }