LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-31-2018, 05:34 PM   #1
shivahoj
LQ Newbie
 
Registered: Jul 2013
Posts: 15

Rep: Reputation: Disabled
weird permission denied error on compiled software


Hello all,
i have a small 4bay NAS system (ACER easystore H341, intel Atom 1,66 GHz), with a fresh Debian 9 installation.
There is a software https://github.com/merelin/mediasmartserverd, that drives the bay LEDs (activity and population of each bay). But when i compile it (as root), the binary gives permission denied, when executed. I remember having compiled this without problems some months ago, but i dont know what was different then (maybe debian 8?).
How do i inspect this software? I am no good in debuggers, disassembling etc.
Any hints or Tips? Any other information needed?

Dirk

This is the compile run:
Code:
root@nas:/root/mediasmartserverd-master# make
rm *.o mediasmartserverd core -f
g++ -Wall -O2 -o device_monitor.o -c src/device_monitor.cpp
g++ -Wall -O2 -o update_monitor.o -c src/update_monitor.cpp -pthread
g++ -Wall -O2 -o mediasmartserverd.o -c src/mediasmartserverd.cpp
g++ -Wall -O2 -o mediasmartserverd device_monitor.o update_monitor.o mediasmartserverd.o -ludev -ldl -lpthread
This is the contents of the directory after compiling:
Code:
root@nas:/root/mediasmartserverd-master# ls -la
total 344
drwx------  7 dirk users   4096 Dec 31 20:22 .
drwxrwsr-x 14 dirk users   4096 Dec 26 20:31 ..
-rw-r--r--  1 root root      47 Jan  7  2018 .gitignore
-rw-r--r--  1 root root     859 Jan  7  2018 LICENSE
-rw-r--r--  1 root root    1597 Jan  7  2018 Makefile
-rw-r--r--  1 root root    3399 Jan  7  2018 README.md
drwxr-xr-x  2 root root    4096 Jan  7  2018 bin
drwxr-xr-x  3 root root    4096 Jan  7  2018 debian
-rw-r--r--  1 root root   46568 Dec 31 20:22 device_monitor.o
drwxr-xr-x  3 root root    4096 Jan  7  2018 etc
drwxr-xr-x  3 root root    4096 Jan  7  2018 lib
-rwxr-xr-x  1 root root   98128 Dec 31 20:22 mediasmartserverd
-rw-r--r--  1 root root  116344 Dec 31 20:22 mediasmartserverd.o
-rw-r--r--  1 root root    3399 Jan  7  2018 readme.txt
drwxr-xr-x  2 root root    4096 Jan  7  2018 src
-rw-r--r--  1 root root   26544 Dec 31 20:22 update_monitor.o
This is the error message
Code:
root@nas:/root/mediasmartserverd-master# ./mediasmartserverd
-bash: ./mediasmartserverd: Permission denied
but as can be seen in the above directory listing, the file is executable, and root is the owner of it!
What linux knows about the file:
Code:
root@nas:/root/mediasmartserverd-master# file mediasmartserverd
mediasmartserverd: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=891299afa7545d49dff9c313e9d2078dcc5bebcb, not stripped
 
Old 12-31-2018, 05:44 PM   #2
Ztcoracat
LQ Guru
 
Registered: Dec 2011
Distribution: Slackware, MX 18
Posts: 9,484
Blog Entries: 15

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Hi:

I was taught not to compile software as root.
The only time you need to become root is when it's time to run make install.

When you get a chance double check on the 'Install' or ReadMe file to see what's recommended to perform the installation.

Try using su - instead of sudo:-
 
Old 12-31-2018, 05:58 PM   #3
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
For some reason, it turns out to be a “ELF 64-bit LSB shared object”. Shared objects can’t run. Try file /bin/ls to see the difference.

Why the compiler (or linker) did that to you, I can’t tell.

Last edited by berndbausch; 12-31-2018 at 05:59 PM.
 
Old 12-31-2018, 06:00 PM   #4
Ztcoracat
LQ Guru
 
Registered: Dec 2011
Distribution: Slackware, MX 18
Posts: 9,484
Blog Entries: 15

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Quote:
Originally Posted by berndbausch View Post
For some reason, it turns out to be a “ELF 64-bit LSB shared object”. Shared objects can’t run. Try file /bin/ls to see the difference.

Why the compiler (or linker) did that to you, I can’t tell.
Thanks for the info.
 
Old 01-01-2019, 12:09 AM   #5
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by Ztcoracat View Post
Thanks for the info.
Essentially a "shared object" is a file, which is executed through a "real" executable (so it does have x rights, but is loaded for its functions, not executed sec). It doesn't have a main() part, only consists of functions that can be shared.
To enhance on the previous reply (#3):
Code:
$ ldd /bin/ls
will show which shared objects will be used BY the ls command.

Normally a shared object is given a .so or .so.<version> extension.

Last edited by ehartman; 01-02-2019 at 06:16 AM. Reason: Expansion about shared objects
 
Old 01-01-2019, 02:23 AM   #6
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by ehartman View Post
It doesn't have a main() part.
Later I thought: maybe that's the problem, that the make didn't link in the (compiled) source file with the main program routine, thus creating a shared object instead of an executable program.
 
Old 01-01-2019, 01:40 PM   #7
Ztcoracat
LQ Guru
 
Registered: Dec 2011
Distribution: Slackware, MX 18
Posts: 9,484
Blog Entries: 15

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Quote:
Originally Posted by ehartman View Post
Later I thought: maybe that's the problem, that the make didn't link in the (compiled) source file with the main program routine, thus creating a shared object instead of an executable program.
I'm thinking that you are right because there have been many times when 'make' didn't work for me either:-
 
Old 02-23-2019, 06:56 AM   #8
shivahoj
LQ Newbie
 
Registered: Jul 2013
Posts: 15

Original Poster
Rep: Reputation: Disabled
found the solution: fileowner root

Hello, i finally found the solution:
i unzipped the source files as root, so the directory and all the files were owned by root.
unzipping the source files as a regular user lets me successfully compile the source, and run the binay
 
  


Reply

Tags
compiling, permission denied, programming



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
mkdir throws Permission Denied error in a directoy even with root ownership and 777 permission surajchalukya Linux - Security 14 09-03-2012 08:34 AM
can't execute c++ binaries, "permission denied"... even though permission is 777 SerfurJ Programming 14 02-20-2009 04:50 AM
permission denied when running compiled app. I'm using root! mconstant Linux - Newbie 13 04-13-2008 05:20 AM
'permission denied" inspite of right permission flags on network drive anirudhvij Linux - Enterprise 8 05-22-2007 05:57 AM
HP Photosmart weird weird weird.... Vlad_M Linux - General 5 02-20-2005 05:41 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:04 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration