mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 21:13:36 +00:00
start-server/restart-server: Drop privileges if necessary.
Rather than tell the user to re-run the command as `zulip` instead of `root`, do the privilege-dropping ourselves.
This commit is contained in:
committed by
Tim Abbott
parent
20d90a6df6
commit
0115fa9c60
@@ -25,6 +25,7 @@ from scripts.lib.zulip_tools import (
|
||||
has_process_fts_updates,
|
||||
overwrite_symlink,
|
||||
start_arg_parser,
|
||||
su_to_zulip,
|
||||
)
|
||||
|
||||
action = "restart"
|
||||
@@ -41,7 +42,10 @@ args = parser.parse_args()
|
||||
deploy_path = os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))
|
||||
os.chdir(deploy_path)
|
||||
|
||||
if pwd.getpwuid(os.getuid()).pw_name != "zulip":
|
||||
username = pwd.getpwuid(os.getuid()).pw_name
|
||||
if username == "root":
|
||||
su_to_zulip()
|
||||
elif username != "zulip":
|
||||
logging.error("Must be run as user 'zulip'.")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
@@ -18,12 +18,16 @@ from scripts.lib.zulip_tools import (
|
||||
WARNING,
|
||||
has_application_server,
|
||||
has_process_fts_updates,
|
||||
su_to_zulip,
|
||||
)
|
||||
|
||||
deploy_path = os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))
|
||||
os.chdir(deploy_path)
|
||||
|
||||
if pwd.getpwuid(os.getuid()).pw_name != "zulip":
|
||||
username = pwd.getpwuid(os.getuid()).pw_name
|
||||
if username == "root":
|
||||
su_to_zulip()
|
||||
elif username != "zulip":
|
||||
logging.error("Must be run as user 'zulip'.")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user