partition info in perl without root access

Lennart Sorensen lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Tue Nov 30 17:30:09 UTC 2004


On Tue, Nov 30, 2004 at 11:32:01AM -0500, Madison Kelly wrote:
> >cat /proc/partitions any use?
> 
> <head slap>
> 
> Yes, quite actually! Thank you!

It doesn't give anymore than a list of partitions the kernel knows
about.  Free space and such and actual size are probably a different
problem.  Actually free space on partition would require mounting or
filesystem specific tools to figure out.

To figure out actual disk size, partition sizes and unused space, well
that would need fdisk, and it probably requries at least read access to
the raw disk device node.

Now on my system (running debian), any user added to the 'disk' group
has full raw access to the disk and can hence use /sbin/fdisk.  probably
not a safe idea in general as it lets the user modify the disk at will.
Having just an sudo entry for running fdisk -l (and no other fdisk
options) should actually be safe.  Sudo can be quite restrictive in how
you are allowed to run a command.  You should be able to say something
like 'only allow user to run fdisk -l' and then not allow passing any
arguments.  It should then just list every partition on every disk and
how big they are and how much unpartitioned space is on the disk and
such.

Now if you add software raid or lvm to the mix, you need additional
tools to determine volume sizes and such. :)

Lennart Sorensen
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list