From acc120a37b8684d4bb4ef570ad221aea3b908565 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Tue, 9 Aug 2011 13:53:56 -0700 Subject: [PATCH] windows: fix test-umask --- src/node.cc | 16 ++++++++++++---- test/simple/test-umask.js | 9 ++++++++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/node.cc b/src/node.cc index bbb46e1202..49d617f381 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1444,13 +1444,15 @@ static Handle Cwd(const Arguments& args) { } -#ifdef __POSIX__ +#ifndef __POSIX__ +# define umask _umask +#endif -static Handle Umask(const Arguments& args){ +static Handle Umask(const Arguments& args) { HandleScope scope; unsigned int old; - if(args.Length() < 1 || args[0]->IsUndefined()) { + if (args.Length() < 1 || args[0]->IsUndefined()) { old = umask(0); umask((mode_t)old); @@ -1484,6 +1486,8 @@ static Handle Umask(const Arguments& args){ } +#ifdef __POSIX__ + static Handle GetUid(const Arguments& args) { HandleScope scope; assert(args.Length() == 0); @@ -1491,6 +1495,7 @@ static Handle GetUid(const Arguments& args) { return scope.Close(Integer::New(uid)); } + static Handle GetGid(const Arguments& args) { HandleScope scope; assert(args.Length() == 0); @@ -1538,6 +1543,7 @@ static Handle SetGid(const Arguments& args) { return Undefined(); } + static Handle SetUid(const Arguments& args) { HandleScope scope; @@ -1577,6 +1583,7 @@ static Handle SetUid(const Arguments& args) { return Undefined(); } + #endif // __POSIX__ @@ -2187,6 +2194,8 @@ Handle SetupProcessObject(int argc, char *argv[]) { NODE_SET_METHOD(process, "chdir", Chdir); NODE_SET_METHOD(process, "cwd", Cwd); + NODE_SET_METHOD(process, "umask", Umask); + #ifdef __POSIX__ NODE_SET_METHOD(process, "getuid", GetUid); NODE_SET_METHOD(process, "setuid", SetUid); @@ -2194,7 +2203,6 @@ Handle SetupProcessObject(int argc, char *argv[]) { NODE_SET_METHOD(process, "setgid", SetGid); NODE_SET_METHOD(process, "getgid", GetGid); - NODE_SET_METHOD(process, "umask", Umask); NODE_SET_METHOD(process, "dlopen", DLOpen); NODE_SET_METHOD(process, "_kill", Kill); #endif // __POSIX__ diff --git a/test/simple/test-umask.js b/test/simple/test-umask.js index 7b7fa9bf94..a41c46b55f 100644 --- a/test/simple/test-umask.js +++ b/test/simple/test-umask.js @@ -22,7 +22,14 @@ var common = require('../common'); var assert = require('assert'); -var mask = '0664'; +// Note in Windows one can only set the "user" bits. +var mask; +if (process.platform == 'win32') { + mask = '0600'; +} else { + mask = '0664'; +} + var old = process.umask(mask); assert.equal(parseInt(mask, 8), process.umask(old));