diff options
author | ludwig <ludwig@edf5b092-35ff-0310-97b2-ce42778d08ea> | 2005-11-06 13:45:20 +0000 |
---|---|---|
committer | ludwig <ludwig@edf5b092-35ff-0310-97b2-ce42778d08ea> | 2005-11-06 13:45:20 +0000 |
commit | ede5566fabac2b5e9a8d407e02143714d5e2cf07 (patch) | |
tree | 1841f8fd52618db28ba79ccbdd8837aa9b449ffd | |
parent | 948b4109720a3a3d7c32c4d51d4836f38d312df7 (diff) | |
download | ioquake3-aero-ede5566fabac2b5e9a8d407e02143714d5e2cf07.tar.gz ioquake3-aero-ede5566fabac2b5e9a8d407e02143714d5e2cf07.zip |
- set umask to 0077 before writing the cdkey, the rest of the world
doesn't need to read it.
git-svn-id: svn://svn.icculus.org/quake3/trunk@293 edf5b092-35ff-0310-97b2-ce42778d08ea
-rw-r--r-- | code/qcommon/common.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/code/qcommon/common.c b/code/qcommon/common.c index fac8cba..a2f76b9 100644 --- a/code/qcommon/common.c +++ b/code/qcommon/common.c @@ -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 @@ -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); @@ -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 ); @@ -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 |