commit b03d3325c4a745b8475106f146405d5913a3f589 Author: Alex <alex@alex-macair.(none)> Date: Wed Mar 13 14:35:57 2013 -0400
Add base64 padding in put_reg_base64().
If the base64 encoded registration lacks equal sign padding, add some before sending it off to the registration daemon. Python decoding functions require padding. --- facilitator/fac.py | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/facilitator/fac.py b/facilitator/fac.py index 9d33a3e..d43a522 100644 --- a/facilitator/fac.py +++ b/facilitator/fac.py @@ -274,6 +274,11 @@ def get_reg(facilitator_addr, proxy_addr): def put_reg_base64(b64): """Attempt to add a registration by running a facilitator-reg program locally.""" + # Padding is optional, but the python base64 functions can't + # handle lack of padding. Add it here. Assumes correct encoding. + mod = len(b64) % 4 + if mod != 0: + b64 += (4 - mod) * "=" p = subprocess.Popen(["facilitator-reg"], stdin=subprocess.PIPE) stdout, stderr = p.communicate(b64) return p.returncode == 0