The problem is that we use underscore for the raw object name encoding.
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
return 0;
}
+static const char alphanum_no_underscore_table[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-.";
+
+int gen_rand_alphanumeric_no_underscore(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<size - 1; i++) {
+ int pos = (unsigned)dest[i];
+ dest[i] = alphanum_no_underscore_table[pos & 63];
+ }
+ dest[i] = '\0';
+
+ return 0;
+}
+
int NameVal::parse()
{
int delim_pos = str.find('=');
extern int gen_rand_alphanumeric(CephContext *cct, char *dest, int size);
extern int gen_rand_alphanumeric_lower(CephContext *cct, char *dest, int size);
extern int gen_rand_alphanumeric_upper(CephContext *cct, char *dest, int size);
+extern int gen_rand_alphanumeric_no_underscore(CephContext *cct, char *dest, int size);
extern int gen_rand_alphanumeric_lower(CephContext *cct, string *str, int length);
#define OBJ_INSTANCE_LEN 32
char buf[OBJ_INSTANCE_LEN + 1];
- gen_rand_alphanumeric(cct, buf, OBJ_INSTANCE_LEN); /* don't want it to get url escaped */
+ gen_rand_alphanumeric_no_underscore(cct, buf, OBJ_INSTANCE_LEN); /* don't want it to get url escaped,
+ no underscore for instance name due to the way we encode the raw keys */
target_obj->set_instance(buf);
}