From 85ee784efc0206703be8de9110b542f515d874ff Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Tue, 20 Feb 2018 09:10:18 -0800 Subject: [PATCH] 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. --- src/sbin/lorax-composer | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/sbin/lorax-composer b/src/sbin/lorax-composer index 87119f3c..437487cd 100755 --- a/src/sbin/lorax-composer +++ b/src/sbin/lorax-composer @@ -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: