diff options
author | Ori Bernstein <ori@eigenstate.org> | 2021-06-22 23:55:54 +0000 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2021-06-22 23:55:54 +0000 |
commit | b904edadd8869787b4419ce93c1c29b5beee3556 (patch) | |
tree | 1c967b0479a0937d705714f858c182840cb1ef44 /sys/src/cmd/git/pack.c | |
parent | 577033228209f28350dc3f75ef9d4ce88dfdf190 (diff) |
git/fs: use a better heuristic for permissions.
Since we now store /dist/plan9front in git, the
initial assumption that the owner of the repo
is the person touching it is not always true.
This change gives us a better heuristic for the
file permissions we should have in the files we
copy around, basing it off of the permissions of
the .git directory.
Diffstat (limited to 'sys/src/cmd/git/pack.c')
-rw-r--r-- | sys/src/cmd/git/pack.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/sys/src/cmd/git/pack.c b/sys/src/cmd/git/pack.c index 50077ba27..2ffcdec57 100644 --- a/sys/src/cmd/git/pack.c +++ b/sys/src/cmd/git/pack.c @@ -70,6 +70,7 @@ int cachemax = 4096; Packf *packf; int npackf; int openpacks; +int gitdirmode = -1; static void clear(Object *o) @@ -887,7 +888,7 @@ parsecommit(Object *o) static void parsetree(Object *o) { - int m, entsz, nent; + int m, a, entsz, nent; Dirent *t, *ent; char *p, *ep; @@ -908,7 +909,15 @@ parsetree(Object *o) if(*p != ' ') sysfatal("malformed tree %H: *p=(%d) %c\n", o->hash, *p, *p); p++; - t->mode = m & 0777; + /* + * only the stored permissions for the user + * are relevant; git fills group and world + * bits with whatever -- so to serve with + * useful permissions, replicate the mode + * of the git repo dir. + */ + a = (m & 0777)>>6; + t->mode = ((a<<6)|(a<<3)|a) & gitdirmode; t->ismod = 0; t->islink = 0; if(m == 0160000){ @@ -1048,7 +1057,14 @@ Object* readobject(Hash h) { Object *o; + Dir *d; + if(gitdirmode == -1){ + if((d = dirstat(".git")) == nil) + sysfatal("stat .git: %r"); + gitdirmode = d->mode & 0777; + free(d); + } if((o = readidxobject(nil, h, 0)) == nil) return nil; parseobject(o); |