Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 7 Oct 2000 20:59:37 +0400
From:      "Artem Koutchine" <matrix@ipform.ru>
To:        <questions@FreeBSD.ORG>
Subject:   Maybe some perl/SQL developer could help.
Message-ID:  <025f01c0307f$fcb87220$0c00a8c0@ipform.ru>

next in thread | raw e-mail | index | archive | help
Sorry for the offtopic, but i am really lost.

I have a very weird situation.

There is a perl script wich gets some data in  files and uses LOAD DATA
INFILE to get that data
into database. It is called import.cgi

There is another script   wich does EXACTLY the same (they use the same
function for
importing data), but it does not unpack the incoming zip file, but uses the
files wich were
unpacked by import.cgi. THIS script is called aimport.cgi

Now, when i run import.cgi (which supports file upload, get a zip file,
unzips it, for each *.dat file
unpacked runs an import function) - it work perfectly.

Now, when i run aimport.cgi from the same cgi dir for files created an
already imported by import.cgi
it fails with:

Can't get stat of '/hosts/ubex.ru/admin/curi/rates.dat' (Errorcode: 13)

hosts, server, curi - mode 750,  owner: ubex, group: ubex
rates.dat - 666, owner: ubex, group: ubex
apache is run as: root with suEXEC (so, all scripts execute as ubex.ubex)
mysql is run as : mysql.mysql
database, db user db password are the same for both scripts (read from the
same config file)
apache: 1.3.9
mysql: 3.23.24
OS: FreeBSD 4.1.1-stable


I desided that something is wrong with permissions or user id, so i printed
it out (right
before executing the query):

import.cgi:
Real user id: 5012 Real group id: 5012 5012 5012
Eff user id : 5012 Eff  group id:5012 5012 5012
/hosts/ubex.ru/admin/curi/rates.dat
134407,1064442,33206,1,5012,5012,0,0,970932306,970932306,970935971,8192,0

amport.cgi
Real user id: 5012 Real group id: 5012 5012 5012
Eff user id : 5012 Eff  group id:5012 5012 5012
/hosts/ubex.ru/admin/curi/rates.dat
134407,1064442,33206,1,5012,5012,0,0,970935971,970932306,970935971,8192,0

for the file stat($file) array is printed:
33206= mode 100666
5012 - uid of ubex
5012 - gid of ubex

The import function is very simple (and the same in both aimport.cgi and
import.cgi)

# import one table from a file
sub import_table {
        my $myname="import_table";
        my $sql;
        my $sth;
        my $table=$_[0];
        my $a=0;

# debug data
warn "Real user id: $< Real group id: $(\n";
warn "Eff user id : $> Eff  group id:$)\n";
$f=$CONFIG{'CURDIR'}.'/'.$table.'.dat';
@aa=stat($f);$"=',';warn "$f @aa\n";


        $sql="LOAD DATA INFILE \'$CONFIG{'CURDIR'}/".$table.".dat\' REPLACE
INTO TABLE $table";
        unless ($sth=$dbh->prepare($sql)){die "$DBI::errstr,$myname\n";}
        unless ($a=$sth->execute()){die "$DBI::errstr,$myname\n";}
        $a=$sth->rows;
        $sth->finish;
        if ($a>0){warn "    $a record(s) in $table\n";}
        return $a;
}

I don't undertsand what going on. It either must not work in import.cgi or
also work in aimport.cgi, since
the conditions for LOAD DATA INFILE are the same.

Am i missing something?

Artem









To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?025f01c0307f$fcb87220$0c00a8c0>