You are not logged in.

#1 2007-03-24 05:01:02

celsofaf
Member
From: Campinas, SP, BR
Registered: 2007-02-20
Posts: 25

Permission denied after compiling with gcc

Hello. I'm learning C and created the following stupid test program:

#include <stdio.h>

main(){
    printf("\nHello World!");
    return(0);
}

Compiled: "gcc -o hello hello.c" then ran: "./hello". What do I get? "bash: ./hello: permission denied".

Yes, I do have permission to execute it:

[celso@arch c]$ ls -l hello*
-rwxr-xr-x 1 celso users 4401 2007-03-24 01:48 hello
-rw-r--r-- 1 celso users   71 2007-03-24 01:48 hello.c
-rw-r--r-- 1 celso users   75 2007-03-24 01:46 hello.c~

And no, gcc returned no errors.

I had no problem doing the same procedure on another distro (and executing the shameful C program), but it happened here in Arch. Have I missed something here, perhaps something very, very obvious?

Offline

#2 2007-03-24 05:14:18

gentoofu
Member
Registered: 2006-10-05
Posts: 34

Re: Permission denied after compiling with gcc

Have you tried

chown celso:celso hello

?

Offline

#3 2007-03-24 05:18:31

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: Permission denied after compiling with gcc

What're the permissions on the pwd?

--edit-- eh, nevermind, I guess that's a dumb question.  In my defense, it's late, and I'm tired.   Not sure yet what's going on here...

Last edited by Cerebral (2007-03-24 05:22:32)

Offline

#4 2007-03-24 21:46:35

celsofaf
Member
From: Campinas, SP, BR
Registered: 2007-02-20
Posts: 25

Re: Permission denied after compiling with gcc

gentoofu wrote:

Have you tried

chown celso:celso hello

?

I don't think it's the case, as I'm under the users group:

[celso@arch c]$ groups
audio optical floppy storage users burning

- -

Cerebral wrote:

What're the permissions on the pwd?

I have full permissions there:

[celso@arch c]$ ls -l ../
total 4
drwxr-xr-x 2 celso users 4096 2007-03-24 01:59 c

- -

I went one step further and tried to run my little program as root:

[root@arch c]# ./hello
bash: ./hello: Permissão negada

"Permissão negada" means "permission denied". I even compiled it as root, and same error.

I've got no clue over what's happening. I love Arch, by the way. smile

Offline

#5 2007-03-24 21:50:08

hacosta
Member
From: Mexico
Registered: 2006-10-22
Posts: 423

Re: Permission denied after compiling with gcc

maybe you have noexec in your fstab?

Offline

#6 2007-03-25 00:56:34

celsofaf
Member
From: Campinas, SP, BR
Registered: 2007-02-20
Posts: 25

Re: Permission denied after compiling with gcc

hacosta wrote:

maybe you have noexec in your fstab?

I don't think this is the case. Here is the fstab line corresponding to the partition where my testing lies:

/dev/hdb6 /home/celso/stuff ext3 defaults,user 0 0

Offline

#7 2007-03-25 14:16:58

celsofaf
Member
From: Campinas, SP, BR
Registered: 2007-02-20
Posts: 25

Re: Permission denied after compiling with gcc

OK, solved. smile I thought puting "defaults" on the fstab entry would do, but it didn't. I straight added "exec" on it and now it works. wink

Thanks for the tips.

Offline

#8 2007-03-25 18:22:08

hacosta
Member
From: Mexico
Registered: 2006-10-22
Posts: 423

Re: Permission denied after compiling with gcc

glad it works now, not sure why noexec was added by default, afaik exec is the default..
oh well

Offline

#9 2007-03-25 20:41:06

sh__
Member
Registered: 2005-07-19
Posts: 272

Re: Permission denied after compiling with gcc

celsofaf wrote:
/dev/hdb6 /home/celso/stuff ext3 defaults,user 0 0

defaults -> exec
user -> noexec

Since user comes after defaults, noexec wins. smile

Offline

Board footer

Powered by FluxBB