Error = Shmget 13 Permission Denied
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up semget fails with “Permission denied” up vote 0 down vote favorite Hi I have 2 processes P1 and P2. P1 is running as root, and is creating a semaphore with the following call: semget (key, 1, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | IPC_CREAT); and am trying to get the handle to the same semaphore in another process P2, which is running under the normal user's context. In this process, the semget call succeeds, but semop calls fail with "Permission Denied" (Errno = 13). Any pointers would be of great help. ~ps7 unix ipc semaphore share|improve this question asked Jul 7 '09 at 15:34 ps7 1113 add a comment| 4 Answers 4 active oldest votes up vote 1 down vote This entry has a long time but i was having the same problem with 0600 | IPC_CREAT but i already fixed running my application with sudo share|improve this answer answered May 5 '12 at 3:24 Alejandro 3411312 add a comment| up vote 0 down vote What is the language we are talking about? I think there is some error in importing the S_ constants, so that they are null and make no effect. What about a brute test with the bit mask as is? Try use directly IPC_CREAT | 0666 my 2 cents :) share|improve this answer answered Jul 10 '09 at 16:42 drAlberT 7,92122231 add a comment| up vote 0 down vote "Permission denied"/EACCES is, of course, consistent with unprivileged process P2 trying to semget an extant semaphore for which it lacks access. So, perhaps there is already an extant semaphore under that key which lacks the needed S_IWOTH|S_IROTH permissions. (Perhaps a remnant from an early version of P1?) What does ipcs -s say the semaphore's permissions are? What happens if you add IPC_EXCL to your semget call in P1? Will it fail? share|improve this answer answered Aug 12 '09 at 3:19 pilcrow 32k55898 add a comment| up vote 0 down vote Use S_IRUSR and S_IWUSR specify read and write permissions for the owner of the shared memory segment, and S_IROTH and S_IWOTH specify read and write permissions for others flags as the third arguement in the shmget(). IP
Reviews CoolUsesForPerl PerlNews Q&A Tutorials Poetry RecentThreads NewestNodes Donate What'sNew on Jan 16, 2009 at 07:31UTC ( #736760=perlquestion: print w/replies, xml ) Need Help?? katharnakh has asked for the wisdom of the Perl Monks concerning the following question: Hi, I have a simple script to test variable sharing between two perl processes, use IPC::Shareable; $robj = {status=>'init'}; tie $robj->{status}, 'IPC::Shareable', 'data_glue', {create => 1, mode => 664, destroy => 1}; $pid = fork(); unless(defined $pid){ print "Error durigng fork\n"; } if($pid){ $robj->{parent=>'parent'}; }else{ tie $robj->{status}, 'IPC::Shareable', 'data_glue', {create => 0, mode => 664, destroy => 0}; $robj->{status} http://stackoverflow.com/questions/1093052/semget-fails-with-permission-denied = 'updated'; sleep(5); exit(0); } print "\n", $robj->{status}, "\n"; [download] When i run i get following error. IPC::Shareable::SharedMem: shmget: Permission denied at /usr/lib/perl5/site_perl/5.8.3/IPC/Shareable.pm line 566 Could not create shared memory segment: at test_ipc_shareable.pl line 3 [download] Problem: I get above error when run as user account other than 'root' . But the script used to work before, but started throwing this http://www.perlmonks.org/?node_id=736760 error, after server where this script runs was down due to storage corruption. I am getting this error after server came online. I am using perl v5.8.3 and IPC::Shareable v0.60. I tried reinstalling the package, using cpan shell, force make IPC::Shareable', but the unfortunately 'test IPC::Shareable' fails. Does any one know how to resolve this? Because running as 'root' creates other problems for my main scripts. Thanks in advance, katharnakhComment on IPC::Shareable::SharedMem: shmget: Permission deniedSelect or Download Code Replies are listed 'Best First'. Re: IPC::Shareable::SharedMem: shmget: Permission denied by tilly (Archbishop) on Jan 16, 2009 at 08:04UTC My guess is that after the reboot the shared memory segment was somehow created by root and not cleaned up. Now when you try to run the scripts as anything else, they try to access the existing one and fail to have permission because that segment is owned by root. And when you run it as root it doesn't clean it up because it didn't create it. Try running it once by root with the following line at the end: (tied
int shmget ( key_t key, int size, int shmflg ); RETURNS: shared memory segment identifier on success -1 on error: errno = EINVAL (Invalid segment http://www.tldp.org/LDP/lpg/node69.html size specified) EEXIST (Segment exists, cannot create) EIDRM (Segment is marked for deletion, or was removed) ENOENT (Segment does not exist) EACCES (Permission denied) ENOMEM (Not enough memory to create segment) https://forums.zoneminder.com/viewtopic.php?t=4324 NOTES: This particular call should almost seem like old news at this point. It is strikingly similar to the corresponding get calls for message queues and semaphore sets. The first error = argument to shmget() is the key value (in our case returned by a call to ftok()). This key value is then compared to existing key values that exist within the kernel for other shared memory segments. At that point, the open or access operation is dependent upon the contents of the shmflg argument. IPC_CREAT Create the segment if it doesn't already exist error = shmget in the kernel. IPC_EXCL When used with IPC_CREAT, fail if segment already exists. If IPC_CREAT is used alone, shmget() either returns the segment identifier for a newly created segment, or returns the identifier for a segment which exists with the same key value. If IPC_EXCL is used along with IPC_CREAT, then either a new segment is created, or if the segment exists, the call fails with -1. IPC_EXCL is useless by itself, but when combined with IPC_CREAT, it can be used as a facility to guarantee that no existing segment is opened for access. Once again, an optional octal mode may be OR'd into the mask. Let's create a wrapper function for locating or creating a shared memory segment : int open_segment( key_t keyval, int segsize ) { int shmid; if((shmid = shmget( keyval, segsize, IPC_CREAT | 0660 )) == -1) { return(-1); } return(shmid); } Note the use of the explicit permissions of 0660. This small function either returns a shared memory segment identifier (int), or -1 on error. The key value and requested segment size (in bytes) are passed as
denied Support and queries relating to all previous versions of ZoneMinder Post Reply Print view Search Advanced search 2 posts • Page 1 of 1 stephen Posts: 1 Joined: Thu Apr 07, 2005 4:46 pm Can't shmget: Permission denied Quote Postby stephen » Thu Apr 07, 2005 4:48 pm Hey all, After quite a few hours I managed to get ZM working, however after a reboot I'm back to square one with this error in the syslog: Apr 7 17:44:15 noc zmu[390]: ERR [Can't shmget, probably not enough shared memory space free: Permission denied] I'm sure this is the error I got before, but I can't remember how I fixed it. I've tried increasing the shared memory available as the FAQ suggests, but it's still not working. I'm sure it's just a really small permission error, but I'm unable to get any further debug information. Any help would be appreciated! Thanks Top zoneminder Site Admin Posts: 5220 Joined: Wed Jul 09, 2003 2:07 pm Location: Bristol, UK Contact: Contact zoneminder ICQ Website WLM Yahoo Messenger AOL Quote Postby zoneminder » Thu Apr 07, 2005 8:49 pm Possibly you created the shared memory as root (as would be normal) but now you're trying to run as another user? Do 'ipcs -m' to list the shared memory segments, the permissions will be listed as per files. Also don't forget that there are two different methods for inreasing shared memory space, a temporay one for the current run and a permanent one for after a reboot. Make sure you have done both. Phil Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Post Reply Print view 2 posts • Page 1 of 1 Return to “ZoneMinder Previous Versions” Jump to General Announcements Website Issues Non-ZoneMinder Chat Support ZoneMinder 1.30.x ZoneMinder 1.29.x ZoneMinder 1.28.x Mobile Apps ZoneMinder Distributions ZoneMinder Translations Archive ZoneMinder 1.27.x ZoneMinder 1.26.x ZoneMinder 1.25.x ZoneMinder 1.24.x ZoneMinder Previous Versions Development Future Development Feature Requests User Contributions Miscellaneous Jobs / For Sale / Wanted / Exchange Hardware Compatibility List Hardware Queries ZoneMinder Hints & Tips Who is online Users browsing this forum: Yahoo [Bot] and 0 guests Home Board index All times are UTC Delete all board cookies The team Contact us Powered by phpBB Forum Software © phpBB Limited