File tree Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -245,6 +245,7 @@ pub(crate) fn require_root() -> Result<()> {
245245/// A few process changes that need to be made for writing.
246246#[ context( "Preparing for write" ) ]
247247pub ( crate ) async fn prepare_for_write ( ) -> Result < ( ) > {
248+ crate :: cli:: require_root ( ) ?;
248249 if ostree_ext:: container_utils:: is_ostree_container ( ) ? {
249250 anyhow:: bail!(
250251 "Detected container (ostree base); this command requires a booted host system."
Original file line number Diff line number Diff line change @@ -104,13 +104,24 @@ pub(crate) fn impl_run_container() -> Result<()> {
104104 let sh = Shell :: new ( ) ?;
105105 let host: Host = serde_yaml:: from_str ( & cmd ! ( sh, "bootc status" ) . read ( ) ?) ?;
106106 assert ! ( host. status. is_container) ;
107+ println ! ( "ok status" ) ;
108+
107109 for c in [ "upgrade" , "update" ] {
108110 let o = Command :: new ( "bootc" ) . arg ( c) . output ( ) ?;
109111 let st = o. status ;
110112 assert ! ( !st. success( ) ) ;
111113 let stderr = String :: from_utf8 ( o. stderr ) ?;
112- assert ! ( stderr. contains( "this command requires a booted host system " ) ) ;
114+ assert ! ( stderr. contains( "This command requires full root privileges " ) ) ;
113115 }
116+ println ! ( "ok upgrade/update are errors in container" ) ;
117+
118+ let o = Command :: new ( "runuser" )
119+ . args ( [ "-u" , "bin" , "bootc" , "upgrade" ] )
120+ . output ( ) ?;
121+ assert ! ( !o. status. success( ) ) ;
122+ let stderr = String :: from_utf8 ( o. stderr ) ?;
123+ assert ! ( stderr. contains( "requires root privileges" ) ) ;
124+
114125 println ! ( "ok container integration testing" ) ;
115126 Ok ( ( ) )
116127}
Original file line number Diff line number Diff line change @@ -261,6 +261,7 @@ pub(crate) fn get_status(
261261}
262262
263263/// Implementation of the `bootc status` CLI command.
264+ #[ context( "Status" ) ]
264265pub ( crate ) async fn status ( opts : super :: cli:: StatusOpts ) -> Result < ( ) > {
265266 let host = if ostree_ext:: container_utils:: is_ostree_container ( ) ? {
266267 let status = HostStatus {
@@ -271,6 +272,7 @@ pub(crate) async fn status(opts: super::cli::StatusOpts) -> Result<()> {
271272 r. status = status;
272273 r
273274 } else {
275+ crate :: cli:: require_root ( ) ?;
274276 let sysroot = super :: cli:: get_locked_sysroot ( ) . await ?;
275277 let booted_deployment = sysroot. booted_deployment ( ) ;
276278 let ( _deployments, host) = get_status ( & sysroot, booted_deployment. as_ref ( ) ) ?;
You can’t perform that action at this time.
0 commit comments