The sudoers
line can only point to the command you're intended to run, not the destination output file. Anything under that /sys
is a special device that characters are written to.
What you want to do is create a script that will do echo 1 > /sys/block/$hd/device/delete
where $hd is checked to match the regular expression /sd[b-i]/
. Point the sudo command at that script rather than where you have it.
Also, Michael Hampton is right: somebody will run a delete command you don't want mess things up. If you don't have proper backups, then your data never existed.
Поместите свой код в скрипт (вы пишете скрипт, верно?) И предоставьте пользователю sudo
доступ к скрипту.
Это, вероятно, закончится выглядит примерно так:
#!/bin/bash
for kill_this_disk in /sys/block/sd[b-i]/device/delete
do
echo 1 > $kill_this_disk
done
И я надеюсь, что у вас хорошие резервные копии.
I don't think **operator ALL=/sys/block/sdb/device/delete ** will enable you to access that device even as non root. The sudoers enables you to specify commands which will not query for the password when ran as sudo (here "tee" for example). Your problem comes from permissions on the /sys/block/$hd/device/delete...
Perhaps you need to use the NOPASSWD option in the sudoers configuration file. I believe the syntax is something like this:
operator ALL=NOPASSWD:/sys/block/sdb/device/delete