Exit on uid/gid errors before checking directory permissions
If the uid/gid check fails there is no sense in trying to examine the ownership or permissions.
This commit is contained in:
parent
5e075f6102
commit
4ae2e1450d
@ -150,6 +150,13 @@ if __name__ == '__main__':
|
||||
except KeyError:
|
||||
errors.append("Missing group '%s'" % opts.group)
|
||||
|
||||
# No point in continuing if there are uid or gid errors
|
||||
if errors:
|
||||
for e in errors:
|
||||
log.error(e)
|
||||
sys.exit(1)
|
||||
|
||||
errors = []
|
||||
# Check the socket path to make sure it exists, and that ownership and permissions are correct.
|
||||
socket_dir = os.path.dirname(opts.socket)
|
||||
if not os.path.exists(socket_dir):
|
||||
@ -164,15 +171,16 @@ if __name__ == '__main__':
|
||||
if sockdir_stat.st_gid != gid or sockdir_stat.st_uid != 0:
|
||||
errors.append("%s should be owned by root:%s" % (socket_dir, opts.group))
|
||||
|
||||
if not os.path.isdir(opts.RECIPES):
|
||||
log.warn("Creating empty recipe directory at %s", opts.RECIPES)
|
||||
os.makedirs(opts.RECIPES)
|
||||
|
||||
# No point in continuing if there are ownership or permission errors
|
||||
if errors:
|
||||
for e in errors:
|
||||
log.error(e)
|
||||
sys.exit(1)
|
||||
|
||||
if not os.path.isdir(opts.RECIPES):
|
||||
log.warn("Creating empty recipe directory at %s", opts.RECIPES)
|
||||
os.makedirs(opts.RECIPES)
|
||||
|
||||
server.config["REPO_DIR"] = opts.RECIPES
|
||||
repo = open_or_create_repo(server.config["REPO_DIR"])
|
||||
server.config["GITLOCK"] = GitLock(repo=repo, lock=Lock(), dir=opts.RECIPES)
|
||||
|
Loading…
Reference in New Issue
Block a user