Changing ownership of /root/boot

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 .


/var/www/


config.txt


/boot






You could write a cron job that runs as root, checks for files in a place accessible to users, like a subdirectory of /tmp, and moves them from the deposited location to the secure location.

– Paul
May 10 '15 at 16:09







I would still get permission denied since i would be overwriting the file

– Zeon
May 10 '15 at 16:11






Is /boot a partition? Often, it is. When you run mount by itself, no parameters, on the affected system, is /boot mounted read-write (rw) or read-only (ro)?

– Paul
May 10 '15 at 16:12



/boot


mount


/boot






/boot part of root in the raspberry pi. Basically i installed a package "raspistill" which the data is stored under /boot , hence i need to edit one of the files

– Zeon
May 10 '15 at 16:14



/boot


/boot






Become root and run echo 123 > /boot/stackoverflowtest. What is the exact error message?

– Paul
May 10 '15 at 16:22


root


echo 123 > /boot/stackoverflowtest




3 Answers
3



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.



Try like this:


sudo chown -R root /root/boot






Done this, still get permission denied even when running it in root O-o Root does not contain a folder "boot" it's a partition i believe, so i have to to sudo chown -R pi /boot which doesnt work operation not permitted when doing sudo chown -R pi /boot

– Zeon
May 10 '15 at 18:34



operation not permitted


sudo chown -R pi /boot






Try: mount -o remount,gid=<pi's gid>,uid=<pi's uid> /boot To determine pi's uid: cat /etc/passwd |grep pi To determine pi's gid: cat /etc/group |grep pi

– Vladimir Djukic
May 10 '15 at 20:43


mount -o remount,gid=<pi's gid>,uid=<pi's uid> /boot


cat /etc/passwd |grep pi


cat /etc/group |grep pi






sorry, first time doing this i'm getting the result for pi's uid: pi:x:1000:1000:,,,:/home/pi:/bin/bash and for gid adm:x:4:pi dialout:x:20:pi cdrom:x:24:pi sudo:x:27:pi audio:x:29:pi www-data:x:33:pi,root video:x:44:pi plugdev:x:46:pi games:x:60:pi users:x:100:pi pi:x:1000: netdev:x:105:pi input:x:999:pi spi:x:1002:pi gpio:x:1003:pi Which one should i type in

– Zeon
May 10 '15 at 21:20


pi:x:1000:1000:,,,:/home/pi:/bin/bash


adm:x:4:pi dialout:x:20:pi cdrom:x:24:pi sudo:x:27:pi audio:x:29:pi www-data:x:33:pi,root video:x:44:pi plugdev:x:46:pi games:x:60:pi users:x:100:pi pi:x:1000: netdev:x:105:pi input:x:999:pi spi:x:1002:pi gpio:x:1003:pi






mount -o remount,gid=1000,uid=1000 /boot

– Vladimir Djukic
May 10 '15 at 22:23



mount -o remount,gid=1000,uid=1000 /boot






Also if that up not success try umount and then mount device like this: sudo umount /root/boot && sudo mount -t auto -o umask=000,dmask=000 /root/boot /media/USBHDD1

– Vladimir Djukic
May 10 '15 at 22:35


sudo umount /root/boot && sudo mount -t auto -o umask=000,dmask=000 /root/boot /media/USBHDD1



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.



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

PHP code is not being executed, instead code shows on the page

Ĝň ċũ,İĨĻĐđēĵſ ĤŹĝĽķũ ĆŹđě,ļ łĂģĚ ŻŷĶĸĦķĖĝŔ ūŬĿŜćīŴĽĺ,ľ,ũĽňĎźāœ,ĉŃĩ,ĎĻē,ŕųūČœijčĶŶĻijŕ,ĩěŗſŗāŸņŰž,Žů ĭğŪľ Čŗćļžĵţ Ūĉņ ĵ ůŁ ţŅ,ĮŶ ŁŵĮ śŁĬŇŏ ŮĜʼnœĦā,Ũŏ Ź ŖŀšĦ ŃłĉŹŅťŸŇ,ŷī