From b2193389ca8867a37a62dd600654cfb72e588830 Mon Sep 17 00:00:00 2001 From: kleiinnn Date: Sun, 29 Sep 2013 16:01:01 +0200 Subject: [PATCH 1/5] delete listen ip --- coder-base/server.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/coder-base/server.js b/coder-base/server.js index f7ec4f97..41a036c0 100644 --- a/coder-base/server.js +++ b/coder-base/server.js @@ -131,7 +131,7 @@ var apphandler = function( req, res, appdir ) { }; var startSSLRedirect = function() { - http.createServer( redirectapp ).listen( config.httpListenPort, config.listenIP ); + http.createServer( redirectapp ).listen( config.httpListenPort ); }; var startSSL = function() { @@ -146,7 +146,7 @@ var startSSL = function() { } if ( privateKey !== "" && certificate !== "" ) { - https.createServer({ key: privateKey, cert: certificate }, sslapp).listen( config.listenPort, config.listenIP ); + https.createServer({ key: privateKey, cert: certificate }, sslapp).listen( config.listenPort ); } else { var spawn = require('child_process').spawn; @@ -170,7 +170,7 @@ var startSSL = function() { var loadServer = function() { privateKey = fs.readFileSync('certs/server.key').toString(); certificate = fs.readFileSync('certs/server.cert').toString(); - https.createServer({ key: privateKey, cert: certificate }, sslapp).listen( config.listenPort, config.listenIP ); + https.createServer({ key: privateKey, cert: certificate }, sslapp).listen( config.listenPort ); }; genSelfSignedCert(); From 72fbe124bb8f9acc991e529014ad88a323195d1b Mon Sep 17 00:00:00 2001 From: kleiinnn Date: Sun, 29 Sep 2013 16:03:41 +0200 Subject: [PATCH 2/5] empty sudo scripts --- coder-base/sudo_scripts/reboot | 1 - coder-base/sudo_scripts/setpipass | 3 +-- coder-base/sudo_scripts/wpa_cli_apscan | 1 - coder-base/sudo_scripts/wpa_cli_scan | 1 - coder-base/sudo_scripts/wpa_cli_scanresults | 1 - 5 files changed, 1 insertion(+), 6 deletions(-) diff --git a/coder-base/sudo_scripts/reboot b/coder-base/sudo_scripts/reboot index f0d3f074..1a248525 100755 --- a/coder-base/sudo_scripts/reboot +++ b/coder-base/sudo_scripts/reboot @@ -1,2 +1 @@ #!/bin/sh -/sbin/shutdown -r now diff --git a/coder-base/sudo_scripts/setpipass b/coder-base/sudo_scripts/setpipass index 4b3cdcbc..96b4b06a 100755 --- a/coder-base/sudo_scripts/setpipass +++ b/coder-base/sudo_scripts/setpipass @@ -1,2 +1 @@ -#!/bin/sh -/usr/bin/passwd pi +#!/bin/sh \ No newline at end of file diff --git a/coder-base/sudo_scripts/wpa_cli_apscan b/coder-base/sudo_scripts/wpa_cli_apscan index bc4d17cf..1a248525 100755 --- a/coder-base/sudo_scripts/wpa_cli_apscan +++ b/coder-base/sudo_scripts/wpa_cli_apscan @@ -1,2 +1 @@ #!/bin/sh -/sbin/wpa_cli scan diff --git a/coder-base/sudo_scripts/wpa_cli_scan b/coder-base/sudo_scripts/wpa_cli_scan index acc643c9..1a248525 100755 --- a/coder-base/sudo_scripts/wpa_cli_scan +++ b/coder-base/sudo_scripts/wpa_cli_scan @@ -1,2 +1 @@ #!/bin/sh -/sbin/wpa_cli ap_scan 2 diff --git a/coder-base/sudo_scripts/wpa_cli_scanresults b/coder-base/sudo_scripts/wpa_cli_scanresults index 0442fda7..1a248525 100755 --- a/coder-base/sudo_scripts/wpa_cli_scanresults +++ b/coder-base/sudo_scripts/wpa_cli_scanresults @@ -1,2 +1 @@ #!/bin/sh -/sbin/wpa_cli scan_results From c6934c5fe05959a6f646e02f325174f3a6931db9 Mon Sep 17 00:00:00 2001 From: kleiinnn Date: Sun, 29 Sep 2013 18:44:48 +0200 Subject: [PATCH 3/5] removed sudo script implementations --- coder-base/apps/auth/app.js | 57 +------------------------------------ coder-base/server.js | 6 ++-- 2 files changed, 4 insertions(+), 59 deletions(-) diff --git a/coder-base/apps/auth/app.js b/coder-base/apps/auth/app.js index 68822f5d..48d56101 100644 --- a/coder-base/apps/auth/app.js +++ b/coder-base/apps/auth/app.js @@ -346,31 +346,9 @@ exports.api_addpassword_handler = function( req, res ) { return; } - var spawn = require('child_process').spawn; var err=0; //device_settings.device_name = devicename; - var erroutput = ""; - var output = ""; - var setpipass = process.cwd() + '/sudo_scripts/setpipass'; - var setpass = spawn( '/usr/bin/sudo', [setpipass] ); - setpass.stdout.on( 'data', function( d ) { - output += d; - }); - setpass.stderr.on( 'data', function( d ) { - erroutput += d; - }); - setpass.addListener( 'exit', function( code, signal ) { - err = code; - - - if ( err ) { - res.json({ - status: "error", - error: erroutput - }); - return; - } //TODO - Load hashed password var s = bcrypt.genSaltSync(10); @@ -389,12 +367,6 @@ exports.api_addpassword_handler = function( req, res ) { error: "Could not save device settings." }); } - - }); - setpass.stdin.write(pass + '\n'); - setpass.stdin.write(pass + '\n'); - setpass.stdin.end(); - }; @@ -431,31 +403,8 @@ exports.api_changepassword_handler = function( req, res ) { return; } - var spawn = require('child_process').spawn; var err=0; - //device_settings.device_name = devicename; - var erroutput = ""; - var output = ""; - var setpipass = process.cwd() + '/sudo_scripts/setpipass'; - var setpass = spawn( '/usr/bin/sudo', [setpipass] ); - setpass.stdout.on( 'data', function( d ) { - output += d; - }); - setpass.stderr.on( 'data', function( d ) { - erroutput += d; - }); - - setpass.addListener( 'exit', function( code, signal ) { - err = code; - - - if ( err ) { - res.json({ - status: "error", - error: erroutput - }); - return; - } + //device_settings.device_name = devicename //TODO - Load hashed password var s = bcrypt.genSaltSync(10); @@ -475,10 +424,6 @@ exports.api_changepassword_handler = function( req, res ) { }); } - }); - setpass.stdin.write(pass + '\n'); - setpass.stdin.write(pass + '\n'); - setpass.stdin.end(); }; diff --git a/coder-base/server.js b/coder-base/server.js index 41a036c0..f7ec4f97 100644 --- a/coder-base/server.js +++ b/coder-base/server.js @@ -131,7 +131,7 @@ var apphandler = function( req, res, appdir ) { }; var startSSLRedirect = function() { - http.createServer( redirectapp ).listen( config.httpListenPort ); + http.createServer( redirectapp ).listen( config.httpListenPort, config.listenIP ); }; var startSSL = function() { @@ -146,7 +146,7 @@ var startSSL = function() { } if ( privateKey !== "" && certificate !== "" ) { - https.createServer({ key: privateKey, cert: certificate }, sslapp).listen( config.listenPort ); + https.createServer({ key: privateKey, cert: certificate }, sslapp).listen( config.listenPort, config.listenIP ); } else { var spawn = require('child_process').spawn; @@ -170,7 +170,7 @@ var startSSL = function() { var loadServer = function() { privateKey = fs.readFileSync('certs/server.key').toString(); certificate = fs.readFileSync('certs/server.cert').toString(); - https.createServer({ key: privateKey, cert: certificate }, sslapp).listen( config.listenPort ); + https.createServer({ key: privateKey, cert: certificate }, sslapp).listen( config.listenPort, config.listenIP ); }; genSelfSignedCert(); From 6059d9fd2aa1a5b1d95d83d56b532193b149ae83 Mon Sep 17 00:00:00 2001 From: kleiinnn Date: Thu, 17 Oct 2013 19:01:27 +0200 Subject: [PATCH 4/5] empty reboot --- coder-base/sudo_scripts/reboot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coder-base/sudo_scripts/reboot b/coder-base/sudo_scripts/reboot index 1a248525..8b137891 100755 --- a/coder-base/sudo_scripts/reboot +++ b/coder-base/sudo_scripts/reboot @@ -1 +1 @@ -#!/bin/sh + From bc4eb72736c0565fa7e568914396646df5131aa1 Mon Sep 17 00:00:00 2001 From: kleiinnn Date: Thu, 17 Oct 2013 19:02:12 +0200 Subject: [PATCH 5/5] fixed http redirect --- coder-base/server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coder-base/server.js b/coder-base/server.js index f7ec4f97..ac5f23aa 100644 --- a/coder-base/server.js +++ b/coder-base/server.js @@ -263,7 +263,7 @@ params.extend( redirectapp ); redirectapp.engine( 'html', cons.mustache ); redirectapp.all( /.*/, function( req, res ) { util.log( 'redirect: ' + getHost(req) + " " + config.httpsVisiblePort + " " + req.url ); - res.redirect("https://" + getHost(req) + ":" + config.httpsVisiblePort + req.url); + res.redirect("https://" + req.host + ":" + config.httpsVisiblePort + req.url); }); startSSL();