The correct value for rwx/r-x/r-x, as an integer, is 493.  That's the 
decimal number representation of the octal number 755.  You can pass the 
string '755' which node kindly, if confusingly, interprets as octal instead 
of decimal when you pass a string to chmod, or 0755, the 
C-language-and-descendants way of writing an octal number, or, to be most 
explicit and least likely to confuse your future self, parseInt('755', 8).

On Tuesday, September 9, 2014 6:16:07 PM UTC-7, Ingwie Phoenix wrote:
>
> Hey list. 
>
> I am trying to use the following function for a matter of security in my 
> app: 
>
> function doDirs(uid, gid) { 
>     var dirs = [ 
>         config.base+"/cache", 
>         config.base+"/cdn/assets", 
>         config.base+"/config" 
>     ]; 
>     for(var i=0; dirs.length > i; i++) { 
>         var dir = dirs[i]; 
>         log.info("BIRD3 Security -> "+dir+"..."); 
>         if(!fs.existsSync(dir)) fs.mkdirSync(dir, 755); 
>         if(!fs.writeFileSync(dir+"/.tmp", "o.o")) { 
>             fs.chmodSync(dir, 755); 
>             fs.unlink(dir+"/.tmp", function(){}); 
>         } 
>         fs.chownSync(dir, uid, gid); 
>     } 
> } 
>
> However, after this function was executed… 
>
> Ingwies-Macbook-Pro:BIRD3 Ingwie$ ls -ald cache/ cdn/assets/ config/ 
> d-wxrw--wt+ 3 Ingwie  staff  102  9 Sep 05:08 cache/ 
> d-wxrw--wt+ 4 Ingwie  staff  136  9 Sep 05:08 cdn/assets/ 
> d-wxrw--wt+ 6 Ingwie  staff  204  9 Sep 05:08 config/ 
>
> All my read permissions are gone O_o. 
>
> What is the correct value to make it: r w x | r - - | r - - ? 
>
> This is done before changing to a new user, assigning read/write/execute 
> permissions jsut for this one user, and read-only for the rest… 
>
> The full code is found here: 
> http://git.ingwie.me/ingwie/bird3/blob/master/lib/security_handler.js 
>
> Kind regards, Ingwie.

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/77df47a9-1e16-4d35-9265-8963c1953e8d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to