Compare commits
No commits in common. "5d049390b88f2c81faffb2ef1447a00d782acf0e" and "cd0b2c3e6d6fee6ea9919821b24dc03f8b1d07b9" have entirely different histories.
5d049390b8
...
cd0b2c3e6d
|
@ -6,8 +6,7 @@ use futures_util::{SinkExt, StreamExt};
|
||||||
use crate::core::protocol::{
|
use crate::core::protocol::{
|
||||||
print_create_users_output_status, print_drop_users_output_status,
|
print_create_users_output_status, print_drop_users_output_status,
|
||||||
print_lock_users_output_status, print_set_password_output_status,
|
print_lock_users_output_status, print_set_password_output_status,
|
||||||
print_unlock_users_output_status, ClientToServerMessageStream, ListUsersError, Request,
|
print_unlock_users_output_status, ClientToServerMessageStream, Request, Response,
|
||||||
Response,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::common::erroneous_server_response;
|
use super::common::erroneous_server_response;
|
||||||
|
@ -208,28 +207,6 @@ async fn passwd_user(
|
||||||
args: UserPasswdArgs,
|
args: UserPasswdArgs,
|
||||||
mut server_connection: ClientToServerMessageStream,
|
mut server_connection: ClientToServerMessageStream,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
// TODO: create a "user" exists check" command
|
|
||||||
let message = Request::ListUsers(Some(vec![args.username.clone()]));
|
|
||||||
if let Err(err) = server_connection.send(message).await {
|
|
||||||
server_connection.close().await.ok();
|
|
||||||
anyhow::bail!(err);
|
|
||||||
}
|
|
||||||
let response = match server_connection.next().await {
|
|
||||||
Some(Ok(Response::ListUsers(users))) => users,
|
|
||||||
response => return erroneous_server_response(response),
|
|
||||||
};
|
|
||||||
match response
|
|
||||||
.get(&args.username)
|
|
||||||
.unwrap_or(&Err(ListUsersError::UserDoesNotExist))
|
|
||||||
{
|
|
||||||
Ok(_) => {}
|
|
||||||
Err(err) => {
|
|
||||||
server_connection.send(Request::Exit).await?;
|
|
||||||
server_connection.close().await.ok();
|
|
||||||
anyhow::bail!("{}", err.to_error_message(&args.username));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let password = if let Some(password_file) = args.password_file {
|
let password = if let Some(password_file) = args.password_file {
|
||||||
std::fs::read_to_string(password_file)
|
std::fs::read_to_string(password_file)
|
||||||
.context("Failed to read password file")?
|
.context("Failed to read password file")?
|
||||||
|
|
|
@ -76,7 +76,6 @@ impl OwnerValidationError {
|
||||||
indoc! {r#"
|
indoc! {r#"
|
||||||
Invalid {} name prefix: '{}' does not match your username or any of your groups.
|
Invalid {} name prefix: '{}' does not match your username or any of your groups.
|
||||||
Are you sure you are allowed to create {} names with this prefix?
|
Are you sure you are allowed to create {} names with this prefix?
|
||||||
The format should be: <prefix>_<{} name>
|
|
||||||
|
|
||||||
Allowed prefixes:
|
Allowed prefixes:
|
||||||
- {}
|
- {}
|
||||||
|
@ -85,7 +84,6 @@ impl OwnerValidationError {
|
||||||
db_or_user.lowercased(),
|
db_or_user.lowercased(),
|
||||||
name,
|
name,
|
||||||
db_or_user.lowercased(),
|
db_or_user.lowercased(),
|
||||||
db_or_user.lowercased(),
|
|
||||||
user.as_ref()
|
user.as_ref()
|
||||||
.map(|u| u.username.clone())
|
.map(|u| u.username.clone())
|
||||||
.unwrap_or("???".to_string()),
|
.unwrap_or("???".to_string()),
|
||||||
|
|
|
@ -45,7 +45,7 @@ pub fn validate_ownership_by_prefixes(
|
||||||
|
|
||||||
if prefixes
|
if prefixes
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|p| name.starts_with(&(p.to_string() + "_")))
|
.filter(|p| name.starts_with(*p))
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.is_empty()
|
.is_empty()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue