partition info in perl without root access

Madison Kelly linux-5ZoueyuiTZhBDgjK7y7TUQ at public.gmane.org
Tue Nov 30 17:45:13 UTC 2004


Lennart Sorensen wrote:
> 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

Actually, that is how I collect free/used space as it is; mount, read in 
the relevant 'df' data and dismount. I was kind of hoping I could find 
another way to get that data without all the cost however it isn't 
critical. You are also right, I did try 'fdisk -l' and now that alone 
works and no other switch (thank you!) however simply cat'ing a file as 
a regular user is yet more safe. :)

Thank you very much again!

Madison
--
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