Exec permission denied linux

php exec() command permission denied

I have a C++ executable file ‘skypeforwarder’. skypeforwarder works if I use command line in Terminal in Mac: henry$ /Users/henry/Desktop/skypeForwarder/skypekit-sdk_sdk-4.1.2.20_793394/examples/cpp/tutorial/step3/skypeForwarder

But it always issued ‘permission denied’ if it is called in php exec();

I searched a lot. The problem should be the problem of the php/browser permission in web server. I also tried to change the owner of the file from:

It still does not work.

2 Answers 2

Although the file itself is readable by the web server, the Desktop folder most likely is not, and the web server therefore cannot traverse into it to locate the executable file. You should move the skypeforwarder binary file into a location readable by the web server, such as a directory parallel to where you are attempting to serve this PHP script. That directory should not, however, be web-accessible. Protect it with .htaccess or place it above the web DocumentRoot, but it must be readable by the web server.

By default, Desktop on OSX is -rwxr—— and it is not advisable to change permissions on that directory.

Moreover, it is very much not advisable to change the file to be owned and writable by _www the web server user. Instead, it should be readable and executable by the web server, but not writable.

Standard disclaimer: As always, be extremely cautious when executing system calls from PHP scripts accessible on the web.

Источник

Ошибка bash permission denied

Многие новички пытаются выполнить запись определенных значений в системные файлы с помощью операторов перенаправления ввода и вывода и получают ошибку bash permission denied. Эта ошибка выводится, даже если вы использовали sudo.

Казалось бы, sudo есть, значит права суперпользователя получены и все должно работать но тут все не так просто. В этой статье мы рассмотрим почему возникает ошибка bash permission denied и как ее обойти.

Ошибка bash permission denied

Допустим, вы выполняете команду:

sudo echo «nameserver 8.8.8.8» >> /etc/resolv.conf

А в результате вместо записи строчки в /etc/resolv.conf получаете ошибку:

bash: /etc/resolv.conf permission denied

В русской локализации это будет отказано в доступе bash linux. Так происходит потому что вы запускаете с правами суперпользователя утилиту echo и она честно выводит вашу строку в стандартный вывод bash с правами суперпользователя. Но bash запущен от обычного пользователя, и когда интерпретатор bash пытается записать полученную строчку в системный файл, естественно, что вы получите ошибку.

Но существует несколько способов обойти это ограничение, вы можете, например, использовать команду tee, которая записывает стандартный вывод в файл или запустить саму оболочку от имени суперпользователя. Рассмотрим сначала вариант с tee:

Читайте также:  Посмотрите содержимое файла linux

echo ‘текст’ | sudo tee -a /путь/к/файлу

echo ‘nameserver 8.8.8.8’ | sudo tee -a /etc/resolv.conf

Это очень простое решение, но, кроме того, вы можете запустить оболочку bash с правами суперпользователя, чтобы дать ей доступ на запись:

sudo sh -c ‘echo текст >> /путь/к/файлу’
sudo bash -c ‘echo текст >> /путь/к/файлу’

sudo bash -c ‘echo nameserver 8.8.8.8 >> /etc/resolv.conf

Еще одно решение, призванное, упростить эту команду, добавить такой код в

sudoe() <
[[ «$#» -ne 2 ]] && echo «Usage: sudoe

» && return 1
echo «$1» | sudo tee —append «$2» > /dev/null
>

Дальше для вывода строки в файл выполняйте:

sudoe ‘текст’ >> /путь/к/файлу

sudoe «nameserver 8.8.8.8» > /etc/resolv.conf

Теперь все будет работать, как и ожидалось, и ошибка bash отказано в доступе не появится. Еще можно поменять права на файл, а потом уже выводить в него строку. Но это очень неправильное решение. И даже не потому, что это небезопасно, а больше потому что там намного больше действий.

Выводы

В этой небольшой статье мы разобрали почему возникает ошибка bash permission denied при использовании команды echo для системных файлов, а также несколько путей ее решения. Как видите, все достаточно просто. Надеюсь, эта информация была полезной для вас.

Источник

Permission denied running my own program on Linux? [closed]

Want to improve this question? Update the question so it’s on-topic for Stack Overflow.

Closed 1 year ago .

I have Ubuntu 9.4. I’ve built the program, some basic OpenGL. The program just makes a rotating square. Then run it and:

And an empty main doesn’t work:

How can I make that disappear?

9 Answers 9

I had the same problem and it appeared that my partition was mounted as noexec cat /etc/mtab

When I configured options in /etc/fstab I wrote exec,user but it appears that «user» option by default sets up «noexec». When I changed the order of these two to user,exec everything went back to normal!

How are you compiling it? Can you post the makefile? If you run

Check the mountpoint to see if it’s mounted as noexec by running «mount»

I use CodeBlocks on Ubuntu and have had this exact problem MANY times. what KermiDT said is exactly the solution (if i had enough rep points, i would have voted it up)
The «user» option by default sets up «noexec».
so in /etc/fstab just add ,exec after user. i.e. mine looks like this:
/dev/sda6 /media/DATA vfat uid=kenny,gid=kenny,users,user,exec 0 0
Though, the spacingis a bit off. but you get the idea.

Apart from the above mentioned chmod +x file, another problem might be a missing library. To check the required libraries, use ldd:

If one of these lines shows a missing library, you’ll know what needs to be installed before you can run your program.

Another possibility is if your program is a script (shell, perl, python or other text-based program). The first line looks like:

If that file cannot be found, you’ll get a permission denied error.

Источник

Getting «standard_init_linux.go:207: exec user process caused «permission denied»» inside docker container for mattermost_app #401

Comments

Philippe-Cote-Morneault commented Jul 9, 2019

Hi, I followed every instruction from the readme and everything seemed to work fine. I’ll show you the exact commands I made in case someone sees something odd.

Читайте также:  Драйвера для acer aspire 5738 windows 10

Step 1) My docker-compose.yml

Step 2) docker-compose build

Step 3) Create volumes
[root@organisationServices mattermost]# mkdir -p /srv/docker/mattermost/

Step 4) Give permissions to volumes
[root@organisationServices mattermost]# sudo chown -R 2000:2000 /srv/docker/mattermost/

Step 5) docker-compose up

Everything seems fine up to here. Also, I am root user, so the permission steps was optional but I did it anyways.

Here’s what happens when I log the mattermost_app_1 container:

I can’t find a way to get more logging information about this container. Also, this is the status for both containers:

So the container keeps restarting with the same error logs. Does anyone have any idea how to fix this and what is the issue?

Also, I am new to Docker. I want to host my database in my own postgres database without creating one with Mattermost. My only issue is understanding what would be the host for said database when adding it in docker-compose . What is the host of a database inside a docker container so I can add it in the docker-compose ?

The text was updated successfully, but these errors were encountered:

Philippe-Cote-Morneault commented Jul 9, 2019

I decided to run docker-compose build with a verbose flag to see if that can help:

pichouk commented Jul 9, 2019

Very surprising, can you just paste the result of ls -la /srv/docker/mattermost to ensure permissions are OK ? I’m pretty sure they should be OK with the command you ran but it seems to be a permissions issue.

Philippe-Cote-Morneault commented Jul 9, 2019 •

@pichouk Thanks for replying! Here’s the result:

pichouk commented Jul 12, 2019

I don’t know, it should be ok.
i’ll try to ping a Mattermost developer to find what trigger this specific log message, maybe we can figure out then.

Philippe-Cote-Morneault commented Jul 12, 2019

@pichouk If you managed to get a hold of a developer that would be great! I also don’t understand why this isn’t working. The problems seem to stem from the container itself, so I wonder if the image is the problem. I also noticed that even if I gave arguments such as team edition in the docker-compose, the image built is enterprise edition.

hmhealey commented Jul 15, 2019 •

That doesn’t look like an error that would come from Mattermost. standard_init_linux.go seems to be part of Docker itself.

pichouk commented Jul 15, 2019

Gosh you’re right @hmhealey this is a Docker error.

@JigsawCorp Is your Docker installation working for other container ? Are you able to run docker run hello-world ? What is the output of docker info ?
I found several issues about this on Github :

egandro commented Aug 13, 2019

Did you do the «chown»?

santiago-mooser commented Oct 3, 2019 •

@egandro I changed the permissions but I’m having the exact same issue when using CentOS, so it seems to be a permissions issue specifically to do with CentOS (possibly SELinux?)

@pichouk You might want to look at the difference in permissions between Ubuntu and CentOS with and without SELinux

I tried this fix with no avail

Читайте также:  Не работает usb модем linux

I’ve attached some extra info for troubleshooting

Docker and dockerCE versions:

sudo ls -la volumes/app/mattermost/ outputs:

Docker logs [container_id] for app container outputs:

My current docker-compose.yml file is as following: essentially unchanged except for passwords, SSL enabling, and changing the volumes’ rw in the app container to Z (I get the same error with rw )

Temporary and unsafe fix

Change the user in the app container to root. This is really not recommended as it is not safe to run a container as root, but it gets the app working if you need it to:

ctivanovich commented Nov 28, 2019

I came across this error for an entirely different service, apache airflow on docker (the puckel image), and what worked in my case was deleting previous docker volumes that were somehow overloading the namespace even though I had moved the build files to a new location and had been trying to mount entirely different volumes to the container.

AaronSharp5 commented Apr 16, 2020

I also encountered this issue in a totally different service*. In my case, the base image I used was Alpine Linux, and my Entrypoint file had the shebang line #!/bin/bash . By replacing it with #!/bin/sh , I got past the error message. It should have been an obvious fix, but the error message didn’t really help me find it.

*My issue had nothing to do with mattermost, but at time the of writing, this issue was the top Google hit when I searched the text of the error message. Hopefully this comment will help others facing the same issue, whether or not they’re using mattermost.

You can’t perform that action at this time.

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.

Источник

How to resolve the «Permission Denied» error in Linux

While using Linux, you may encounter the error, “permission denied”. This error occurs when the user does not have the privileges to make edits to a file. Root has access to all files and folders and can make any edits. Other users, however, may not be allowed to make such edits.

Remember that only root or users with Sudo privileges can change permissions for files and folders.

The permissions can be changed using the chmod keyword. The syntax for the command is:

chmod flags permissions filename

  • flags are the additional options users can set.
  • permissions define if the user can read, write, or execute the file. They can be represented using symbolic or octal numbers.
  • filename is the name of the file whose permissions are changed.

Here is an example where users can read, write, and execute a file; whereas, group and others can only read it.

Here, each letter has a meaning:

r gives read permissions

w gives write permissions

x gives execute permissions

The same command can be run using octal notation:

Here, each digit represents the sum of the permissions allowed:

4 gives read permissions

2 gives write permissions

1 gives execute permissions

0 gives no permissions

The sum of these permissions is used to represent each type of author.

Источник

Оцените статью