Merge branch '16689-shell-sync-groups' refs #16689
[arvados.git] / services / login-sync / bin / arvados-login-sync
index 9152b29336b7ed44225c0a2a43a56ae1ac93d705..8162e22a2ff6f815ac7904d28ad6ec0413faa7c3 100755 (executable)
@@ -181,8 +181,6 @@ begin
     userdotconfig = File.join(homedir, ".config")
     if !File.exist?(userdotconfig)
       Dir.mkdir(userdotconfig)
-      FileUtils.chown_R(l[:username], nil, userdotconfig)
-      File.chmod(0700, userdotconfig)
     end
 
     configarvados = File.join(userdotconfig, "arvados")
@@ -197,18 +195,21 @@ begin
         f.write("ARVADOS_API_HOST=#{ENV['ARVADOS_API_HOST']}\n")
         f.write("ARVADOS_API_TOKEN=v2/#{user_token[:uuid]}/#{user_token[:api_token]}\n")
         f.close()
-        File.chmod(0600, tokenfile)
       end
     rescue => e
       STDERR.puts "Error setting token for #{l[:username]}: #{e}"
     end
 
     FileUtils.chown_R(l[:username], nil, userdotssh)
-    FileUtils.chown_R(l[:username], nil, configarvados)
+    FileUtils.chown_R(l[:username], nil, userdotconfig)
     File.chmod(0700, userdotssh)
+    File.chmod(0700, userdotconfig)
+    File.chmod(0700, configarvados)
     File.chmod(0750, homedir)
     File.chmod(0600, keysfile)
-    File.chmod(0700, configarvados)
+    if File.exist?(tokenfile)
+      File.chmod(0600, tokenfile)
+    end
   end
 
 rescue Exception => bang