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.