mirror of
https://gitlab.redox-os.org/CoffeeCode/redox-ssh.git
synced 2025-12-28 15:02:18 +01:00
Merge branch 'patch-2' into 'master'
Cleanup non-destructive warnings See merge request redox-os/redox-ssh!2
This commit is contained in:
commit
8607dd6a66
8 changed files with 18 additions and 31 deletions
|
|
@ -6,5 +6,5 @@ use ssh::public_key;
|
|||
pub fn main() {
|
||||
let keypair = (public_key::ED25519.generate_key_pair)(None);
|
||||
let mut buffer = File::create("server.key").unwrap();
|
||||
keypair.export(&mut buffer);
|
||||
let _ = keypair.export(&mut buffer);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.read_id(stream)?;
|
||||
|
||||
|
|
@ -334,7 +334,7 @@ impl<'a> Connection {
|
|||
|
||||
|
||||
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);
|
||||
}
|
||||
else {
|
||||
|
|
@ -356,7 +356,7 @@ impl<'a> Connection {
|
|||
let channel_id = reader.read_uint32()?;
|
||||
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())?;
|
||||
|
||||
Ok(None)
|
||||
|
|
@ -403,7 +403,7 @@ impl<'a> Connection {
|
|||
self.hash_data.client_kexinit = Some(packet.payload());
|
||||
|
||||
// Create a random 16 byte cookie
|
||||
use rand::{self, Rng};
|
||||
use rand::Rng;
|
||||
let mut rng = rand::thread_rng();
|
||||
let cookie: Vec<u8> = rng.gen_iter::<u8>().take(16).collect();
|
||||
|
||||
|
|
|
|||
24
src/error.rs
24
src/error.rs
|
|
@ -1,5 +1,3 @@
|
|||
use std::convert::From;
|
||||
use std::error::Error;
|
||||
use std::fmt;
|
||||
use std::io;
|
||||
|
||||
|
|
@ -17,22 +15,16 @@ pub enum ConnectionError {
|
|||
|
||||
impl fmt::Display for ConnectionError {
|
||||
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::*;
|
||||
match self
|
||||
write!(f, "connection error: {}", (match &self
|
||||
{
|
||||
&IoError(_) => "io error",
|
||||
&ProtocolError => "protocol error",
|
||||
&NegotiationError => "negotiation error",
|
||||
&KeyExchangeError => "key exchange error",
|
||||
&KeyGenerationError => "key generation error",
|
||||
&IntegrityError => "integrity error",
|
||||
}
|
||||
IoError(err) => format!("io error: {}", err),
|
||||
ProtocolError => "protocol error".to_owned(),
|
||||
NegotiationError => "negotiation error".to_owned(),
|
||||
KeyExchangeError => "key exchange error".to_owned(),
|
||||
KeyGenerationError => "key generation error".to_owned(),
|
||||
IntegrityError => "integrity error".to_owned(),
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use key_exchange::{KexResult, KeyExchange};
|
|||
use message::MessageType;
|
||||
use num_bigint::{BigInt, Sign};
|
||||
use packet::{Packet, ReadPacketExt, WritePacketExt};
|
||||
use rand::{self, Rng};
|
||||
use rand::Rng;
|
||||
|
||||
const ECDH_KEX_INIT: u8 = 30;
|
||||
const ECDH_KEX_REPLY: u8 = 31;
|
||||
|
|
|
|||
|
|
@ -44,12 +44,12 @@ impl From<u8> for MessageType {
|
|||
6 => ServiceAccept,
|
||||
20 => KexInit,
|
||||
21 => NewKeys,
|
||||
30...49 => KeyExchange(id),
|
||||
30..=49 => KeyExchange(id),
|
||||
50 => UserAuthRequest,
|
||||
51 => UserAuthFailure,
|
||||
52 => UserAuthSuccess,
|
||||
53 => UserAuthBanner,
|
||||
60...79 => UserAuth(id),
|
||||
60..=79 => UserAuth(id),
|
||||
80 => GlobalRequest,
|
||||
81 => RequestSuccess,
|
||||
82 => RequestFailure,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
use std::fmt;
|
||||
use std::io::{self, BufReader, Read, Result, Write};
|
||||
use std::str::{self, FromStr};
|
||||
use std::string::ToString;
|
||||
|
||||
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use std::io::ErrorKind::InvalidData;
|
|||
|
||||
use crypto::ed25519;
|
||||
use public_key::{CryptoSystem, KeyPair};
|
||||
use rand::{self, Rng};
|
||||
use rand::Rng;
|
||||
|
||||
pub static ED25519: CryptoSystem = CryptoSystem {
|
||||
id: "ed25519",
|
||||
|
|
@ -26,7 +26,7 @@ impl Ed25519KeyPair {
|
|||
let (private, public) = ed25519::keypair(&seed);
|
||||
Box::new(Ed25519KeyPair {
|
||||
private: Some(private),
|
||||
public: public,
|
||||
public,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ use std::os::unix::io::RawFd;
|
|||
use std::path::PathBuf;
|
||||
|
||||
pub fn before_exec() -> Result<()> {
|
||||
use libc;
|
||||
unsafe {
|
||||
libc::setsid();
|
||||
libc::ioctl(0, libc::TIOCSCTTY, 1);
|
||||
|
|
@ -12,12 +11,10 @@ pub fn before_exec() -> Result<()> {
|
|||
}
|
||||
|
||||
pub fn fork() -> usize {
|
||||
use libc;
|
||||
unsafe { libc::fork() as usize }
|
||||
}
|
||||
|
||||
pub fn set_winsize(fd: RawFd, row: u16, col: u16, xpixel: u16, ypixel: u16) {
|
||||
use libc;
|
||||
unsafe {
|
||||
let size = libc::winsize {
|
||||
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) {
|
||||
use libc;
|
||||
use std::ffi::CStr;
|
||||
use std::fs::OpenOptions;
|
||||
use std::io::Error;
|
||||
|
|
|
|||
Loading…
Reference in a new issue