Skip to content

Commit 4294738

Browse files
committed
running daemon as coder user instead of root
1 parent 040dc7d commit 4294738

File tree

11 files changed

+41
-15
lines changed

11 files changed

+41
-15
lines changed

coder-base/apps/auth/app.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ var device_settings = {
3232
coder_color: '#3e3e3e'
3333
};
3434

35+
var setpipass = '/home/coder/coder-dist/coder-base/sudo_scripts/setpipass';
3536

3637
exports.settings={};
3738
//These are dynamically updated by the runtime
@@ -345,7 +346,7 @@ exports.api_addpassword_handler = function( req, res ) {
345346
//device_settings.device_name = devicename;
346347
var erroutput = "";
347348
var output = "";
348-
var setpass = spawn( '/usr/bin/sudo', ['/usr/bin/passwd', 'pi'] );
349+
var setpass = spawn( '/usr/bin/sudo', [setpipass] );
349350
setpass.stdout.on( 'data', function( d ) {
350351
output += d;
351352
});
@@ -429,7 +430,7 @@ exports.api_changepassword_handler = function( req, res ) {
429430
//device_settings.device_name = devicename;
430431
var erroutput = "";
431432
var output = "";
432-
var setpass = spawn( '/usr/bin/sudo', ['/usr/bin/passwd', 'pi'] );
433+
var setpass = spawn( '/usr/bin/sudo', [setpipass] );
433434
setpass.stdout.on( 'data', function( d ) {
434435
output += d;
435436
});

coder-base/apps/eyeball/meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"created": "2013-03-15",
3-
"modified": "2013-06-26",
3+
"modified": "2013-07-08",
44
"color": "#f39c12",
55
"author": "Justin Windle",
66
"name": "Eyeball",

coder-base/apps/hello_coder/meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"created": "2013-05-08",
3-
"modified": "2013-06-26",
3+
"modified": "2013-07-08",
44
"color": "#d977d4",
55
"author": "Jason Striegel",
66
"name": "Hello Coder",

coder-base/config.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11

22
exports.listenIP = null; //Defaults to *
3-
exports.listenPort = '443'; //the SSL port things run on
4-
exports.httpListenPort = '80'; //this will all be redirected to SSL
3+
exports.listenPort = '8081'; //the SSL port things run on
4+
exports.httpListenPort = '8080'; //this will all be redirected to SSL
55
exports.cacheApps = true;
6+
exports.httpVisiblePort = '80'; //forwarded http port the user sees
7+
exports.httpsVisiblePort = '443'; //forwarded https port the user sees
68

79

810
//SSL Info

coder-base/server.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ var apphandler = function( req, res, appdir ) {
6969
auth = require(appdir + "auth" + "/app");
7070
user = auth.isAuthenticated(req, res);
7171
if ( !user && publicAllowed.indexOf( appname ) < 0) {
72-
res.redirect("https://" + getHost(req) + ":" + config.listenPort + '/app/auth' );
72+
res.redirect("https://" + getHost(req) + ":" + config.httpsVisiblePort + '/app/auth' );
7373
return;
7474
}
7575

@@ -262,8 +262,8 @@ var redirectapp = express();
262262
params.extend( redirectapp );
263263
redirectapp.engine( 'html', cons.mustache );
264264
redirectapp.all( /.*/, function( req, res ) {
265-
util.log( 'redirect: ' + getHost(req) + " " + config.listenPort + " " + req.url );
266-
res.redirect("https://" + getHost(req) + ":" + config.listenPort + req.url);
265+
util.log( 'redirect: ' + getHost(req) + " " + config.httpsVisiblePort + " " + req.url );
266+
res.redirect("https://" + getHost(req) + ":" + config.httpsVisiblePort + req.url);
267267
});
268268

269269
startSSL();

coder-base/sudo_scripts/setpipass

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
/usr/bin/passwd pi
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# The init.d script will only run if this variable non-empty.
2-
CODER_USER="root" # !!!CHANGE THIS!!!!
2+
CODER_USER="coder" # !!!should not be root!!!!
33

44
# Should we run at startup?
55
RUN_AT_STARTUP="YES"

raspbian-addons/etc/init.d/coder-daemon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
1818
DESC="Coder Server"
1919
NAME="coder-daemon"
2020
DAEMON=/usr/bin/nodejs
21-
DAEMON_ARGS="/home/pi/coder/coder-base/server.js"
22-
DAEMON_PATH="/home/pi/coder/coder-base/"
21+
DAEMON_ARGS="/home/coder/coder-dist/coder-base/server.js"
22+
DAEMON_PATH="/home/coder/coder-dist/coder-base/"
2323
PIDFILE=/var/run/$NAME.pid
2424
UMASK=022 # Change this to 0 if running deluged as its own user
2525
PKGNAME=coder-daemon

raspbian-addons/etc/init.d/pull-coder-reset

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ logger="logger -t $prog"
1717
reset_file="/boot/reset.txt"
1818
source_wpa_conf="/etc/wpa_supplicant/wpa_supplicant.conf.reset"
1919
dest_wpa_conf="/etc/wpa_supplicant/wpa_supplicant.conf"
20-
source_device_json="/home/pi/coder/coder-base/device.json.reset"
21-
dest_device_json="/home/pi/coder/coder-base/device.json"
20+
source_device_json="/home/coder/coder-dist/coder-base/device.json.reset"
21+
dest_device_json="/home/coder/coder-dist/coder-base/device.json"
2222

2323
# copy from source to dest if source exists
2424
if [ -f $reset_file ]; then
@@ -27,7 +27,7 @@ if [ -f $reset_file ]; then
2727
chmod 600 $dest_wpa_conf
2828
echo "-----RESET DEVICE.JSON-----" | $logger
2929
cp $source_device_json $dest_device_json
30-
chown pi $dest_device_json
30+
chown coder $dest_device_json
3131
chmod 600 $dest_device_json
3232
rm -f $reset_file
3333
fi

raspbian-addons/etc/iptables.up.rules

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Generated by iptables-save v1.4.14 on Mon Jul 8 15:57:20 2013
2+
*nat
3+
:PREROUTING ACCEPT [99:5850]
4+
:INPUT ACCEPT [113:6746]
5+
:OUTPUT ACCEPT [0:0]
6+
:POSTROUTING ACCEPT [0:0]
7+
-A PREROUTING -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 8081
8+
-A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080
9+
COMMIT
10+
# Completed on Mon Jul 8 15:57:20 2013
11+
# Generated by iptables-save v1.4.14 on Mon Jul 8 15:57:20 2013
12+
*filter
13+
:INPUT ACCEPT [1237:98511]
14+
:FORWARD ACCEPT [0:0]
15+
:OUTPUT ACCEPT [672:465045]
16+
COMMIT
17+
# Completed on Mon Jul 8 15:57:20 2013
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
#restore iptables on boot
3+
4+
iptables-restore < /etc/iptables.up.rules

0 commit comments

Comments
 (0)