Skip to content

Commit b75c81a

Browse files
committed
Move passwords around a bit more.
1 parent c00ce7a commit b75c81a

File tree

7 files changed

+18
-9
lines changed

7 files changed

+18
-9
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ paths, hostnames, usernames and so on in the code itself:
2727
SetEnv SROU_HOST_UKGPL www.ukgpl.com
2828
SetEnv SROU_DB_HOST an.internal.host.name
2929
SetEnv SROU_DB_PREFIX some_random_prefix_
30-
SetEnv SROU_DB_PASSWD 'aPasswordNotTheRealOneHereObviously'
3130
SetEnv SROU_ROOT /srv/www/SimRacing.org.uk
31+
SetEnv SROU_S3_ACCESS '$$theRealCode$$'
3232
</Directory>
3333
```
3434

35+
In addition, the most sensitive information such as passwords are stored in their own files in the [`cfg` directory](cfg).
36+
3537
As a consequence, changing certain SMF settings from the forum's own administrative pages tends to overwrite places
3638
in [`Settings.php`](public_html.srou/www/smf/Settings.php) which are supposed to get values from the environment
3739
with the values themselves. One must be careful when committing to restore such code to use the environment again.

cfg/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*

cfg/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
This directory should contain the following files, which should be read only and visible only to the relevant user.
2+
3+
Under no circumstances should these files be committed to source control.
4+
5+
* `s3.secret`: secret key for making AWS S3 calls
6+
* `smf-db.password`: password matching SROU_DB_USER
7+
* `migrate-login.options`: user/password options for `mysql` when doing migration activities which cannot use normal login

dories/common.sh

+4-5
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ if [ ! -d .git ]; then
77
fi
88

99
eval $(grep -E 'SetEnv\s+SROU_' $(grep -l "SetEnv SROU_ROOT $(pwd)" /etc/httpd/conf.d/*.conf) |
10-
sed -re 's/\s+SetEnv\s+//' |
10+
sed -re 's/^\s+SetEnv\s+//' |
1111
while read name value; do echo $name=$value; done
1212
)
1313
set | grep SROU
1414

15-
SMF_LOGIN="--user=${SROU_DB_PREFIX}smf --password=${SROU_DB_PASSWD}"
16-
# The following file should not be world readable, and should set MIGRATE_LOGIN in thesame format as SMF_LOGIN
17-
. ~/.srou-migrate
18-
SHARED_OPTIONS="--host=${SROU_DB_HOST} --batch $LOGIN_OPTIONS"
15+
SMF_LOGIN="--user=${SROU_DB_PREFIX}smf --password=$(cat cfg/smf-db.password)"
16+
MIGRATE_LOGIN=$(cat cfg/migrate-login.options)
17+
SHARED_OPTIONS="--host=${SROU_DB_HOST} --batch"

dories/recreate-db-users.zsh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
# then afterwards: SET GLOBAL validate_password_policy = 'MEDIUM';
99
cat <<-EOF
1010
DROP USER IF EXISTS '${SROU_DB_PREFIX}smf'@'%';
11-
CREATE USER '${SROU_DB_PREFIX}smf'@'%' IDENTIFIED BY '${SROU_DB_PASSWD}';
11+
CREATE USER '${SROU_DB_PREFIX}smf'@'%' IDENTIFIED BY '$(cat cfg/smf-db.password)';
1212
EOF
1313
) | mysql ${=SHARED_OPTIONS} ${=MIGRATE_LOGIN}

public_html.srou/downloads/s3.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
($bucket = $_REQUEST['bucket']) || ($bucket = $defaultBucket);
6262
$bucket = rawurlencode($bucket);
6363
$accessKey = $_SERVER['SROU_S3_ACCESS'];
64-
$secretKey = $_SERVER['SROU_S3_SECRET'];
64+
$secretKey = trim(file_get_contents("{$_SERVER['SROU_ROOT']}/cfg/s3.secret"));
6565

6666
function encodeKey($key) {
6767
$key = rawurlencode($key);

public_html.srou/www/smf/Settings.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
$db_server = $_SERVER['SROU_DB_HOST'];
7474
$db_name = "{$_SERVER['SROU_DB_PREFIX']}smf";
7575
$db_user = $db_name;
76-
$db_passwd = $_SERVER['SROU_DB_PASSWD'];
76+
$db_passwd = trim(file_get_contents("{$_SERVER['SROU_ROOT']}/cfg/smf-db.password"));
7777
$db_prefix = 'smf_';
7878
$db_persist = 0;
7979
$db_error_send = 0;

0 commit comments

Comments
 (0)