shadowsocks: Create a config with stricter permissions

So that the server password is not read by other users on the system.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Sunil Mohan Adapa 2017-11-29 16:12:33 +05:30
parent 0a9c2667bf
commit 9cfcc08434
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2

View File

@ -22,6 +22,7 @@ Helper script for configuring Shadowsocks.
import argparse
import json
import os
import sys
from plinth import action_utils
@ -79,7 +80,11 @@ def subcommand_merge_config(arguments):
new_config.update(config)
new_config = json.dumps(new_config, indent=4, sort_keys=True)
open(SHADOWSOCKS_CONFIG, 'w').write(new_config)
old_umask = os.umask(0o027)
try:
open(SHADOWSOCKS_CONFIG, 'w').write(new_config)
finally:
os.umask(old_umask)
action_utils.service_reload(shadowsocks.managed_services[0])