pseudofile: allow setting uid and gid of files

Necessary for Dropbear to accept non-root authorized_keys files.
This commit is contained in:
Brian McKenna 2023-04-14 09:18:27 +10:00 committed by Daniel Barlow
parent 9f3c80e774
commit fb796e61e0
2 changed files with 4 additions and 1 deletions

View file

@ -69,6 +69,7 @@ in {
(name: val: dir { (name: val: dir {
".ssh" = dir { ".ssh" = dir {
authorized_keys = { authorized_keys = {
inherit (val) uid gid;
type = "f"; type = "f";
mode = "0400"; mode = "0400";
file = lib.concatStringsSep file = lib.concatStringsSep

View file

@ -20,12 +20,14 @@ let
, file ? null , file ? null
, major ? null , major ? null
, minor ? null , minor ? null
, uid ? 0
, gid ? 0
}: }:
let let
mode' = if mode != null then mode else mode' = if mode != null then mode else
(if type == "d" then "0755" else "0644"); (if type == "d" then "0755" else "0644");
pathname = "${prefix}/${filename}"; pathname = "${prefix}/${filename}";
line = "${pathname} ${type} ${mode'} 0 0"; line = "${pathname} ${type} ${mode'} ${toString uid} ${toString gid}";
in in
if type == "f" then if type == "f" then
"${line} echo -n \"${qprint file}\" |qprint -d" "${line} echo -n \"${qprint file}\" |qprint -d"