#40760 [NEW]: not honoring mode of shm_attach

Ask a Question related to PHP Bugs, Design and Development.

  1. #1

    Default #40760 [NEW]: not honoring mode of shm_attach

    From: secker at careviewcom dot com
    Operating system: Debian 'Etch', kern 2.6.17-2-486
    PHP version: 5.2.1
    PHP Bug Type: Unknown/Other Function
    Bug description: not honoring mode of shm_attach

    Description:
    ------------
    If I create a Shared memory segment using shm_attach with one user, and
    set it as readable by all users, but only writable by the owner, then
    other users cannot open the segment via shm_attach, they get permission
    denied errors.

    I would guess this is maybe because shm_attach can't open a segment as
    read-only, and always tried to open it as rw?

    Reproduce code:
    ---------------
    run as someuser1:

    <?php
    $f = ftok('somefile', 'I');
    $sh = shm_attach($f, 1024000, 0644);
    ?>

    works if its not already created by another user...


    run as someuser2:

    <?php
    $f = ftok('somefile', 'I');
    $sh = shm_attach($f);
    ?>



    Expected result:
    ----------------
    what I would expect is that since I created it as 0644, other users should
    be able to access it via read-only mode (which I can do if I open it using
    shmop_open with the read-only flag instead).

    Actual result:
    --------------
    second user gets "Permission Denied" php warning messages.

    once again, I think this is mearly a result of shm_attach not actually
    ever opening an shm as read-only, always read-write... but I might be
    mistaken.


    Thanks.

    --
    Edit bug report at [url]http://bugs.php.net/?id=40760&edit=1[/url]
    --
    Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=40760&r=trysnapshot44[/url]
    Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=40760&r=trysnapshot52[/url]
    Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=40760&r=trysnapshot60[/url]
    Fixed in CVS: [url]http://bugs.php.net/fix.php?id=40760&r=fixedcvs[/url]
    Fixed in release: [url]http://bugs.php.net/fix.php?id=40760&r=alreadyfixed[/url]
    Need backtrace: [url]http://bugs.php.net/fix.php?id=40760&r=needtrace[/url]
    Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=40760&r=needscript[/url]
    Try newer version: [url]http://bugs.php.net/fix.php?id=40760&r=oldversion[/url]
    Not developer issue: [url]http://bugs.php.net/fix.php?id=40760&r=support[/url]
    Expected behavior: [url]http://bugs.php.net/fix.php?id=40760&r=notwrong[/url]
    Not enough info: [url]http://bugs.php.net/fix.php?id=40760&r=notenoughinfo[/url]
    Submitted twice: [url]http://bugs.php.net/fix.php?id=40760&r=submittedtwice[/url]
    register_globals: [url]http://bugs.php.net/fix.php?id=40760&r=globals[/url]
    PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=40760&r=php3[/url]
    Daylight Savings: [url]http://bugs.php.net/fix.php?id=40760&r=dst[/url]
    IIS Stability: [url]http://bugs.php.net/fix.php?id=40760&r=isapi[/url]
    Install GNU Sed: [url]http://bugs.php.net/fix.php?id=40760&r=gnused[/url]
    Floating point limitations: [url]http://bugs.php.net/fix.php?id=40760&r=float[/url]
    No Zend Extensions: [url]http://bugs.php.net/fix.php?id=40760&r=nozend[/url]
    MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=40760&r=mysqlcfg[/url]
    secker at careviewcom dot com Guest

  2. Similar Questions and Discussions

    1. #39289 [NEW]: all right in CGI/FastCGI mode, but not right in ISAPI mode.
      From: bin at tbswe dot com Operating system: Windows 2003 PHP version: 5.1.6 PHP Bug Type: Dynamic loading Bug description: ...
    2. Difference b/w Flex Mode and Classic Mode
      Hi can anyone explain the difference b/w Flex Mode and Classic mode of serialization tag in gateway-config.xml .? what is the purpose of ...
    3. PAR executables not honoring perl5opt
      I just installed PAR 0.81 on my ActivePerl 5.6.1 for Win32 (build 629). When I use pp to create an executable, everything works fine if I don't...
    4. Normal Mode and Expert Mode in MX2004
      In this case I think the appalling way MM is treating us WAY trumps any "netiquette" issues. In fact, I think more people should be posting the...
    5. PHP and I-mode
      Does somebody know if PHP works in I-mode pages? Thanks
  3. #2

    Default #40760 [Opn->Bgs]: not honoring mode of shm_attach

    ID: 40760
    Updated by: [email]tony2001@php.net[/email]
    Reported By: secker at careviewcom dot com
    -Status: Open
    +Status: Bogus
    Bug Type: Unknown/Other Function
    Operating System: Debian 'Etch', kern 2.6.17-2-486
    PHP Version: 5.2.1
    New Comment:
    >$sh = shm_attach($f);
    [url]http://php.net/shm_attach[/url]
    "..and the optional perm-bits perm (default: 0666)..."
    >I would guess this is maybe because shm_attach can't open a segment
    >as read-only, and always tried to open it as rw?
    Exactly.
    That's because by default it tries to open it in 0666 mode.
    Specify 0644 and voila..


    Previous Comments:
    ------------------------------------------------------------------------

    [2007-03-08 17:41:31] secker at careviewcom dot com

    Description:
    ------------
    If I create a Shared memory segment using shm_attach with one user, and
    set it as readable by all users, but only writable by the owner, then
    other users cannot open the segment via shm_attach, they get permission
    denied errors.

    I would guess this is maybe because shm_attach can't open a segment as
    read-only, and always tried to open it as rw?

    Reproduce code:
    ---------------
    run as someuser1:

    <?php
    $f = ftok('somefile', 'I');
    $sh = shm_attach($f, 1024000, 0644);
    ?>

    works if its not already created by another user...


    run as someuser2:

    <?php
    $f = ftok('somefile', 'I');
    $sh = shm_attach($f);
    ?>



    Expected result:
    ----------------
    what I would expect is that since I created it as 0644, other users
    should be able to access it via read-only mode (which I can do if I
    open it using shmop_open with the read-only flag instead).

    Actual result:
    --------------
    second user gets "Permission Denied" php warning messages.

    once again, I think this is mearly a result of shm_attach not actually
    ever opening an shm as read-only, always read-write... but I might be
    mistaken.


    Thanks.


    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=40760&edit=1[/url]
    tony2001@php.net Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139