Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: edcompsci on June 05, 2021, 10:03:14 pm

Title: Permission Denied though my linux chmod has allowed 777
Post by: edcompsci on June 05, 2021, 10:03:14 pm
I built a simple program on my linux machine following a tutorial and it builds but I don't see why it is getting Permission Denied when I run it even though I chmod'd the whole directory recursively to 777.

Can someone help?
Title: Re: Permission Denied though my linux chmod has allowed 777
Post by: stahta01 on June 06, 2021, 12:11:44 am
Did you try rebooting your computer?
Or you can lookup how to kill a program on Linux because you can not run a program already running on Windows if the file has a file lock on it. The same is likely true on Linux; but, since the file system is different it might not be true.

Tim S.
Title: Re: Permission Denied though my linux chmod has allowed 777
Post by: edcompsci on June 06, 2021, 12:32:20 am
Thanks.

to kill linux process (as sudo) you can use

kill [pid]


or

killall [name of program]


or from a ui with system monitor, kill it just like you would in task manager in Windows.


I will see now if there are hanging processes. Thanks again.
Title: Re: Permission Denied though my linux chmod has allowed 777
Post by: edcompsci on June 06, 2021, 12:48:55 am
No there's no running processes still.

I tried even running codeblocks as sudo and still no luck.

I don't think a reboot will help but I may try that later.
Title: Re: Permission Denied though my linux chmod has allowed 777
Post by: edcompsci on June 06, 2021, 08:18:39 pm
reboot did nothing.
Title: Re: Permission Denied though my linux chmod has allowed 777
Post by: stahta01 on June 07, 2021, 12:20:40 am
You might post the run log and maybe someone could see the cause of the problem.

Tim S.
Title: Re: Permission Denied though my linux chmod has allowed 777
Post by: edcompsci on June 07, 2021, 02:38:40 am
Thank you.  Nothing runs at all on any piece of code I create (making small c programs).  Down where the logs are no run log appears, only a build log, and I am clicking and Build and Run.


Here's some example code, code isn't the issue, because no matter what program I run, the Permission error comes up right away without running anything.
Code
#include <stdio.h>
#include <string.h>

int main()
{
char a;double b;float c;int d;char *aa;char e[5];char *ee;

printf("address of a char example: %p\n",&a);//%p is "placeholder"
printf("address of a double example: %p\n",&b);//addresses are in hex
printf("address of a float example: %p\n",&c);
printf("address of an int example: %p\n",&d);

aa=&a;
printf("address of a char a example: %p\n",&a);
printf("pointer to address of char a example: %p\n",aa);

ee=e;
printf("address of a array e example: %p\n",e);
printf("pointer to address of array e example: %p\n",ee);
printf("address symbol used (optional), array e example: %p\n",&e);
ee=&e[1];
printf("address symbol used for one element, array e example: %p\n",&e[1]);

return (0);
}

It's some kind of configuration, but I haven't pinpointed it. I thought maybe codeblocks had to run as some kind of user and that user had to be in a certain group maybe, but with the linux users command I only see me, no other user.  Then I though well maybe if I do an ls - l that execute and read permissions aren't set on the files, so I set them all to 777 and still no luck.  Now I am thinking that maybe I need to tell codeblocks to allow my username to use it to run programs, but I don't know how I would do that. I clicked around the menus on top a little bit but haven't found anything.

Title: Re: Permission Denied though my linux chmod has allowed 777
Post by: Commaster on June 07, 2021, 04:32:22 am
That space in "c programs" is very suspicious... Could you try removing spaces from your path?
Title: Re: Permission Denied though my linux chmod has allowed 777
Post by: edcompsci on June 07, 2021, 06:29:31 am
new path
Title: Re: Permission Denied though my linux chmod has allowed 777
Post by: Commaster on June 07, 2021, 07:56:29 am
Please share your values for Settings - Environment... - General settings, lower three values.
I've set mine to
Code
/bin/sh -c
xterm -T $TITLE -e
xdg-open
trying to mimic your screenshots.

But I was unable to reproduce your issue:
Code
/media/IDE/ProgrammingCode/0._Console/c_programs$ ls -lAtr
total 28
-rw-rw-r-- 1 commaster commaster  1080 Jun  7 07:48 c_programs.cbp
-rw-r--r-- 1 commaster commaster   738 Jun  7 07:50 main.c
drwxr-xr-x 2 commaster commaster  4096 Jun  7 07:50 .objs
-rwxrwxr-x 1 commaster commaster 14472 Jun  7 07:50 pointers_addressof

Code
address of a char example: 0x7fffd37732df
address of a double example: 0x7fffd37732e8
address of a float example: 0x7fffd37732e0
address of an int example: 0x7fffd37732e4
address of a char a example: 0x7fffd37732df
pointer to address of char a example: 0x7fffd37732df
address of a array e example: 0x7fffd37732f3
pointer to address of array e example: 0x7fffd37732f3
address symbol used (optional), array e example: 0x7fffd37732f3
address symbol used for one element, array e example: 0x7fffd37732f4

Process returned 0 (0x0)   execution time : 0.005 s
Press ENTER to continue.

P.S. Also try executing the compiled binary from the terminal using ./pointers_addressof
I also suspect that "/media/IDE/ProgrammingCode/0._Console/c_programs/pointers_addressof" is a folder, not your executable, in which case "sh" says "Permission denied" to execute a folder.
Title: Re: Permission Denied though my linux chmod has allowed 777
Post by: edcompsci on June 10, 2021, 01:48:16 am
here's my shell settings. Not sure where you entered the xdg-open part.



It isn't trying to execute a folder because all I'm doing is clicking Build and Run.


Sorry, no it's not a folder. At first it was a file that I forgot to put the .c extension on but the I got the same error with the same program with a .c extension, and 5 or more other .c programs all the same error.

I'll try changing the /bin/sh to /bin/bash
Title: Re: Permission Denied though my linux chmod has allowed 777
Post by: oBFusCATed on June 10, 2021, 01:58:03 am
I don't see full build log in your posts, please post one.
Also after a build please post the output of "ls -lAtr" in the folder where you expect the executable to be.
The output should look something like the output from Commaster.
You have to have x-es in the permissions for the executable.
Title: Re: Permission Denied though my linux chmod has allowed 777
Post by: edcompsci on June 10, 2021, 01:58:58 am
changing to /bin/bash did nothing. maybe it needs to run in csh.. will try
Title: Re: Permission Denied though my linux chmod has allowed 777
Post by: edcompsci on June 12, 2021, 02:06:41 am
still stuck.
Title: Re: Permission Denied though my linux chmod has allowed 777
Post by: oBFusCATed on June 12, 2021, 07:45:16 am
I don't see full build log in your posts, please post one.
Also after a build please post the output of "ls -lAtr" in the folder where you expect the executable to be.
The output should look something like the output from Commaster.
You have to have x-es in the permissions for the executable.
Title: Re: Permission Denied though my linux chmod has allowed 777
Post by: edcompsci 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
Title: Re: Permission Denied though my linux chmod has allowed 777
Post by: oBFusCATed on June 14, 2021, 01:20:53 am
What happens if you run the executable from terminal?
Title: Re: Permission Denied though my linux chmod has allowed 777
Post by: Commaster on June 14, 2021, 06:32:09 am
> "no target" in "no project"

Building without a Code::Blocks project can be unhealthy indeed...
Title: Re: Permission Denied though my linux chmod has allowed 777
Post by: edcompsci 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]esktop:/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.
Title: Re: Permission Denied though my linux chmod has allowed 777
Post by: edcompsci 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.
Title: Re: Permission Denied though my linux chmod has allowed 777
Post by: Commaster 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...
Title: Re: Permission Denied though my linux chmod has allowed 777
Post by: edcompsci 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 (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.
Title: Re: Permission Denied though my linux chmod has allowed 777
Post by: edcompsci 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.
Title: Re: Permission Denied though my linux chmod has allowed 777
Post by: Commaster 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.
Title: Re: Permission Denied though my linux chmod has allowed 777
Post by: Miguel Gimenez 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.