From 6b365144862cbd387d8b931939a3dc2cfe17bbbd Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Mon, 20 Jul 2015 20:27:33 -0700 Subject: [PATCH] rgw: avoid using slashes for generated secret keys Just use plain alphanumeric characterset. Fixes: #7647 Signed-off-by: Yehuda Sadeh (cherry picked from commit 3f04a6126fdbfb93304f798da3775c0eec9b7d44) --- src/rgw/rgw_common.cc | 20 ++++++++++++++++++++ src/rgw/rgw_common.h | 1 + src/rgw/rgw_user.cc | 4 ++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index f3988cffd34..c270c6fdb08 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -525,6 +525,26 @@ int gen_rand_alphanumeric_no_underscore(CephContext *cct, char *dest, int size) return 0; } +static const char alphanum_plain_table[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + +int gen_rand_alphanumeric_plain(CephContext *cct, char *dest, int size) /* size should be the required string size + 1 */ +{ + int ret = get_random_bytes(dest, size); + if (ret < 0) { + lderr(cct) << "cannot get random bytes: " << cpp_strerror(-ret) << dendl; + return ret; + } + + int i; + for (i=0; i