简体   繁体   中英

Changing ownership of /root/boot

I need to access /boot so i can change a file continuously involving a PHP script ( To enable a raspberry pi and disable by changing start_x=' ' ) . However this involves me changing the permissions of boot.

I have tried sudo chown -R /boot and still get permissions denied when running as root. Also tried FTP and changing the folder of boot to let users modify content however this did not work either.

Is there anyway going around this???

<?php
$myfile = fopen("config.txt", "w") or die("Unable to open file!");
[...]
?>

Update: I have tried to do chmod 775 /boot/config.txt and also symlink (ran successfully) so i have a shortcut in /var/www/ however when trying to save the php script into config.txt (in www) still get permission denied even though that shortcut is set to 775. The issue still persists with changing to change the permission of the original file under /boot .

Try launching a shell and trying your command:

sudo sh -c "echo 123 >/boot/test"

works but

sudo echo 123 >/boot/test

fails. I don't understand the cause of this difference.

The user running as php would need permissions set in sudoers.d to execute the commands you need.

试试这样:

sudo chown -R root /root/boot

PHP runs under a restricted account and can't write anything in the boot partition.

You might be able to add the account PHP runs as to the sudoers file, although it's a pretty huge security risk.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM