Skip to content

Commit ad9929d

Browse files
committed
BUGFIX: Adjust our .config permissions
- .config should only be readable by the user. - eventually change this to use python's keyring module.
1 parent a25e163 commit ad9929d

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

bashhub/bashhub_setup.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import getpass
99
import traceback
1010
import uuid
11+
import stat
1112
from model import *
1213
from model import System
1314
from bashhub_globals import *
@@ -183,10 +184,13 @@ def handle_system_information(user_id):
183184

184185
def write_config_file(user_id, system_id):
185186
exists = os.path.exists(BH_HOME)
187+
file_path = BH_HOME + '/.config'
188+
permissions = stat.S_IRUSR | stat.S_IWUSR
186189
if exists:
187-
config_file = open(BH_HOME + '/.config', 'w')
188-
config_file.write("export BH_USER_ID=\"" + user_id + "\"\n")
189-
config_file.write("export BH_SYSTEM_ID=\"" + system_id + "\"\n")
190+
with open(file_path, 'w') as config_file:
191+
config_file.write("export BH_USER_ID=\"" + user_id + "\"\n")
192+
config_file.write("export BH_SYSTEM_ID=\"" + system_id + "\"\n")
193+
os.chmod(file_path, permissions)
190194
else:
191195
print "Couldn't find bashhub home directory. Sorry."
192196

install-bashhub.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,10 @@ setup_bashhub_files() {
202202

203203
# Check if we already have a config. If not run setup.
204204
if [ -e $backup_config ]; then
205-
cp $backup_config $bashhub_config
205+
cp "$backup_config" "$bashhub_config"
206+
207+
# Make sure our config is only readable to us.
208+
chmod 600 "$bashhub_config"
206209
rm $backup_config
207210
else
208211
# Setup our config file

0 commit comments

Comments
 (0)