use $USERNAME on windows when defaulting ssh user
This commit is contained in:
1 parent
127b2a567b
commit
b46dbe60ba
2 files changed
+13
-2
No files matched your search
+10
-1
@@ -212,6 +212,15 @@ struct SshParameters {
|
||||
host_and_port: String,
|
||||
}
|
||||
|
||||
fn username_from_env() -> Fallible<String> {
|
||||
#[cfg(unix)]
|
||||
const USER: &str = "USER";
|
||||
#[cfg(windows)]
|
||||
const USER: &str = "USERNAME";
|
||||
|
||||
std::env::var(USER).map_err(|e| format_err!("while resolving {} env var: {}", USER, e))
|
||||
}
|
||||
|
||||
impl SshParameters {
|
||||
fn parse(host: &str) -> Fallible<Self> {
|
||||
let parts: Vec<&str> = host.split('@').collect();
|
||||
@@ -223,7 +232,7 @@ impl SshParameters {
|
||||
})
|
||||
} else if parts.len() == 1 {
|
||||
Ok(Self {
|
||||
username: std::env::var("USER")?,
|
||||
username: username_from_env()?,
|
||||
host_and_port: parts[0].to_string(),
|
||||
})
|
||||
} else {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
use crate::config::{Config, TlsDomainServer, UnixDomain};
|
||||
use crate::create_user_owned_dirs;
|
||||
use crate::mux::tab::{Tab, TabId};
|
||||
use crate::mux::{Mux, MuxNotification, MuxSubscriber};
|
||||
use crate::ratelim::RateLimiter;
|
||||
use crate::server::codec::*;
|
||||
use crate::server::pollable::*;
|
||||
use crate::server::UnixListener;
|
||||
use crate::{create_user_owned_dirs, running_under_wsl};
|
||||
use crossbeam_channel::TryRecvError;
|
||||
use failure::{bail, err_msg, format_err, Error, Fallible};
|
||||
#[cfg(unix)]
|
||||
@@ -899,7 +899,9 @@ fn safely_create_sock_path(unix_dom: &UnixDomain) -> Result<UnixListener, Error>
|
||||
|
||||
#[cfg(unix)]
|
||||
{
|
||||
use crate::running_under_wsl;
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
|
||||
if !running_under_wsl() && !unix_dom.skip_permissions_check {
|
||||
// Let's be sure that the ownership looks sane
|
||||
let meta = sock_dir.symlink_metadata()?;
|
||||
|
||||
Reference in new issue
Block a user