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

Discussion in 'General' started by sophrosyne, Sep 5, 2011.

  1. sophrosyne

    sophrosyne Member

    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] [] Failed to initialize VMemBuf.
    2011-09-05 13:45:25.228 [INFO] [] 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] [] oops! 503 Service Unavailable
    2011-09-05 13:45:25.228 [NOTICE] [] Content len: 74, Request line:
    POST /catalog/index.php/admin/sales_order/pdfinvoices/key/e5b2f8a77e012d61aa38d36fef25f6fe/ HTTP/1.1


    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?
  2. NiteWave

    NiteWave Administrator

    ~>man mkstemp
    MKSTEMP(3)                 Linux Programmer's Manual                MKSTEMP(3)
           mkstemp - create a unique temporary file
           #include <stdlib.h>
           int mkstemp(char *template);
           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
    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. sophrosyne

    sophrosyne Member

    Thanks for the reply. What about the following error?

    2011-09-04 06:28:22.654 [ERROR] [] Failed to initialize VMemBuf.
  4. sophrosyne

    sophrosyne Member

    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.
  5. NiteWave

    NiteWave Administrator

  6. sophrosyne

    sophrosyne Member

    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.

Share This Page