@@ -0,0 +1,47 @@
1+Ignore EINVAL errors. This matters within user namespaces.
2+
3+See:
4+https://github.com/NixOS/nixpkgs/issues/25901
5+https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=802612
6+https://github.com/NixOS/nixpkgs/issues/10496
7+
8+diff --git a/libfakeroot.c b/libfakeroot.c
9+index 68a95fb..70da8bc 100644
10+--- a/libfakeroot.c
11++++ b/libfakeroot.c
12+@@ -792,7 +792,7 @@ int chown(const char *path, uid_t owner, gid_t group){
13+ r=next_lchown(path,owner,group);
14+ else
15+ r=0;
16+- if(r&&(errno==EPERM))
17++ if(r&&(errno==EPERM||errno==EINVAL))
18+ r=0;
19+
20+ return r;
21+@@ -819,7 +819,7 @@ int lchown(const char *path, uid_t owner, gid_t group){
22+ r=next_lchown(path,owner,group);
23+ else
24+ r=0;
25+- if(r&&(errno==EPERM))
26++ if(r&&(errno==EPERM||errno==EINVAL))
27+ r=0;
28+
29+ return r;
30+@@ -843,7 +843,7 @@ int fchown(int fd, uid_t owner, gid_t group){
31+ else
32+ r=0;
33+
34+- if(r&&(errno==EPERM))
35++ if(r&&(errno==EPERM||errno==EINVAL))
36+ r=0;
37+
38+ return r;
39+@@ -870,7 +870,7 @@ int fchownat(int dir_fd, const char *path, uid_t owner, gid_t group, int flags)
40+ else
41+ r=0;
42+
43+- if(r&&(errno==EPERM))
44++ if(r&&(errno==EPERM||errno==EINVAL))
45+ r=0;
46+
47+ return r;