From bb40856f3e650c3b0d7ddc22611d8d72d0a3668d 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-cli | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/bin/composer-cli b/src/bin/composer-cli index f42b225b..23171ee9 100755 --- a/src/bin/composer-cli +++ b/src/bin/composer-cli @@ -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: