Author Topic: Permission Denied though my linux chmod has allowed 777  (Read 11715 times)

Offline edcompsci

  • Multiple posting newcomer
  • *
  • Posts: 18
Re: Permission Denied though my linux chmod has allowed 777
« Reply #15 on: June 13, 2021, 11:38:26 pm »
Code
-------------- Build file: "no target" in "no project" (compiler: unknown)---------------

gcc   -c /media/IDE/ProgrammingCode/0._Console/c_programs/pointers-addressof.c -o /media/IDE/ProgrammingCode/0._Console/c_programs/pointers-addressof.o
g++  -o /media/IDE/ProgrammingCode/0._Console/c_programs/pointers-addressof /media/IDE/ProgrammingCode/0._Console/c_programs/pointers-addressof.o   
Process terminated with status 0 (0 minute(s), 2 second(s))
0 error(s), 0 warning(s) (0 minute(s), 2 second(s))

Code
$ ls -lAtr
total 176
-rwxrwx--x 1 edward   1002   581 Nov 24  2013  FileExistance.c
-rwxrwx--x 1 edward   1002  2083 Mar 28  2016  playwav-sdl.c
drwxrwx--x 3 edward   1002  4096 Mar  4 21:21  cpp
drwxrwx--x 2 edward   1002  4096 Mar  4 21:21 'learning asynchronous programming'
-rwxr-xr-x 1 edward edward   120 Jun  5 10:36  test.c
-rwxr-xr-x 1 edward edward 16632 Jun  5 10:36  a.out
drwxr-xr-x 4 edward edward  4096 Jun  5 13:54  Ch02-01
drwxr-xr-x 2 edward edward  4096 Jun  5 14:40  pre-defined-headers
-rwxr-xr-x 1 edward edward   966 Jun  5 15:32  staticvar.c
-rw-r--r-- 1 root   root    2960 Jun  5 15:33  staticvar.o
-rwxr-xr-x 1 root   root   16808 Jun  5 15:33  staticvar
-rwxr-xr-x 1 edward edward  2576 Jun  5 16:25  bubblesort.c
-rwxr-xr-x 1 edward edward  3040 Jun  5 16:50  quicksort.c
-rwxr-xr-x 1 edward edward   235 Jun  5 16:58  using-strlen.c
-rwxr-xr-x 1 edward edward   732 Jun  6 07:03  array-passin-and-return-values.c
-rwxr-xr-x 1 edward edward   845 Jun  6 07:35  struct-pass-ins.c
-rwxr-xr-x 1 edward edward   788 Jun  6 08:10  struct-curlybracketsassign.c
-rwxr-xr-x 1 edward edward   745 Jun  6 08:14  struct-arrays-of-structs.c
-rwxr-xr-x 1 edward edward   951 Jun  6 08:19  struct-array-swap-elements.c
-rwxr-xr-x 1 edward edward  1433 Jun  6 08:23  struct-returnvalue.c
-rwxr-xr-x 1 edward edward   741 Jun  6 08:44  pointers-addressof.c
-rwxr-xr-x 1 edward edward   308 Jun  6 08:59  pointers-incrementing.c
-rwxr-xr-x 1 edward edward   495 Jun  6 09:07  pointers-incrementing-usingduplicatestring.c
-rwxr-xr-x 1 edward edward   585 Jun  6 09:13  pointers-incrementing-plusplusbefore-orafter.c
-rwxr-xr-x 1 edward edward   157 Jun  6 09:20  count.c
-rwxr-xr-x 1 edward edward   371 Jun  6 10:51  pointers-loops-increments-with-int_iterator.c
-rw-r--r-- 1 edward edward  2648 Jun 13 14:18  pointers-addressof.o
-rwxr-xr-x 1 edward edward 16624 Jun 13 14:18  pointers-addressof

but I have the compiler set as gcc

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13438
    • Travis build status
Re: Permission Denied though my linux chmod has allowed 777
« Reply #16 on: June 14, 2021, 01:20:53 am »
What happens if you run the executable from terminal?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Commaster

  • Almost regular
  • **
  • Posts: 129
Re: Permission Denied though my linux chmod has allowed 777
« Reply #17 on: June 14, 2021, 06:32:09 am »
> "no target" in "no project"

Building without a Code::Blocks project can be unhealthy indeed...

Offline edcompsci

  • Multiple posting newcomer
  • *
  • Posts: 18
Re: Permission Denied though my linux chmod has allowed 777
« Reply #18 on: June 15, 2021, 03:00:11 am »
What happens if you run the executable from terminal?
Code
gcc -c pointers-addressof.c -o pointers-address-of.run
/pointers-address-of.run
bash: ./pointers-address-of.run: Permission denied
[email protected]:/media/IDE/ProgrammingCode/0._Console/c_programs$ chmod + ./pointers-address-of.run
[email protected]:/media/IDE/ProgrammingCode/0._Console/c_programs$ ./pointers-address-of.run
bash: ./pointers-address-of.run: Permission denied
[email protected]:/media/IDE/ProgrammingCode/0._Console/c_programs$ sudo chmod -R 777 .
[email protected]:/media/IDE/ProgrammingCode/0._Console/c_programs$ ./pointers-address-of.run
bash: ./pointers-address-of.run: Permission denied
[email protected]:/media/IDE/ProgrammingCode/0._Console/c_programs$ ls -l
total 188.
.
.
-rwxrwxrwx 1 edward edward 16624 Jun 13 14:18  pointers-addressof
-rwxrwxrwx 1 edward edward   741 Jun  6 08:44  pointers-addressof.c
-rwxrwxrwx 1 edward edward  2648 Jun 14 17:34  pointers-addressof.o
-rwxrwxrwx 1 edward edward  2648 Jun 14 17:38  pointers-address-of.run

 

So then it's not a codeblocks issue, but compiler issue.

Offline edcompsci

  • Multiple posting newcomer
  • *
  • Posts: 18
Re: Permission Denied though my linux chmod has allowed 777
« Reply #19 on: June 15, 2021, 03:22:33 am »
> "no target" in "no project"

Building without a Code::Blocks project can be unhealthy indeed...

 I tried that.  I started a brand new c console project, and copied the contents of my file to main.c, built it and still get permission denied.

Offline Commaster

  • Almost regular
  • **
  • Posts: 129
Re: Permission Denied though my linux chmod has allowed 777
« Reply #20 on: June 15, 2021, 04:36:56 am »
Code
gcc -c pointers-addressof.c -o pointers-address-of.run
/pointers-address-of.run
bash: ./pointers-address-of.run: Permission denied
-rwxrwxrwx 1 edward edward 16624 Jun 13 14:18  pointers-addressof
-rwxrwxrwx 1 edward edward  2648 Jun 14 17:34  pointers-addressof.o
-rwxrwxrwx 1 edward edward  2648 Jun 14 17:38  pointers-address-of.run
Google "GCC flags":
Code
-c
    Compile or assemble the source files, but do not link. The linking stage simply is not done. The ultimate output is in the form of an object file for each source file.
    By default, the object file name for a source file is made by replacing the suffix .c, .i, .s, etc., with .o.
Why are you trying to run the object file instead of the compiled binary? Even the file size should hint at that...

Offline edcompsci

  • Multiple posting newcomer
  • *
  • Posts: 18
Re: Permission Denied though my linux chmod has allowed 777
« Reply #21 on: June 16, 2021, 01:21:12 am »
Code
gcc -c pointers-addressof.c -o pointers-address-of.run
/pointers-address-of.run
bash: ./pointers-address-of.run: Permission denied
-rwxrwxrwx 1 edward edward 16624 Jun 13 14:18  pointers-addressof
-rwxrwxrwx 1 edward edward  2648 Jun 14 17:34  pointers-addressof.o
-rwxrwxrwx 1 edward edward  2648 Jun 14 17:38  pointers-address-of.run
Google "GCC flags":
Code
-c
    Compile or assemble the source files, but do not link. The linking stage simply is not done. The ultimate output is in the form of an object file for each source file.
    By default, the object file name for a source file is made by replacing the suffix .c, .i, .s, etc., with .o.
Why are you trying to run the object file instead of the compiled binary? Even the file size should hint at that...

Thanks, I'll looking at what I found looking up  "GCC flags"..may take some time to look through but I'm looking.
https://developers.redhat.com/blog/2018/03/21/compiler-and-linker-flags-gcc

The compiled binary is the .run file. Please forgive the attempt at running the .o file. My analogy is it's like checking a drawer that I know nothing's in when trying to find a lost object in a household. sometimes I try that drawer anyway without any logic behind it. That's if its my drawer and my lost object.
« Last Edit: June 16, 2021, 04:47:01 am by edcompsci »

Offline edcompsci

  • Multiple posting newcomer
  • *
  • Posts: 18
Re: Permission Denied though my linux chmod has allowed 777
« Reply #22 on: June 16, 2021, 05:01:25 am »
Does codeblocks use the header files found in /usr/include or some other location?  I tried giving myself ownership with +rwx permissions to all of the /usr/include/ header files but it didn't help.

Offline Commaster

  • Almost regular
  • **
  • Posts: 129
Re: Permission Denied though my linux chmod has allowed 777
« Reply #23 on: June 16, 2021, 08:14:23 am »
Please stop doing what you are doing. Especially giving 777 access rights to everything, 2x especially outside your personal folders.

I provided the snippet from the google search already:
Code
-c
    Compile or assemble the source files, but do not link. The linking stage simply is not done. The ultimate output is in the form of an object file for each source file.
    By default, the object file name for a source file is made by replacing the suffix .c, .i, .s, etc., with .o.

Please run the 16kb executable in the terminal, not the 2kb object file that you renamed to .run for some odd reason.

Offline Miguel Gimenez

  • Lives here!
  • ****
  • Posts: 773
Re: Permission Denied though my linux chmod has allowed 777
« Reply #24 on: June 16, 2021, 08:15:16 am »
Do not mess with ownerships outside your home directory.

C::B uses the paths listed in Project -> Build options -> Search directories -> Compiler tab.

Offline edcompsci

  • Multiple posting newcomer
  • *
  • Posts: 18
Re: Permission Denied though my linux chmod has allowed 777
« Reply #25 on: June 19, 2021, 07:27:34 pm »
Do not mess with ownerships outside your home directory.

C::B uses the paths listed in Project -> Build options -> Search directories -> Compiler tab.

I followed your advice by making a dir ~/code and copying my .c file to it and it does run that way. Thanks.

Is there any way around this? Maybe the way my other drive is mounted in /etc/fstab?  I tried to see is I could instead use a symbolic link ~/code to get the same effect but no luck.  It would just be easier if I could keep all of my c files on my share and compile/run from there. No big deal if no one answers, I see that this isn't a gcc forum but a code::blocks one, so I'm a bit off topic now. 

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13438
    • Travis build status
Re: Permission Denied though my linux chmod has allowed 777
« Reply #26 on: June 19, 2021, 09:46:57 pm »
What is the file system of the other drive? Is it linux compatible?
If it is fat or ntfs, you're probably out of luck or at least you'll have to read about umasks during mounting.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline edcompsci

  • Multiple posting newcomer
  • *
  • Posts: 18
Re: Permission Denied though my linux chmod has allowed 777
« Reply #27 on: June 19, 2021, 10:13:34 pm »
What is the file system of the other drive? Is it linux compatible?
If it is fat or ntfs, you're probably out of luck or at least you'll have to read about umasks during mounting.

The other drive is a NAS appliance connected via NFS.  Umasks? Ok I'll look into that, thanks.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13438
    • Travis build status
Re: Permission Denied though my linux chmod has allowed 777
« Reply #28 on: June 19, 2021, 11:09:51 pm »
NFS should support unix permissions, so it should be fine if you mount it correctly, but I'm not a sysadmin, so I might be wrong.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline edcompsci

  • Multiple posting newcomer
  • *
  • Posts: 18
Re: Permission Denied though my linux chmod has allowed 777
« Reply #29 on: June 20, 2021, 02:42:08 am »
What is the file system of the other drive? Is it linux compatible?
If it is fat or ntfs, you're probably out of luck or at least you'll have to read about umasks during mounting.

found this on another forum:

Quote
In the options, when you add user it also implies noexec.
noexec will not allow any binaries on the mounted file system to be executed.

Take a look at the mount MAN page for more information concerning the available options

I think I may be on the right track