Author: eelco
Date: Wed Apr 25 14:14:20 2012
New Revision: 33918
URL: https://nixos.org/websvn/nix/?rev=33918&sc=1

Log:
* In the implementation of the ‘authorizedKeys’, don't delete all
  lines below a certain marker.  This is undesirable because commands
  like "ssh-copy-id" add keys to the end of the file.  Instead mark
  all automatically added lines individually.

Modified:
   nixos/trunk/modules/services/networking/ssh/sshd.nix

Modified: nixos/trunk/modules/services/networking/ssh/sshd.nix
==============================================================================
--- nixos/trunk/modules/services/networking/ssh/sshd.nix        Wed Apr 25 
13:56:08 2012        (r33917)
+++ nixos/trunk/modules/services/networking/ssh/sshd.nix        Wed Apr 25 
14:14:20 2012        (r33918)
@@ -73,7 +73,7 @@
 
   mkAuthkeyScript =
     let
-      marker1 = "### NixOS will regenerate this line and every line below it.";
+      marker1 = "### NixOS auto-added key. Do not edit!";
       marker2 = "### NixOS will regenerate this file. Do not edit!";
       users = map (userName: getAttr userName config.users.extraUsers) 
(attrNames config.users.extraUsers);
       usersWithKeys = flip filter users (u:
@@ -98,7 +98,7 @@
 
         for f in $authKeyFiles; do
           if [ -f "$f" ]; then
-            authKeys="$(${pkgs.coreutils}/bin/cat "$f"),$authKeys"
+            authKeys="$(${pkgs.coreutils}/bin/cat "$f") ${marker1},$authKeys"
           fi
         done
 
@@ -110,8 +110,7 @@
             rm -f "$authfile"
             authKeys="${marker2},$authKeys"
           else
-            ${pkgs.gnused}/bin/sed -i '/^### NixOS.*$/,$d' "$authfile"
-            authKeys="${marker1},$authKeys"
+            ${pkgs.gnused}/bin/sed -i '/${marker1}/ d' "$authfile"
           fi
           for key in $authKeys; do ${pkgs.coreutils}/bin/echo "$key" >> 
"$authfile"; done
         fi
_______________________________________________
nix-commits mailing list
[email protected]
http://lists.science.uu.nl/mailman/listinfo/nix-commits

Reply via email to