1
0
Fork 0
mirror of https://gitlab.redox-os.org/CoffeeCode/redox-ssh.git synced 2025-12-28 15:02:18 +01:00

Cleanup non-destructive warnings

This commit is contained in:
Wildan M 2024-04-16 04:51:10 +07:00
parent 656f021eb9
commit 16a8673948
8 changed files with 18 additions and 31 deletions

View file

@ -6,5 +6,5 @@ use ssh::public_key;
pub fn main() { pub fn main() {
let keypair = (public_key::ED25519.generate_key_pair)(None); let keypair = (public_key::ED25519.generate_key_pair)(None);
let mut buffer = File::create("server.key").unwrap(); let mut buffer = File::create("server.key").unwrap();
keypair.export(&mut buffer); let _ = keypair.export(&mut buffer);
} }

View file

@ -60,7 +60,7 @@ impl<'a> Connection {
} }
} }
pub fn run<S: Read + Write>(&mut self, mut stream: &mut S) -> Result<()> { pub fn run<S: Read + Write>(&mut self, stream: &mut S) -> Result<()> {
self.send_id(stream)?; self.send_id(stream)?;
self.read_id(stream)?; self.read_id(stream)?;
@ -334,7 +334,7 @@ impl<'a> Connection {
if let Some(request) = request { if let Some(request) = request {
let mut channel = self.channels.get_mut(&channel_id).unwrap(); let channel = self.channels.get_mut(&channel_id).unwrap();
channel.request(request); channel.request(request);
} }
else { else {
@ -356,7 +356,7 @@ impl<'a> Connection {
let channel_id = reader.read_uint32()?; let channel_id = reader.read_uint32()?;
let data = reader.read_string()?; let data = reader.read_string()?;
let mut channel = self.channels.get_mut(&channel_id).unwrap(); let channel = self.channels.get_mut(&channel_id).unwrap();
channel.data(data.as_slice())?; channel.data(data.as_slice())?;
Ok(None) Ok(None)
@ -403,7 +403,7 @@ impl<'a> Connection {
self.hash_data.client_kexinit = Some(packet.payload()); self.hash_data.client_kexinit = Some(packet.payload());
// Create a random 16 byte cookie // Create a random 16 byte cookie
use rand::{self, Rng}; use rand::Rng;
let mut rng = rand::thread_rng(); let mut rng = rand::thread_rng();
let cookie: Vec<u8> = rng.gen_iter::<u8>().take(16).collect(); let cookie: Vec<u8> = rng.gen_iter::<u8>().take(16).collect();

View file

@ -1,5 +1,3 @@
use std::convert::From;
use std::error::Error;
use std::fmt; use std::fmt;
use std::io; use std::io;
@ -17,22 +15,16 @@ pub enum ConnectionError {
impl fmt::Display for ConnectionError { impl fmt::Display for ConnectionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "connection error: {}", (self as &Error).description())
}
}
impl Error for ConnectionError {
fn description(&self) -> &str {
use self::ConnectionError::*; use self::ConnectionError::*;
match self write!(f, "connection error: {}", (match &self
{ {
&IoError(_) => "io error", IoError(err) => format!("io error: {}", err),
&ProtocolError => "protocol error", ProtocolError => "protocol error".to_owned(),
&NegotiationError => "negotiation error", NegotiationError => "negotiation error".to_owned(),
&KeyExchangeError => "key exchange error", KeyExchangeError => "key exchange error".to_owned(),
&KeyGenerationError => "key generation error", KeyGenerationError => "key generation error".to_owned(),
&IntegrityError => "integrity error", IntegrityError => "integrity error".to_owned(),
} }))
} }
} }

View file

@ -6,7 +6,7 @@ use key_exchange::{KexResult, KeyExchange};
use message::MessageType; use message::MessageType;
use num_bigint::{BigInt, Sign}; use num_bigint::{BigInt, Sign};
use packet::{Packet, ReadPacketExt, WritePacketExt}; use packet::{Packet, ReadPacketExt, WritePacketExt};
use rand::{self, Rng}; use rand::Rng;
const ECDH_KEX_INIT: u8 = 30; const ECDH_KEX_INIT: u8 = 30;
const ECDH_KEX_REPLY: u8 = 31; const ECDH_KEX_REPLY: u8 = 31;

View file

@ -44,12 +44,12 @@ impl From<u8> for MessageType {
6 => ServiceAccept, 6 => ServiceAccept,
20 => KexInit, 20 => KexInit,
21 => NewKeys, 21 => NewKeys,
30...49 => KeyExchange(id), 30..=49 => KeyExchange(id),
50 => UserAuthRequest, 50 => UserAuthRequest,
51 => UserAuthFailure, 51 => UserAuthFailure,
52 => UserAuthSuccess, 52 => UserAuthSuccess,
53 => UserAuthBanner, 53 => UserAuthBanner,
60...79 => UserAuth(id), 60..=79 => UserAuth(id),
80 => GlobalRequest, 80 => GlobalRequest,
81 => RequestSuccess, 81 => RequestSuccess,
82 => RequestFailure, 82 => RequestFailure,

View file

@ -1,7 +1,6 @@
use std::fmt; use std::fmt;
use std::io::{self, BufReader, Read, Result, Write}; use std::io::{self, BufReader, Read, Result, Write};
use std::str::{self, FromStr}; use std::str::{self, FromStr};
use std::string::ToString;
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};

View file

@ -3,7 +3,7 @@ use std::io::ErrorKind::InvalidData;
use crypto::ed25519; use crypto::ed25519;
use public_key::{CryptoSystem, KeyPair}; use public_key::{CryptoSystem, KeyPair};
use rand::{self, Rng}; use rand::Rng;
pub static ED25519: CryptoSystem = CryptoSystem { pub static ED25519: CryptoSystem = CryptoSystem {
id: "ed25519", id: "ed25519",
@ -26,7 +26,7 @@ impl Ed25519KeyPair {
let (private, public) = ed25519::keypair(&seed); let (private, public) = ed25519::keypair(&seed);
Box::new(Ed25519KeyPair { Box::new(Ed25519KeyPair {
private: Some(private), private: Some(private),
public: public, public,
}) })
} }

View file

@ -3,7 +3,6 @@ use std::os::unix::io::RawFd;
use std::path::PathBuf; use std::path::PathBuf;
pub fn before_exec() -> Result<()> { pub fn before_exec() -> Result<()> {
use libc;
unsafe { unsafe {
libc::setsid(); libc::setsid();
libc::ioctl(0, libc::TIOCSCTTY, 1); libc::ioctl(0, libc::TIOCSCTTY, 1);
@ -12,12 +11,10 @@ pub fn before_exec() -> Result<()> {
} }
pub fn fork() -> usize { pub fn fork() -> usize {
use libc;
unsafe { libc::fork() as usize } unsafe { libc::fork() as usize }
} }
pub fn set_winsize(fd: RawFd, row: u16, col: u16, xpixel: u16, ypixel: u16) { pub fn set_winsize(fd: RawFd, row: u16, col: u16, xpixel: u16, ypixel: u16) {
use libc;
unsafe { unsafe {
let size = libc::winsize { let size = libc::winsize {
ws_row: row, ws_row: row,
@ -30,7 +27,6 @@ pub fn set_winsize(fd: RawFd, row: u16, col: u16, xpixel: u16, ypixel: u16) {
} }
pub fn getpty() -> (RawFd, PathBuf) { pub fn getpty() -> (RawFd, PathBuf) {
use libc;
use std::ffi::CStr; use std::ffi::CStr;
use std::fs::OpenOptions; use std::fs::OpenOptions;
use std::io::Error; use std::io::Error;