Browse files

More thorough executable checking for #33

  • Loading branch information...
1 parent 64019bc commit 41dbdff6f6672aeecc9d7c441d90bdc2f7563c6b Corey Richardson committed Jan 7, 2012
Showing with 12 additions and 4 deletions.
  1. +12 −4 lib/tap-runner.js
View
16 lib/tap-runner.js
@@ -149,11 +149,19 @@ Runner.prototype.runFiles = function (files, dir, cb) {
} else if (path.extname(f) === ".coffee") {
cmd = "coffee"
args = [fileName]
- } else if ((st.mode & 0111) == 0) {
- // Execute bit not set for user/group/other and isn't js/cs
- // TODO: more advanced permissions checking ("can I execute?"
- // instead of "can it be executed?"
+ } else {
+ // Check if file is executable
+ if ((st.mode & 0100) && process.getuid) {
+ if (process.getuid() != st.uid) {
+ return cb()
+ }
+ } else if ((st.mode & 0010) && process.getgid) {
+ if (process.getgid() != st.gid) {
+ return cb()
+ }
+ } else if ((st.mode & 0001) == 0) {
return cb()
+ }
}
if (st.isDirectory()) {

0 comments on commit 41dbdff

Please sign in to comment.