Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Windows build #1253

Merged
merged 21 commits into from
Jun 13, 2016
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ docopt = "0.6"
time = "0.1"
ctrlc = { git = "https://github.com/ethcore/rust-ctrlc.git" }
fdlimit = { path = "util/fdlimit" }
daemonize = "0.2"
num_cpus = "0.2"
number_prefix = "0.2"
rpassword = "0.2.1"
Expand All @@ -37,6 +36,9 @@ ethcore-ipc = { path = "ipc/rpc" }
json-ipc-server = { git = "https://github.com/ethcore/json-ipc-server.git" }
ansi_term = "0.7"

[target.'cfg(not(windows))'.dependencies]
daemonize = "0.2"

[dependencies.hyper]
version = "0.8"
default-features = false
Expand Down
22 changes: 16 additions & 6 deletions parity/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ extern crate log as rlog;
extern crate env_logger;
extern crate ctrlc;
extern crate fdlimit;
#[cfg(not(windows))]
extern crate daemonize;
extern crate time;
extern crate number_prefix;
Expand Down Expand Up @@ -86,7 +87,6 @@ use ethcore::service::ClientService;
use ethcore::spec::Spec;
use ethsync::EthSync;
use ethcore::miner::{Miner, MinerService, ExternalMiner};
use daemonize::Daemonize;
use migration::migrate;
use informant::Informant;

Expand Down Expand Up @@ -115,11 +115,7 @@ fn execute(conf: Configuration) {
execute_upgrades(&conf, &spec, &client_config);

if conf.args.cmd_daemon {
Daemonize::new()
.pid_file(conf.args.arg_pid_file.clone())
.chown_pid_file(true)
.start()
.unwrap_or_else(|e| die!("Couldn't daemonize; {}", e));
daemonize(&conf);
}

if conf.args.cmd_account {
Expand All @@ -145,6 +141,20 @@ fn execute(conf: Configuration) {
execute_client(conf, spec, client_config);
}

#[cfg(not(windows))]
fn daemonize(conf: &Configuration) {
use daemonize::Daemonize;
Daemonize::new()
.pid_file(conf.args.arg_pid_file.clone())
.chown_pid_file(true)
.start()
.unwrap_or_else(|e| die!("Couldn't daemonize; {}", e));
}

#[cfg(windows)]
fn daemonize(_conf: &Configuration) {
}

fn execute_upgrades(conf: &Configuration, spec: &Spec, client_config: &ClientConfig) {
match ::upgrade::upgrade(Some(&conf.path())) {
Ok(upgrades_applied) if upgrades_applied > 0 => {
Expand Down
23 changes: 16 additions & 7 deletions parity/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use std::sync::Arc;
use std::net::SocketAddr;
use util::panics::PanicHandler;
use die::*;
#[cfg(not(windows))]
use jsonipc;
use rpc_apis;

Expand Down Expand Up @@ -66,12 +67,6 @@ pub fn new_http(conf: HttpConfiguration, deps: &Dependencies) -> Option<RpcServe
Some(setup_http_rpc_server(deps, &addr, conf.cors, apis))
}

pub fn new_ipc(conf: IpcConfiguration, deps: &Dependencies) -> Option<jsonipc::Server> {
if !conf.enabled { return None; }
let apis = conf.apis.split(',').collect();
Some(setup_ipc_rpc_server(deps, &conf.socket_addr, apis))
}

fn setup_rpc_server(apis: Vec<&str>, deps: &Dependencies) -> Server {
let apis = rpc_apis::from_str(apis);
let server = Server::new();
Expand Down Expand Up @@ -109,11 +104,20 @@ pub fn setup_http_rpc_server(
},
}
}

#[cfg(not(feature = "rpc"))]
pub fn setup_ipc_rpc_server(_dependencies: &Dependencies, _addr: &str, _apis: Vec<&str>) -> ! {
die!("Your Parity version has been compiled without JSON-RPC support.")
}
#[cfg(feature = "rpc")]

#[cfg(not(windows))]
pub fn new_ipc(conf: IpcConfiguration, deps: &Dependencies) -> Option<jsonipc::Server> {
if !conf.enabled { return None; }
let apis = conf.apis.split(',').collect();
Some(setup_ipc_rpc_server(deps, &conf.socket_addr, apis))
}

#[cfg(all(feature = "rpc", not(windows)))]
pub fn setup_ipc_rpc_server(dependencies: &Dependencies, addr: &str, apis: Vec<&str>) -> jsonipc::Server {
let server = setup_rpc_server(apis, dependencies);
match server.start_ipc(addr) {
Expand All @@ -122,3 +126,8 @@ pub fn setup_ipc_rpc_server(dependencies: &Dependencies, addr: &str, apis: Vec<&
Ok(server) => server
}
}

#[cfg(windows)]
pub fn new_ipc(_conf: IpcConfiguration, _deps: &Dependencies) -> Option<()> {
Some(())
}
1 change: 1 addition & 0 deletions rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ impl RpcServer {
Server::start(addr, self.handler.clone(), cors_domains)
}

#[cfg(not(windows))]
/// Start ipc server asynchronously and returns result with `Server` handle on success or an error.
pub fn start_ipc(&self, addr: &str) -> Result<ipc::Server, ipc::Error> {
let server = try!(ipc::Server::new(addr, &self.handler));
Expand Down
2 changes: 1 addition & 1 deletion util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ log = "0.3"
env_logger = "0.3"
rustc-serialize = "0.3"
arrayvec = "0.3"
mio = "0.5.1"
mio = { git = "https://github.com/ethcore/mio", branch = "v0.5.x" }
nix ="0.5.0"
rand = "0.3.12"
time = "0.1.34"
Expand Down
2 changes: 1 addition & 1 deletion util/src/io/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ impl<Message> IoService<Message> where Message: Send + Sync + Clone + 'static {
/// Starts IO event loop
pub fn start() -> Result<IoService<Message>, UtilError> {
let panic_handler = PanicHandler::new_in_arc();
let mut event_loop = EventLoop::new().unwrap();
let mut event_loop = EventLoop::new().unwrap();
let channel = event_loop.channel();
let panic = panic_handler.clone();
let thread = thread::spawn(move || {
Expand Down
7 changes: 7 additions & 0 deletions util/src/keys/directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ pub struct KeyDirectory {
}

/// Restricts the permissions of given path only to the owner.
#[cfg(not(windows))]
pub fn restrict_permissions_owner(file_path: &Path) -> Result<(), i32> {
let cstr = ::std::ffi::CString::new(file_path.to_str().unwrap()).unwrap();
match unsafe { ::libc::chmod(cstr.as_ptr(), ::libc::S_IWUSR | ::libc::S_IRUSR) } {
Expand All @@ -474,6 +475,12 @@ pub fn restrict_permissions_owner(file_path: &Path) -> Result<(), i32> {
}
}

#[cfg(windows)]
pub fn restrict_permissions_owner(_file_path: &Path) -> Result<(), i32> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no docs for windows version btw

//TODO: implement me
Ok(())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does having this unimplemented create a potential security hole on windows?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't thinks so
windows restricts permissions to the user home directory on it's own

}

impl KeyDirectory {
/// Initializes new cache directory context with a given `path`
pub fn new(path: &Path) -> KeyDirectory {
Expand Down
Loading