Menu

#49 attach: no export possible in read-only mode

v1.0 (example)
closed-fixed
attachment (1)
9
2023-01-12
2023-01-04
No

I can't export attachments in read-only mode, though that seems like a reasonable feature. The attach function is fully denied in this mode.

In the patch below, I have reduced this denial to the function selections which would or might modify the database: attach add, attach delete, and no attachments available. This works okay for me, even regarding the messaging. But it might be considered a hack. (The logging is clumsy if no attachment is available.)

Please consider a similar change for the next release. Thanks!

--- /usr/bin/kpcli      2022-11-29 16:02:50.000000000 +0100
+++ kpcli       2023-01-04 17:54:15.937695929 +0100
@@ -4707,7 +4707,7 @@
   my $params = shift @_;
   our $state;

-  if (recent_sigint() || deny_if_readonly() || warn_if_file_changed()) {
+  if (recent_sigint() || warn_if_file_changed()) {
     return;
   }

@@ -4732,6 +4732,7 @@
       $t .= show_helper_files_strings($tmp_ent,{f=>1,v=>1},'binary');
       $t .= "$prompt: (a)dd/(e)xport/(d)elete/(c)ancel/(F)inish? ";
     } else {
+      if (deny_if_readonly()) { return; }
       $t .= "No files attached.\n";
       $t .= "$prompt: (a)dd/(c)ancel/(F)inish? ";
     }
@@ -4756,6 +4757,7 @@
         }
         return;
       } elsif (lc($key) eq 'd') {
+        if (deny_if_readonly()) { return; }
         if (defined($tmp_ent->{binary}) && ref($tmp_ent->{binary}) eq 'HASH') {
           if ($strings_count < 2) {
             %{$tmp_ent->{binary}} = ();
@@ -4821,6 +4823,7 @@
         }
         next ATTACH_INTERFACE;
       } elsif (lc($key) eq 'a') { # add
+        if (deny_if_readonly()) { return; }
         if ($strings_count > 0 && $state->{kdb_ver} == 1) {
           print "\n" .color('yellow').
                'KeePass v1 files support only one attachment per entry.' .

Discussion

  • Lester Hightower

    • status: open --> closed-fixed
    • assigned_to: Lester Hightower
    • Priority: 5 --> 9
     
  • Lester Hightower

    Thanks for providing this patch. I implemented this concept with a little more tact and it will be released with the next version -- either 4.0-beta7 or 4.0, whichever comes next.

     
    • Moritz Barsnick

      Moritz Barsnick - 2023-01-12

      Thank you, looking forward to this! (I actually forgot to look at the existing prereleases, will do so now.)

       

Log in to post a comment.