Explorar o código

feat(ssh-ident): Add new patch to ssh-ident

Signed-off-by: Jeremy MAURO <jeremy.mauro@gmail.com>
Jeremy MAURO %!s(int64=2) %!d(string=hai) anos
pai
achega
580f0cf80c

+ 26 - 0
cookbooks/workstation/files/0001-fix-timeout-Increase-the-ssh-key-in-memory-timeout-t.patch

@@ -0,0 +1,26 @@
+From 0b02ff87466505b961ca1b482b85e3d442b512dd Mon Sep 17 00:00:00 2001
+From: Jeremy MAURO <jeremy.mauro@gmail.com>
+Date: Mon, 30 May 2022 18:18:01 +0200
+Subject: [PATCH] fix(timeout): Increase the ssh key in memory timeout to a day
+
+Signed-off-by: Jeremy MAURO <jeremy.mauro@gmail.com>
+---
+ ssh-ident | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/ssh-ident b/ssh-ident
+index ff218ba..0ab2d8b 100755
+--- a/ssh-ident
++++ b/ssh-ident
+@@ -439,7 +439,7 @@ class Config(object):
+       "SSH_ADD_OPTIONS": {},
+       # ssh-add default options. By default, don't keep a key longer
+       # than 2 hours.
+-      "SSH_ADD_DEFAULT_OPTIONS": "-t 7200",
++      "SSH_ADD_DEFAULT_OPTIONS": "-t 86400",
+ 
+       # Like BatchMode in ssh, see man 5 ssh_config.
+       # In BatchMode ssh-ident will not print any output and not ask for
+-- 
+2.35.1
+

+ 19 - 13
cookbooks/workstation/recipes/_ssh-ident.rb

@@ -9,7 +9,6 @@ username = node['my_workstation']['default_user'].first[0]
 user_repo_directory = ::File.join(node['my_workstation']['default_user'][username]['home'], 'repo')
 ssh_ident_repo = ::File.join(user_repo_directory, 'ssh-ident')
 ssh_ident_bin = ::File.join(ssh_ident_repo, 'ssh-ident')
-patch_file = '001-ssh_ident-fix-python.patch'
 
 git ssh_ident_repo do
   repository 'https://github.com/ccontavalli/ssh-ident'
@@ -17,20 +16,27 @@ git ssh_ident_repo do
   action :checkout
 end
 
-cookbook_file ::File.join(ssh_ident_repo, patch_file) do
-  source patch_file
-  owner username
-  group username
-  notifies :run, "execute[git am #{patch_file}]", :immediately
-end
 
 # How to create a git patch:
 #   Ref: https://devconnected.com/how-to-create-and-apply-git-patch-files/
-execute "git am #{patch_file}" do
-  cwd ssh_ident_repo
-  action :nothing
-end
+patch_files = %w{
+  001-ssh_ident-fix-python.patch
+  0001-fix-timeout-Increase-the-ssh-key-in-memory-timeout-t.patch
+}
+
+patch_files.each do |patch_file|
+  cookbook_file ::File.join(ssh_ident_repo, patch_file) do
+    source patch_file
+    owner username
+    group username
+  end
+
+  execute "git am #{patch_file}" do
+    cwd ssh_ident_repo
+    only_if "/usr/bin/git apply #{patch_file} --check"
+  end
 
-execute "/usr/bin/install #{ssh_ident_bin} /usr/sbin/ssh-ident" do
-  not_if { ::FileUtils.uptodate?('/usr/sbin/ssh-ident', [ssh_ident_bin]) }
+  execute "/usr/bin/install #{ssh_ident_bin} /usr/sbin/ssh-ident" do
+    not_if { ::FileUtils.uptodate?('/usr/sbin/ssh-ident', [ssh_ident_bin]) }
+  end
 end