migrated write_chunk() to chunk_write()
This commit is contained in:
+1
-1
@@ -308,7 +308,7 @@ insert_crl(chunk_t blob, chunk_t crl_uri, bool cache_crl)
|
||||
|
||||
datatot(subjectKeyID.ptr, subjectKeyID.len, 16, buf, BUF_LEN);
|
||||
snprintf(path, BUF_LEN, "%s/%s.crl", CRL_PATH, buf);
|
||||
write_chunk(path, "crl", crl->certificateList, 0022, TRUE);
|
||||
chunk_write(crl->certificateList, path, "crl", 0022, TRUE);
|
||||
}
|
||||
|
||||
/* is the fetched crl valid? */
|
||||
|
||||
@@ -94,55 +94,6 @@ mv_chunk(u_char **pos, chunk_t content)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* write the binary contents of a chunk_t to a file
|
||||
*/
|
||||
bool
|
||||
write_chunk(const char *filename, const char *label, chunk_t ch
|
||||
, mode_t mask, bool force)
|
||||
{
|
||||
mode_t oldmask;
|
||||
FILE *fd;
|
||||
size_t written;
|
||||
|
||||
if (!force)
|
||||
{
|
||||
fd = fopen(filename, "r");
|
||||
if (fd)
|
||||
{
|
||||
fclose(fd);
|
||||
plog(" %s file '%s' already exists", label, filename);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* set umask */
|
||||
oldmask = umask(mask);
|
||||
|
||||
fd = fopen(filename, "w");
|
||||
|
||||
if (fd)
|
||||
{
|
||||
written = fwrite(ch.ptr, sizeof(u_char), ch.len, fd);
|
||||
fclose(fd);
|
||||
if (written != ch.len)
|
||||
{
|
||||
plog(" writing to %s file '%s' failed", label, filename);
|
||||
umask(oldmask);
|
||||
return FALSE;
|
||||
}
|
||||
plog(" written %s file '%s' (%d bytes)", label, filename, (int)ch.len);
|
||||
umask(oldmask);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
plog(" could not open %s file '%s' for writing", label, filename);
|
||||
umask(oldmask);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* checks if the expiration date has been reached and
|
||||
* warns during the warning_interval of the imminent
|
||||
* expiry. strict=TRUE declares a fatal error,
|
||||
|
||||
@@ -63,10 +63,6 @@ extern const char* concatenate_paths(const char *a, const char *b);
|
||||
/* move a chunk to a memory position and free it after insertion */
|
||||
extern void mv_chunk(u_char **pos, chunk_t content);
|
||||
|
||||
/* write the binary contents of a chunk_t to a file */
|
||||
extern bool write_chunk(const char *filename, const char *label, chunk_t ch
|
||||
,mode_t mask, bool force);
|
||||
|
||||
/* warns a predefined interval before expiry */
|
||||
extern const char* check_expiry(time_t expiration_date,
|
||||
int warning_interval, bool strict);
|
||||
@@ -88,10 +84,8 @@ typedef struct dirent dirent_t;
|
||||
extern int file_select(const dirent_t *entry);
|
||||
|
||||
/* cleanly exit Pluto */
|
||||
|
||||
extern void exit_pluto(int /*status*/) NEVER_RETURNS;
|
||||
|
||||
|
||||
/* zero all bytes */
|
||||
#define zero(x) memset((x), '\0', sizeof(*(x)))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user