Matthew Gregan writes:
 > On Thu, Aug 08, 2002 at 08:54:44PM -0400, Andrew Tarr wrote:
 > 
 > >  > >      su -; dd if=/dev/zero of=/dev/hda
 > >  > 
 > >  > So what does the above command do, should I try it out and see ;-)
 > 
 > > 'su' gives you 'superuser' or root priviledges.
 > 
 > In the case above, what ``su -'' will do is spawn the shell specified
 > for uid 0 (root) in /etc/passwd as a login shell owned by uid 0.
 > 
 > Since ``su -'' spawns a shell, ``dd if=/dev/zero of=/dev/hda'' will not
 > execute until the new shell exits, and will execute with the uid of the
 > original user *not* uid 0; this means you would not have permission to
 > overwrite the device unless the original user has write access to the
 > device, see below for the user=root, group=disk stuff.

Yes, I read your previous message to that effect, and I can see that
now. 

 > 
 > > The '-' tells the 'su' program that it's a 'login' shell, not really
 > > sure what that means in this case.
 > 
 > See the ``INVOCATIONS'' section of the bash(1) manpage.
 > 
 > > So 'dd if=/dev/zero of=/dev/hda' writes zeros to the first hard-drive
 > > of the system. Thankfully, you can only do this as root, hence the su.
 > 
 > It depends on the permissions of /dev/hda, for example:
 > 
 >      $ ls -la /dev/hda
 >      brw-rw----    1 root     disk       3,   0 Mar 15 10:51 /dev/hda
 > 
 > If a normal user was in the group ``disk'', in this case, they could
 > also overwrite the entire device with that ``dd'' command.

I was aware of this, just for the record. I just thought it would be
clearer if I said 'only root can do this' without going into the
details... the exposition of how 'dd' works, what with involving
device files and so forth. 


Andrew. 

Reply via email to