Subject Re: [firebird-support] OS X, external file, and firebird.conf
Author Helen Borrie
At 01:38 PM 19/02/2006, you wrote:
>Hiya. Get ready for a real beginner's 1st question. This refers to
>Firebird 1.5 on Mac OS X. I'm just starting out with Firebird
>because it looks like a good way to get acquainted with the
>client-server paradigm, and because I'm not going to be able to keep
>using my 1993 version of MS FoxPro forever.
>
>So I need to move some data from my FoxPro files into a Firebird
>database. I exported data from FoxPro in, I think, the right kind
>of text format; the file is "sample.txt."

Fixed-length format, right?


>When I tell Firebird ...
> ..............................................
> SQL> CREATE TABLE testTable EXTERNAL FILE 'sample.txt'
> CON> (
> CON> NAME1 CHAR(79),
> CON> IN1 CHAR(27),
> ... (more field specifiers) ...
> CON> NEWLINE CHAR(1)
> CON> );
> ..............................................
>I always get
> ..............................................
> Statement failed, SQLCODE = -902
> Access to external file "sample.txt" is denied by server
> administrator
> ..............................................
>
>I played around with the permissions of sample.txt and I don't think
>that's the issue.

Actually, it *is* the issue. The exact solution really depends on
the system user that owns your Firebird server process, should be
'firebird', if the MacOSX version is consistent with the official
Firebird POSIX distributions. In that case, the firebird user must
have rw permissions for the file *and* rwx permissions for the
directories in the entire filepath. The smartest way to deal with
this is to create a firebird group and assign the required
permissions to the group. Make firebird a member of the group, but
also the user(s) that are going to be creating files that firebird
has to read and write. All that is filesystem-level stuff that
Firebird has no say in.

>I think this has to do with how Firebird deals with external files in general.

The way Firebird deals with external files is consistent across
platforms. However, platforms are not consistent in the way they
manage permissions.

>The documentation seems to say it should be solvable by placing
>ExternalFileAccess = Restrict
>into
>/Library/Frameworks/Firebird.framework/Versions/Current/Resources/English.lproj/var/
>firebird.conf.

That is a security setting and the default is NONE (the server
doesn't support external tables at all). The path you are indicating
here certainly looks obscure but it doesn't seem like an ideal thing
to bury a file that is to be available to different applications
inside a software framework. Far better to have a much simpler
"security area" for data files that isn't available to any users
other than those that are supposed to access it.

Suppose you create a directory called /data/files/foxpro. Make
firebird its owner and, of course, make sure that the firebird group
has all the required permissions to everything in the /data subtree.

Then, make your configuration as follows:

ExternalFileAccess = Restrict /data/files

Don't forget to stop and restart the server after the change.

Now, the external tables feature is available to the server and the
server will only access files that are in or beneath /data/files,
provided of course that you have previously set up the filesystem
privileges correctly.

>but I tried that & it didn't help (I did un-comment the
>line). That's where I'm stuck. I'm kinda wondering if Firebird
>gets its configuration in OS X differently than it does in other platforms.

That's a possibility one can't rule out. The procedure above refers
to the standard POSIX setup. I simply don't know whether filesystem
privileges work differently on Mac. But the configuration settings
for Firebird apply regardless of platform.

Btw, it's pretty vital to understand that the "release notes" for
Firebird are not just marketing blurb. In fact, they don't market
anything. They do fill up a lot of gaps in knowledge and
understanding of things like installation and configuration. Since
you won't have a 1.5.3 version of Firebird for MacOSX, I suggest that
you go to the Downloads page at the Firebird website and get the
latest release notes.

./heLen