+ Reply to Thread
Results 1 to 6 of 6

Permission Denied on /dev/stderr and /dev/stdout

  1. Permission Denied on /dev/stderr and /dev/stdout

    I'm having a problem with bash shell scripts that are being called by
    PHP web pages on a CentOS 4 system. When a script attempts to write
    to /dev/stdout or /dev/stderr I get a 'Permission denied' error. When
    logged in as a normal user, there is no problem using stderr or stdout
    from a terminal. The permissions on /dev (drwxr-xr-x, obtained as
    root), /dev/stderr (lrwxrwxrwx), and /dev/stdout (lrwxrwxrwx) appear
    to be correct.

    The same PHP pages and scripts running on a different Linux
    distribution (Ubuntu) do not give any errors.

    Anyone have any ideas what is going on?

    Thanks
    Phil


  2. Re: Permission Denied on /dev/stderr and /dev/stdout

    On Sep 20, 11:34 am, NorthumberlandCo...@googlemail.com wrote:
    > I'm having a problem with bash shell scripts that are being called by
    > PHP web pages on a CentOS 4 system. When a script attempts to write
    > to /dev/stdout or /dev/stderr I get a 'Permission denied' error. When
    > logged in as a normal user, there is no problem using stderr or stdout
    > from a terminal. The permissions on /dev (drwxr-xr-x, obtained as
    > root), /dev/stderr (lrwxrwxrwx), and /dev/stdout (lrwxrwxrwx) appear
    > to be correct.
    >
    > The same PHP pages and scripts running on a different Linux
    > distribution (Ubuntu) do not give any errors.
    >
    > Anyone have any ideas what is going on?


    Not really. But I can suggest some places to look.

    The permissions you show for /dev/stdout and /dev/stderr show that
    both of those "files" are really symbolic links to other files. Do the
    files that /dev/stdout and /dev/stderr link to exist? What are their
    permissions? (For symbolic links, the permissions on the target file
    are the ones used for permission checking, and the symbolic link file /
    always/ has a=rwx access)

    For what its worth, on my Slackware systems, /dev/stdout and /dev/
    stderr link to /dev/fd/1 and /dev/fd/2 respectively.




  3. Re: Permission Denied on /dev/stderr and /dev/stdout

    On 09/20/2007 10:34 AM, NorthumberlandCoder@googlemail.com wrote:
    > I'm having a problem with bash shell scripts that are being called by
    > PHP web pages on a CentOS 4 system. When a script attempts to write
    > to /dev/stdout or /dev/stderr I get a 'Permission denied' error. When
    > logged in as a normal user, there is no problem using stderr or stdout
    > from a terminal. The permissions on /dev (drwxr-xr-x, obtained as
    > root), /dev/stderr (lrwxrwxrwx), and /dev/stdout (lrwxrwxrwx) appear
    > to be correct.
    >
    > The same PHP pages and scripts running on a different Linux
    > distribution (Ubuntu) do not give any errors.
    >
    > Anyone have any ideas what is going on?
    >
    > Thanks
    > Phil
    >


    You didn't say what version of PHP you're using, and I don't have CentOS
    4 (yet). I'm looking at the PHP3 manual that's shipped with Debian 3.1,
    and it says this regarding the 'fopen' function:

    > If filename is one of "php://stdin", "php://stdout", or "php://stderr", the corresponding stdio stream will be opened. (This was introduced in PHP 3.0.13; in earlier versions, a filename such as "/dev/stdin" or "/dev/fd/0" must be used to access the stdio streams.)



  4. Re: Permission Denied on /dev/stderr and /dev/stdout

    On 20 Sep, 22:55, "Mumia W." +nos...@earthlink.net> wrote:
    > On 09/20/2007 10:34 AM, NorthumberlandCo...@googlemail.com wrote:
    >
    >
    >
    > > I'm having a problem with bash shell scripts that are being called by
    > > PHP web pages on a CentOS 4 system. When a script attempts to write
    > > to /dev/stdout or /dev/stderrI get a 'Permission denied' error. When
    > > logged in as a normal user, there is no problem using stderr or stdout
    > > from a terminal. The permissions on /dev (drwxr-xr-x, obtained as
    > > root), /dev/stderr(lrwxrwxrwx), and /dev/stdout (lrwxrwxrwx) appear
    > > to be correct.

    >
    > > The same PHP pages and scripts running on a different Linux
    > > distribution (Ubuntu) do not give any errors.

    >
    > > Anyone have any ideas what is going on?

    >
    > > Thanks
    > > Phil

    >
    > You didn't say what version of PHP you're using, and I don't have CentOS
    > 4 (yet). I'm looking at the PHP3 manual that's shipped with Debian 3.1,
    > and it says this regarding the 'fopen' function:
    >
    > > If filename is one of "php://stdin", "php://stdout", or "php://stderr", the corresponding stdio stream will be opened. (This was introduced in PHP 3.0.13; in earlier versions, a filename such as "/dev/stdin" or "/dev/fd/0" must be used to access the stdio streams.)



    PHP version is 5.1.6. The error is occuring in the scripts called by
    the PHP pages, not in the pages themselves, so I'm not sure that php://stdout
    and php://stderr are relevant.

    When logged in as user 'normal' I get the following information

    lrwxrwxrwx 1 root root 15 Sep 20 14:50 /dev/stderr -> /proc/self/fd/2
    lrwxrwxrwx 1 root root 15 Sep 20 14:50 /dev/stdout -> /proc/self/fd/1

    lrwx------ 1 normal normal 64 Sep 21 08:31 /proc/self/fd/1 -> /dev/
    pts/2
    lrwx------ 1 normal normal 64 Sep 21 08:31 /proc/self/fd/2 -> /dev/
    pts/2

    crw--w---- 1 normal tty 136, 2 Sep 21 08:31 /dev/pts/2

    If I edit one of the scripts that is being called by the PHP pages to
    display the same information, the script gets a 'permission denied'
    error when running the ls command on /dev/stderr and /dev/stdout, so I
    can't even see what the permissions are. The script can see the
    permissions on /dev, which are

    drwxr-xr-x 11 root root 6780 Sep 20 14:51 /dev

    So I really don't understand what is going on.


  5. Re: Permission Denied on /dev/stderr and /dev/stdout

    On 09/21/2007 02:38 AM, NorthumberlandCoder@googlemail.com wrote:
    > [...]
    > If I edit one of the scripts that is being called by the PHP pages to
    > display the same information, the script gets a 'permission denied'
    > error when running the ls command on /dev/stderr and /dev/stdout, so I
    > can't even see what the permissions are. The script can see the
    > permissions on /dev, which are
    >
    > drwxr-xr-x 11 root root 6780 Sep 20 14:51 /dev
    >
    > So I really don't understand what is going on.
    >


    Try manipulating the selinux configuration to allow the webserver access
    to the /dev directory.


  6. Re: Permission Denied on /dev/stderr and /dev/stdout

    The easiest fix is te add the tty group to the user that is running your web service.

    usermod -a -G tty apache

    this should solve the problem

+ Reply to Thread