public UnixStream Open (OpenFlags flags) { int fd = Syscall.open (FullPath, flags); if (fd < 0) UnixMarshal.ThrowExceptionForLastError (); return new UnixStream (fd); }
// fd, error public static void open(string path, OpenFlags flags, Mono.Unix.Native.FilePermissions mode, Action<FileStream, Exception> callback) { ThreadPool.QueueUserWorkItem(a => { try { FileMode fm; FileAccess fa; FileShare fs = FileShare.ReadWrite; if (0 != (flags & OpenFlags.O_CREAT)) fm = FileMode.Create; else fm = FileMode.Open; if (0 != (flags & OpenFlags.O_RDWR)) fa = FileAccess.ReadWrite; else if (0 != (flags & OpenFlags.O_WRONLY)) fa = FileAccess.Write; else fa = FileAccess.Read; var stream = new FileStream(path, fm, fa, fs); Boundary.Instance.ExecuteOnTargetLoop (() => callback (stream, null)); } catch(Exception e) { Boundary.Instance.ExecuteOnTargetLoop (() => callback (null, e)); } }); }
/// <summary> /// Open /// </summary> /// <param name="flags"> /// A <see cref="OpenFlags"/> /// </param> /// <param name="readTimeoutMilliseconds"> /// A <see cref="System.Int32"/> /// </param> /// <param name="remoteAuthentication"> /// A <see cref="RemoteAuthentication"/> /// </param> public void Open(OpenFlags flags, int readTimeoutMilliseconds, RemoteAuthentication remoteAuthentication) { if (!Opened) { var errbuf = new StringBuilder(Pcap.PCAP_ERRBUF_SIZE); //will hold errors IntPtr rmAuthPointer; if (remoteAuthentication == null) rmAuthPointer = IntPtr.Zero; else rmAuthPointer = remoteAuthentication.GetUnmanaged(); PcapHandle = SafeNativeMethods.pcap_open(Name, Pcap.MAX_PACKET_SIZE, // portion of the packet to capture. (int)flags, readTimeoutMilliseconds, rmAuthPointer, errbuf); if (rmAuthPointer != IntPtr.Zero) Marshal.FreeHGlobal(rmAuthPointer); if (PcapHandle == IntPtr.Zero) { string err = "Unable to open the adapter (" + Name + "). " + errbuf.ToString(); throw new PcapException(err); } } }
private static void DoStoreOp(StoreLocation location, OpenFlags flags, Action<X509Store> op) { var store = new X509Store(StoreName.My, location); using (new StoreOpener(store, flags)) { op(store); } }
internal AppleKeychainStore(SafeKeychainHandle keychainHandle, OpenFlags openFlags) { Debug.Assert(keychainHandle != null && !keychainHandle.IsInvalid); _keychainHandle = keychainHandle; _readonly = (openFlags & (OpenFlags.ReadWrite | OpenFlags.MaxAllowed)) == 0; }
private static O_Flags Translate(OpenFlags flags) { return(Enum .GetValues(typeof(OpenFlags)) .Cast <OpenFlags>() .Where(f => flags.HasFlag(f)) .Aggregate(O_Flags.O_NONE, (acc, f) => acc | TranslateOne(f))); }
public OptionsBuilder(StoreName storeName, StoreLocation storeLocation, X509FindType x509FindType, OpenFlags openFlags, string findValue) { StoreName = storeName; StoreLocation = storeLocation; X509FindType = x509FindType; OpenFlags = openFlags; FindValue = findValue; }
static void RedirectOutputToFileUnix() { const int STDOUT_FILENO = 1; const int STDERR_FILENO = 2; const OpenFlags flags = OpenFlags.O_WRONLY | OpenFlags.O_CREAT | OpenFlags.O_TRUNC; const FilePermissions mode = FilePermissions.S_IFREG | FilePermissions.S_IRUSR | FilePermissions.S_IWUSR | FilePermissions.S_IRGRP | FilePermissions.S_IWGRP; FilePath logDir = UserProfile.Current.LogDir; Directory.CreateDirectory(logDir); int fd; string logFile; int oldIdx = logFileSuffix; while (true) { logFile = logDir.Combine(GetSessionLogFileName("Ide")); // if the file already exists, retry with a suffix, up to 10 times fd = Syscall.open(logFile, flags, mode); if (fd >= 0) { break; } var err = Stdlib.GetLastError(); if (logFileSuffix >= oldIdx + 10 || err != Errno.EEXIST) { logFileSuffix++; continue; } throw new IOException("Unable to open file: " + err); } try { int res = Syscall.dup2(fd, STDOUT_FILENO); if (res < 0) { throw new IOException("Unable to redirect stdout: " + Stdlib.GetLastError()); } res = Syscall.dup2(fd, STDERR_FILENO); if (res < 0) { throw new IOException("Unable to redirect stderr: " + Stdlib.GetLastError()); } //try to symlink timestamped file to generic one. NBD if it fails. SymlinkWithRetry(logFile, logDir.Combine("Ide.log"), 10); } finally { Syscall.close(fd); } }
void setFlags(OpenFlags flags) { var ret = Syscall.fcntl(Fd, FcntlCommand.F_SETFL, (int)flags); if (ret == -1) { throw new UnixIOException(Marshal.GetLastWin32Error()); } }
private static void DoStoreOp(StoreLocation location, OpenFlags flags, Action <X509Store> op) { var store = new X509Store(StoreName.My, location); using (new StoreOpener(store, flags)) { op(store); } }
private static OpenFlags CreateOpenFlags(FileDesiredAccess desiredAccess, FileShare fileShare, FileMode fileMode, bool openSymlink) { OpenFlags flags = ShouldCreateAndOpen(fileMode) ? OpenFlags.O_CREAT : 0; switch (fileMode) { case FileMode.Append: flags |= OpenFlags.O_APPEND; break; case FileMode.Truncate: flags |= OpenFlags.O_TRUNC; break; case FileMode.CreateNew: if (!openSymlink) { flags |= OpenFlags.O_EXCL; } break; default: break; } if (fileShare == FileShare.None) { flags |= OpenFlags.O_EXLOCK; } else { flags |= OpenFlags.O_SHLOCK; } if (desiredAccess.HasFlag(FileDesiredAccess.GenericRead) && !desiredAccess.HasFlag(FileDesiredAccess.GenericWrite)) { flags |= OpenFlags.O_RDONLY; } if (desiredAccess.HasFlag(FileDesiredAccess.GenericWrite) && !desiredAccess.HasFlag(FileDesiredAccess.GenericRead)) { flags |= OpenFlags.O_WRONLY; } if (desiredAccess.HasFlag(FileDesiredAccess.GenericRead | FileDesiredAccess.GenericWrite)) { flags |= OpenFlags.O_RDWR; } if (openSymlink) { flags |= OpenFlags.O_SYMLINK; } return(flags); }
public unsafe static int open( string pathname, OpenFlags flags, FilePermissions mode) { byte[] pathNameBytes = System.Text.Encoding.UTF8.GetBytes(pathname); fixed(byte *pPath = pathNameBytes) { return(open((IntPtr)pPath, flags, mode)); } }
public static int open(string Path, OpenFlags Flags) { int flags = (int)Flags; IntPtr path = MallocString(Path); int result = _open(path, flags); FreeMallocString(path); return(result); }
public static IntPtr zip_open(string path, OpenFlags flags, out ErrorCode errorp) { IntPtr utfPath = Utilities.StringToUtf8StringPtr(path); try { return(zip_open(utfPath, flags, out errorp)); } finally { Utilities.FreeUtf8StringPtr(utfPath); } }
public UnixStream Open(OpenFlags flags, FilePermissions mode) { int num = Syscall.open(base.FullPath, flags, mode); if (num < 0) { UnixMarshal.ThrowExceptionForLastError(); } return(new UnixStream(num)); }
public static Int32 FromOpenFlags(OpenFlags value) { Int32 rval; if (FromOpenFlags(value, out rval) == -1) { ThrowArgumentException(value); } return(rval); }
public bool Open(string filename, OpenFlags flags) { var err = sqlite3_open_v2(filename, out _db, (int)flags); if (err != SQLITE_OK) { _dbLogger?.LogError(Error.Message); } return(err == SQLITE_OK); }
public static IDatabase OpenTest(this ISQLite sqlite, string path, OpenFlags flags, params string[] statements) { var db = sqlite.Open(path, flags); foreach (var s in statements) { db.Execute(s); } return(db); }
static FileStream Open(string fileName, int blockSize, OpenFlags openFlags, FilePermissions perms) { var fd = Mono.Unix.Native.Syscall.open(fileName, openFlags, perms); var mask = OpenFlags.O_RDONLY | OpenFlags.O_RDWR | OpenFlags.O_WRONLY; var canRead = (openFlags & mask) == OpenFlags.O_RDONLY || (openFlags & mask) == OpenFlags.O_RDWR; var canWrite = (openFlags & mask) == OpenFlags.O_WRONLY || (openFlags & mask) == OpenFlags.O_RDWR; return(new FileStream(new IntPtr(fd), blockSize, canRead, canWrite)); }
internal UnsupportedDisallowedStore(OpenFlags openFlags) { // ReadOnly is 0x00, so it is implicit unless either ReadWrite or MaxAllowed // was requested. OpenFlags writeFlags = openFlags & (OpenFlags.ReadWrite | OpenFlags.MaxAllowed); if (writeFlags == OpenFlags.ReadOnly) { _readOnly = true; } }
public static int open(string pathname, OpenFlags flags) { if ((flags & OpenFlags.O_CREAT) != 0) { throw new ArgumentException("If you pass O_CREAT, you must call the method with the mode flag"); } int posix_flags = map_Mono_Posix_OpenFlags(flags); return(syscall_open(pathname, posix_flags, 0)); }
public static void Join(IEnumerable <string> swms, string outputPath, OpenFlags swmOpenFlags, WriteFlags wimWriteFlags, ProgressCallback callback, object userData) { ManagedProgressCallback mCallback = new ManagedProgressCallback(callback, userData); string[] swmArr = swms.ToArray(); ErrorCode ret = NativeMethods.JoinWithProgress(swmArr, (uint)swmArr.Length, outputPath, swmOpenFlags, wimWriteFlags, mCallback.NativeFunc, IntPtr.Zero); WimLibException.CheckWimLibError(ret); }
static ZipArchive CreateInstanceFromStream(Stream stream, OpenFlags flags = OpenFlags.RDOnly, IPlatformOptions options = null) { if (Environment.OSVersion.Platform == PlatformID.Unix) { return(new UnixZipArchive(stream, EnsureOptions(options) as UnixPlatformOptions, flags)); } else { return(new WindowsZipArchive(stream, EnsureOptions(options) as WindowsPlatformOptions, flags)); } }
public UnixStream Open(FileMode mode, FileAccess access, FilePermissions perms) { OpenFlags openFlags = NativeConvert.ToOpenFlags(mode, access); int num = Syscall.open(base.FullPath, openFlags, perms); if (num < 0) { UnixMarshal.ThrowExceptionForLastError(); } return(new UnixStream(num)); }
private void OpenStore(OpenFlags openFlags) { try { _storeWrapper.Open(_storeName, _storeLocation, openFlags); } catch (SecurityException securityException) { throw new CertificateException(_storeName, _storeLocation, securityException); } catch (CryptographicException cryptographicException) { throw new CertificateException("open", _storeName, _storeLocation, cryptographicException); } }
public static AndroidKeyStore OpenDefault(OpenFlags openFlags) { SafeX509StoreHandle store = Interop.AndroidCrypto.X509StoreOpenDefault(); if (store.IsInvalid) { store.Dispose(); throw new CryptographicException(); } return(new AndroidKeyStore(store, openFlags)); }
public static FileStream Open(Context context, string fileName, int blockSize, OpenFlags openFlags) { var fd = Syscall.open (fileName, openFlags, FilePermissions.S_IRUSR | FilePermissions.S_IWUSR | FilePermissions.S_IROTH); var mask = OpenFlags.O_RDONLY | OpenFlags.O_RDWR | OpenFlags.O_WRONLY; var canRead = (openFlags & mask) == OpenFlags.O_RDONLY || (openFlags & mask) == OpenFlags.O_RDWR; var canWrite = (openFlags & mask) == OpenFlags.O_WRONLY || (openFlags & mask) == OpenFlags.O_RDWR; return new FileStream (context, new IntPtr (fd), blockSize, canRead, canWrite); }
/// <summary>Linux specific implementation of <see cref="IO.Open"/> </summary> internal static SafeFileHandle Open(string pathname, OpenFlags flags, FilePermissions permissions) { int result; while ( (result = open(pathname, Translate(flags), permissions)) < 0 && Marshal.GetLastWin32Error() == (int)Errno.EINTR) { ; } return(new SafeFileHandle(new IntPtr(result), ownsHandle: true)); }
public void Open(OpenFlags openFlags) { uint dwFlags = this.MapX509StoreFlags(this.storeLocation, openFlags); System.IdentityModel.SafeCertStoreHandle handle = System.IdentityModel.CAPI.CertOpenStore(new IntPtr(10L), 0x10001, IntPtr.Zero, dwFlags, this.storeName); if ((handle == null) || handle.IsInvalid) { int hr = Marshal.GetLastWin32Error(); throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CryptographicException(hr)); } this.certStoreHandle = handle; }
/// <summary> /// Open a WIM file and create a instance of Wim class for it. /// </summary> /// <param name="wimFile">The path to the WIM file to open.</param> /// <param name="openFlags">Bitwise OR of flags prefixed with WIMLIB_OPEN_FLAG.</param> /// <returns> /// On success, a new instance of Wim class backed by the specified /// on-disk WIM file is returned. This instance must be disposed /// when finished with it. /// </returns> /// <exception cref="WimLibException">wimlib did not return ErrorCode.SUCCESS.</exception> public static Wim OpenWim(string wimFile, OpenFlags openFlags) { if (!NativeMethods.Loaded) { throw new InvalidOperationException(NativeMethods.MsgInitFirstError); } ErrorCode ret = NativeMethods.OpenWim(wimFile, openFlags, out IntPtr wimPtr); WimLibException.CheckWimLibError(ret); return(new Wim(wimPtr)); }
public static FileStream Open(Context context, string fileName, int blockSize, OpenFlags openFlags) { var fd = Syscall.open(fileName, openFlags, FilePermissions.S_IRUSR | FilePermissions.S_IWUSR | FilePermissions.S_IROTH); var mask = OpenFlags.O_RDONLY | OpenFlags.O_RDWR | OpenFlags.O_WRONLY; var canRead = (openFlags & mask) == OpenFlags.O_RDONLY || (openFlags & mask) == OpenFlags.O_RDWR; var canWrite = (openFlags & mask) == OpenFlags.O_WRONLY || (openFlags & mask) == OpenFlags.O_RDWR; return(new FileStream(context, new IntPtr(fd), blockSize, canRead, canWrite)); }
ErrorCode Open(string path, OpenFlags flags) { LastErrorCode = ErrorCode.OK; ErrorCode error = ErrorCode.OK; archive = Native.zip_open(path, flags, out error); if (archive == IntPtr.Zero) { LastErrorCode = error; } return(LastErrorCode); }
// Attempts to open all the stores in the given list of stores. // After returning, the list of stores contains only the stores which could be opened. private void TryOpenStores(List <X509Store> stores, OpenFlags flags) { for (int i = stores.Count - 1; i >= 0; i--) { try { stores[i].Open(flags); } catch { stores.RemoveAt(i); } } }
public static int open( string pathname, OpenFlags flags, FilePermissions mode) { IntPtr pathNamePtr = Marshal.StringToHGlobalAuto(pathname); try { return(open(pathNamePtr, flags, mode)); } finally { Marshal.FreeHGlobal(pathNamePtr); } }
private static X509Store OpenStore(OpenFlags flags = OpenFlags.ReadOnly) { var store = new X509Store(StoreName.My, StoreLocation.LocalMachine); try { store.Open(flags); return(store); } catch (Exception ex) { throw new Exception("Try run as administrator to access the X509Store when using https.", ex); } }
private static X509Certificate2 FindCertificate(string Store, string Name, OpenFlags Mode) { //Look to see if we can find the certificate store X509Store store = new X509Store(Store, StoreLocation.CurrentUser); store.Open(Mode); foreach (X509Certificate2 Cert in store.Certificates) { if (Cert.Subject.ToLower() == "cn=" + Name.ToLower()) { return(Cert); //Yep found it } } return(null); }
public void Open(OpenFlags openFlags) { DiagnosticUtility.DebugAssert(this.certStoreHandle.IsInvalid, ""); uint dwOpenFlags = MapX509StoreFlags(this.storeLocation, openFlags); SafeCertStoreHandle certStoreHandle = CAPI.CertOpenStore(new IntPtr(CAPI.CERT_STORE_PROV_SYSTEM), CAPI.X509_ASN_ENCODING | CAPI.PKCS_7_ASN_ENCODING, IntPtr.Zero, dwOpenFlags, this.storeName); if (certStoreHandle == null || certStoreHandle.IsInvalid) { int error = Marshal.GetLastWin32Error(); throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CryptographicException(error)); } this.certStoreHandle = certStoreHandle; }
public static IStorePal FromSystemStore(string storeName, StoreLocation storeLocation, OpenFlags openFlags) { CertStoreFlags certStoreFlags = MapX509StoreFlags(storeLocation, openFlags); SafeCertStoreHandle certStore = Interop.crypt32.CertOpenStore(CertStoreProvider.CERT_STORE_PROV_SYSTEM_W, CertEncodingType.All, IntPtr.Zero, certStoreFlags, storeName); if (certStore.IsInvalid) throw Marshal.GetLastWin32Error().ToCryptographicException(); // // We want the store to auto-resync when requesting a snapshot so that // updates to the store will be taken into account. // // For compat with desktop, ignoring any failures from this call. (It is pretty unlikely to fail, in any case.) // bool ignore = Interop.crypt32.CertControlStore(certStore, CertControlStoreFlags.None, CertControlStoreType.CERT_STORE_CTRL_AUTO_RESYNC, IntPtr.Zero); return new StorePal(certStore); }
public static IStorePal FromSystemStore(string storeName, StoreLocation storeLocation, OpenFlags openFlags) { if (storeLocation != StoreLocation.LocalMachine) { // TODO (#2206): Support CurrentUser persisted stores. throw new NotImplementedException(); } if (openFlags.HasFlag(OpenFlags.ReadWrite)) { // TODO (#2206): Support CurrentUser persisted stores // (they'd not be very useful without the ability to add/remove content) throw new NotImplementedException(); } // The static store approach here is making an optimization based on not // having write support. Once writing is permitted the stores would need // to fresh-read whenever being requested (or use FileWatcher/etc). if (s_machineRootStore == null) { lock (s_machineIntermediateStore) { if (s_machineRootStore == null) { LoadMachineStores(); } } } if (StringComparer.Ordinal.Equals("Root", storeName)) { return CloneStore(s_machineRootStore); } if (StringComparer.Ordinal.Equals("CA", storeName)) { return CloneStore(s_machineIntermediateStore); } // TODO (#2207): Support the rest of the stores, or throw PlatformNotSupportedException. throw new NotImplementedException(); }
internal DirectoryBasedStoreProvider(string storeName, OpenFlags openFlags) { if (string.IsNullOrEmpty(storeName)) { throw new CryptographicException(SR.Arg_EmptyOrNullString); } string directoryName = GetDirectoryName(storeName); if (s_userStoreRoot == null) { // Do this here instead of a static field initializer so that // the static initializer isn't capable of throwing the "home directory not found" // exception. s_userStoreRoot = PersistedFiles.GetUserFeatureDirectory( X509Persistence.CryptographyFeatureName, X509Persistence.X509StoresSubFeatureName); } _storePath = Path.Combine(s_userStoreRoot, directoryName); if (0 != (openFlags & OpenFlags.OpenExistingOnly)) { if (!Directory.Exists(_storePath)) { throw new CryptographicException(SR.Cryptography_X509_StoreNotFound); } } // ReadOnly is 0x00, so it is implicit unless either ReadWrite or MaxAllowed // was requested. OpenFlags writeFlags = openFlags & (OpenFlags.ReadWrite | OpenFlags.MaxAllowed); if (writeFlags == OpenFlags.ReadOnly) { _readOnly = true; } }
// this method maps X509Store OpenFlags to a combination of crypto API flags internal static uint MapX509StoreFlags (StoreLocation storeLocation, OpenFlags flags) { uint dwFlags = 0; uint openMode = ((uint)flags) & 0x3; switch (openMode) { case (uint) OpenFlags.ReadOnly: dwFlags |= CAPI.CERT_STORE_READONLY_FLAG; break; case (uint) OpenFlags.MaxAllowed: dwFlags |= CAPI.CERT_STORE_MAXIMUM_ALLOWED_FLAG; break; } if ((flags & OpenFlags.OpenExistingOnly) == OpenFlags.OpenExistingOnly) dwFlags |= CAPI.CERT_STORE_OPEN_EXISTING_FLAG; if ((flags & OpenFlags.IncludeArchived) == OpenFlags.IncludeArchived) dwFlags |= CAPI.CERT_STORE_ENUM_ARCHIVED_FLAG; if (storeLocation == StoreLocation.LocalMachine) dwFlags |= CAPI.CERT_SYSTEM_STORE_LOCAL_MACHINE; else if (storeLocation == StoreLocation.CurrentUser) dwFlags |= CAPI.CERT_SYSTEM_STORE_CURRENT_USER; return dwFlags; }
public StoreOpener(X509Store store, OpenFlags openFlags) { store.Open(openFlags); this.store = store; }
private static void DoStoreOp(OpenFlags flags, Action<X509Store> op) { DoStoreOp(StoreLocation.CurrentUser, flags, op); }
public CertificateStore (OpenFlags flags, StoreName name, StoreLocation location) { _store = new X509Store(name, location); _store.Open(flags); }
/// <summary> /// Create a open request packet for client to open a share on server. /// </summary> /// <param name = "messageId">the id of message, used to identity the request and the server response. </param> /// <param name = "sessionUid">the valid session id, must be response by server of the session setup request. </param> /// <param name = "treeId">the valid tree connect id, must be response by server of the tree connect. </param> /// <param name = "flags"> /// The Flags field contains individual flags, as specified in [CIFS] sections 2.4.2 and 3.1.1. /// </param> /// <param name = "flags2"> /// The Flags2 field contains individual bit flags that, depending on the negotiated SMB dialect, indicate /// various client and server capabilities. /// </param> /// <param name = "shareName">the file name to open </param> /// <param name = "fileOpenMode">file open mode </param> /// <param name = "fileOpenFunction"> /// A 16-bit field that controls the way a file SHOULD be treated when it is opened for use by certain /// extended SMB requests. /// </param> /// <param name = "extFileAttributes">the extend file attributes </param> /// <param name = "extSearchAttributes">the search attributes of file </param> /// <param name = "allocationSize">Bytes to reserve on create or truncate </param> /// <param name = "openFlags">A 16-bit field of flags for requesting attribute data and locking </param> /// <returns>a open request packet </returns> private SmbOpenAndxRequestPacket CreateOpenRequest( ushort messageId, ushort sessionUid, ushort treeId, SmbHeader_Flags_Values flags, SmbHeader_Flags2_Values flags2, string shareName, AccessMode fileOpenMode, OpenMode fileOpenFunction, SmbFileAttributes extFileAttributes, SmbFileAttributes extSearchAttributes, uint allocationSize, OpenFlags openFlags) { return new SmbOpenAndxRequestPacket( this.cifsClient.CreateOpenAndxRequest(messageId, sessionUid, treeId, (SmbFlags)flags, (SmbFlags2)flags2, (Flags)openFlags, fileOpenMode, extSearchAttributes, extFileAttributes, new UTime(), fileOpenFunction, allocationSize, this.capability.Timeout, shareName, null)); }
public static int open(string pathname, OpenFlags flags, FileMode mode) { int posix_flags = map_Mono_Posix_OpenFlags (flags); int posix_mode = map_Mono_Posix_FileMode (mode); return syscall_open (pathname, posix_flags, posix_mode); }
public static IStorePal FromSystemStore(string storeName, StoreLocation storeLocation, OpenFlags openFlags) { if (storeLocation != StoreLocation.LocalMachine) { return new DirectoryBasedStoreProvider(storeName, openFlags); } if (openFlags.HasFlag(OpenFlags.ReadWrite)) { throw new PlatformNotSupportedException(SR.Cryptography_Unix_X509_MachineStoresReadOnly); } // The static store approach here is making an optimization based on not // having write support. Once writing is permitted the stores would need // to fresh-read whenever being requested (or use FileWatcher/etc). if (s_machineRootStore == null) { lock (s_machineIntermediateStore) { if (s_machineRootStore == null) { LoadMachineStores(); } } } if (StringComparer.Ordinal.Equals("Root", storeName)) { return CloneStore(s_machineRootStore); } if (StringComparer.Ordinal.Equals("CA", storeName)) { return CloneStore(s_machineIntermediateStore); } throw new PlatformNotSupportedException(SR.Cryptography_Unix_X509_MachineStoresRootOnly); }
public static void OpenMachineRootStore_Permissions(OpenFlags permissions, bool shouldThrow) { using (X509Store store = new X509Store(StoreName.Root, StoreLocation.LocalMachine)) { if (shouldThrow) { Assert.Throws<PlatformNotSupportedException>(() => store.Open(permissions)); } else { // Assert.DoesNotThrow store.Open(permissions); } } }
public static UnixStream Open (string path, OpenFlags flags, FilePermissions mode) { int fd = Syscall.open (path, flags, mode); if (fd < 0) UnixMarshal.ThrowExceptionForLastError (); return new UnixStream (fd); }
public void Open(OpenFlags flags);
/// <summary> /// Open a device with specific flags /// WinPcap extension - Use of this method will exclude your application /// from working on Linux or Mac /// </summary> public virtual void Open(OpenFlags flags, int read_timeout) { ThrowIfNotWinPcap(); if(!Opened) { var errbuf = new StringBuilder(Pcap.PCAP_ERRBUF_SIZE); PcapHandle = SafeNativeMethods.pcap_open ( Name, // name of the device Pcap.MAX_PACKET_SIZE, // portion of the packet to capture. // MAX_PACKET_SIZE (65536) grants that the whole packet will be captured on all the MACs. (short)flags, // one or more flags (short)read_timeout, // read timeout IntPtr.Zero, // no authentication right now errbuf ); // error buffer if ( PcapHandle == IntPtr.Zero) { string err = "Unable to open the adapter ("+Name+"). "+errbuf.ToString(); throw new PcapException( err ); } } }
public void Open (OpenFlags flags) { if (String.IsNullOrEmpty (_name)) throw new CryptographicException (Locale.GetText ("Invalid store name (null or empty).")); /* keep existing Mono installations (pre 2.0) compatible with new stuff */ string name; switch (_name) { case "Root": name = "Trust"; break; default: name = _name; break; } bool create = ((flags & OpenFlags.OpenExistingOnly) != OpenFlags.OpenExistingOnly); store = Factory.Open (name, create); if (store == null) throw new CryptographicException (Locale.GetText ("Store {0} doesn't exists.", _name)); _flags = flags; foreach (MX.X509Certificate x in store.Certificates) { Certificates.Add (new X509Certificate2 (x.RawData)); } }
private Errno ProcessFile(string path, OpenFlags flags, FdCb cb) { int fd = Syscall.open(path, flags); if (fd == -1) { return Stdlib.GetLastError(); } int r = cb(fd); Errno res = 0; if (r == -1) { res = Stdlib.GetLastError(); } Syscall.close(fd); return res; }
public static void open(string path, OpenFlags flags, FilePermissions mode, Action<int, int> callback) { eio_open (path, flags, mode, 0, openCB, GCHandle.ToIntPtr (GCHandle.Alloc (callback))); }
public static int open(string pathname, OpenFlags flags) { if ((flags & OpenFlags.O_CREAT) != 0) throw new ArgumentException ("If you pass O_CREAT, you must call the method with the mode flag"); int posix_flags = map_Mono_Posix_OpenFlags (flags); return syscall_open (pathname, posix_flags, 0); }
static extern IntPtr eio_open(string path, OpenFlags flags, mode_t mode, int pri, eio_cb cb, IntPtr data);
internal static extern int map_Mono_Posix_OpenFlags(OpenFlags flags);
internal static int map_Mono_Posix_OpenFlags (OpenFlags flags) { throw new System.NotImplementedException(); }
public void Open(OpenFlags flags) { Close(); _storePal = StorePal.FromSystemStore(Name, Location, flags); }
/// <summary> /// Parse the RopLogonRequest structure. /// </summary> /// <param name="s">An stream containing RopLogonRequest structure.</param> public override void Parse(Stream s) { base.Parse(s); this.RopId = (RopIdType)ReadByte(); this.LogonId = ReadByte(); this.OutputHandleIndex = ReadByte(); this.LogonFlags = (LogonFlags)ReadByte(); this.OpenFlags = (OpenFlags)ReadUint(); this.StoreState = ReadUint(); this.EssdnSize = ReadUshort(); if (this.EssdnSize > 0) { this.Essdn = new MAPIString(Encoding.ASCII); this.Essdn.Parse(s); } }