diff --git a/Cargo.lock b/Cargo.lock index 1446c61403..d8cdcd5216 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -177,15 +177,6 @@ version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" -[[package]] -name = "bincode" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" -dependencies = [ - "serde", -] - [[package]] name = "binread" version = "2.2.0" @@ -1958,19 +1949,6 @@ dependencies = [ "tempfile", ] -[[package]] -name = "nix" -version = "0.22.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4916f159ed8e5de0082076562152a76b7a1f64a01fd9d1e0fea002c37624faf" -dependencies = [ - "bitflags 1.3.2", - "cc", - "cfg-if", - "libc", - "memoffset 0.6.5", -] - [[package]] name = "nix" version = "0.23.2" @@ -2668,7 +2646,6 @@ dependencies = [ "tempfile", "termcolor", "tokio", - "tokio-unix-ipc", "tracing", "tracing-subscriber", "xmlrpc", @@ -3236,20 +3213,6 @@ dependencies = [ "tokio-util", ] -[[package]] -name = "tokio-unix-ipc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b21b8f3705a64cf49fb2738cba5bb28305c305edcd31dda167b8294b0cae48f" -dependencies = [ - "bincode", - "libc", - "nix 0.22.3", - "rand", - "serde", - "tokio", -] - [[package]] name = "tokio-util" version = "0.7.8" diff --git a/Cargo.toml b/Cargo.toml index 629c1628b2..4ca6c44ac6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -94,7 +94,6 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] } tokio = { version = "1.28.2", features = ["time", "process", "rt", "net"] } xmlrpc = "0.15.1" termcolor = "1.1.3" -tokio-unix-ipc = { version = "0.2.0", features = ["serde"] } [build-dependencies] anyhow = "1.0" @@ -126,8 +125,6 @@ lto = "thin" # Note: If you add a feature here, you also probably want to update utils.rs:get_features() fedora-integration = [] rhsm = ["libdnf-sys/rhsm"] -# Enable hard requirement on `rpm-ostreed.socket`; requires https://bugzilla.redhat.com/show_bug.cgi?id=2110012 -client-socket = [] bin-unit-tests = [] # ASAN+UBSAN sanitizers = [] diff --git a/configure.ac b/configure.ac index 54caeac72a..4373c7acd0 100644 --- a/configure.ac +++ b/configure.ac @@ -70,13 +70,6 @@ AC_ARG_ENABLE(featuresrs, [Rust features, see Cargo.toml for more information]),, [enable_featuresrs=]) -AC_ARG_ENABLE(client-socket, - AS_HELP_STRING([--enable-client-socket], - [(default: no)]),, - [enable_client_socket=no]) -AS_IF([test x$enable_client_socket = xyes], [enable_featuresrs="$enable_featuresrs client-socket"]) -AM_CONDITIONAL(CLIENT_SOCKET, [echo $enable_featuresrs | grep -q 'client-socket']) - AC_SUBST([RUST_FEATURES], $enable_featuresrs) # Initialize libtool diff --git a/packaging/rpm-ostree.spec.in b/packaging/rpm-ostree.spec.in index 90cd80844f..c2123593b4 100644 --- a/packaging/rpm-ostree.spec.in +++ b/packaging/rpm-ostree.spec.in @@ -34,13 +34,6 @@ BuildRequires: rust %bcond_with rhsm %endif -# https://bugzilla.redhat.com/show_bug.cgi?id=2110012 -%if 0%{?fedora} >= 37 -%bcond_without client_socket -%else -%bcond_with client_socket -%endif - # RHEL (8,9) doesn't ship zchunk today. Keep this in sync # with libdnf: https://gitlab.com/redhat/centos-stream/rpms/libdnf/-/blob/762f631e36d1e42c63a794882269d26c156b68c1/libdnf.spec#L45 %if 0%{?rhel} @@ -182,7 +175,7 @@ env NOCONFIGURE=1 ./autogen.sh export RUSTFLAGS="%{build_rustflags}" %endif %configure --disable-silent-rules --enable-gtk-doc %{?rpmdb_default} %{?with_sanitizers:--enable-sanitizers} %{?with_bin_unit_tests:--enable-bin-unit-tests} \ - %{?with_rhsm:--enable-featuresrs=rhsm} %{?with_client_socket:--enable-client-socket} + %{?with_rhsm:--enable-featuresrs=rhsm} %make_build diff --git a/rust/src/client.rs b/rust/src/client.rs index 869a2d9ba8..6ab2847bc5 100644 --- a/rust/src/client.rs +++ b/rust/src/client.rs @@ -159,11 +159,10 @@ pub(crate) fn client_handle_fd_argument( /// Connect to the client socket and ensure the daemon is initialized; /// this avoids DBus and ensures that we get any early startup errors /// returned cleanly. -#[cfg(feature = "client-socket")] fn start_daemon_via_socket() -> Result<()> { use cap_std::io_lifetimes::IntoSocketlike; - let conn = tokio::net::UnixStream::connect("/run/rpm-ostree/client.sock")?; + let conn = tokio::net::UnixStream::connect("/run/rpm-ostree/client.sock"); let address = sockaddr()?; let socket = rustix::net::socket( @@ -197,62 +196,13 @@ pub(crate) fn sockaddr() -> Result { rustix::net::SocketAddrUnix::new("/run/rpm-ostree/client.sock").map_err(anyhow::Error::msg) } -/// Explicitly ensure the daemon is started via systemd, if possible. -/// -/// This works around bugs from DBus activation, see -/// https://github.com/coreos/rpm-ostree/pull/2932 -/// -/// Basically we load too much data before claiming the bus name, -/// and dbus doesn't give us a useful error. Instead, let's talk -/// to systemd directly and use its client tools to scrape errors. -/// -/// What we really should do probably is use native socket activation. -#[cfg(not(feature = "client-socket"))] -fn start_daemon_via_systemctl() -> Result<()> { - use std::process::Command; - - let service = "rpm-ostreed.service"; - // Assume non-root can't use systemd right now. - if rustix::process::getuid().as_raw() != 0 { - return Ok(()); - } - - // Unfortunately, RHEL8 systemd will count "systemctl start" - // invocations against the restart limit, so query the status - // first. - let activeres = Command::new("systemctl") - .args(&["is-active", "rpm-ostreed"]) - .output()?; - // Explicitly don't check the error return value, we don't want to - // hard fail on it. - if String::from_utf8_lossy(&activeres.stdout).starts_with("active") { - // It's active, we're done. Note that while this is a race - // condition, that's fine because it will be handled by DBus - // activation. - return Ok(()); - } - let res = Command::new("systemctl") - .args(&["--no-ask-password", "start", service]) - .status()?; - if !res.success() { - let _ = Command::new("systemctl") - .args(&["--no-pager", "status", service]) - .status(); - return Err(anyhow!("{}", res).into()); - } - Ok(()) -} - pub(crate) fn client_start_daemon() -> CxxResult<()> { // systemctl and socket paths only work for root right now; in the future // the socket may be opened up. if rustix::process::getuid().as_raw() != 0 { return Ok(()); } - #[cfg(feature = "client-socket")] return start_daemon_via_socket().map_err(Into::into); - #[cfg(not(feature = "client-socket"))] - return start_daemon_via_systemctl().map_err(Into::into); } /// Convert the GVariant parameters from the DownloadProgress DBus API to a human-readable English string. diff --git a/src/daemon/rpm-ostreed.socket b/src/daemon/rpm-ostreed.socket index 020c640360..ba05a151fc 100644 --- a/src/daemon/rpm-ostreed.socket +++ b/src/daemon/rpm-ostreed.socket @@ -2,7 +2,7 @@ ConditionKernelCommandLine=ostree [Socket] -ListenStream=/run/rpm-ostree/client.sock +ListenSequentialPacket=/run/rpm-ostree/client.sock SocketMode=0600 [Install]