Skip to content

Commit

Permalink
Implement RemoteFileOpenAbility on Windows. This also implements CORE…
Browse files Browse the repository at this point in the history
…-1038 improvement
  • Loading branch information
skidder committed Sep 29, 2009
1 parent 6191d63 commit 0070f23
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 35 deletions.
82 changes: 48 additions & 34 deletions builds/install/misc/firebird.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,54 @@
#
#FileSystemCacheSize = 30

# ----------------------------
# Remove protection against opening databases on NFS mounted volumes on
# Linux/Unix and SMB/CIFS volumes on Windows
#
# This also permits creating database shadows on mounted network volumes
#
# ***WARNING*** ***WARNING*** ***WARNING*** ***WARNING***
#
# This option removes an important safety feature of Firebird and can
# cause irrecoverable database corruption. Do not use this option unless
# you understand the risks and are prepared to accept the loss of the
# contents of your database.
# Unless this configuration option is changed from 0 to 1, Firebird can
# open a database only if the database is stored on a drive physically
# attached to the local computer - the computer running that copy of
# Firebird. Requests for connections to databases stored on NFS mounted
# drives are redirected to a Firebird server running on the computer that
# "owns" the disk.
# This restriction prevents two different copies of Firebird from opening
# the same database without coordinating their activities. Uncoordinated
# access by multiple copies of Firebird will corrupt a database. On a local
# system, the system-level file locking prevents uncoordinated access to
# the database file.
#
# NFS does not provide a reliable way to detect multiple users of a file on
# an NFS mounted disk. If a second copy of Firebird connects to a database on
# an NFS mounted disk, it will corrupt the database.
# Under some circumstances, running a Firebird server on the computer that
# owns NFS mounted volumes is inconvenient or impossible. Applications that
# use the "embedded" variant of Firebird and never share access to a database
# can use this option to permit direct access to databases on NFS mounted
# volumes.
#
# The situation for SMB/CIFS is quite similar to NFS with not all configurations
# providing file locking mechanisms needed for safe operation. Using SuperServer
# engine with the database on NT file server may be considered relatively safe
# as file locking protects the database from being used by the several engines.
# Network stack can still change order of writes so you may get a corrupted
# database in case of network errors or power outage.
#
# The useful and safe case is working with a shared database marked read-only.
#
# DO NOT ENABLE THIS OPTION UNLESS YOU REALLY KNOW WHAT YOU ARE DOING.
#
# Type: boolean
#
#RemoteFileOpenAbility = 0

# ----------------------------
# Temporary space management
#
Expand Down Expand Up @@ -716,40 +764,6 @@
# Settings for Unix/Linux platforms
# ============================

# ----------------------------
# Remove protection against opening databases on NFS mounted volumes
#
# ***WARNING*** ***WARNING*** ***WARNING*** ***WARNING***
#
# This option removes an important safety feature of Firebird and can
# cause irrecoverable database corruption. Do not use this option unless
# you understand the risks and are prepared to accept the loss of the
# contents of your database.
# Unless this configuration option is changed from 0 to 1, Firebird can
# open a database only if the database is stored on a drive physically
# attached to the local computer - the computer running that copy of
# Firebird. Requests for connections to databases stored on NFS mounted
# drives are redirected to a Firebird server running on the computer that
# "owns" the disk.
# This restriction prevents two different copies of Firebird from opening
# the same database without coordinating their activities. Uncoordinated
# access by multiple copies of Firebird will corrupt a database. On a local
# system, the system-level file locking prevents uncoordinated access to
# the database file.
# NFS does not provide a reliable way to detect multiple users of a file on
# an NFS mounted disk. If a second copy of Firebird connects to a database on
# an NFS mounted disk, it will corrupt the database.
# Under some circumstances, running a Firebird server on the computer that
# owns NFS mounted volumes is inconvenient or impossible. Applications that
# use the "embedded" variant of Firebird and never share access to a database
# can use this option to permit direct access to databases on NFS mounted
# volumes.
# DO NOT ENABLE THIS OPTION UNLESS YOU REALLY KNOW WHAT YOU ARE DOING.
#
# Type: boolean
#
#RemoteFileOpenAbility = 0

# ----------------------------
# Remove protection against redirecting requests to other servers
#
Expand Down
7 changes: 6 additions & 1 deletion src/jrd/isc_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ bool ISC_analyze_tcp(tstring& file_name, tstring& node_name)
{
const ULONG dtype = GetDriveType((node_name + ":\\").c_str());
// Is it removable, fixed, cdrom or ramdisk?
if (dtype > DRIVE_NO_ROOT_DIR && dtype != DRIVE_REMOTE)
if (dtype > DRIVE_NO_ROOT_DIR && (dtype != DRIVE_REMOTE || Config::getRemoteFileOpenAbility()))
{
// CVC: If we didn't match, clean our garbage or we produce side effects
// in the caller.
Expand Down Expand Up @@ -900,6 +900,11 @@ void ISC_expand_share(tstring& file_name)
return;
}

// If RemoteFileOpenAbility = 1 doesn't expand share
if (Config::getRemoteFileOpenAbility()) {
return;
}

tstring device(file_name.substr(0, 1));
const USHORT dtype = GetDriveType((device + ":\\").c_str());
if (dtype != DRIVE_REMOTE)
Expand Down

0 comments on commit 0070f23

Please sign in to comment.