LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-11-2003, 11:32 PM   #1
SerfurJ
Member
 
Registered: May 2003
Posts: 80

Rep: Reputation: 15
Question can't execute c++ binaries, "permission denied"... even though permission is 777


i'm having trouble executing simple c++ binaries. bash returns a permission denied error, even though i set the file's permissions to 777. i'm using g++ compiler on RH9. for some reason it works on my laptop, also RH9. does it have something to do with installed c++ libraries? any suggestions on how to fix it?

thanks
 
Old 10-12-2003, 02:59 AM   #2
mr_segfault
Member
 
Registered: Oct 2003
Location: Australia
Distribution: Redhat 9
Posts: 95

Rep: Reputation: 15
I think we would need a little more info than you have provided to determine what is going wrong..

Can you paste the command you entered, the error output and anything else that might help us determine what's going on.

It is possible that your binary is attempting to load a shared object for which you dont have read permissions..

If you are not getting much info on what is going bad, you can do an strace on your binary to see if it is something like that.

Code:
strace -e trace=file <your_executable>
This will allow you to see all system calls to file routines and see if it is your binary accessing something or not, also you will see what it failed to open.

Cheers.
 
Old 10-12-2003, 08:22 AM   #3
BigFred
LQ Newbie
 
Registered: Sep 2003
Location: Mount Isa, Queensland, Australia
Distribution: RedHat
Posts: 13

Rep: Reputation: 0
Hi SerfurJ

Who ownes the directory where the executable will end up? Perhaps it needs 777 also. And if you are trying to execute from the current directory, is it in the path. BF
 
Old 10-13-2003, 05:48 PM   #4
SerfurJ
Member
 
Registered: May 2003
Posts: 80

Original Poster
Rep: Reputation: 15
mr_segfault,
i don't get much info. here's what i enter along with the output:

$ ./hello-test
bash: ./hello-test: Permission denied

alternatively

$ bash hello-test
hello-test: hello-test: cannot execute binary file

trying what you suggested:

$strace -e trace=file ./hello-test
strace: exec: Permission denied
execve("./hello-test", ["./hello-test"], [/* 53 vars */]) = 0

i'm not sure what to make of that.

big fred,
i tried that... no banana. i'm using "./" in front of the binary, so it doesn't have to be in the path.

any more ideas? how could i find out if i don't have read permissions for a shared object?

thanks
 
Old 10-13-2003, 05:52 PM   #5
mr_segfault
Member
 
Registered: Oct 2003
Location: Australia
Distribution: Redhat 9
Posts: 95

Rep: Reputation: 15
It looks like you may not have permission to run/call exec.. I'll do some testing and get back to you..

Cheers.
 
Old 10-14-2003, 03:59 PM   #6
bastard23
Member
 
Registered: Mar 2003
Distribution: Debian
Posts: 275

Rep: Reputation: 30
SerfurJ,

Is your filesystem mounted with the noexec option? "grep -i exec /etc/fstab" or "mount|grep -i exec". Have you configured any of the Access control systems. (I don't know what Redhat includes).

Can you run a shell script (or simple c program) from this directory. It may not be related to c++ at all.

Good Luck,
chris
 
Old 10-14-2003, 09:01 PM   #7
SerfurJ
Member
 
Registered: May 2003
Posts: 80

Original Poster
Rep: Reputation: 15
hey good suggestions chris. the drive where i am running these binaries is separate from my linux installation drive, so that seemed like a pretty good explanation. unfortunately, that wasn't it. here's the entry for the drive where it's running from:

/dev/hdh1 /home/jason/mydocs ext3 defaults,user 1 1

i've never heard of any "access control systems" in redhat. is this a gui configurator in debian?

i tried copying the cat binary to the directory that i'm trying to run the c++ binaries from. here's the input/output:

$./cat hello.cc
bash: ./cat: Permission denied

it's funny that perl scripts run from this drive. i think we're on to something. i copied the c++ binary to my other drive and it worked. so what else would keep binaries from running on a mounted filesystem?
 
Old 10-14-2003, 09:27 PM   #8
megaspaz
Senior Member
 
Registered: Nov 2002
Location: Silly Con Valley
Distribution: Red Hat 7.3, Red Hat 9.0
Posts: 2,054

Rep: Reputation: 46
can you try to change that fstab entry to something like this?

/dev/hdh1 /home/jason/mydocs ext3 defaults,user,exec 1 1

i guess you'll have to log out and log in as root so you can unmount it and remount it.
 
Old 10-14-2003, 10:09 PM   #9
bastard23
Member
 
Registered: Mar 2003
Distribution: Debian
Posts: 275

Rep: Reputation: 30
This option implies the options noexec, nosuid, and nodev (unless overridden by subsequent options, as in the option line user,exec,dev,suid). Quothe the mount man page on the user option. Makes sense, I guess.
 
Old 10-17-2003, 08:26 AM   #10
SerfurJ
Member
 
Registered: May 2003
Posts: 80

Original Poster
Rep: Reputation: 15
i just removed the user option and that fixed it. thanks a lot bastard23 et al. for the help.
 
Old 01-23-2007, 07:31 PM   #11
gengiskanhg
LQ Newbie
 
Registered: May 2005
Posts: 6

Rep: Reputation: 0
Thanks very much GNU brothers

I am new in ubuntu with two years of GNU experience. GNU systems like linux are marvelous and you, the community too. Thanks for your help. The solution and the process to diagnosticate the problem help me too. Thanks. Adding "Mount" option "exec" is the key... eh ;-)
$more /etc/fstab | grep exec
/dev/hda9 /home/user/docs ext3 defaults,user,exec 0 2
 
Old 05-28-2008, 02:57 PM   #12
serg.kr
LQ Newbie
 
Registered: Jul 2007
Distribution: Debian
Posts: 15

Rep: Reputation: 2
Thank you very much -- had the same problem here. This was pretty difficult to track down...
 
Old 02-19-2009, 04:48 AM   #13
Sanchi
LQ Newbie
 
Registered: Feb 2009
Posts: 2

Rep: Reputation: 0
problem in getting output

I am new to ubuntu. was writing a cpp program in vi editor(i suppose d editor is not dat important though), but as i put the command for output, it said permission denied... i tried out crtain things that i am pasting here.. even that didnot work.. I have no ida whatsoever


sanchita@sanchita-desktop:~$ ./unary_op_overload.cpp
bash: ./unary_op_overload.cpp: Permission denied
sanchita@sanchita-desktop:~$ strace -e trace=file./unary_op_overload.cpp
strace: invalid system call `file./unary_op_overload.cpp'
sanchita@sanchita-desktop:~$ strace -e trace=file ./unary_op_overload.cpp
execve("./unary_op_overload.cpp", ["./unary_op_overload.cpp"], [/* 36 vars */]) = -1 EACCES (Permission denied)
strace: exec: Permission denied
Process 7807 detached
sanchita@sanchita-desktop:~$ grep -i exec /etc/fstab
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0
 
Old 02-19-2009, 06:58 AM   #14
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,507

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
Sanchi

You need to compile/link your application before you can run it. Maybe you already have?

Code:
g++ unary_op_overload.cpp -o unary_op_overload
./unary_op_overload
Note the when running the program, the .cpp extension is not used.

P.S. The -o option instructs the GCC (g++) linker what to name the executable program. Change the name to something else if you wish. If you do not specify the -o option, the executable program will be named a.out.
 
Old 02-20-2009, 04:50 AM   #15
Sanchi
LQ Newbie
 
Registered: Feb 2009
Posts: 2

Rep: Reputation: 0
dwhitney67

thanks for the post... it worked!
wel i had compiled it earlier and then executed ofcourse. wel couldnot understand 1 little part in dis... i had tried ./a.out as well. and if -o is not utilized, ./a.out should give the result, which didnot occur so.. can you please explain me this?
thanks anyway, it worked.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Submount, "permission denied" when writing to floppy as normal user DaneM Linux - Software 5 02-22-2006 02:05 PM
Only root hears sounds, alsa gives "permission denied" Baix Linux - General 4 07-02-2005 01:30 PM
MPlayer "make install" Permission denied. Belgium! Chrax Linux - General 2 09-09-2004 07:22 PM
Eclipse SDK v3.0 running problem: "Permission denied" AlexDunnCpp Linux - Newbie 1 08-03-2004 11:45 AM
"permission denied" when I try to send raw data to the sound device. Travis86 Linux - Hardware 2 10-29-2003 09:08 AM


All times are GMT -5. The time now is 07:24 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration