Skip to content

Commit

Permalink
Merge pull request #15 from cancerit/feature/chmodPwFile
Browse files Browse the repository at this point in the history
Feature/chmod pw file
  • Loading branch information
keiranmraine committed Jun 25, 2018
2 parents dfa4ea1 + 7c3cff1 commit f35d99c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changes

## NEXT

* Warn and change file permissions if password file has permissive access.
* Display warning when Windows as can't do it.

## 2.1.1

* Missing package in dependencies
Expand Down
22 changes: 21 additions & 1 deletion js/jbrowse_rasterize.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const path = require('path');
const colon = encodeURIComponent(':');
const fs = require('fs');
const mkdirp = require('mkdirp');
const Mode = require('stat-mode');

/**
* Process command line args and check validity
Expand Down Expand Up @@ -244,7 +245,26 @@ function headerHeight(options) {
* @return {string|null} - Loaded password or null
*/
function loadPw(options) {
if(options.passwdFile) return fs.readFileSync(options.passwdFile, "utf-8").replace(/\r?\n/g, '');
if(options.passwdFile) {
if(process.platform == 'win32') {
console.warn("Windows system, cannot check or correct file permissions of --passwdFile");
}
else {
const mode = new Mode(fs.statSync(options.passwdFile));
if(mode.group.read || mode.others.read) {
console.warn("File provided to --passwdFile is readable by people other than you, changing permissions...");
mode.owner.execute = false;
mode.group.read = false;
mode.group.write = false;
mode.group.execute = false;
mode.others.read = false;
mode.others.write = false;
mode.others.execute = false;
fs.chmodSync(options.passwdFile, mode.stat.mode);
}
}
return fs.readFileSync(options.passwdFile, "utf-8").replace(/\r?\n/g, '');
}
return null;
}

Expand Down
11 changes: 8 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"dependencies": {
"commander": "^2.15.1",
"mkdirp": "^0.5.1",
"puppeteer": "^1.1.1"
"puppeteer": "^1.1.1",
"stat-mode": "^0.2.2"
},
"bin": {
"jbrowse_rasterize": "js/jbrowse_rasterize.js"
Expand Down

0 comments on commit f35d99c

Please sign in to comment.