Internal.Cryptography.Pal.DirectoryBasedStoreProvider.EnsureDirectoryPermissions C# (CSharp) Method

EnsureDirectoryPermissions() private static method

Checks the store directory has the correct permissions.
private static EnsureDirectoryPermissions ( string path, uint userId ) : void
path string /// The path of the directory to check. ///
userId uint /// The current userId from GetEUid(). ///
return void
        private static void EnsureDirectoryPermissions(string path, uint userId)
        {
            Interop.Sys.FileStatus dirStat;
            if (Interop.Sys.Stat(path, out dirStat) != 0)
            {
                Interop.ErrorInfo error = Interop.Sys.GetLastErrorInfo();
                throw new CryptographicException(
                    SR.Cryptography_FileStatusError,
                    new IOException(error.GetErrorMessage(), error.RawErrno));
            }

            if (dirStat.Uid != userId)
            {
                throw new CryptographicException(SR.Format(SR.Cryptography_OwnerNotCurrentUser, path));
            }

            if ((dirStat.Mode & (int)Interop.Sys.Permissions.S_IRWXU) != (int)Interop.Sys.Permissions.S_IRWXU)
            {
                throw new CryptographicException(SR.Format(SR.Cryptography_InvalidDirectoryPermissions, path));
            }
        }