2013-04-30 05:24:46 -04:00
|
|
|
/* wrapper.c -- implements wrapper.h */
|
|
|
|
#include "wrapper.h"
|
|
|
|
|
2013-05-01 02:00:16 -04:00
|
|
|
#include <stdio.h>
|
2010-12-03 20:32:08 -05:00
|
|
|
#include <stdlib.h>
|
2015-03-23 23:58:04 -04:00
|
|
|
#include <sys/stat.h>
|
2013-04-30 05:24:46 -04:00
|
|
|
#include <unistd.h>
|
2010-12-03 20:32:08 -05:00
|
|
|
|
2013-05-01 02:00:16 -04:00
|
|
|
static void die( const char *err) {
|
|
|
|
fprintf( stderr, "fatal: %s\n", err) ;
|
|
|
|
exit( EXIT_FAILURE) ;
|
|
|
|
}
|
|
|
|
|
2010-12-03 20:32:08 -05:00
|
|
|
/* Function copyright: git */
|
2013-04-30 05:24:46 -04:00
|
|
|
void xmkstemp( char *template) {
|
|
|
|
int fd ;
|
2015-03-23 23:58:04 -04:00
|
|
|
mode_t o_mask ;
|
2013-04-30 05:24:46 -04:00
|
|
|
|
2015-03-23 23:58:04 -04:00
|
|
|
o_mask = umask( 0177) ;
|
2013-04-30 05:24:46 -04:00
|
|
|
fd = mkstemp( template) ;
|
|
|
|
if( fd < 0)
|
|
|
|
die( "Unable to create temporary file") ;
|
|
|
|
|
2015-03-23 23:58:04 -04:00
|
|
|
umask( o_mask) ;
|
2013-04-30 05:24:46 -04:00
|
|
|
close( fd) ;
|
2010-12-03 20:32:08 -05:00
|
|
|
}
|
2010-12-15 20:34:57 -05:00
|
|
|
|
2013-04-30 05:24:46 -04:00
|
|
|
/* end of wrapper.c */
|