Skip to content

Commit

Permalink
- set umask to 0077 before writing the cdkey, the rest of the world
Browse files Browse the repository at this point in the history
  doesn't need to read it.
  • Loading branch information
lnussel committed Nov 6, 2005
1 parent 4eaebe4 commit 87b1210
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions code/qcommon/common.c
Expand Up @@ -24,8 +24,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "q_shared.h"
#include "qcommon.h"
#include <setjmp.h>
#if defined __linux__ || defined MACOS_X || defined __FreeBSD__ || defined __sun
#ifndef _WIN32
#include <netinet/in.h>
#include <sys/stat.h> // umask
#else
#include <winsock.h>
#endif
Expand Down Expand Up @@ -2312,6 +2313,9 @@ static void Com_WriteCDKey( const char *filename, const char *ikey ) {
fileHandle_t f;
char fbuffer[MAX_OSPATH];
char key[17];
#ifndef _WIN32
mode_t savedumask;
#endif


sprintf(fbuffer, "%s/q3key", filename);
Expand All @@ -2323,10 +2327,13 @@ static void Com_WriteCDKey( const char *filename, const char *ikey ) {
return;
}

#ifndef _WIN32
savedumask = umask(0077);
#endif
f = FS_SV_FOpenFileWrite( fbuffer );
if ( !f ) {
Com_Printf ("Couldn't write %s.\n", filename );
return;
Com_Printf ("Couldn't write CD key to %s.\n", fbuffer );
goto out;
}

FS_Write( key, 16, f );
Expand All @@ -2336,6 +2343,11 @@ static void Com_WriteCDKey( const char *filename, const char *ikey ) {
FS_Printf( f, "// id Software and Activision will NOT ask you to send this file to them.\r\n");

FS_FCloseFile( f );
out:
#ifndef _WIN32
umask(savedumask);
#endif
return;
}
#endif

Expand Down

0 comments on commit 87b1210

Please sign in to comment.