return 1;
// Create a temporary file
- FILE* f = pakfire_mktemp(path);
+ FILE* f = pakfire_mktemp(path, 0);
if (!f)
goto ERROR;
const char* data = pakfire_scriptlet_get_data(scriptlet, &size);
// Create a temporary file
- FILE* f = pakfire_mktemp(path);
+ FILE* f = pakfire_mktemp(path, 0);
if (!f)
return 1;
if (r)
return 1;
- transfer->f = pakfire_mktemp(transfer->tempfile);
+ transfer->f = pakfire_mktemp(transfer->tempfile, 0);
if (!transfer->f) {
ERROR(downloader->pakfire, "Could not create temporary file for download %s: %m\n",
transfer->tempfile);
int pakfire_touch(const char* path, mode_t mode);
int pakfire_mkparentdir(const char* path, mode_t mode);
int pakfire_mkdir(const char* path, mode_t mode);
-FILE* pakfire_mktemp(char* path);
+FILE* pakfire_mktemp(char* path, const mode_t mode);
char* pakfire_mkdtemp(char* path);
int pakfire_rmtree(const char* path, int flags);
goto ERROR;
// Create a temporary result file
- f = pakfire_mktemp(tmppath);
+ f = pakfire_mktemp(tmppath, 0);
if (!f)
goto ERROR;
return r;
// Create a temporary file to write to
- FILE* f = pakfire_mktemp(tmp);
+ FILE* f = pakfire_mktemp(tmp, 0644);
if (!f) {
ERROR(repo->pakfire, "Could not open temporary file for writing: %m\n");
return 1;
char path[PATH_MAX] = PAKFIRE_TMP_DIR "/pakfire-download.XXXXXX";
// Allocate a temporary file name
- FILE* f = pakfire_mktemp(path);
+ FILE* f = pakfire_mktemp(path, 0);
if (!f)
return 1;
return pakfire_try_mkdir(path, mode);
}
-FILE* pakfire_mktemp(char* path) {
+FILE* pakfire_mktemp(char* path, const mode_t mode) {
int r = pakfire_mkparentdir(path, 0755);
if (r)
return NULL;
if (fd < 0)
return NULL;
+ // Set desired mode
+ if (mode) {
+ r = fchmod(fd, mode);
+ if (r)
+ return NULL;
+ }
+
// Re-open as file handle
return fdopen(fd, "w+");
}