canonical / pebble

Take control of your internal daemons!
GNU General Public License v3.0
136 stars 51 forks source link

"pebble pull" gives wrong error in case of access denied #413

Open benhoyt opened 2 months ago

benhoyt commented 2 months ago

When pebble is running as root and you do a pebble pull, the error message is unexpected:

$ PEBBLE=/var/lib/pebble/default/ ./pebble pull /etc/hosts hosts
error: expected a multipart response, got "application/json"

Compare that to what you get with curl:

$ curl --unix-socket /var/lib/pebble/default/.pebble.socket 'http://x/v1/files?action=read&path=/etc/hosts'
{"type":"error","status-code":401,"status":"Unauthorized","result":{"message":"access denied","kind":"login-required"}}

Presumably this is happening because it's checking the media type before checking for an early error response.