bug-recutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Add decryption support to rec2csv


From: Jose E. Marchesi
Subject: Re: Add decryption support to rec2csv
Date: Mon, 04 Sep 2023 06:57:45 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Hi Craig.

> This patch adds decryption support (-s, --password, and prompted
> password) to rec2csv. One patch for utils/rec2csv.c and one for
> torture/utils/rec2csv.sh

Thanks for the patch.

This is gonna need an update for the manual (doc/recutils.texi) and also
ChangeLog entries.

> @@ -196,10 +218,14 @@
>            field = rec_record_get_field_by_name (record,
>                                                  rec_fex_elem_field_name 
> (fex_elem),
>                                                  rec_fex_elem_min (fex_elem));
> -          if (field)
> +          if (field) {

Please use GNU style formatting: open braces on their own line.

> +#if defined REC_CRYPT_SUPPORT
> +            if (rec2csv_password) rec_decrypt_field(field, rec2csv_password);

Please put the statement in its own line.

> +#endif
>              csv_fwrite (stdout,
>                          rec_field_value (field),
>                          strlen (rec_field_value (field)));
> +          }
>          }
>  
>        putc ('\n', stdout);
> @@ -252,6 +278,45 @@
>    size_t i;
>    rec_rset_t rset;
>  
> +
> +
> +#if defined REC_CRYPT_SUPPORT
> +
> +  /* If recsel was called interactively and with an empty -s, was not

I assume it must say `rec2csv' there instead of `recsel'.
Maybe abstract the code below in a function in recutl.[ch]?

> +     used then prompt the user for it.  Otherwise use the password
> +     specified in the command line if any.  */
> +  if (!rec2csv_password
> +      && (recutl_type || (rec_db_size (db) == 1))
> +      && recutl_interactive ())
> +    {
> +      rec_rset_t rset;
> +      rec_fex_t confidential_fields;
> +
> +      if (recutl_type)
> +        rset = rec_db_get_rset_by_type (db, recutl_type);
> +      else
> +        rset = rec_db_get_rset (db, 0);
> +
> +      if (rset)
> +        {
> +          confidential_fields = rec_rset_confidential (rset);
> +          if (rec_fex_size (confidential_fields) > 0)
> +            rec2csv_password = recutl_getpass (false);
> +
> +          rec_fex_destroy (confidential_fields);
> +        }
> +    }
> +
> +  /* Note that the password must be at least one character long.  */
> +
> +  if (rec2csv_password && (strlen (rec2csv_password) == 0))
> +    {
> +      free (rec2csv_password);
> +      rec2csv_password = NULL;
> +    }
> +    
> +
> +#endif /* REC_CRYPT_SUPPORT */  
>    ret = true;
>  
>    for (i = 0; i < rec_db_size (db); i++)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]