Commit 87a4b351 authored by Dominik Rimpf's avatar Dominik Rimpf
Browse files

ADD: Check if configfile is readable by others...

parent f92e8b8b
Pipeline #117414 passed with stage
in 23 seconds
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import argparse import argparse
import configparser import configparser
import os import os
import stat
class ArgumentParser(argparse.ArgumentParser): class ArgumentParser(argparse.ArgumentParser):
...@@ -40,8 +41,11 @@ class ArgumentParser(argparse.ArgumentParser): ...@@ -40,8 +41,11 @@ class ArgumentParser(argparse.ArgumentParser):
def parse_args(self, args=None, namespace=None): def parse_args(self, args=None, namespace=None):
args = super().parse_args(args, namespace) args = super().parse_args(args, namespace)
config = configparser.ConfigParser() config = configparser.ConfigParser()
if os.path.isfile(os.path.expanduser(args.auth_config)): configpath = os.path.expanduser(args.auth_config)
config.read(os.path.expanduser(args.auth_config)) if os.path.isfile(configpath):
if os.stat(configpath).st_mode & stat.S_IRWXO:
self.error(f"Config file is readable by others. Please set it at least to 660.")
config.read(configpath)
def load_configoption(option): def load_configoption(option):
if getattr(args, option) is None: if getattr(args, option) is None:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment