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.
This commit is contained in:
Lars Karlitski 2018-09-24 09:09:49 +02:00 committed by Brian C. Lane
parent c7b4dce2b6
commit ec47fe12a9

View File

@ -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: