Merge pull request #38011 from mgfritch/cephadm-sudo-log-dir

cephadm: verify root privileges before log dir create

Reviewed-by: Dimitri Savineau <dsavinea@redhat.com>
Reviewed-by: Juan Miguel Olmo <jolmomar@redhat.com>
This commit is contained in:
Michael Fritch 2020-11-13 19:23:34 -07:00 committed by GitHub
commit d2df27ef63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6059,6 +6059,11 @@ def _parse_args(av):
if __name__ == "__main__":
# root?
if os.geteuid() != 0:
sys.stderr.write('ERROR: cephadm should be run as root\n')
sys.exit(1)
# Logger configuration
if not os.path.exists(LOG_DIR):
os.makedirs(LOG_DIR)
@ -6079,11 +6084,6 @@ if __name__ == "__main__":
if handler.name == "console":
handler.setLevel(logging.DEBUG)
# root?
if os.geteuid() != 0:
sys.stderr.write('ERROR: cephadm should be run as root\n')
sys.exit(1)
if 'func' not in args:
sys.stderr.write('No command specified; pass -h or --help for usage\n')
sys.exit(1)