diff --git a/install.sh b/install.sh index e69de29..4ab18e6 100644 --- a/install.sh +++ b/install.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +ROOT=`dirname $0` + +# Give nodejs the ability to bind to ports below 1024. +# Since apparently you can't setcap on a user may as well +# give this power to ANYONE WITH THE NODE BINARY LOL. +sudo setcap cap_net_bind_service=ep /usr/bin/nodejs + +# Fix some retardation. This is unbelievably annoying. +sudo cp "${ROOT}/share/lxc/fuck-lxc.conf" "/etc/init/fuck-lxc.conf" + +# Think we good now +# Yea boi. diff --git a/lib/app.js b/lib/app.js index 1f6a7c0..b7e9f58 100644 --- a/lib/app.js +++ b/lib/app.js @@ -294,7 +294,7 @@ app.get( kiddies(assignment, function(err) { load(assignment, { principal: req.principal }, function(err, context) { if (err) return next(err); - console.log(context); + //console.log(context); res.render('assignment', { assignment: assignment, context: context @@ -352,7 +352,6 @@ var loaders = [{ mongoose.model('EvaluationSettings').findOne({ assignment: assignment }, next) }, 'evaluations': function(next) { - console.log({ assignment: assignment.id, target: context.principal }) mongoose.model('Evaluation').find({ assignment: assignment.id, target: context.principal }).limit(10).exec(next); } }, next); @@ -404,7 +403,6 @@ var loaders = [{ }); } else { - console.log('returning repo!'); return next(undefined, { repository: item.repository }); } }); @@ -439,7 +437,6 @@ function load(component, context, done) { function get(name) { var model = mongoose.model(name), key = name.toLowerCase(); return function(req, res, next, id) { - console.log('finding',name) if (req[key]) return next(); model.findById(id, function(err, result) { if (err) return next(err); @@ -456,6 +453,12 @@ app.param('repository', get('Repository')) mongoose.model('Repository').schema.set('repository path', app.get('path')+'/var/repositories'); +function onlyOwner() { + return function(req, res, next) { + if (req.principal !== req.repository.owner) return next({ statusCode: 403 }); + next(); + } +} var git = require('./git'), authSK = require('./authentication/secure-key')(mongoose.model('SecureKey')); @@ -464,7 +467,7 @@ app.post( '/code/:repository/git-upload-pack', authSK('git'), authenticated(), - //authorize.owner(), + onlyOwner(), git.uploadPack() ); @@ -473,7 +476,7 @@ app.post( '/code/:repository/git-receive-pack', authSK('git'), authenticated(), - //authorize.owner(), + onlyOwner(), git.receivePack() ); @@ -481,7 +484,7 @@ app.post( app.get('/code/:repository/info/refs', authSK('git'), authenticated(), - //authorize.owner(), + onlyOwner(), git.refs() ); diff --git a/lib/models/repository.js b/lib/models/repository.js index d2080cb..5641873 100644 --- a/lib/models/repository.js +++ b/lib/models/repository.js @@ -70,7 +70,6 @@ module.exports = function(app) { else { fs.realpath(source, function(err, path) { if (err) return done(err); - console.log('linking ',path,'->',destination) fs.symlink(path, destination, done); }); } @@ -129,7 +128,7 @@ module.exports = function(app) { // FIXME: What's the best way of doing this? This is pretty ugly. // FIXME: Method cannot be called hook Repository.method('gitHook', function(type, name, script, args, next) { - console.log(arguments); + //console.log(arguments); mongoose.model('RepositoryHook')({ repository: this, kind: type, diff --git a/views/assignment.jade b/views/assignment.jade index 0e11899..e30bd4e 100644 --- a/views/assignment.jade +++ b/views/assignment.jade @@ -16,6 +16,7 @@ mixin boilerplate(context) code | git clone -o boilerplate #{url({ path: context.repository.url })} #{assignment.key} | cd #{assignment.key} + | cat README.md mixin submission(context) h2 Submissions @@ -24,33 +25,33 @@ mixin submission(context) if context.key p Settings: code - | git remote add prelude #{url({ auth: 'submit:'+context.key.key, path: context.configuration.repository.url })} - | git push prelude master + | git remote add submit #{url({ auth: 'submit:'+context.key.key, path: context.configuration.repository.url })} + | git push submit master else p Unfortunately it looks like you're not logged in so you can't do this. if context.submissions - table.submissions - thead - tr - th Submitter - th Received - th Commit - th - tbody - for submission in context.submissions + if context.submissions.length > 0 + table.submissions + thead tr - td.submitter - | #{submission.submitter} - td.received - time(datetime=submission.at) #{submission.at} - td.commit - +commit(submission) - td.evaluate - form(method="post",action="/submission/"+submission.id+"/evaluate") - input.button(type="submit",value="Evaluate") - - unless context.submissions.length > 0 + th Submitter + th Received + th Commit + th + tbody + for submission in context.submissions + tr + td.submitter + | #{submission.submitter} + td.received + time(datetime=submission.at) #{submission.at} + td.commit + +commit(submission) + td.evaluate + form(method="post",action="/submission/"+submission.id+"/evaluate") + input.button(type="submit",value="Evaluate") + else p You haven't made any submissions yet. Get on it! mixin evaluation(context)