From ec47fe12a989de695f9fbc2840aa43e6b6f31c72 Mon Sep 17 00:00:00 2001 From: Lars Karlitski Date: Mon, 24 Sep 2018 09:09:49 +0200 Subject: [PATCH] cli: Clarify error message for unprivileged access `os.path.exists("/run/weldr/api.socket")` returns False for users which have no access. This leads to composer printing that the file does not exist, which is misleading. Since it's no possible to distinguish the two cases, fix this problem by combining them and showing a single error message. --- src/bin/composer | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/bin/composer b/src/bin/composer index 4914f4a2..194f8282 100755 --- a/src/bin/composer +++ b/src/bin/composer @@ -81,10 +81,9 @@ if __name__ == '__main__': errors = [] # Check to see if the socket exists and can be accessed - if not os.path.exists(opts.socket): - errors.append("%s does not exist" % opts.socket) - elif not os.access(opts.socket, os.R_OK|os.W_OK): - errors.append("This user cannot access %s" % opts.socket) + if not os.access(opts.socket, os.R_OK|os.W_OK): + errors.append("Cannot access '%s'. Is lorax-composer running and " + "this user allowed to access it?" % opts.socket) # No point in continuing if there are errors if errors: