SYS V messages: permission denied

Ask a Question related to UNIX Programming, Design and Development.

  1. #1

    Default SYS V messages: permission denied

    I don't recall ever getting a permission denied on a message queue
    that I created before. SuSE Linux 8.2, GNU gcc 3.3

    This code calls msgget() then msgsnd(), basically cramming messages
    into the queue up to the system limit.

    If I compile and run it as my (non-root) self, I get a permission
    denied on the msgsnd(). If I run it as root, all is well. I don't
    get it, although it's probably something simple/stupid.

    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <errno.h>
    #include <fcntl.h>

    #include <sys/types.h>
    #include <sys/msg.h>

    extern int errno ;

    #define MQKEY 4321

    void
    bail( char *, int ) ;

    typedef struct msg_struct_tag
    {
    long type ;
    int ndx ;
    int len ;

    } msg_struct ;

    msg_struct msg ;

    int
    main(void)
    {
    int i, tot = 0, mqh ;

    if ( (mqh = msgget( MQKEY, IPC_CREAT )) < 0 )
    bail( "msqget()", errno ) ;

    msg.type = 1 ;
    msg.len = sizeof( msg ) ;

    for ( i = 0 ; i < 30000 ; i++ )
    {
    msg.ndx = i ;
    if ( msgsnd( mqh, (const void *)&msg, msg.len, IPC_NOWAIT ) < 0 )
    bail( "msgsend()", errno ) ;
    else
    {
    tot += msg.len ;
    printf( "Msg %d: Total bytes sent: %d\n", i+1, tot ) ;
    }
    }
    return 0 ;
    }

    void
    bail( char * s, int e )
    {
    printf( "%s: %s\n", s, strerror( e ) ) ;
    exit ( -1 ) ;
    }


    --
    For email, put NOT SPAM in Subject or I'll probably miss it.
    <><
    Richard Guest

  2. Similar Questions and Discussions

    1. Permission Denied...
      I'm not sure how many people have run into this problem, but it's one that is extremely annoying. When a user submits a file to me (or anyone else),...
    2. Permission denied
      I'm running a intranet site on a NT 4.0 IIS 4 server. I have a page that uses CDONTS. I recently change this intranet application to run as an...
    3. ocx permission denied
      I've updated an ocx (using VB6) that is currently being used in an asp 3.0 application. I created an internet package(using VB6) containing the...
    4. permission denied WHY?
      Hi! I wrote this script and executed on my server, with php 4.1.2 <?php $fp = fopen('test.txt', 'w'); fwrite($fp, "Bla bla"); fclose($fp); ...
    5. Permission Denied (in FTP)
      Hello, I'm having some slight issues. I have a script which creates a directory and then copies a blank file into it 4 times each with different...
  3. #2

    Default Re: SYS V messages: permission denied

    [email]rochkind@basepath.com[/email] wrote...
    > On Wed, 30 Jul 2003 05:35:15 GMT, Richard <rh310@hotmail.com> wrote:
    >
    > > I don't recall ever getting a permission denied on a message queue that I
    > > created before. SuSE Linux 8.2, GNU gcc 3.3
    > >
    >
    > [snip]
    >
    > Following based on a quick look... sorry if I missed something:
    >
    > Looks like the message queue is created with no permissions (you need to OR
    > them in with IPC_CREAT). So, if the queue already exists, it can't be
    > opened.
    >
    > Either remove the queue each time, or give yourself some permissions, such
    > as at least 0600.
    <blush>. Thank you.

    I owe you. Least I can do is order your book and read it. :)

    --
    For email, put NOT SPAM in Subject or I'll probably miss it.
    <><
    Richard 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