[parted-devel] [PATCH] fix for 'parted --list' option -- does not generate an exception in non superuser mode
Otavio Salvador
otavio at debian.org
Mon May 5 13:33:18 UTC 2008
"Rakesh Pandit" <rakesh.pandit at gmail.com> writes:
> 2008/5/5 Rakesh Pandit <rakesh.pandit at gmail.com>:
>> There where two convention errors in spacing. Corrected.
>>
>> Attached is the patch.
>>
>> -
>> Rakesh Pandit
>>
>
> Sorry for trouble, I mistakenly attached my patch and was scrubbed.
> So, correct patch is below:
>
> diff --git a/parted/parted.c b/parted/parted.c
> index 0f6768b..15c2d23 100644
> --- a/parted/parted.c
> +++ b/parted/parted.c
> @@ -181,6 +181,17 @@ _timer_handler (PedTimer* timer, void* context)
> }
> }
>
> +static void
> +_superuser_warn ()
> +{
> +#ifdef HAVE_GETUID
> + if (getuid() != 0 && !opt_script_mode) {
> + puts (_("WARNING: You are not superuser. Watch out for "
> + "permissions."));
> + }
> +#endif
> +}
> +
> static int
> _partition_warn_busy (PedPartition* part)
> {
> @@ -1573,11 +1584,23 @@ _print_list ()
> {
> PedDevice *current_dev = NULL;
>
> - ped_device_probe_all();
> + _superuser_warn ();
^^^^^ bad indent
> +retry:
> + ped_device_probe_all ();
> + current_dev = ped_device_get_next (NULL);
> +
> + if (!current_dev) {
> + if (ped_exception_throw (PED_EXCEPTION_ERROR,
> + PED_EXCEPTION_RETRY_CANCEL,
> + _("No device found"))
> + == PED_EXCEPTION_RETRY)
> + goto retry;
> + }
>
> - while ((current_dev = ped_device_get_next(current_dev))) {
> + while (current_dev) {
> do_print (¤t_dev);
> putchar ('\n');
> + current_dev = ped_device_get_next (current_dev);
> }
>
> return 1;
> @@ -2429,12 +2452,7 @@ _init_commands ();
> if (!_parse_options (argc_ptr, argv_ptr))
> goto error_done_commands;
>
> -#ifdef HAVE_GETUID
> - if (getuid() != 0 && !opt_script_mode) {
> - puts (_("WARNING: You are not superuser. Watch out for "
> - "permissions."));
> - }
> -#endif
> +_superuser_warn ();
^^ same here
> dev = _choose_device (argc_ptr, argv_ptr);
> if (!dev)
Could you try to make a test case for this problem?
--
O T A V I O S A L V A D O R
---------------------------------------------
E-mail: otavio at debian.org UIN: 5906116
GNU/Linux User: 239058 GPG ID: 49A5F855
Home Page: http://otavio.ossystems.com.br
---------------------------------------------
"Microsoft sells you Windows ... Linux gives
you the whole house."
More information about the parted-devel
mailing list