diff options
| author | Junio C Hamano <gitster@pobox.com> | 2010-03-08 00:36:00 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2010-03-08 00:36:00 -0800 |
| commit | 493e433277ee72b200e72f7a17e08266ed9497c5 (patch) | |
| tree | 8db1b524e77ee9d24ed89d22f311f17ff50baf64 /wrapper.c | |
| parent | 6ae611fa8d1e15e918e59b7e20abf98643cd25e4 (diff) | |
| parent | 5256b006312e4d06e11b49a8b128e9e550e54f31 (diff) | |
| download | git-493e433277ee72b200e72f7a17e08266ed9497c5.tar.gz | |
Merge branch 'mm/mkstemps-mode-for-packfiles' into maint
* mm/mkstemps-mode-for-packfiles:
Use git_mkstemp_mode instead of plain mkstemp to create object files
git_mkstemps_mode: don't set errno to EINVAL on exit.
Use git_mkstemp_mode and xmkstemp_mode in odb_mkstemp, not chmod later.
git_mkstemp_mode, xmkstemp_mode: variants of gitmkstemps with mode argument.
Move gitmkstemps to path.c
Add a testcase for ACL with restrictive umask.
Diffstat (limited to 'wrapper.c')
| -rw-r--r-- | wrapper.c | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -204,6 +204,16 @@ int xmkstemp(char *template) return fd; } +int xmkstemp_mode(char *template, int mode) +{ + int fd; + + fd = git_mkstemp_mode(template, mode); + if (fd < 0) + die_errno("Unable to create temporary file"); + return fd; +} + /* * zlib wrappers to make sure we don't silently miss errors * at init time. @@ -267,10 +277,14 @@ int git_inflate(z_streamp strm, int flush) int odb_mkstemp(char *template, size_t limit, const char *pattern) { int fd; - + /* + * we let the umask do its job, don't try to be more + * restrictive except to remove write permission. + */ + int mode = 0444; snprintf(template, limit, "%s/%s", get_object_directory(), pattern); - fd = mkstemp(template); + fd = git_mkstemp_mode(template, mode); if (0 <= fd) return fd; @@ -279,7 +293,7 @@ int odb_mkstemp(char *template, size_t limit, const char *pattern) snprintf(template, limit, "%s/%s", get_object_directory(), pattern); safe_create_leading_directories(template); - return xmkstemp(template); + return xmkstemp_mode(template, mode); } int odb_pack_keep(char *name, size_t namesz, unsigned char *sha1) |
