[Solved] Failed to create temp file with mkstemp()

#1
Trying to output a report using the Zend Pdf library throws this error in stderror log:

2011-09-05 13:20:35.444 [STDERR] Failed to create temp file with mkstemp(): Permission denied
2011-09-05 13:20:35.444 [STDERR] Failed to increase temp file size with ftrancate(): Bad file descriptor

This error in the error.log:

2011-09-05 13:45:25.228 [ERROR] [216.234.104.50:50982-0#APVH_207.32.184.195_example.com] Failed to initialize VMemBuf.
2011-09-05 13:45:25.228 [INFO] [216.234.104.50:50982-0#APVH_207.32.184.195_example.com] connection to [/tmp/lshttpd/APVH_demo.example.com_Suphp.sock.480] on request #0, confirmed, 1, associated process: 1011, running: 1, error: Illegal seek!
2011-09-05 13:45:25.228 [NOTICE] [216.234.104.50:50982-0#APVH_207.32.184.195_example.com] oops! 503 Service Unavailable
2011-09-05 13:45:25.228 [NOTICE] [216.234.104.50:50982-0#APVH_207.32.184.195_snowleotards.com] Content len: 74, Request line:
POST /catalog/index.php/admin/sales_order/pdfinvoices/key/e5b2f8a77e012d61aa38d36fef25f6fe/ HTTP/1.1

INFO:

Litespeed Web Server Enterprise v4.0.15

PHP 5.2.17 (cli) (built: Jun 13 2011 14:23:24)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
with eAccelerator v0.9.5.3, Copyright (c) 2004-2006 eAccelerator, by eAccelerator
with the ionCube PHP Loader v4.0.8, Copyright (c) 2002-2011, by ionCube Ltd., and
with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies

I checked permissions on /tmp and it's open to all rw. Suggestions on where to look?
 

NiteWave

Administrator
#2
Code:
~>man mkstemp
MKSTEMP(3)                 Linux Programmer's Manual                MKSTEMP(3)

NAME
       mkstemp - create a unique temporary file

SYNOPSIS
       #include <stdlib.h>

       int mkstemp(char *template);

DESCRIPTION
       The  mkstemp() function generates a unique temporary filename from template.  The last six characters of template must be
       XXXXXX and these are replaced with a string that makes the filename unique. The file is then created with mode read/write
       and  permissions  0666 (glibc 2.0.6 and earlier), 0600 (glibc 2.0.7 and later).  Since it will be modified, template must
       not be a string constant, but should be declared as a character array.  The file is opened with the open(2) O_EXCL  flag,
       guaranteeing that when mkstemp() returns successfully we are the only user.
the error message
Code:
2011-09-05 13:20:35.444 [STDERR] Failed to create temp file with mkstemp(): Permission denied
should be from Zend Pdf library, since it looks mkstemp() is not a php function, but a C function.

it depends on the value of variable "template". assume it's "a.XXXXXX". then temporary file will be created at current working directory, not /tmp/. for more information, please check what user lsphp is running as, and the location of the php scripts and the directory permission.
 
#3
Thanks for the reply. What about the following error?

2011-09-04 06:28:22.654 [ERROR] [208.69.120.120:61555-0#APVH_207.32.184.195_example.com] Failed to initialize VMemBuf.
 
#4
Also, switching to apache the Pdf outputs as it should. It has to be an lsws/lsapi configuration issue somewhere. Just can't seem to figure out where.

FYI: lsws is running as apache:apache.
 
#6
I figured it out. /tmp/lshttpd/swap was not owned by the apache user for some reason. chown'ing to apache fixed the problem.

Thanks for your help.
 
Top