File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed
Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change 88import getpass
99import traceback
1010import uuid
11+ import stat
1112from model import *
1213from model import System
1314from bashhub_globals import *
@@ -183,10 +184,13 @@ def handle_system_information(user_id):
183184
184185def 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
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments