FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu User

 
 
LinkBack Thread Tools
 
Old 08-14-2008, 01:36 AM
Patrick Drechsler
 
Default accessing fdisk -l as user

Hi,

can I access the output of

fdisk -l

as user on Ubuntu 8.04.1 LTS?

I would like to use this information for a script without root
privileges. The user running this script is sudo user.

According to the man page of fdisk, the -l option is:

,----
| -l List the partition tables for the specified devices and then exit.
| If no devices are given, those mentioned in /proc/partitions (if that
| exists) are used.
`----

The file /proc/partitions is empty:

,----
| # ls -al /proc/partitions
| -r--r--r-- 1 root root 0 2008-08-14 03:23 /proc/partitions
`----

Should this file be created automatically during boot time?

Thankful for any pointers,

Patrick



--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 08-14-2008, 02:11 AM
Leonard Chatagnier
 
Default accessing fdisk -l as user

--- Patrick Drechsler <patrick@pdrechsler.de> wrote:

> Hi,
>
> can I access the output of
>
> fdisk -l
>
> as user on Ubuntu 8.04.1 LTS?
>
> I would like to use this information for a script
> without root
> privileges. The user running this script is sudo
> user.
>
> According to the man page of fdisk, the -l option
> is:
>
> ,----
> | -l List the partition tables for the specified
> devices and then exit.
> | If no devices are given, those mentioned in
> /proc/partitions (if that
> | exists) are used.
> `----
>
> The file /proc/partitions is empty:
>
> ,----
> | # ls -al /proc/partitions
> | -r--r--r-- 1 root root 0 2008-08-14 03:23
> /proc/partitions
> `----
>
> Should this file be created automatically during
> boot time?
>
> Thankful for any pointers,
For me on a X86_64 ubuntu, fdisk -l /dev/sda without
sud gave no output, well it said "Cannot open
/dev/sda". ls -al /proc/partitions gave your same
results with $ prompt. But cat /proc/partitions
listed all my partitions using a $ prompt. HTH. Don't
have any idea on your last question.

Leonard Chatagnier
lenc5570@sbcglobal.net

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 08-14-2008, 02:17 AM
"Owen Townend"
 
Default accessing fdisk -l as user

2008/8/14 Patrick Drechsler <patrick@pdrechsler.de>:
> Hi,
>
> can I access the output of
>
> fdisk -l
>
> as user on Ubuntu 8.04.1 LTS?
>
> I would like to use this information for a script without root
> privileges. The user running this script is sudo user.
>
> According to the man page of fdisk, the -l option is:
>
> ,----
> | -l List the partition tables for the specified devices and then exit.
> | If no devices are given, those mentioned in /proc/partitions (if that
> | exists) are used.
> `----
>
> The file /proc/partitions is empty:
>
> ,----
> | # ls -al /proc/partitions
> | -r--r--r-- 1 root root 0 2008-08-14 03:23 /proc/partitions
> `----
>
> Should this file be created automatically during boot time?
>
> Thankful for any pointers,
>
> Patrick

Hey,

One _possible_ solution would be to write a script such as:
#!/bin/sh
/sbin/fdisk -l
Place it in a suitable location, `chown root:root` and `chmod 500` it
and add it to the user's sudo permissions.
If you want to keep arguments such as device node but strip out other
(dangerous) options then obviously the script will need a few
additions.

cheers,
Owen.

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 08-14-2008, 02:34 AM
Smoot Carl-Mitchell
 
Default accessing fdisk -l as user

On Thu, 2008-08-14 at 03:36 +0200, Patrick Drechsler wrote:
> Hi,
>
> can I access the output of
>
> fdisk -l
>
> as user on Ubuntu 8.04.1 LTS?
>
> I would like to use this information for a script without root
> privileges. The user running this script is sudo user.
>
> According to the man page of fdisk, the -l option is:
>
> ,----
> | -l List the partition tables for the specified devices and then exit.
> | If no devices are given, those mentioned in /proc/partitions (if that
> | exists) are used.
> `----
>
> The file /proc/partitions is empty:

The file is not empty. It is a filename in the special "proc"
filesystem. Do:

cat /proc/partitions

and you will see a list of your disk partitions. The -l option to fdisk
requires read access to your disk devices in the /dev/ directory. These
have rw permission granted for the root user and the disk group. If you
put the user running the script in the "disk" group in /etc/group, then
you will be able to read the disk partition table. Be aware that the
user will now have read/write access to all your disks which is a
potential security issue.

An alternate to the above is to add something like this to your sudoers
file with visudo:

test ALL=NOPASSWD: /sbin/fdisk -l

This lets the "test" user execute the fdisk command only with the "-l"
option without entering a password.
--
Smoot Carl-Mitchell
System/Network Architect
smoot@tic.com
+1 480 922 7313
cell: +1 602 421 9005

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 08-14-2008, 12:48 PM
Karl Larsen
 
Default accessing fdisk -l as user

Patrick Drechsler wrote:
> Hi,
>
> can I access the output of
>
> fdisk -l
>
> as user on Ubuntu 8.04.1 LTS?
>
In a terminal type sudo fdisk -l and give your password.


> I would like to use this information for a script without root
> privileges. The user running this script is sudo user.
>
>
The user of fdisk must be a root user I believe.
> According to the man page of fdisk, the -l option is:
>
> ,----
> | -l List the partition tables for the specified devices and then exit.
> | If no devices are given, those mentioned in /proc/partitions (if that
> | exists) are used.
> `----
>
> The file /proc/partitions is empty:
>
> ,----
> | # ls -al /proc/partitions
> | -r--r--r-- 1 root root 0 2008-08-14 03:23 /proc/partitions
> `----
>
> Should this file be created automatically during boot time?
>
> Thankful for any pointers,
>
> Patrick
>
>
Well before you do much do what I gave you above and it should print
out

karl@karl-hardy:~$ sudo fdisk -l
[sudo] password for karl:

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00056ea5

Device Boot Start End Blocks Id System
/dev/sda1 * 1 974 7823623+ 83 Linux
/dev/sda2 975 1948 7823655 83 Linux
/dev/sda3 1949 2192 1959930 82 Linux swap / Solaris
/dev/sda4 2193 5598 27358695 5 Extended
/dev/sda5 2193 4625 19543041 83 Linux
/dev/sda6 4626 5598 7815591 83 Linux

This is mine of course and shows I have a lot of free space!

Karl

>
>


--

Karl F. Larsen, AKA K5DI
Linux User
#450462 http://counter.li.org.
PGP 4208 4D6E 595F 22B9 FF1C ECB6 4A3C 2C54 FE23 53A7


--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 08-14-2008, 01:39 PM
Patrick Drechsler
 
Default accessing fdisk -l as user

Patrick Drechsler <patrick@pdrechsler.de> writes:

> can I access the output of
>
> fdisk -l
>
> as user on Ubuntu 8.04.1 LTS?
[...]

Leonard, Owen and Smoot: Thank you very much for your help!

To summarize:

* /proc/partitions is not empty (my mistake for not looking into the
file but just looking at the output of 'ls -l').

* A sudo user can have

sudo /sbin/fdisk -l

in a script without having to enter a password when the script is
executed by the user. Editing /etc/sudoers with visudo was not necessary
(although I am thankful for the pointer from Smoot--I will certainly
keep this in mind).

Thanks again,

Patrick


--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 

Thread Tools




All times are GMT. The time now is 09:16 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org