Skip to content

Commit

Permalink
overlay: introduce openssh modifications to disable permission checking
Browse files Browse the repository at this point in the history
Disable openssh's ~/.ssh/config permission checking.
It's too pedantic that does not work with FHS-shim on NixOS.

- Also removes the hack in home-manager configuration.

Link: nix-community/home-manager#322
  • Loading branch information
inclyc committed Nov 30, 2024
1 parent fc66cba commit 6cac815
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
5 changes: 0 additions & 5 deletions home/lyc/configurations/adrastea/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,4 @@
user = "zxy";
port = 22;
};

home.file.".ssh/config" = {
target = ".ssh/config_source";
onChange = ''cat .ssh/config_source > .ssh/config && chmod 400 .ssh/config'';
};
}
1 change: 1 addition & 0 deletions overlays/modifications.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ let
in
(lib.composeManyExtensions [
(import ./chromium.nix)
(import ./openssh)
])
final
prev
9 changes: 9 additions & 0 deletions overlays/openssh/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
Disable "bad permission" checking in openssh.
*/
final: prev: {
openssh = prev.openssh.overrideAttrs (old: {
patches = (old.patches or [ ]) ++ [ ./no-check-permission.patch ];
doCheck = false;
});
}
13 changes: 13 additions & 0 deletions overlays/openssh/no-check-permission.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/readconf.h b/readconf.h
index ded13c9..94f489e 100644
--- a/readconf.h
+++ b/readconf.h
@@ -203,7 +203,7 @@ typedef struct {
#define SESSION_TYPE_SUBSYSTEM 1
#define SESSION_TYPE_DEFAULT 2

-#define SSHCONF_CHECKPERM 1 /* check permissions on config file */
+#define SSHCONF_CHECKPERM 0 /* check permissions on config file */
#define SSHCONF_USERCONF 2 /* user provided config file not system */
#define SSHCONF_FINAL 4 /* Final pass over config, after canon. */
#define SSHCONF_NEVERMATCH 8 /* Match/Host never matches; internal only */

0 comments on commit 6cac815

Please sign in to comment.