FAQ
Hi,

I have an odd problem with my tiny app. Under server script
(MyApp/script/myapp_server -d) it runs without error. However under
fascgi I am encountering a problem with one of my controllers that
uses a FormFU. There an abridged version of the controller is pasted
below.


sub edit : Local :FormConfig('record_data/edit.yml') {
my ($self, $c, $id) = @_;
my $record_data = $c->model('MyAppDB::record_data')->find({'sub_id' => $id});
unless($record_data) {
$c->flash->{error_msg} = "Invalid submission $id -- Cannot edit";
$c->response->redirect($c->uri_for('/submissions/list'));
$c->detach;
}
my $form = $c->stash->{form};
# Update the HD and display the checkbox as checked.
if ($record_data->sub_id->hasHD == 1) {
my $watermarked = $form->get_field({name => 'hasHD'});
$watermarked->checked($record_data->sub_id->hasHD);
}
...
if ($form->submitted_and_valid) {
# create an entry
# Update the validation flag on the submission
$record_data->sub_id->update({validation_pass => 1}); #
Line 89. This line cause CascadeActions::update() error
# Update the record_data
$form->model->update($record_data); # This line causes
Row::update_or_insert() error
$c->flash->{status_msg} = 'metadata updated';
$c->response->redirect($c->uri_for('/submissions/list'));
$c->detach;
}
else {
$form->model->default_values($record_data);
}
$c->stash->{template} = 'submissions/edit.tt2';
}


The controller loads the data from $c->model('MyAppDB::record_data')
fine and displays it in the form. It's when you attempt the
update/submit you get the error. So the issue seems to be with
$form->model->update($record_data);

My conf file has:

<Model::FormFu>
stash_key form
</Model::FormFu>


The error in the http error log is:
:CascadeActions::update(): DBI Exception: DBD::SQLite::st execute
failed: unable to open database file(14) at dbdimp.c line 403 [for
Statement "UPDATE submissions SET validation_pass = ? WHERE ( id = ?
)"] at ..lib/MyApp/Controller/RecordData.pm line 89, referer: ...

DBIx::Class::Row::update_or_insert(): DBI Exception: DBD::SQLite::st
execute failed: unable to open database file(14) at dbdimp.c line 403
[for Statement "UPDATE clipData SET audio = ? WHERE ( id = ? )"] at
/usr/lib/perl5/site_perl/5.8.8/HTML/FormFu/Model/DBIC.pm line 324,


Server configuration.

DocumentRoot /var/www/MyApp/root
Alias /static /var/www/MyApp/root/static

FastCgiServer /var/www/MyApp/script/myapp_fastcgi.pl -processes 3
Alias /motion /var/www/MyApp/script/myapp_fastcgi.pl/

Does anyone have any ideas what the problem might be? I can't see why
it might work in one environment and not the other.
Tia,
Dp.

Search Discussions

  • Robert Krimen at Aug 13, 2008 at 11:24 am

    On Wed, Aug 13, 2008 at 3:08 AM, Dermot wrote:

    Hi,

    I have an odd problem with my tiny app. Under server script
    (MyApp/script/myapp_server -d) it runs without error. However under
    fascgi I am encountering a problem with one of my controllers that
    uses a FormFU. There an abridged version of the controller is pasted
    below.

    The error in the http error log is:
    :CascadeActions::update(): DBI Exception: DBD::SQLite::st execute
    failed: unable to open database file(14) at dbdimp.c line 403 [for
    Statement "UPDATE submissions SET validation_pass = ? WHERE ( id = ?
    )"] at ..lib/MyApp/Controller/RecordData.pm line 89, referer: ...

    DBIx::Class::Row::update_or_insert(): DBI Exception: DBD::SQLite::st
    execute failed: unable to open database file(14) at dbdimp.c line 403
    [for Statement "UPDATE clipData SET audio = ? WHERE ( id = ? )"] at
    /usr/lib/perl5/site_perl/5.8.8/HTML/FormFu/Model/DBIC.pm line 324,

    Server configuration.

    DocumentRoot /var/www/MyApp/root
    Alias /static /var/www/MyApp/root/static

    FastCgiServer /var/www/MyApp/script/myapp_fastcgi.pl -processes 3
    Alias /motion /var/www/MyApp/script/myapp_fastcgi.pl/

    Does anyone have any ideas what the problem might be? I can't see why
    it might work in one environment and not the other.
    This looks like a permissions issue to me. You're running the "server
    script" as one
    user and then running the application via Apache (which is a different user
    like nobody or www).

    Apache doesn't have write (or maybe even read) access to your SQLite
    database file or directory.

    Rob
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20080813/63344dbd/attachment.htm
  • Dermot at Aug 13, 2008 at 11:35 am

    DBIx::Class::Row::update_or_insert(): DBI Exception: DBD::SQLite::st
    execute failed: unable to open database file(14) at dbdimp.c line 403
    [for Statement "UPDATE clipData SET audio = ? WHERE ( id = ? )"] at
    /usr/lib/perl5/site_perl/5.8.8/HTML/FormFu/Model/DBIC.pm line 324,

    Server configuration.

    DocumentRoot /var/www/MyApp/root
    Alias /static /var/www/MyApp/root/static

    FastCgiServer /var/www/MyApp/script/myapp_fastcgi.pl -processes 3
    Alias /motion /var/www/MyApp/script/myapp_fastcgi.pl/

    Does anyone have any ideas what the problem might be? I can't see why
    it might work in one environment and not the other.
    This looks like a permissions issue to me. You're running the "server
    script" as one
    user and then running the application via Apache (which is a different user
    like nobody or www).

    Apache doesn't have write (or maybe even read) access to your SQLite
    database file or directory.

    Rob
    Thanx Rob but chmod was the first thing I did.

    -rwxrwxrwx 1 someuser root 793600 Aug 12 13:30 mydata.db

    Changing the owner/group hasn't helped either.

    I am not sure but I would have expected a permission denied message if
    the permissions were incorrect. This reads more like file not found.

    Thanx,
    Dp.
  • Matthias Zeichmann at Aug 13, 2008 at 11:43 am

    On Wed, Aug 13, 2008 at 12:35, Dermot wrote:
    -rwxrwxrwx 1 someuser root 793600 Aug 12 13:30 mydata.db
    better change permissions to something like 664 and chgrp www-data (or
    whatever your webserver runs as) and make sure that webserver user can
    traverse the path to db

    like i.e.
    # su -m www-data
    $ cd $PATH_TO_YOUR_DB

    cheers
    m
    --
    siggen.pl: Segmentation Fault
  • Dermot at Aug 13, 2008 at 12:08 pm

    2008/8/13 Matthias Zeichmann <matthias.zeichmann@gmail.com>:
    On Wed, Aug 13, 2008 at 12:35, Dermot wrote:
    -rwxrwxrwx 1 someuser root 793600 Aug 12 13:30 mydata.db
    better change permissions to something like 664 and chgrp www-data (or
    whatever your webserver runs as) and make sure that webserver user can
    traverse the path to db

    like i.e.
    # su -m www-data
    $ cd $PATH_TO_YOUR_DB

    cheers
    m
    Hi Matthias,

    Is that for security reason? My http daemon runs as apache. Below is
    the permissions as they are now.

    -rw-r-xr-- 1 apache apache 793600 Aug 12 13:30 mydata.db

    It doesn't resolve my problem. The error:

    unable to open database file(14)

    Is still there, even after a graceful restart.

    I suspect this is a configuration problem with FormFU but I am not
    sure what. I have tickered with my conf file

    name MyApp
    ...
    <Model::FormFu>
    config_dir __HOME__
    stash_key form
    </Model::FormFu>
    ..

    but that doesn't appear to make a difference.
    Thanx,
    Dp.
  • Carl Franks at Aug 13, 2008 at 12:28 pm

    2008/8/13 Dermot <paikkos@googlemail.com>:
    2008/8/13 Matthias Zeichmann <matthias.zeichmann@gmail.com>:
    On Wed, Aug 13, 2008 at 12:35, Dermot wrote:
    -rwxrwxrwx 1 someuser root 793600 Aug 12 13:30 mydata.db
    better change permissions to something like 664 and chgrp www-data (or
    whatever your webserver runs as) and make sure that webserver user can
    traverse the path to db

    like i.e.
    # su -m www-data
    $ cd $PATH_TO_YOUR_DB

    cheers
    m
    Hi Matthias,

    Is that for security reason? My http daemon runs as apache. Below is
    the permissions as they are now.

    -rw-r-xr-- 1 apache apache 793600 Aug 12 13:30 mydata.db

    It doesn't resolve my problem. The error:

    unable to open database file(14)

    Is still there, even after a graceful restart.

    I suspect this is a configuration problem with FormFU but I am not
    sure what. I have tickered with my conf file
    You're passing $form->model->update() your row object, so I don't
    think it can be a problem with formfu, as it'll just be working with
    that.
    Did you follow Matthias' advice to `su apache` and check you can
    change into the directory containing the db file?

    Carl
  • Dermot at Aug 13, 2008 at 12:40 pm

    2008/8/13 Carl Franks <fireartist@gmail.com>:
    2008/8/13 Dermot <paikkos@googlemail.com>:
    2008/8/13 Matthias Zeichmann <matthias.zeichmann@gmail.com>:
    On Wed, Aug 13, 2008 at 12:35, Dermot wrote:
    -rwxrwxrwx 1 someuser root 793600 Aug 12 13:30 mydata.db
    better change permissions to something like 664 and chgrp www-data (or
    whatever your webserver runs as) and make sure that webserver user can
    traverse the path to db

    like i.e.
    # su -m www-data
    $ cd $PATH_TO_YOUR_DB

    cheers
    m
    Hi Matthias,

    Is that for security reason? My http daemon runs as apache. Below is
    the permissions as they are now.

    -rw-r-xr-- 1 apache apache 793600 Aug 12 13:30 mydata.db

    It doesn't resolve my problem. The error:

    unable to open database file(14)

    Is still there, even after a graceful restart.

    I suspect this is a configuration problem with FormFU but I am not
    sure what. I have tickered with my conf file
    You're passing $form->model->update() your row object, so I don't
    think it can be a problem with formfu, as it'll just be working with
    that.
    Did you follow Matthias' advice to `su apache` and check you can
    change into the directory containing the db file?

    Carl
    Thanx Carl and Sorry Matthias, I didn't follow you exactly because

    su apache
    This account is currently not available

    and

    su -m apache
    bash: /root/.bashrc: Permission denied

    So I have chown apache:apache MyApp directory and it works.

    Is it okay to leave the top level directory and the datafile owned by
    the httpd user? I would have thought all the other code should be
    read-only for other that user.

    Thanx again,
    Dp.
  • Matt S Trout at Aug 17, 2008 at 6:49 pm

    On Wed, Aug 13, 2008 at 12:40:13PM +0100, Dermot wrote:
    So I have chown apache:apache MyApp directory and it works.

    Is it okay to leave the top level directory and the datafile owned by
    the httpd user? I would have thought all the other code should be
    read-only for other that user.
    If you use FastCgiExternalServer you can run the app as its own user.

    That's what I usually do.

    --
    Matt S Trout Need help with your Catalyst or DBIx::Class project?
    Technical Director http://www.shadowcat.co.uk/catalyst/
    Shadowcat Systems Ltd. Want a managed development or deployment platform?
    http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/servers/
  • Marcus Ramberg at Aug 28, 2008 at 8:05 pm

    On 13. aug.. 2008, at 13.40, Dermot wrote:
    Thanx Carl and Sorry Matthias, I didn't follow you exactly because

    su apache
    This account is currently not available

    and

    su -m apache
    bash: /root/.bashrc: Permission denied

    So I have chown apache:apache MyApp directory and it works.

    Is it okay to leave the top level directory and the datafile owned by
    the httpd user? I would have thought all the other code should be
    read-only for other that user.
    SQLite requires write access on the directory the data file is in as
    well as the data file to be able to provide locking. leaving the app
    writeable by the httpd user isn't really recommended. I suggest moving
    your sqlite database to a db directory or something similar.

    Marcus
  • Dermot at Aug 28, 2008 at 9:18 pm
    2008/8/28 Marcus Ramberg <marcus@nordaaker.com>:
    On 13. aug.. 2008, at 13.40, Dermot wrote:

    Thanx Carl and Sorry Matthias, I didn't follow you exactly because

    su apache
    This account is currently not available

    and

    su -m apache
    bash: /root/.bashrc: Permission denied

    So I have chown apache:apache MyApp directory and it works.

    Is it okay to leave the top level directory and the datafile owned by
    the httpd user? I would have thought all the other code should be
    read-only for other that user.
    SQLite requires write access on the directory the data file is in as well as
    the data file to be able to provide locking. leaving the app writeable by
    the httpd user isn't really recommended. I suggest moving your sqlite
    database to a db directory or something similar.

    Marcus
    Thanx Marcus. That's useful to know.
    Dp.
  • Wade Stuart at Aug 28, 2008 at 10:47 pm
    Marcus Ramberg wrote on 08/28/2008 02:05:44 PM:
    On 13. aug.. 2008, at 13.40, Dermot wrote:

    Thanx Carl and Sorry Matthias, I didn't follow you exactly because

    su apache
    This account is currently not available
    look at your apache users' passwd entry, you will see a shell for
    /sbin/nologin (which produces that error), if you pass a valid shell to su
    you can use it to run commands as apache...

    #su -s /bin/sh -c "whoami" apache
    apache



    and

    su -m apache
    bash: /root/.bashrc: Permission denied

    So I have chown apache:apache MyApp directory and it works.

    Is it okay to leave the top level directory and the datafile owned by
    the httpd user? I would have thought all the other code should be
    read-only for other that user.
    SQLite requires write access on the directory the data file is in as
    well as the data file to be able to provide locking. leaving the app
    writeable by the httpd user isn't really recommended. I suggest moving
    your sqlite database to a db directory or something similar.

    Marcus

    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive:
    http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/
  • Iain Hubbard at Aug 13, 2008 at 1:00 pm

    On Wed, 2008-08-13 at 11:35 +0100, Dermot wrote:
    I am not sure but I would have expected a permission denied message if
    the permissions were incorrect. This reads more like file not found.
    A quick google turned up a similar problem
    http://www.perlmonks.org/?node_idi5467

    This turned out to be a permissions problem.

    Iain.
    --------------------------------------------------------
    GMG Regional Digital is part of the Guardian Media Group plc.




    CONFIDENTIALITY NOTICE. The information contained in this e-mail is intended only for catalyst@lists.scsys.co.uk. It may contain privileged and confidential information that is exempt from disclosure by law and if you are not an intended recipient, you must not copy, distribute or take any action in reliance on it. If you have received this e-mail in error, you may notify us by telephone on 44 (0)161 832 7200. E-mail transmission cannot be guaranteed to be secure or error-free. The sender (iain.hubbard@gmgrd.co.uk) therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission. If verification is required please request a hard-copy version.

    Scanned by MailDefender - managed email security from intY - www.maildefender.net
  • Dermot at Aug 13, 2008 at 1:52 pm

    2008/8/13 Iain Hubbard <iain.hubbard@gmgrd.co.uk>:
    On Wed, 2008-08-13 at 11:35 +0100, Dermot wrote:
    I am not sure but I would have expected a permission denied message if
    the permissions were incorrect. This reads more like file not found.
    A quick google turned up a similar problem
    http://www.perlmonks.org/?node_idi5467

    This turned out to be a permissions problem.

    Iain.
    --------------------------------------------------------
    GMG Regional Digital is part of the Guardian Media Group plc.




    CONFIDENTIALITY NOTICE. The information contained in this e-mail is intended only for catalyst@lists.scsys.co.uk. It may contain privileged and confidential information that is exempt from disclosure by law and if you are not an intended recipient, you must not copy, distribute or take any action in reliance on it. If you have received this e-mail in error, you may notify us by telephone on 44 (0)161 832 7200. E-mail transmission cannot be guaranteed to be secure or error-free. The sender (iain.hubbard@gmgrd.co.uk) therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission. If verification is required please request a hard-copy version.

    Scanned by MailDefender - managed email security from intY - www.maildefender.net
    If your suggesting that I didn't try that, your mistaken.

    I searched for "fastcgi" at
    http://www.mail-archive.com/catalyst@lists.scsys.co.uk/

    and didn't see anything relevant.

    Thanx,
    Dp.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedAug 13, '08 at 11:08a
activeAug 28, '08 at 10:47p
posts13
users8
websitecatalystframework.org
irc#catalyst

People

Translate

site design / logo © 2022 Grokbase