Ejemplo n.º 1
0
        /// <summary>
        /// Checks access to file
        /// </summary>
        /// <param name="filePath">Path to file for check</param>
        /// <param name="permissionAccess">Permission to check</param>
        private static void CheckFileAccess(string filePath, FileIOPermissionAccess permissionAccess)
        {
            if (!Path.IsPathRooted(filePath))
            {
                var currentExecutablePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                if (string.IsNullOrWhiteSpace(currentExecutablePath))
                {
                    throw new ConfigurationException("Failed to determine current executable path");
                }

                filePath = Path.Combine(currentExecutablePath, filePath);
            }

            var configDirectory = Path.GetDirectoryName(filePath);
            if (string.IsNullOrWhiteSpace(configDirectory))
            {
                throw new ConfigurationException("ClusterKit.Web.Nginx.PathToConfig has no defined directory");
            }

            if (!Directory.Exists(configDirectory))
            {
                throw new ConfigurationException($"{configDirectory} does not exists");
            }

            var path = File.Exists(filePath) ? filePath : configDirectory;
            var permission = new FileIOPermission(permissionAccess, path);
            if (!permission.IsGranted())
            {
                throw new ConfigurationException($"Cannot access {path} for writing");
            }
        }
 internal LogStream(string path, int bufferSize, LogRetentionOption retention, long maxFileSize, int maxNumOfFiles)
 {
     string fullPath = Path.GetFullPath(path);
     this._fileName = fullPath;
     if (fullPath.StartsWith(@"\\.\", StringComparison.Ordinal))
     {
         throw new NotSupportedException(System.SR.GetString("NotSupported_IONonFileDevices"));
     }
     Microsoft.Win32.UnsafeNativeMethods.SECURITY_ATTRIBUTES secAttrs = GetSecAttrs(FileShare.Read);
     int num = 0x100000;
     this._canWrite = true;
     this._pathSav = fullPath;
     this._fAccessSav = 0x40000000;
     this._shareSav = FileShare.Read;
     this._secAttrsSav = secAttrs;
     this._secAccessSav = FileIOPermissionAccess.Write;
     this._modeSav = (retention != LogRetentionOption.SingleFileUnboundedSize) ? FileMode.Create : FileMode.OpenOrCreate;
     this._flagsAndAttributesSav = num;
     this._seekToEndSav = retention == LogRetentionOption.SingleFileUnboundedSize;
     base.bufferSize = bufferSize;
     this._retention = retention;
     this._maxFileSize = maxFileSize;
     this._maxNumberOfFiles = maxNumOfFiles;
     this._Init(fullPath, this._fAccessSav, this._shareSav, this._secAttrsSav, this._secAccessSav, this._modeSav, this._flagsAndAttributesSav, this._seekToEndSav);
 }
	public FileIOPermission(FileIOPermissionAccess flag, String pathList)
			{
				if(pathList == null)
				{
					throw new ArgumentNullException("pathList");
				}
				if((flag & ~(FileIOPermissionAccess.AllAccess)) != 0)
				{
					throw new ArgumentException(_("Arg_FileIOAccess"));
				}
				this.state = PermissionState.None;
				String[] split = EnvironmentPermission.SplitPath(pathList);
				if((flag & FileIOPermissionAccess.Read) != 0)
				{
					readList = split;
				}
				if((flag & FileIOPermissionAccess.Write) != 0)
				{
					writeList = split;
				}
				if((flag & FileIOPermissionAccess.Append) != 0)
				{
					appendList = split;
				}
				if((flag & FileIOPermissionAccess.PathDiscovery) != 0)
				{
					discoveryList = split;
				}
				allLocalFiles = FileIOPermissionAccess.NoAccess;
				allFiles = FileIOPermissionAccess.NoAccess;
			}
Ejemplo n.º 4
0
		/// <summary>
		/// Ensure chosen filepath is not protected before operating
		/// </summary>
		/// <param name="Path">The location to check access to</param>
		/// <param name="ShowDialog">Whether to show an error message</param>
		/// <param name="Permissions">What type of permissions to check for</param>
		/// <returns></returns>
		public static PathType Accessible(
			string Path
			, bool ShowDialog = true
			, FileIOPermissionAccess Permissions = FileIOPermissionAccess.Read | FileIOPermissionAccess.Write)
		{
			PathType pathType = PathType.Invalid;

			try {
				if (!string.IsNullOrWhiteSpace(Path)) {
					if (Directory.Exists(Path)) {
						foreach (string dir in Directory.EnumerateDirectories(Path, "*", SearchOption.TopDirectoryOnly)) {
							(new FileIOPermission(Permissions, dir)).Demand();
						}
						pathType = PathType.ValidDirectory;
					}
					else if (File.Exists(Path)) {
						(new FileIOPermission(Permissions, Path)).Demand();
						pathType = PathType.ValidFile;
					}
				}
			} catch (Exception exc) {
				SQL.LogMessage(exc, SQL.EventType.HandledException, Path);
			}

			if (pathType == PathType.Invalid && ShowDialog) {
				xMessage.ShowError("The indicated HDD location could not be opened. Either it doesn't exist or you don't have permission.\n" + Path);
			}

			return pathType;
		}
Ejemplo n.º 5
0
        [System.Security.SecuritySafeCritical]  // auto-generated
        public FileIOPermission(FileIOPermissionAccess access, String path)
        {
            VerifyAccess(access);

            String[] pathList = new String[] { path };
            AddPathList(access, pathList, false, true, false);
        }
Ejemplo n.º 6
0
		public FileIOPermission (FileIOPermissionAccess access, string[] pathList)
		{
			if (pathList == null)
				throw new ArgumentNullException ("pathList");

			CreateLists ();
			// access and path will be validated in AddPathList
			AddPathList (access, pathList);
		}
Ejemplo n.º 7
0
 public void SetPathList( FileIOPermissionAccess access, String path )
 {
     String[] pathList;
     if(path == null)
         pathList = new String[] {};
     else
         pathList = new String[] { path };
     SetPathList( access, pathList, false );
 }
Ejemplo n.º 8
0
		public FileIOPermission (PermissionState state)
		{
			if (CheckPermissionState (state, true) == PermissionState.Unrestricted) {
				m_Unrestricted = true;
				m_AllFilesAccess = FileIOPermissionAccess.AllAccess;
				m_AllLocalFilesAccess = FileIOPermissionAccess.AllAccess;
			}
			CreateLists ();
		}
Ejemplo n.º 9
0
        public static bool VerifyVermission(FileIOPermissionAccess permission, string path)
        {
            var ioPermission = new FileIOPermission(permission, path);

            try
            {
                ioPermission.Demand();
                return true;
            }
            catch (SecurityException s)
            {
                return false;
            }
        }
	// Constructors.
	public FileIOPermission(PermissionState state)
			{
				if(state != PermissionState.Unrestricted &&
				   state != PermissionState.None)
				{
					throw new ArgumentException(_("Arg_PermissionState"));
				}
				this.state = state;
				if(state == PermissionState.Unrestricted)
				{
					allLocalFiles = FileIOPermissionAccess.AllAccess;
					allFiles = FileIOPermissionAccess.AllAccess;
				}
				else
				{
					allLocalFiles = FileIOPermissionAccess.NoAccess;
					allFiles = FileIOPermissionAccess.NoAccess;
				}
			}
 internal void _Init(string path, int fAccess, FileShare share, Microsoft.Win32.UnsafeNativeMethods.SECURITY_ATTRIBUTES secAttrs, FileIOPermissionAccess secAccess, FileMode mode, int flagsAndAttributes, bool seekToEnd)
 {
     string fullPath = Path.GetFullPath(path);
     this._fileName = fullPath;
     new FileIOPermission(secAccess, new string[] { fullPath }).Demand();
     int newMode = Microsoft.Win32.UnsafeNativeMethods.SetErrorMode(1);
     try
     {
         this._handle = Microsoft.Win32.UnsafeNativeMethods.SafeCreateFile(fullPath, fAccess, share, secAttrs, mode, flagsAndAttributes, Microsoft.Win32.UnsafeNativeMethods.NULL);
         int errorCode = Marshal.GetLastWin32Error();
         if (this._handle.IsInvalid)
         {
             bool flag = false;
             try
             {
                 new FileIOPermission(FileIOPermissionAccess.PathDiscovery, new string[] { this._fileName }).Demand();
                 flag = true;
             }
             catch (SecurityException)
             {
             }
             if (flag)
             {
                 System.IO.__Error.WinIOError(errorCode, this._fileName);
             }
             else
             {
                 System.IO.__Error.WinIOError(errorCode, Path.GetFileName(this._fileName));
             }
         }
     }
     finally
     {
         Microsoft.Win32.UnsafeNativeMethods.SetErrorMode(newMode);
     }
     base.pos = 0L;
     if (seekToEnd)
     {
         this.SeekCore(0L, SeekOrigin.End);
     }
 }
Ejemplo n.º 12
0
 private static bool AccessIsSet(FileIOPermissionAccess access, FileIOPermissionAccess question)
 {
     return (access & question) != 0;
 }
Ejemplo n.º 13
0
 public FileCodeGroup(IMembershipCondition membershipCondition, FileIOPermissionAccess access)
     : base(membershipCondition, null)
 {
     // note: FileIOPermissionAccess is a [Flag]
     m_access = access;
 }
Ejemplo n.º 14
0
        [System.Security.SecurityCritical]  // auto-generated
        internal void AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, bool checkForDuplicates, bool needFullPath, bool copyPathList)
        {
            if (pathListOrig == null)
            {
                throw new ArgumentNullException("pathList");
            }
            if (pathListOrig.Length == 0)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_EmptyPath"));
            }
            Contract.EndContractBlock();
            // @

            VerifyAccess(access);

            if (m_unrestricted)
                return;

            String[] pathList = pathListOrig;
            if (copyPathList)
            {
                // Make a copy of pathList (in case its value changes after we check for illegal chars)
                pathList = new String[pathListOrig.Length];
                Array.Copy(pathListOrig, pathList, pathListOrig.Length);
            }

            // If we need the full path the standard illegal characters will be checked in StringExpressionSet.
            CheckIllegalCharacters(pathList, onlyCheckExtras: needFullPath);

            // StringExpressionSet will do minor normalization, trimming spaces and replacing alternate
            // directory separators. It will make an attemt to expand short file names and will check
            // for standard colon placement.
            //
            // If needFullPath is true it will call NormalizePath- which performs short name expansion
            // and does the normal validity checks.
            ArrayList pathArrayList = StringExpressionSet.CreateListFromExpressions(pathList, needFullPath);

            if ((access & FileIOPermissionAccess.Read) != 0)
            {
                if (m_read == null)
                {
                    m_read = new FileIOAccess();
                }
                m_read.AddExpressions(pathArrayList, checkForDuplicates);
            }

            if ((access & FileIOPermissionAccess.Write) != 0)
            {
                if (m_write == null)
                {
                    m_write = new FileIOAccess();
                }
                m_write.AddExpressions(pathArrayList, checkForDuplicates);
            }

            if ((access & FileIOPermissionAccess.Append) != 0)
            {
                if (m_append == null)
                {
                    m_append = new FileIOAccess();
                }
                m_append.AddExpressions(pathArrayList, checkForDuplicates);
            }

            if ((access & FileIOPermissionAccess.PathDiscovery) != 0)
            {
                if (m_pathDiscovery == null)
                {
                    m_pathDiscovery = new FileIOAccess(true);
                }
                m_pathDiscovery.AddExpressions(pathArrayList, checkForDuplicates);
            }

#if FEATURE_MACL
            if ((control & AccessControlActions.View) != 0)
            {
                if (m_viewAcl == null)
                {
                    m_viewAcl = new FileIOAccess();
                }
                m_viewAcl.AddExpressions(pathArrayList, checkForDuplicates);
            }

            if ((control & AccessControlActions.Change) != 0)
            {
                if (m_changeAcl == null)
                {
                    m_changeAcl = new FileIOAccess();
                }
                m_changeAcl.AddExpressions(pathArrayList, checkForDuplicates);
            }
#endif
        }
Ejemplo n.º 15
0
 private static void VerifyAccess(FileIOPermissionAccess access)
 {
     if ((access & ~FileIOPermissionAccess.AllAccess) != 0)
         throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", (int)access));
 }
Ejemplo n.º 16
0
 internal void SetPathList(FileIOPermissionAccess access,
     String[] pathList, bool checkForDuplicates)
 {
     SetPathList(access, AccessControlActions.None, pathList, checkForDuplicates);
 }
Ejemplo n.º 17
0
 [System.Security.SecuritySafeCritical]  // auto-generated
 public void AddPathList(FileIOPermissionAccess access, String[] pathList)
 {
     AddPathList(access, pathList, true, true, true);
 }
Ejemplo n.º 18
0
 internal FileIOPermission(FileIOPermissionAccess access, AccessControlActions control, string[] pathList, bool checkForDuplicates, bool needFullPath)
 {
     FileIOPermission.VerifyAccess(access);
     this.AddPathList(access, control, pathList, checkForDuplicates, needFullPath, true);
 }
Ejemplo n.º 19
0
 internal static void QuickDemand(FileIOPermissionAccess access, AccessControlActions control, string[] fullPathList, bool checkForDuplicates = true, bool needFullPath = true)
 {
     if (!CodeAccessSecurityEngine.QuickCheckForAllDemands())
     {
         new FileIOPermission(access, control, fullPathList, checkForDuplicates, needFullPath).Demand();
     }
     else
     {
         foreach (string fullPath in fullPathList)
         {
             EmulateFileIOPermissionChecks(fullPath);
         }
     }
 }
Ejemplo n.º 20
0
 public FileCodeGroup(IMembershipCondition membershipCondition, FileIOPermissionAccess access)
     : base(membershipCondition, (PolicyStatement)null)
 {
     m_access = access;
 }
Ejemplo n.º 21
0
 public string[] GetPathList(FileIOPermissionAccess access)
 {
     return(null);
 }
Ejemplo n.º 22
0
 /// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.FileCodeGroup" /> class.</summary>
 /// <param name="membershipCondition">A membership condition that tests evidence to determine whether this code group applies policy. </param>
 /// <param name="access">One of the <see cref="T:System.Security.Permissions.FileIOPermissionAccess" /> values. This value is used to construct the <see cref="T:System.Security.Permissions.FileIOPermission" /> that is granted. </param>
 /// <exception cref="T:System.ArgumentNullException">The <paramref name="membershipCondition" /> parameter is null. </exception>
 /// <exception cref="T:System.ArgumentException">The type of the <paramref name="membershipCondition" /> parameter is not valid.-or- The type of the <paramref name="access" /> parameter is not valid. </exception>
 public FileCodeGroup(IMembershipCondition membershipCondition, FileIOPermissionAccess access) : base(membershipCondition, null)
 {
     this.m_access = access;
 }
Ejemplo n.º 23
0
 [System.Security.SecuritySafeCritical]  // auto-generated
 public FileIOPermission(FileIOPermissionAccess access, AccessControlActions control, String[] pathList)
     : this(access, control, pathList, true, true)
 {
 }
Ejemplo n.º 24
0
        [System.Security.SecurityCritical]  // auto-generated
        internal void AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, bool checkForDuplicates, bool needFullPath, bool copyPathList)
        {
            if (pathListOrig == null)
            {
                throw new ArgumentNullException("pathList");
            }
            if (pathListOrig.Length == 0)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_EmptyPath"));
            }
            Contract.EndContractBlock();

            VerifyAccess(access);

            if (m_unrestricted)
            {
                return;
            }

            String[] pathList = pathListOrig;
            if (copyPathList)
            {
                // Make a copy of pathList (in case its value changes after we check for illegal chars)
                pathList = new String[pathListOrig.Length];
                Array.Copy(pathListOrig, pathList, pathListOrig.Length);
            }

            CheckIllegalCharacters(pathList);
            ArrayList pathArrayList = StringExpressionSet.CreateListFromExpressions(pathList, needFullPath);

            if ((access & FileIOPermissionAccess.Read) != 0)
            {
                if (m_read == null)
                {
                    m_read = new FileIOAccess();
                }
                m_read.AddExpressions(pathArrayList, checkForDuplicates);
            }

            if ((access & FileIOPermissionAccess.Write) != 0)
            {
                if (m_write == null)
                {
                    m_write = new FileIOAccess();
                }
                m_write.AddExpressions(pathArrayList, checkForDuplicates);
            }

            if ((access & FileIOPermissionAccess.Append) != 0)
            {
                if (m_append == null)
                {
                    m_append = new FileIOAccess();
                }
                m_append.AddExpressions(pathArrayList, checkForDuplicates);
            }

            if ((access & FileIOPermissionAccess.PathDiscovery) != 0)
            {
                if (m_pathDiscovery == null)
                {
                    m_pathDiscovery = new FileIOAccess(true);
                }
                m_pathDiscovery.AddExpressions(pathArrayList, checkForDuplicates);
            }

#if FEATURE_MACL
            if ((control & AccessControlActions.View) != 0)
            {
                if (m_viewAcl == null)
                {
                    m_viewAcl = new FileIOAccess();
                }
                m_viewAcl.AddExpressions(pathArrayList, checkForDuplicates);
            }

            if ((control & AccessControlActions.Change) != 0)
            {
                if (m_changeAcl == null)
                {
                    m_changeAcl = new FileIOAccess();
                }
                m_changeAcl.AddExpressions(pathArrayList, checkForDuplicates);
            }
#endif
        }
Ejemplo n.º 25
0
 /// <summary>设置对指定文件和目录的指定访问权限,同时用一组新路径替换指定访问权限的当前状态。</summary>
 /// <param name="access">
 /// <see cref="T:System.Security.Permissions.FileIOPermissionAccess" /> 值的按位组合。</param>
 /// <param name="pathList">一个数组,它包含文件和目录的绝对路径。</param>
 /// <exception cref="T:System.ArgumentException">
 /// <paramref name="access" /> 参数不是有效的 <see cref="T:System.Security.Permissions.FileIOPermissionAccess" /> 值。- 或 -<paramref name="pathList" /> 参数中的项不是有效的字符串。</exception>
 public void SetPathList(FileIOPermissionAccess access, string[] pathList)
 {
     this.SetPathList(access, pathList, true);
 }
Ejemplo n.º 26
0
        internal void AddPathList(FileIOPermissionAccess access, AccessControlActions control, string[] pathListOrig, bool checkForDuplicates, bool needFullPath, bool copyPathList)
        {
            if (pathListOrig == null)
            {
                throw new ArgumentNullException("pathList");
            }
            if (pathListOrig.Length == 0)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_EmptyPath"));
            }
            FileIOPermission.VerifyAccess(access);
            if (this.m_unrestricted)
            {
                return;
            }
            string[] str = pathListOrig;
            if (copyPathList)
            {
                str = new string[pathListOrig.Length];
                Array.Copy((Array)pathListOrig, (Array)str, pathListOrig.Length);
            }
            FileIOPermission.CheckIllegalCharacters(str);
            ArrayList listFromExpressions = StringExpressionSet.CreateListFromExpressions(str, needFullPath);

            if ((access & FileIOPermissionAccess.Read) != FileIOPermissionAccess.NoAccess)
            {
                if (this.m_read == null)
                {
                    this.m_read = new FileIOAccess();
                }
                this.m_read.AddExpressions(listFromExpressions, checkForDuplicates);
            }
            if ((access & FileIOPermissionAccess.Write) != FileIOPermissionAccess.NoAccess)
            {
                if (this.m_write == null)
                {
                    this.m_write = new FileIOAccess();
                }
                this.m_write.AddExpressions(listFromExpressions, checkForDuplicates);
            }
            if ((access & FileIOPermissionAccess.Append) != FileIOPermissionAccess.NoAccess)
            {
                if (this.m_append == null)
                {
                    this.m_append = new FileIOAccess();
                }
                this.m_append.AddExpressions(listFromExpressions, checkForDuplicates);
            }
            if ((access & FileIOPermissionAccess.PathDiscovery) != FileIOPermissionAccess.NoAccess)
            {
                if (this.m_pathDiscovery == null)
                {
                    this.m_pathDiscovery = new FileIOAccess(true);
                }
                this.m_pathDiscovery.AddExpressions(listFromExpressions, checkForDuplicates);
            }
            if ((control & AccessControlActions.View) != AccessControlActions.None)
            {
                if (this.m_viewAcl == null)
                {
                    this.m_viewAcl = new FileIOAccess();
                }
                this.m_viewAcl.AddExpressions(listFromExpressions, checkForDuplicates);
            }
            if ((control & AccessControlActions.Change) == AccessControlActions.None)
            {
                return;
            }
            if (this.m_changeAcl == null)
            {
                this.m_changeAcl = new FileIOAccess();
            }
            this.m_changeAcl.AddExpressions(listFromExpressions, checkForDuplicates);
        }
Ejemplo n.º 27
0
 public FileIOPermission(FileIOPermissionAccess access, AccessControl.AccessControlActions actions, string[] pathList)
 {
 }
Ejemplo n.º 28
0
 public IFileIOPermission CreateFileIOPermission(FileIOPermissionAccess access, string[] pathList)
 {
     return(new FileIOPermissionWrap(access, pathList));
 }
Ejemplo n.º 29
0
 public void SetPathList(FileIOPermissionAccess access, string path)
 {
 }
Ejemplo n.º 30
0
 public IFileIOPermission CreateFileIOPermission(FileIOPermissionAccess access, AccessControlActions control, string[] pathList)
 {
     return(new FileIOPermissionWrap(access, control, pathList));
 }
Ejemplo n.º 31
0
 internal static void QuickDemand(FileIOPermissionAccess access, string fullPath, bool checkForDuplicates = false, bool needFullPath = false)
 {
     EmulateFileIOPermissionChecks(fullPath);
 }
Ejemplo n.º 32
0
 internal FileIOPermission(FileIOPermissionAccess access, string[] pathList, bool checkForDuplicates, bool needFullPath)
 {
 }
Ejemplo n.º 33
0
        [System.Security.SecurityCritical]  // auto-generated
        internal FileIOPermission(FileIOPermissionAccess access, AccessControlActions control, String[] pathList, bool checkForDuplicates, bool needFullPath)
        {
            VerifyAccess(access);

            AddPathList(access, control, pathList, checkForDuplicates, needFullPath, true);
        }
Ejemplo n.º 34
0
 public FileIOPermission(FileIOPermissionAccess access, string path)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 35
0
        [System.Security.SecuritySafeCritical]  // auto-generated
        internal void SetPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathList, bool checkForDuplicates)
        {
            VerifyAccess(access);

            if ((access & FileIOPermissionAccess.Read) != 0)
                m_read = null;

            if ((access & FileIOPermissionAccess.Write) != 0)
                m_write = null;

            if ((access & FileIOPermissionAccess.Append) != 0)
                m_append = null;

            if ((access & FileIOPermissionAccess.PathDiscovery) != 0)
                m_pathDiscovery = null;

#if FEATURE_MACL
            if ((control & AccessControlActions.View) != 0)
                m_viewAcl = null;

            if ((control & AccessControlActions.Change) != 0)
                m_changeAcl = null;
#else
            m_viewAcl = null;
            m_changeAcl = null;
#endif

            m_unrestricted = false;
#if FEATURE_MACL
            AddPathList(access, control, pathList, checkForDuplicates, true, true);
#else
            AddPathList( access, pathList, checkForDuplicates, true, true );
#endif
        }
Ejemplo n.º 36
0
 public FileIOPermission(FileIOPermissionAccess access, AccessControlActions control, string[] pathList)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 37
0
 [System.Security.SecurityCritical]  // auto-generated
 internal void AddPathList(FileIOPermissionAccess access, String[] pathListOrig, bool checkForDuplicates, bool needFullPath, bool copyPathList)
 {
     AddPathList(access, AccessControlActions.None, pathListOrig, checkForDuplicates, needFullPath, copyPathList);
 }
Ejemplo n.º 38
0
 [System.Security.SecuritySafeCritical]  // auto-generated
 public FileIOPermission(FileIOPermissionAccess access, AccessControlActions control, String[] pathList)
     : this(access, control, pathList, true, true)
 {
 }
Ejemplo n.º 39
0
        public String[] GetPathList(FileIOPermissionAccess access)
        {
            VerifyAccess(access);
            ExclusiveAccess(access);

            if (AccessIsSet(access, FileIOPermissionAccess.Read))
            {
                if (m_read == null)
                {
                    return null;
                }
                return m_read.ToStringArray();
            }

            if (AccessIsSet(access, FileIOPermissionAccess.Write))
            {
                if (m_write == null)
                {
                    return null;
                }
                return m_write.ToStringArray();
            }

            if (AccessIsSet(access, FileIOPermissionAccess.Append))
            {
                if (m_append == null)
                {
                    return null;
                }
                return m_append.ToStringArray();
            }

            if (AccessIsSet(access, FileIOPermissionAccess.PathDiscovery))
            {
                if (m_pathDiscovery == null)
                {
                    return null;
                }
                return m_pathDiscovery.ToStringArray();
            }

            // not reached

            return null;
        }
Ejemplo n.º 40
0
 internal static void DemandFileIO(FileIOPermissionAccess access, string fileName)
 {
     new FileIOPermission(access, UnsafeGetFullPath(fileName)).Demand();
 }
Ejemplo n.º 41
0
        private static void ExclusiveAccess(FileIOPermissionAccess access)
        {
            if (access == FileIOPermissionAccess.NoAccess)
            {
                throw new ArgumentException(Environment.GetResourceString("Arg_EnumNotSingleFlag"));
            }

            if (((int)access & ((int)access - 1)) != 0)
            {
                throw new ArgumentException(Environment.GetResourceString("Arg_EnumNotSingleFlag"));
            }
        }
        public void SetPathList (FileIOPermissionAccess access, String[] pathList) {

        }
Ejemplo n.º 43
0
 public void AddPathList(FileIOPermissionAccess access, string[] pathList)
 {
     throw new NotImplementedException();
 }
        public FileIOPermission (FileIOPermissionAccess access, String[] pathList) {

          return default(FileIOPermission);
        }
Ejemplo n.º 45
0
 internal static void QuickDemand(FileIOPermissionAccess access, string fullPath, bool checkForDuplicates = false, bool needFullPath = true)
 {
     if (!CodeAccessSecurityEngine.QuickCheckForAllDemands())
     {
         new FileIOPermission(access, new string[] { fullPath }, checkForDuplicates, needFullPath).Demand();
     }
     else
     {
         EmulateFileIOPermissionChecks(fullPath);
     }
 }
Ejemplo n.º 46
0
 public string[] GetPathList(FileIOPermissionAccess access)
 {
     throw new NotImplementedException();
 }
        public String[] GetPathList (FileIOPermissionAccess access) {

          return default(String[]);
        }
Ejemplo n.º 48
0
 internal void SetPathList(FileIOPermissionAccess access,
                           String[] pathList, bool checkForDuplicates)
 {
     SetPathList(access, AccessControlActions.None, pathList, checkForDuplicates);
 }
        public void SetPathList (FileIOPermissionAccess access, string path) {

        }
Ejemplo n.º 50
0
 [System.Security.SecuritySafeCritical]  // auto-generated
 public void AddPathList(FileIOPermissionAccess access, String[] pathList)
 {
     AddPathList(access, pathList, true, true, true);
 }
        public FileIOPermission (FileIOPermissionAccess access, string path) {

          return default(FileIOPermission);
        }
Ejemplo n.º 52
0
 [System.Security.SecurityCritical]  // auto-generated
 internal void AddPathList(FileIOPermissionAccess access, String[] pathListOrig, bool checkForDuplicates, bool needFullPath, bool copyPathList)
 {
     AddPathList(access, AccessControlActions.None, pathListOrig, checkForDuplicates, needFullPath, copyPathList);
 }
Ejemplo n.º 53
0
 public FileIOPermission(FileIOPermissionAccess access, string[] pathList)
 {
 }
Ejemplo n.º 54
0
        [System.Security.SecurityCritical]  // auto-generated
        internal void AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, bool checkForDuplicates, bool needFullPath, bool copyPathList)
        {
            if (pathListOrig == null)
            {
                throw new ArgumentNullException("pathList");
            }
            if (pathListOrig.Length == 0)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_EmptyPath"));
            }
            Contract.EndContractBlock();

            VerifyAccess(access);

            if (m_unrestricted)
            {
                return;
            }

            String[] pathList = pathListOrig;
            if (copyPathList)
            {
                // Make a copy of pathList (in case its value changes after we check for illegal chars)
                pathList = new String[pathListOrig.Length];
                Array.Copy(pathListOrig, pathList, pathListOrig.Length);
            }

            ArrayList pathArrayList = StringExpressionSet.CreateListFromExpressions(pathList, needFullPath);

            // If we need the full path the standard illegal characters will be checked in StringExpressionSet.
            CheckIllegalCharacters(pathList, onlyCheckExtras: needFullPath);

            // StringExpressionSet will do minor normalization, trimming spaces and replacing alternate
            // directory separators. It will make an attemt to expand short file names and will check
            // for standard colon placement.
            //
            // If needFullPath is true it will call NormalizePath- which performs short name expansion
            // and does the normal validity checks.

            if ((access & FileIOPermissionAccess.Read) != 0)
            {
                if (m_read == null)
                {
                    m_read = new FileIOAccess();
                }
                m_read.AddExpressions(pathArrayList, checkForDuplicates);
            }

            if ((access & FileIOPermissionAccess.Write) != 0)
            {
                if (m_write == null)
                {
                    m_write = new FileIOAccess();
                }
                m_write.AddExpressions(pathArrayList, checkForDuplicates);
            }

            if ((access & FileIOPermissionAccess.Append) != 0)
            {
                if (m_append == null)
                {
                    m_append = new FileIOAccess();
                }
                m_append.AddExpressions(pathArrayList, checkForDuplicates);
            }

            if ((access & FileIOPermissionAccess.PathDiscovery) != 0)
            {
                if (m_pathDiscovery == null)
                {
                    m_pathDiscovery = new FileIOAccess(true);
                }
                m_pathDiscovery.AddExpressions(pathArrayList, checkForDuplicates);
            }
        }
Ejemplo n.º 55
0
 public void AddPathList(FileIOPermissionAccess access, string[] pathList)
 {
 }
Ejemplo n.º 56
0
 private static bool AccessIsSet(FileIOPermissionAccess access, FileIOPermissionAccess question)
 {
     return((access & question) != 0);
 }
Ejemplo n.º 57
0
 public FileIOPermission(FileIOPermissionAccess access, string path)
 {
 }
Ejemplo n.º 58
0
        [System.Security.SecuritySafeCritical]  // auto-generated
        public FileIOPermission(FileIOPermissionAccess access, String[] pathList)
        {
            VerifyAccess(access);

            AddPathList(access, pathList, false, true, false);
        }
Ejemplo n.º 59
0
 internal static FileSecurityStateAccess ToFileSecurityState(FileIOPermissionAccess access)
 {
     Contract.Requires((access & ~FileIOPermissionAccess.AllAccess) == 0);
     return (FileSecurityStateAccess)access; // flags are identical; just cast
 }
Ejemplo n.º 60
0
        [System.Security.SecurityCritical]  // auto-generated
        internal FileIOPermission(FileIOPermissionAccess access, String[] pathList, bool checkForDuplicates, bool needFullPath)
        {
            VerifyAccess(access);

            AddPathList(access, pathList, checkForDuplicates, needFullPath, true);
        }