Explicitly disable dumping core (closes #72)
This is a precaution to avoid saving sensitive data to disk, e.g. session keys. We expect that corefiles are not world readable, but they're still sitting on the physical disk and it's safer just to disable creating them. GitHub issue #71 deals with a similar concern.
This commit is contained in:
committed by
Keith Winstein
parent
b6c3e450fd
commit
9f38c76699
@@ -20,6 +20,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
|
||||||
#include "byteorder.h"
|
#include "byteorder.h"
|
||||||
#include "crypto.h"
|
#include "crypto.h"
|
||||||
@@ -246,3 +247,17 @@ Message Session::decrypt( string ciphertext )
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Disable dumping core, as a precaution to avoid saving sensitive data
|
||||||
|
to disk. */
|
||||||
|
void Crypto::disable_dumping_core( void ) {
|
||||||
|
struct rlimit limit;
|
||||||
|
limit.rlim_cur = 0;
|
||||||
|
limit.rlim_max = 0;
|
||||||
|
if ( 0 != setrlimit( RLIMIT_CORE, &limit ) ) {
|
||||||
|
/* We don't throw CryptoException because this is called very early
|
||||||
|
in main(), outside of 'try'. */
|
||||||
|
perror( "setrlimit(RLIMIT_CORE)" );
|
||||||
|
exit( 1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -84,6 +84,8 @@ namespace Crypto {
|
|||||||
Session( const Session & );
|
Session( const Session & );
|
||||||
Session & operator=( const Session & );
|
Session & operator=( const Session & );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void disable_dumping_core( void );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -54,6 +54,9 @@ void print_colorcount( void )
|
|||||||
|
|
||||||
int main( int argc, char *argv[] )
|
int main( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
|
/* For security, make sure we don't dump core */
|
||||||
|
Crypto::disable_dumping_core();
|
||||||
|
|
||||||
/* Get arguments */
|
/* Get arguments */
|
||||||
int opt;
|
int opt;
|
||||||
while ( (opt = getopt( argc, argv, "c" )) != -1 ) {
|
while ( (opt = getopt( argc, argv, "c" )) != -1 ) {
|
||||||
|
|||||||
@@ -103,6 +103,9 @@ string get_SSH_IP( void )
|
|||||||
|
|
||||||
int main( int argc, char *argv[] )
|
int main( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
|
/* For security, make sure we don't dump core */
|
||||||
|
Crypto::disable_dumping_core();
|
||||||
|
|
||||||
char *desired_ip = NULL;
|
char *desired_ip = NULL;
|
||||||
char *desired_port = NULL;
|
char *desired_port = NULL;
|
||||||
char **command = NULL;
|
char **command = NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user