Only chown recipe directory if it already exists

Since creation of the directory has been moved after switching users
this now needs to check to make sure it exists first.
This commit is contained in:
Brian C. Lane 2018-02-20 09:10:18 -08:00
parent 0e3b87a1da
commit 85ee784efc
1 changed files with 4 additions and 3 deletions

View File

@ -181,9 +181,10 @@ if __name__ == '__main__':
server.config["COMPOSER_CFG"] = configure(conf_file=opts.config)
# Make sure the git repo can be accessed by the API uid/gid
repodir_stat = os.stat(opts.RECIPES)
if repodir_stat.st_gid != gid or repodir_stat.st_uid != uid:
subprocess.call(["chown", "-R", "%s:%s" % (opts.user, opts.group), opts.RECIPES])
if os.path.exists(opts.RECIPES):
repodir_stat = os.stat(opts.RECIPES)
if repodir_stat.st_gid != gid or repodir_stat.st_uid != uid:
subprocess.call(["chown", "-R", "%s:%s" % (opts.user, opts.group), opts.RECIPES])
# If the user passed in a releasever set it in the configuration
if opts.releasever: