diff -Nru ceph-15.2.13/debian/changelog ceph-15.2.13/debian/changelog --- ceph-15.2.13/debian/changelog 2021-07-26 10:25:32.000000000 +0000 +++ ceph-15.2.13/debian/changelog 2021-08-06 13:04:10.000000000 +0000 @@ -1,3 +1,10 @@ +ceph (15.2.13-0ubuntu0.20.04.3) UNRELEASED; urgency=medium + [ Nikhil Kshirsagar ] + * d/p/1914584_new.patch: Improve diagnostic when reusing email + (LP: #1914584) + + -- nikhil Fri, 06 Aug 2021 18:34:10 +0530 + ceph (15.2.13-0ubuntu0.20.04.2) focal; urgency=medium [ Chris MacNaughton ] diff -Nru ceph-15.2.13/debian/patches/1914584_new.patch ceph-15.2.13/debian/patches/1914584_new.patch --- ceph-15.2.13/debian/patches/1914584_new.patch 1970-01-01 00:00:00.000000000 +0000 +++ ceph-15.2.13/debian/patches/1914584_new.patch 2021-08-06 13:03:40.000000000 +0000 @@ -0,0 +1,208 @@ +Description: Improve diagnostic when reusing email. + The error message if you try and create an S3 user with + an email address that is already associated with another + S3 account is very confusing. + +Author: Nikhil Kshirsagar, nkshirsagar@gmail.com +Origin: upstream, https://github.com/ceph/ceph/pull/41784 +Bug: https://tracker.ceph.com/issues/49137 +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/ceph/+bug/1914584 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +Index: ceph-15.2.13/src/rgw/rgw_user.cc +=================================================================== +--- ceph-15.2.13.orig/src/rgw/rgw_user.cc ++++ ceph-15.2.13/src/rgw/rgw_user.cc +@@ -326,7 +326,7 @@ static void set_err_msg(std::string *sin + /* + * Dump either the full user info or a subset to a formatter. + * +- * NOTE: It is the caller's respnsibility to ensure that the ++ * NOTE: It is the caller's responsibility to ensure that the + * formatter is flushed at the correct time. + */ + +@@ -441,6 +441,43 @@ static void dump_user_info(Formatter *f, + f->close_section(); + } + ++static int user_add_helper(RGWUserAdminOpState& op_state, std::string *err_msg) ++{ ++ int ret = 0; ++ const rgw_user& uid = op_state.get_user_id(); ++ std::string user_email = op_state.get_user_email(); ++ std::string display_name = op_state.get_display_name(); ++ ++ // fail if the user exists already ++ if (op_state.has_existing_user()) { ++ if (op_state.found_by_email) { ++ set_err_msg(err_msg, "email: " + user_email + ++ " is the email address of an existing user"); ++ ret = -ERR_EMAIL_EXIST; ++ } else if (op_state.found_by_key) { ++ set_err_msg(err_msg, "duplicate key provided"); ++ ret = -ERR_KEY_EXIST; ++ } else { ++ set_err_msg(err_msg, "user: " + uid.to_str() + " exists"); ++ ret = -EEXIST; ++ } ++ return ret; ++ } ++ ++ // fail if the user_info has already been populated ++ if (op_state.is_populated()) { ++ set_err_msg(err_msg, "cannot overwrite already populated user"); ++ return -EEXIST; ++ } ++ ++ // fail if the display name was not included ++ if (display_name.empty()) { ++ set_err_msg(err_msg, "no display name specified"); ++ return -EINVAL; ++ } ++ ++ return ret; ++} + + RGWAccessKeyPool::RGWAccessKeyPool(RGWUser* usr) + { +@@ -1028,7 +1065,7 @@ int RGWSubUserPool::check_op(RGWUserAdmi + } + + if (op_state.get_subuser_perm() == RGW_PERM_INVALID) { +- set_err_msg(err_msg, "invaild subuser access"); ++ set_err_msg(err_msg, "invalid subuser access"); + return -EINVAL; + } + +@@ -1530,28 +1567,21 @@ int RGWUser::update(RGWUserAdminOpState& + + int RGWUser::check_op(RGWUserAdminOpState& op_state, std::string *err_msg) + { +- bool same_id; +- bool populated; +- rgw_user& op_id = op_state.get_user_id(); +- +- RGWUserInfo user_info; +- +- same_id = (user_id.compare(op_id) == 0); +- populated = is_populated(); ++ int ret = 0; ++ const rgw_user& uid = op_state.get_user_id(); + +- if (op_id.compare(RGW_USER_ANON_ID) == 0) { ++ if (uid.compare(RGW_USER_ANON_ID) == 0) { + set_err_msg(err_msg, "unable to perform operations on the anonymous user"); + return -EINVAL; + } +- +- if (populated && !same_id) { +- set_err_msg(err_msg, "user id mismatch, operation id: " + op_id.to_str() +- + " does not match: " + user_id.to_str()); ++ if (is_populated() && user_id.compare(uid) != 0) { ++ set_err_msg(err_msg, "user id mismatch, operation id: " + uid.to_str() ++ + " does not match: " + user_id.to_str()); + + return -EINVAL; + } + +- int ret = rgw_validate_tenant_name(op_id.tenant); ++ ret = rgw_validate_tenant_name(uid.tenant); + if (ret) { + set_err_msg(err_msg, + "invalid tenant only alphanumeric and _ characters are allowed"); +@@ -1691,46 +1721,13 @@ int RGWUser::execute_rename(RGWUserAdmin + + int RGWUser::execute_add(RGWUserAdminOpState& op_state, std::string *err_msg) + { +- std::string subprocess_msg; +- int ret = 0; +- bool defer_user_update = true; +- +- RGWUserInfo user_info; + + rgw_user& uid = op_state.get_user_id(); + std::string user_email = op_state.get_user_email(); + std::string display_name = op_state.get_display_name(); + +- // fail if the user exists already +- if (op_state.has_existing_user()) { +- if (op_state.found_by_email) { +- set_err_msg(err_msg, "email: " + user_email + +- " is the email address an existing user"); +- ret = -ERR_EMAIL_EXIST; +- } else if (op_state.found_by_key) { +- set_err_msg(err_msg, "duplicate key provided"); +- ret = -ERR_KEY_EXIST; +- } else { +- set_err_msg(err_msg, "user: " + op_state.user_id.to_str() + " exists"); +- ret = -EEXIST; +- } +- return ret; +- } +- +- // fail if the user_info has already been populated +- if (op_state.is_populated()) { +- set_err_msg(err_msg, "cannot overwrite already populated user"); +- return -EEXIST; +- } +- +- // fail if the display name was not included +- if (display_name.empty()) { +- set_err_msg(err_msg, "no display name specified"); +- return -EINVAL; +- } +- +- + // set the user info ++ RGWUserInfo user_info; + user_id = uid; + user_info.user_id = user_id; + user_info.display_name = display_name; +@@ -1787,13 +1784,16 @@ int RGWUser::execute_add(RGWUserAdminOpS + op_state.set_populated(); + + // update the helper objects +- ret = init_members(op_state); ++ int ret = init_members(op_state); + if (ret < 0) { + set_err_msg(err_msg, "unable to initialize user"); + return ret; + } ++ + + // see if we need to add an access key ++ std::string subprocess_msg; ++ bool defer_user_update = true; + if (op_state.has_key_op()) { + ret = keys.add(op_state, &subprocess_msg, defer_user_update); + if (ret < 0) { +@@ -1822,7 +1822,11 @@ int RGWUser::execute_add(RGWUserAdminOpS + int RGWUser::add(RGWUserAdminOpState& op_state, std::string *err_msg) + { + std::string subprocess_msg; +- int ret; ++ int ret = user_add_helper(op_state, &subprocess_msg); ++ if (ret != 0) { ++ set_err_msg(err_msg, "unable to parse parameters, " + subprocess_msg); ++ return ret; ++ } + + ret = check_op(op_state, &subprocess_msg); + if (ret < 0) { +@@ -2096,14 +2100,7 @@ int RGWUser::modify(RGWUserAdminOpState& + + ret = check_op(op_state, &subprocess_msg); + if (ret < 0) { +- if (is_populated() && (user_id.compare(op_state.get_user_id()) != 0)) { +- set_err_msg(err_msg, "unable to create user " + user_id.to_str() +- + " because user id " + op_state.get_user_id().to_str() +- + " already exists with email " +- + op_state.get_user_email()); +- } else { +- set_err_msg(err_msg, "unable to parse parameters, " + subprocess_msg); +- } ++ set_err_msg(err_msg, "unable to parse parameters, " + subprocess_msg); + return ret; + } + diff -Nru ceph-15.2.13/debian/patches/series ceph-15.2.13/debian/patches/series --- ceph-15.2.13/debian/patches/series 2021-07-26 10:25:09.000000000 +0000 +++ ceph-15.2.13/debian/patches/series 2021-08-06 12:57:48.000000000 +0000 @@ -12,3 +12,4 @@ disable-log-slow-requests.patch # AARCH64 EC regression bug1917414.patch +1914584_new.patch diff -Nru ceph-15.2.13/src/test/debian-jessie/debian/changelog ceph-15.2.13/src/test/debian-jessie/debian/changelog --- ceph-15.2.13/src/test/debian-jessie/debian/changelog 2021-07-26 10:25:32.000000000 +0000 +++ ceph-15.2.13/src/test/debian-jessie/debian/changelog 2021-08-06 13:04:10.000000000 +0000 @@ -1,3 +1,10 @@ +ceph (15.2.13-0ubuntu0.20.04.3) UNRELEASED; urgency=medium + [ Nikhil Kshirsagar ] + * d/p/1914584_new.patch: Improve diagnostic when reusing email + (LP: #1914584) + + -- nikhil Fri, 06 Aug 2021 18:34:10 +0530 + ceph (15.2.13-0ubuntu0.20.04.2) focal; urgency=medium [ Chris MacNaughton ] diff -Nru ceph-15.2.13/src/test/debian-jessie/debian/patches/1914584_new.patch ceph-15.2.13/src/test/debian-jessie/debian/patches/1914584_new.patch --- ceph-15.2.13/src/test/debian-jessie/debian/patches/1914584_new.patch 1970-01-01 00:00:00.000000000 +0000 +++ ceph-15.2.13/src/test/debian-jessie/debian/patches/1914584_new.patch 2021-08-06 13:03:40.000000000 +0000 @@ -0,0 +1,208 @@ +Description: Improve diagnostic when reusing email. + The error message if you try and create an S3 user with + an email address that is already associated with another + S3 account is very confusing. + +Author: Nikhil Kshirsagar, nkshirsagar@gmail.com +Origin: upstream, https://github.com/ceph/ceph/pull/41784 +Bug: https://tracker.ceph.com/issues/49137 +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/ceph/+bug/1914584 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +Index: ceph-15.2.13/src/rgw/rgw_user.cc +=================================================================== +--- ceph-15.2.13.orig/src/rgw/rgw_user.cc ++++ ceph-15.2.13/src/rgw/rgw_user.cc +@@ -326,7 +326,7 @@ static void set_err_msg(std::string *sin + /* + * Dump either the full user info or a subset to a formatter. + * +- * NOTE: It is the caller's respnsibility to ensure that the ++ * NOTE: It is the caller's responsibility to ensure that the + * formatter is flushed at the correct time. + */ + +@@ -441,6 +441,43 @@ static void dump_user_info(Formatter *f, + f->close_section(); + } + ++static int user_add_helper(RGWUserAdminOpState& op_state, std::string *err_msg) ++{ ++ int ret = 0; ++ const rgw_user& uid = op_state.get_user_id(); ++ std::string user_email = op_state.get_user_email(); ++ std::string display_name = op_state.get_display_name(); ++ ++ // fail if the user exists already ++ if (op_state.has_existing_user()) { ++ if (op_state.found_by_email) { ++ set_err_msg(err_msg, "email: " + user_email + ++ " is the email address of an existing user"); ++ ret = -ERR_EMAIL_EXIST; ++ } else if (op_state.found_by_key) { ++ set_err_msg(err_msg, "duplicate key provided"); ++ ret = -ERR_KEY_EXIST; ++ } else { ++ set_err_msg(err_msg, "user: " + uid.to_str() + " exists"); ++ ret = -EEXIST; ++ } ++ return ret; ++ } ++ ++ // fail if the user_info has already been populated ++ if (op_state.is_populated()) { ++ set_err_msg(err_msg, "cannot overwrite already populated user"); ++ return -EEXIST; ++ } ++ ++ // fail if the display name was not included ++ if (display_name.empty()) { ++ set_err_msg(err_msg, "no display name specified"); ++ return -EINVAL; ++ } ++ ++ return ret; ++} + + RGWAccessKeyPool::RGWAccessKeyPool(RGWUser* usr) + { +@@ -1028,7 +1065,7 @@ int RGWSubUserPool::check_op(RGWUserAdmi + } + + if (op_state.get_subuser_perm() == RGW_PERM_INVALID) { +- set_err_msg(err_msg, "invaild subuser access"); ++ set_err_msg(err_msg, "invalid subuser access"); + return -EINVAL; + } + +@@ -1530,28 +1567,21 @@ int RGWUser::update(RGWUserAdminOpState& + + int RGWUser::check_op(RGWUserAdminOpState& op_state, std::string *err_msg) + { +- bool same_id; +- bool populated; +- rgw_user& op_id = op_state.get_user_id(); +- +- RGWUserInfo user_info; +- +- same_id = (user_id.compare(op_id) == 0); +- populated = is_populated(); ++ int ret = 0; ++ const rgw_user& uid = op_state.get_user_id(); + +- if (op_id.compare(RGW_USER_ANON_ID) == 0) { ++ if (uid.compare(RGW_USER_ANON_ID) == 0) { + set_err_msg(err_msg, "unable to perform operations on the anonymous user"); + return -EINVAL; + } +- +- if (populated && !same_id) { +- set_err_msg(err_msg, "user id mismatch, operation id: " + op_id.to_str() +- + " does not match: " + user_id.to_str()); ++ if (is_populated() && user_id.compare(uid) != 0) { ++ set_err_msg(err_msg, "user id mismatch, operation id: " + uid.to_str() ++ + " does not match: " + user_id.to_str()); + + return -EINVAL; + } + +- int ret = rgw_validate_tenant_name(op_id.tenant); ++ ret = rgw_validate_tenant_name(uid.tenant); + if (ret) { + set_err_msg(err_msg, + "invalid tenant only alphanumeric and _ characters are allowed"); +@@ -1691,46 +1721,13 @@ int RGWUser::execute_rename(RGWUserAdmin + + int RGWUser::execute_add(RGWUserAdminOpState& op_state, std::string *err_msg) + { +- std::string subprocess_msg; +- int ret = 0; +- bool defer_user_update = true; +- +- RGWUserInfo user_info; + + rgw_user& uid = op_state.get_user_id(); + std::string user_email = op_state.get_user_email(); + std::string display_name = op_state.get_display_name(); + +- // fail if the user exists already +- if (op_state.has_existing_user()) { +- if (op_state.found_by_email) { +- set_err_msg(err_msg, "email: " + user_email + +- " is the email address an existing user"); +- ret = -ERR_EMAIL_EXIST; +- } else if (op_state.found_by_key) { +- set_err_msg(err_msg, "duplicate key provided"); +- ret = -ERR_KEY_EXIST; +- } else { +- set_err_msg(err_msg, "user: " + op_state.user_id.to_str() + " exists"); +- ret = -EEXIST; +- } +- return ret; +- } +- +- // fail if the user_info has already been populated +- if (op_state.is_populated()) { +- set_err_msg(err_msg, "cannot overwrite already populated user"); +- return -EEXIST; +- } +- +- // fail if the display name was not included +- if (display_name.empty()) { +- set_err_msg(err_msg, "no display name specified"); +- return -EINVAL; +- } +- +- + // set the user info ++ RGWUserInfo user_info; + user_id = uid; + user_info.user_id = user_id; + user_info.display_name = display_name; +@@ -1787,13 +1784,16 @@ int RGWUser::execute_add(RGWUserAdminOpS + op_state.set_populated(); + + // update the helper objects +- ret = init_members(op_state); ++ int ret = init_members(op_state); + if (ret < 0) { + set_err_msg(err_msg, "unable to initialize user"); + return ret; + } ++ + + // see if we need to add an access key ++ std::string subprocess_msg; ++ bool defer_user_update = true; + if (op_state.has_key_op()) { + ret = keys.add(op_state, &subprocess_msg, defer_user_update); + if (ret < 0) { +@@ -1822,7 +1822,11 @@ int RGWUser::execute_add(RGWUserAdminOpS + int RGWUser::add(RGWUserAdminOpState& op_state, std::string *err_msg) + { + std::string subprocess_msg; +- int ret; ++ int ret = user_add_helper(op_state, &subprocess_msg); ++ if (ret != 0) { ++ set_err_msg(err_msg, "unable to parse parameters, " + subprocess_msg); ++ return ret; ++ } + + ret = check_op(op_state, &subprocess_msg); + if (ret < 0) { +@@ -2096,14 +2100,7 @@ int RGWUser::modify(RGWUserAdminOpState& + + ret = check_op(op_state, &subprocess_msg); + if (ret < 0) { +- if (is_populated() && (user_id.compare(op_state.get_user_id()) != 0)) { +- set_err_msg(err_msg, "unable to create user " + user_id.to_str() +- + " because user id " + op_state.get_user_id().to_str() +- + " already exists with email " +- + op_state.get_user_email()); +- } else { +- set_err_msg(err_msg, "unable to parse parameters, " + subprocess_msg); +- } ++ set_err_msg(err_msg, "unable to parse parameters, " + subprocess_msg); + return ret; + } + diff -Nru ceph-15.2.13/src/test/debian-jessie/debian/patches/series ceph-15.2.13/src/test/debian-jessie/debian/patches/series --- ceph-15.2.13/src/test/debian-jessie/debian/patches/series 2021-07-26 10:25:09.000000000 +0000 +++ ceph-15.2.13/src/test/debian-jessie/debian/patches/series 2021-08-06 12:57:48.000000000 +0000 @@ -12,3 +12,4 @@ disable-log-slow-requests.patch # AARCH64 EC regression bug1917414.patch +1914584_new.patch diff -Nru ceph-15.2.13/src/test/ubuntu-16.04/debian/changelog ceph-15.2.13/src/test/ubuntu-16.04/debian/changelog --- ceph-15.2.13/src/test/ubuntu-16.04/debian/changelog 2021-07-26 10:25:32.000000000 +0000 +++ ceph-15.2.13/src/test/ubuntu-16.04/debian/changelog 2021-08-06 13:04:10.000000000 +0000 @@ -1,3 +1,10 @@ +ceph (15.2.13-0ubuntu0.20.04.3) UNRELEASED; urgency=medium + [ Nikhil Kshirsagar ] + * d/p/1914584_new.patch: Improve diagnostic when reusing email + (LP: #1914584) + + -- nikhil Fri, 06 Aug 2021 18:34:10 +0530 + ceph (15.2.13-0ubuntu0.20.04.2) focal; urgency=medium [ Chris MacNaughton ] diff -Nru ceph-15.2.13/src/test/ubuntu-16.04/debian/patches/1914584_new.patch ceph-15.2.13/src/test/ubuntu-16.04/debian/patches/1914584_new.patch --- ceph-15.2.13/src/test/ubuntu-16.04/debian/patches/1914584_new.patch 1970-01-01 00:00:00.000000000 +0000 +++ ceph-15.2.13/src/test/ubuntu-16.04/debian/patches/1914584_new.patch 2021-08-06 13:03:40.000000000 +0000 @@ -0,0 +1,208 @@ +Description: Improve diagnostic when reusing email. + The error message if you try and create an S3 user with + an email address that is already associated with another + S3 account is very confusing. + +Author: Nikhil Kshirsagar, nkshirsagar@gmail.com +Origin: upstream, https://github.com/ceph/ceph/pull/41784 +Bug: https://tracker.ceph.com/issues/49137 +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/ceph/+bug/1914584 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +Index: ceph-15.2.13/src/rgw/rgw_user.cc +=================================================================== +--- ceph-15.2.13.orig/src/rgw/rgw_user.cc ++++ ceph-15.2.13/src/rgw/rgw_user.cc +@@ -326,7 +326,7 @@ static void set_err_msg(std::string *sin + /* + * Dump either the full user info or a subset to a formatter. + * +- * NOTE: It is the caller's respnsibility to ensure that the ++ * NOTE: It is the caller's responsibility to ensure that the + * formatter is flushed at the correct time. + */ + +@@ -441,6 +441,43 @@ static void dump_user_info(Formatter *f, + f->close_section(); + } + ++static int user_add_helper(RGWUserAdminOpState& op_state, std::string *err_msg) ++{ ++ int ret = 0; ++ const rgw_user& uid = op_state.get_user_id(); ++ std::string user_email = op_state.get_user_email(); ++ std::string display_name = op_state.get_display_name(); ++ ++ // fail if the user exists already ++ if (op_state.has_existing_user()) { ++ if (op_state.found_by_email) { ++ set_err_msg(err_msg, "email: " + user_email + ++ " is the email address of an existing user"); ++ ret = -ERR_EMAIL_EXIST; ++ } else if (op_state.found_by_key) { ++ set_err_msg(err_msg, "duplicate key provided"); ++ ret = -ERR_KEY_EXIST; ++ } else { ++ set_err_msg(err_msg, "user: " + uid.to_str() + " exists"); ++ ret = -EEXIST; ++ } ++ return ret; ++ } ++ ++ // fail if the user_info has already been populated ++ if (op_state.is_populated()) { ++ set_err_msg(err_msg, "cannot overwrite already populated user"); ++ return -EEXIST; ++ } ++ ++ // fail if the display name was not included ++ if (display_name.empty()) { ++ set_err_msg(err_msg, "no display name specified"); ++ return -EINVAL; ++ } ++ ++ return ret; ++} + + RGWAccessKeyPool::RGWAccessKeyPool(RGWUser* usr) + { +@@ -1028,7 +1065,7 @@ int RGWSubUserPool::check_op(RGWUserAdmi + } + + if (op_state.get_subuser_perm() == RGW_PERM_INVALID) { +- set_err_msg(err_msg, "invaild subuser access"); ++ set_err_msg(err_msg, "invalid subuser access"); + return -EINVAL; + } + +@@ -1530,28 +1567,21 @@ int RGWUser::update(RGWUserAdminOpState& + + int RGWUser::check_op(RGWUserAdminOpState& op_state, std::string *err_msg) + { +- bool same_id; +- bool populated; +- rgw_user& op_id = op_state.get_user_id(); +- +- RGWUserInfo user_info; +- +- same_id = (user_id.compare(op_id) == 0); +- populated = is_populated(); ++ int ret = 0; ++ const rgw_user& uid = op_state.get_user_id(); + +- if (op_id.compare(RGW_USER_ANON_ID) == 0) { ++ if (uid.compare(RGW_USER_ANON_ID) == 0) { + set_err_msg(err_msg, "unable to perform operations on the anonymous user"); + return -EINVAL; + } +- +- if (populated && !same_id) { +- set_err_msg(err_msg, "user id mismatch, operation id: " + op_id.to_str() +- + " does not match: " + user_id.to_str()); ++ if (is_populated() && user_id.compare(uid) != 0) { ++ set_err_msg(err_msg, "user id mismatch, operation id: " + uid.to_str() ++ + " does not match: " + user_id.to_str()); + + return -EINVAL; + } + +- int ret = rgw_validate_tenant_name(op_id.tenant); ++ ret = rgw_validate_tenant_name(uid.tenant); + if (ret) { + set_err_msg(err_msg, + "invalid tenant only alphanumeric and _ characters are allowed"); +@@ -1691,46 +1721,13 @@ int RGWUser::execute_rename(RGWUserAdmin + + int RGWUser::execute_add(RGWUserAdminOpState& op_state, std::string *err_msg) + { +- std::string subprocess_msg; +- int ret = 0; +- bool defer_user_update = true; +- +- RGWUserInfo user_info; + + rgw_user& uid = op_state.get_user_id(); + std::string user_email = op_state.get_user_email(); + std::string display_name = op_state.get_display_name(); + +- // fail if the user exists already +- if (op_state.has_existing_user()) { +- if (op_state.found_by_email) { +- set_err_msg(err_msg, "email: " + user_email + +- " is the email address an existing user"); +- ret = -ERR_EMAIL_EXIST; +- } else if (op_state.found_by_key) { +- set_err_msg(err_msg, "duplicate key provided"); +- ret = -ERR_KEY_EXIST; +- } else { +- set_err_msg(err_msg, "user: " + op_state.user_id.to_str() + " exists"); +- ret = -EEXIST; +- } +- return ret; +- } +- +- // fail if the user_info has already been populated +- if (op_state.is_populated()) { +- set_err_msg(err_msg, "cannot overwrite already populated user"); +- return -EEXIST; +- } +- +- // fail if the display name was not included +- if (display_name.empty()) { +- set_err_msg(err_msg, "no display name specified"); +- return -EINVAL; +- } +- +- + // set the user info ++ RGWUserInfo user_info; + user_id = uid; + user_info.user_id = user_id; + user_info.display_name = display_name; +@@ -1787,13 +1784,16 @@ int RGWUser::execute_add(RGWUserAdminOpS + op_state.set_populated(); + + // update the helper objects +- ret = init_members(op_state); ++ int ret = init_members(op_state); + if (ret < 0) { + set_err_msg(err_msg, "unable to initialize user"); + return ret; + } ++ + + // see if we need to add an access key ++ std::string subprocess_msg; ++ bool defer_user_update = true; + if (op_state.has_key_op()) { + ret = keys.add(op_state, &subprocess_msg, defer_user_update); + if (ret < 0) { +@@ -1822,7 +1822,11 @@ int RGWUser::execute_add(RGWUserAdminOpS + int RGWUser::add(RGWUserAdminOpState& op_state, std::string *err_msg) + { + std::string subprocess_msg; +- int ret; ++ int ret = user_add_helper(op_state, &subprocess_msg); ++ if (ret != 0) { ++ set_err_msg(err_msg, "unable to parse parameters, " + subprocess_msg); ++ return ret; ++ } + + ret = check_op(op_state, &subprocess_msg); + if (ret < 0) { +@@ -2096,14 +2100,7 @@ int RGWUser::modify(RGWUserAdminOpState& + + ret = check_op(op_state, &subprocess_msg); + if (ret < 0) { +- if (is_populated() && (user_id.compare(op_state.get_user_id()) != 0)) { +- set_err_msg(err_msg, "unable to create user " + user_id.to_str() +- + " because user id " + op_state.get_user_id().to_str() +- + " already exists with email " +- + op_state.get_user_email()); +- } else { +- set_err_msg(err_msg, "unable to parse parameters, " + subprocess_msg); +- } ++ set_err_msg(err_msg, "unable to parse parameters, " + subprocess_msg); + return ret; + } + diff -Nru ceph-15.2.13/src/test/ubuntu-16.04/debian/patches/series ceph-15.2.13/src/test/ubuntu-16.04/debian/patches/series --- ceph-15.2.13/src/test/ubuntu-16.04/debian/patches/series 2021-07-26 10:25:09.000000000 +0000 +++ ceph-15.2.13/src/test/ubuntu-16.04/debian/patches/series 2021-08-06 12:57:48.000000000 +0000 @@ -12,3 +12,4 @@ disable-log-slow-requests.patch # AARCH64 EC regression bug1917414.patch +1914584_new.patch diff -Nru ceph-15.2.13/src/test/ubuntu-18.04/debian/changelog ceph-15.2.13/src/test/ubuntu-18.04/debian/changelog --- ceph-15.2.13/src/test/ubuntu-18.04/debian/changelog 2021-07-26 10:25:32.000000000 +0000 +++ ceph-15.2.13/src/test/ubuntu-18.04/debian/changelog 2021-08-06 13:04:10.000000000 +0000 @@ -1,3 +1,10 @@ +ceph (15.2.13-0ubuntu0.20.04.3) UNRELEASED; urgency=medium + [ Nikhil Kshirsagar ] + * d/p/1914584_new.patch: Improve diagnostic when reusing email + (LP: #1914584) + + -- nikhil Fri, 06 Aug 2021 18:34:10 +0530 + ceph (15.2.13-0ubuntu0.20.04.2) focal; urgency=medium [ Chris MacNaughton ] diff -Nru ceph-15.2.13/src/test/ubuntu-18.04/debian/patches/1914584_new.patch ceph-15.2.13/src/test/ubuntu-18.04/debian/patches/1914584_new.patch --- ceph-15.2.13/src/test/ubuntu-18.04/debian/patches/1914584_new.patch 1970-01-01 00:00:00.000000000 +0000 +++ ceph-15.2.13/src/test/ubuntu-18.04/debian/patches/1914584_new.patch 2021-08-06 13:03:40.000000000 +0000 @@ -0,0 +1,208 @@ +Description: Improve diagnostic when reusing email. + The error message if you try and create an S3 user with + an email address that is already associated with another + S3 account is very confusing. + +Author: Nikhil Kshirsagar, nkshirsagar@gmail.com +Origin: upstream, https://github.com/ceph/ceph/pull/41784 +Bug: https://tracker.ceph.com/issues/49137 +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/ceph/+bug/1914584 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +Index: ceph-15.2.13/src/rgw/rgw_user.cc +=================================================================== +--- ceph-15.2.13.orig/src/rgw/rgw_user.cc ++++ ceph-15.2.13/src/rgw/rgw_user.cc +@@ -326,7 +326,7 @@ static void set_err_msg(std::string *sin + /* + * Dump either the full user info or a subset to a formatter. + * +- * NOTE: It is the caller's respnsibility to ensure that the ++ * NOTE: It is the caller's responsibility to ensure that the + * formatter is flushed at the correct time. + */ + +@@ -441,6 +441,43 @@ static void dump_user_info(Formatter *f, + f->close_section(); + } + ++static int user_add_helper(RGWUserAdminOpState& op_state, std::string *err_msg) ++{ ++ int ret = 0; ++ const rgw_user& uid = op_state.get_user_id(); ++ std::string user_email = op_state.get_user_email(); ++ std::string display_name = op_state.get_display_name(); ++ ++ // fail if the user exists already ++ if (op_state.has_existing_user()) { ++ if (op_state.found_by_email) { ++ set_err_msg(err_msg, "email: " + user_email + ++ " is the email address of an existing user"); ++ ret = -ERR_EMAIL_EXIST; ++ } else if (op_state.found_by_key) { ++ set_err_msg(err_msg, "duplicate key provided"); ++ ret = -ERR_KEY_EXIST; ++ } else { ++ set_err_msg(err_msg, "user: " + uid.to_str() + " exists"); ++ ret = -EEXIST; ++ } ++ return ret; ++ } ++ ++ // fail if the user_info has already been populated ++ if (op_state.is_populated()) { ++ set_err_msg(err_msg, "cannot overwrite already populated user"); ++ return -EEXIST; ++ } ++ ++ // fail if the display name was not included ++ if (display_name.empty()) { ++ set_err_msg(err_msg, "no display name specified"); ++ return -EINVAL; ++ } ++ ++ return ret; ++} + + RGWAccessKeyPool::RGWAccessKeyPool(RGWUser* usr) + { +@@ -1028,7 +1065,7 @@ int RGWSubUserPool::check_op(RGWUserAdmi + } + + if (op_state.get_subuser_perm() == RGW_PERM_INVALID) { +- set_err_msg(err_msg, "invaild subuser access"); ++ set_err_msg(err_msg, "invalid subuser access"); + return -EINVAL; + } + +@@ -1530,28 +1567,21 @@ int RGWUser::update(RGWUserAdminOpState& + + int RGWUser::check_op(RGWUserAdminOpState& op_state, std::string *err_msg) + { +- bool same_id; +- bool populated; +- rgw_user& op_id = op_state.get_user_id(); +- +- RGWUserInfo user_info; +- +- same_id = (user_id.compare(op_id) == 0); +- populated = is_populated(); ++ int ret = 0; ++ const rgw_user& uid = op_state.get_user_id(); + +- if (op_id.compare(RGW_USER_ANON_ID) == 0) { ++ if (uid.compare(RGW_USER_ANON_ID) == 0) { + set_err_msg(err_msg, "unable to perform operations on the anonymous user"); + return -EINVAL; + } +- +- if (populated && !same_id) { +- set_err_msg(err_msg, "user id mismatch, operation id: " + op_id.to_str() +- + " does not match: " + user_id.to_str()); ++ if (is_populated() && user_id.compare(uid) != 0) { ++ set_err_msg(err_msg, "user id mismatch, operation id: " + uid.to_str() ++ + " does not match: " + user_id.to_str()); + + return -EINVAL; + } + +- int ret = rgw_validate_tenant_name(op_id.tenant); ++ ret = rgw_validate_tenant_name(uid.tenant); + if (ret) { + set_err_msg(err_msg, + "invalid tenant only alphanumeric and _ characters are allowed"); +@@ -1691,46 +1721,13 @@ int RGWUser::execute_rename(RGWUserAdmin + + int RGWUser::execute_add(RGWUserAdminOpState& op_state, std::string *err_msg) + { +- std::string subprocess_msg; +- int ret = 0; +- bool defer_user_update = true; +- +- RGWUserInfo user_info; + + rgw_user& uid = op_state.get_user_id(); + std::string user_email = op_state.get_user_email(); + std::string display_name = op_state.get_display_name(); + +- // fail if the user exists already +- if (op_state.has_existing_user()) { +- if (op_state.found_by_email) { +- set_err_msg(err_msg, "email: " + user_email + +- " is the email address an existing user"); +- ret = -ERR_EMAIL_EXIST; +- } else if (op_state.found_by_key) { +- set_err_msg(err_msg, "duplicate key provided"); +- ret = -ERR_KEY_EXIST; +- } else { +- set_err_msg(err_msg, "user: " + op_state.user_id.to_str() + " exists"); +- ret = -EEXIST; +- } +- return ret; +- } +- +- // fail if the user_info has already been populated +- if (op_state.is_populated()) { +- set_err_msg(err_msg, "cannot overwrite already populated user"); +- return -EEXIST; +- } +- +- // fail if the display name was not included +- if (display_name.empty()) { +- set_err_msg(err_msg, "no display name specified"); +- return -EINVAL; +- } +- +- + // set the user info ++ RGWUserInfo user_info; + user_id = uid; + user_info.user_id = user_id; + user_info.display_name = display_name; +@@ -1787,13 +1784,16 @@ int RGWUser::execute_add(RGWUserAdminOpS + op_state.set_populated(); + + // update the helper objects +- ret = init_members(op_state); ++ int ret = init_members(op_state); + if (ret < 0) { + set_err_msg(err_msg, "unable to initialize user"); + return ret; + } ++ + + // see if we need to add an access key ++ std::string subprocess_msg; ++ bool defer_user_update = true; + if (op_state.has_key_op()) { + ret = keys.add(op_state, &subprocess_msg, defer_user_update); + if (ret < 0) { +@@ -1822,7 +1822,11 @@ int RGWUser::execute_add(RGWUserAdminOpS + int RGWUser::add(RGWUserAdminOpState& op_state, std::string *err_msg) + { + std::string subprocess_msg; +- int ret; ++ int ret = user_add_helper(op_state, &subprocess_msg); ++ if (ret != 0) { ++ set_err_msg(err_msg, "unable to parse parameters, " + subprocess_msg); ++ return ret; ++ } + + ret = check_op(op_state, &subprocess_msg); + if (ret < 0) { +@@ -2096,14 +2100,7 @@ int RGWUser::modify(RGWUserAdminOpState& + + ret = check_op(op_state, &subprocess_msg); + if (ret < 0) { +- if (is_populated() && (user_id.compare(op_state.get_user_id()) != 0)) { +- set_err_msg(err_msg, "unable to create user " + user_id.to_str() +- + " because user id " + op_state.get_user_id().to_str() +- + " already exists with email " +- + op_state.get_user_email()); +- } else { +- set_err_msg(err_msg, "unable to parse parameters, " + subprocess_msg); +- } ++ set_err_msg(err_msg, "unable to parse parameters, " + subprocess_msg); + return ret; + } + diff -Nru ceph-15.2.13/src/test/ubuntu-18.04/debian/patches/series ceph-15.2.13/src/test/ubuntu-18.04/debian/patches/series --- ceph-15.2.13/src/test/ubuntu-18.04/debian/patches/series 2021-07-26 10:25:09.000000000 +0000 +++ ceph-15.2.13/src/test/ubuntu-18.04/debian/patches/series 2021-08-06 12:57:48.000000000 +0000 @@ -12,3 +12,4 @@ disable-log-slow-requests.patch # AARCH64 EC regression bug1917414.patch +1914584_new.patch