@@ -159,11 +159,10 @@ pub(crate) fn client_handle_fd_argument(
159
159
/// Connect to the client socket and ensure the daemon is initialized;
160
160
/// this avoids DBus and ensures that we get any early startup errors
161
161
/// returned cleanly.
162
- #[ cfg( feature = "client-socket" ) ]
163
162
fn start_daemon_via_socket ( ) -> Result < ( ) > {
164
163
use cap_std:: io_lifetimes:: IntoSocketlike ;
165
164
166
- let conn = tokio:: net:: UnixStream :: connect ( "/run/rpm-ostree/client.sock" ) ? ;
165
+ let conn = tokio:: net:: UnixStream :: connect ( "/run/rpm-ostree/client.sock" ) ;
167
166
168
167
let address = sockaddr ( ) ?;
169
168
let socket = rustix:: net:: socket (
@@ -197,62 +196,13 @@ pub(crate) fn sockaddr() -> Result<rustix::net::SocketAddrUnix> {
197
196
rustix:: net:: SocketAddrUnix :: new ( "/run/rpm-ostree/client.sock" ) . map_err ( anyhow:: Error :: msg)
198
197
}
199
198
200
- /// Explicitly ensure the daemon is started via systemd, if possible.
201
- ///
202
- /// This works around bugs from DBus activation, see
203
- /// https://github.com/coreos/rpm-ostree/pull/2932
204
- ///
205
- /// Basically we load too much data before claiming the bus name,
206
- /// and dbus doesn't give us a useful error. Instead, let's talk
207
- /// to systemd directly and use its client tools to scrape errors.
208
- ///
209
- /// What we really should do probably is use native socket activation.
210
- #[ cfg( not( feature = "client-socket" ) ) ]
211
- fn start_daemon_via_systemctl ( ) -> Result < ( ) > {
212
- use std:: process:: Command ;
213
-
214
- let service = "rpm-ostreed.service" ;
215
- // Assume non-root can't use systemd right now.
216
- if rustix:: process:: getuid ( ) . as_raw ( ) != 0 {
217
- return Ok ( ( ) ) ;
218
- }
219
-
220
- // Unfortunately, RHEL8 systemd will count "systemctl start"
221
- // invocations against the restart limit, so query the status
222
- // first.
223
- let activeres = Command :: new ( "systemctl" )
224
- . args ( & [ "is-active" , "rpm-ostreed" ] )
225
- . output ( ) ?;
226
- // Explicitly don't check the error return value, we don't want to
227
- // hard fail on it.
228
- if String :: from_utf8_lossy ( & activeres. stdout ) . starts_with ( "active" ) {
229
- // It's active, we're done. Note that while this is a race
230
- // condition, that's fine because it will be handled by DBus
231
- // activation.
232
- return Ok ( ( ) ) ;
233
- }
234
- let res = Command :: new ( "systemctl" )
235
- . args ( & [ "--no-ask-password" , "start" , service] )
236
- . status ( ) ?;
237
- if !res. success ( ) {
238
- let _ = Command :: new ( "systemctl" )
239
- . args ( & [ "--no-pager" , "status" , service] )
240
- . status ( ) ;
241
- return Err ( anyhow ! ( "{}" , res) . into ( ) ) ;
242
- }
243
- Ok ( ( ) )
244
- }
245
-
246
199
pub ( crate ) fn client_start_daemon ( ) -> CxxResult < ( ) > {
247
200
// systemctl and socket paths only work for root right now; in the future
248
201
// the socket may be opened up.
249
202
if rustix:: process:: getuid ( ) . as_raw ( ) != 0 {
250
203
return Ok ( ( ) ) ;
251
204
}
252
- #[ cfg( feature = "client-socket" ) ]
253
205
return start_daemon_via_socket ( ) . map_err ( Into :: into) ;
254
- #[ cfg( not( feature = "client-socket" ) ) ]
255
- return start_daemon_via_systemctl ( ) . map_err ( Into :: into) ;
256
206
}
257
207
258
208
/// Convert the GVariant parameters from the DownloadProgress DBus API to a human-readable English string.
0 commit comments