<div dir="ltr">First of all, according to docs, `DeviceAllow` syntax is somewhat different from what you have.<br>Second, you might want to check `DevicePolicy`, as now your unit has access not only to `/dev/zero`, but also to four other devices.<br>
<br>And hm, I thought, those directives control access to device nodes. Why are you expecting them to limit access to the filesystem?<br></div><div class="gmail_extra"><br clear="all"><div><div dir="ltr"><div><br></div>--<br>
Кирилл Елагин</div></div>
<br><br><div class="gmail_quote">On Wed, Jun 4, 2014 at 10:18 AM, Mohit Agrawal <span dir="ltr"><<a href="mailto:moagrawa@redhat.com" target="_blank">moagrawa@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
I want to block the device through the systemd cgroup so I have created a below unit file<br>
<br>
[Unit]<br>
Description=mydevblock<br>
[Service]<br>
DeviceAllow=/dev/zero<br>
ExecStart=/usr/bin/dd if=/dev/zero of=/root/file_1 bs=1M count=40<br>
Restart=always<br>
[Install]<br>
WantedBy=multi-user.target<br>
<br>
<br>
As per my understanding in this unit file I have allowed only /dev/zero device so dd command should not create the file_1 successfully it should give the error .<br>
<br>
systemctl start mydevblock.service<br>
<br>
Below is the status after start the service and file_1 is successfully created<br>
<br>
[host-name ~]# systemctl status mydevblock.service<br>
● mydev.service - mydevblock<br>
Loaded: loaded (/etc/systemd/system/mydev.service; disabled)<br>
Active: failed (Result: start-limit) since Wed 2014-06-04 11:32:24 IST; 831ms ago<br>
Process: 27800 ExecStart=/usr/bin/dd if=/dev/zero of=/root/file_1 bs=1M count=40 (code=exited, status=0/SUCCESS)<br>
Main PID: 27800 (code=exited, status=0/SUCCESS)<br>
<br>
Jun 04 11:32:24 <host-name> systemd[1]: mydev.service holdoff time over, scheduling restart.<br>
Jun 04 11:32:24 <host-name> systemd[1]: Stopping mydevblock...<br>
Jun 04 11:32:24 <host-name> systemd[1]: Starting mydevblock...<br>
Jun 04 11:32:24 <host-name> sytemd[1]: mydev.service start request repeated too quickly, refusing to start.<br>
Jun 04 11:32:24 <host-name> systemd[1]: Failed to start mydevblock.<br>
Jun 04 11:32:24 <host-name> systemd[1]: Unit mydev.service entered failed state.<br>
<br>
[host-name> ~]# ls -lrt<br>
-rw-r--r--. 1 root root 41943040 Jun 4 11:32 file_1<br>
<br>
<br>
Can someone reply why file_1 is created successfully?<br>
Do anyone have idea how can i put the restriction on device?<br>
Appreciate your inputs on this.<br>
<br>
<br>
Regards<br>
<span class="HOEnZb"><font color="#888888">Mohit Agrawal<br>
_______________________________________________<br>
systemd-devel mailing list<br>
<a href="mailto:systemd-devel@lists.freedesktop.org">systemd-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/systemd-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/systemd-devel</a><br>
</font></span></blockquote></div><br></div>