partition info in perl without root access

John Macdonald john-Z7w/En0MP3xWk0Htik3J/w at public.gmane.org
Tue Nov 30 19:36:18 UTC 2004


On Tue, Nov 30, 2004 at 11:32:01AM -0500, Madison Kelly wrote:
> Lennart Sorensen wrote:
> >On Tue, Nov 30, 2004 at 11:08:52AM -0500, Madison Kelly wrote:
> >
> >> I am trying to find a way in perl as a regular user to get the same 
> >>type of information as I get when I run 'fdisk -l' as root. Currently I 
> >>have put 'fdisk' in my '/etc/sudoers' file and use sudo to get the data. 
> >>This obviously is not ideal though because 'fdisk' has many potentially 
> >>dangerous uses than simple partition information gathering.
> >>
> >> Does anyone know of a way that I can get information like which 
> >>partitions are online but NOT mounted (probably most important), how 
> >>much space is used and available on a given partition and so forth? 
> >>Thanks!
> >
> >
> >cat /proc/partitions any use?
> 
> <head slap>
> 
> Yes, quite actually! Thank you!

In cases where there isn't such a simple answer, you can write
a front-end script to the program you want to make available
in limited fashion.  So, instead of allowing fdisk from sudo,
you allow a fdpart script that calls fdisk with the right args
and filters the result into a nice format, but the script
is very careful about limiting its use and transmission of
user-provided arguments, so the use has no direct control over
the set of flags and arguments used in the fdisk invokation
that actually does the underlying work.

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