forked from DGNum/liminix
systemconfig: chown files if uid/gid > 0
This commit is contained in:
parent
5dd0c6e3c0
commit
65dfbad365
3 changed files with 18 additions and 5 deletions
|
@ -28,8 +28,6 @@ let
|
||||||
, uid ? 0
|
, uid ? 0
|
||||||
, gid ? 0
|
, gid ? 0
|
||||||
}:
|
}:
|
||||||
assert uid == 0;
|
|
||||||
assert gid == 0;
|
|
||||||
let
|
let
|
||||||
pathname = "${prefix}/${filename}";
|
pathname = "${prefix}/${filename}";
|
||||||
qpathname = builtins.toJSON pathname;
|
qpathname = builtins.toJSON pathname;
|
||||||
|
@ -49,7 +47,10 @@ let
|
||||||
"i" = "MKNOD_P(${qpathname}, ${mode'});";
|
"i" = "MKNOD_P(${qpathname}, ${mode'});";
|
||||||
};
|
};
|
||||||
cmd = cmds.${type};
|
cmd = cmds.${type};
|
||||||
in "${cmd}";
|
chown = if uid>0 || gid>0
|
||||||
|
then "\nCHOWN(${qpathname},${toString uid},${toString gid});\n"
|
||||||
|
else "";
|
||||||
|
in "${cmd} ${chown}";
|
||||||
in mapAttrsToList (makeFile prefix) attrset;
|
in mapAttrsToList (makeFile prefix) attrset;
|
||||||
activateScript = attrset: writeText "makedevs.c" ''
|
activateScript = attrset: writeText "makedevs.c" ''
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
|
|
|
@ -35,3 +35,4 @@ void print_file(char * path, mode_t mode, char * text) {
|
||||||
#define LN_S(target, path) (void)symlink(target, path)
|
#define LN_S(target, path) (void)symlink(target, path)
|
||||||
#define LN(target, path) link(target, path)
|
#define LN(target, path) link(target, path)
|
||||||
#define MKNOD_P(path, mode) mkfifo(path, mode)
|
#define MKNOD_P(path, mode) mkfifo(path, mode)
|
||||||
|
#define CHOWN(path, uid, gid) chown(path, uid, gid)
|
||||||
|
|
|
@ -1,8 +1,19 @@
|
||||||
{ config, pkgs, lib, ... } :
|
{ config, pkgs, lib, ... } :
|
||||||
{
|
let
|
||||||
|
inherit (pkgs.pseudofile) dir symlink;
|
||||||
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
../../vanilla-configuration.nix
|
../../vanilla-configuration.nix
|
||||||
|
../../modules/squashfs.nix
|
||||||
../../modules/jffs2.nix
|
../../modules/jffs2.nix
|
||||||
];
|
];
|
||||||
config.rootfsType = "jffs2";
|
config.rootfsType = "jffs2";
|
||||||
|
config.filesystem = dir {
|
||||||
|
hello = {
|
||||||
|
type = "f";
|
||||||
|
uid = 7;
|
||||||
|
gid = 24;
|
||||||
|
file = "hello world";
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue