1
1
use std:: future:: Future ;
2
2
use std:: io:: Write ;
3
- use std:: os:: fd:: { AsFd , BorrowedFd , OwnedFd } ;
4
- use std:: path:: Path ;
3
+ use std:: os:: fd:: BorrowedFd ;
5
4
use std:: process:: Command ;
6
5
use std:: time:: Duration ;
7
6
@@ -17,7 +16,6 @@ use libsystemd::logging::journal_print;
17
16
use ostree:: glib;
18
17
use ostree_ext:: container:: SignatureSource ;
19
18
use ostree_ext:: ostree;
20
- use rustix:: path:: Arg ;
21
19
22
20
/// Try to look for keys injected by e.g. rpm-ostree requesting machine-local
23
21
/// changes; if any are present, return `true`.
@@ -54,33 +52,6 @@ pub(crate) fn deployment_fd(
54
52
sysroot_dir. open_dir ( & dirpath) . map_err ( Into :: into)
55
53
}
56
54
57
- /// A thin wrapper for [`openat2`] but that retries on interruption.
58
- pub fn openat2_with_retry (
59
- dirfd : impl AsFd ,
60
- path : impl AsRef < Path > ,
61
- oflags : rustix:: fs:: OFlags ,
62
- mode : rustix:: fs:: Mode ,
63
- resolve : rustix:: fs:: ResolveFlags ,
64
- ) -> rustix:: io:: Result < OwnedFd > {
65
- let dirfd = dirfd. as_fd ( ) ;
66
- let path = path. as_ref ( ) ;
67
- // We loop forever on EAGAIN right now. The cap-std version loops just 4 times,
68
- // which seems really arbitrary.
69
- path. into_with_c_str ( |path_c_str| ' start: loop {
70
- match rustix:: fs:: openat2 ( dirfd, path_c_str, oflags, mode, resolve) {
71
- Ok ( file) => {
72
- return Ok ( file) ;
73
- }
74
- Err ( rustix:: io:: Errno :: AGAIN | rustix:: io:: Errno :: INTR ) => {
75
- continue ' start;
76
- }
77
- Err ( e) => {
78
- return Err ( e) ;
79
- }
80
- }
81
- } )
82
- }
83
-
84
55
/// Given an mount option string list like foo,bar=baz,something=else,ro parse it and find
85
56
/// the first entry like $optname=
86
57
/// This will not match a bare `optname` without an equals.
@@ -110,25 +81,6 @@ pub(crate) fn open_dir_remount_rw(root: &Dir, target: &Utf8Path) -> Result<Dir>
110
81
root. open_dir ( target) . map_err ( anyhow:: Error :: new)
111
82
}
112
83
113
- /// Open the target directory, but return Ok(None) if this would cross a mount point.
114
- pub fn open_dir_noxdev (
115
- parent : & Dir ,
116
- path : impl AsRef < std:: path:: Path > ,
117
- ) -> std:: io:: Result < Option < Dir > > {
118
- use rustix:: fs:: { Mode , OFlags , ResolveFlags } ;
119
- match openat2_with_retry (
120
- parent,
121
- path,
122
- OFlags :: CLOEXEC | OFlags :: DIRECTORY | OFlags :: NOFOLLOW ,
123
- Mode :: empty ( ) ,
124
- ResolveFlags :: NO_XDEV | ResolveFlags :: BENEATH ,
125
- ) {
126
- Ok ( r) => Ok ( Some ( Dir :: reopen_dir ( & r) ?) ) ,
127
- Err ( e) if e == rustix:: io:: Errno :: XDEV => Ok ( None ) ,
128
- Err ( e) => return Err ( e. into ( ) ) ,
129
- }
130
- }
131
-
132
84
/// Given a target path, remove its immutability if present
133
85
#[ context( "Removing immutable flag from {target}" ) ]
134
86
pub ( crate ) fn remove_immutability ( root : & Dir , target : & Utf8Path ) -> Result < ( ) > {
@@ -236,8 +188,6 @@ pub(crate) fn digested_pullspec(image: &str, digest: &str) -> String {
236
188
237
189
#[ cfg( test) ]
238
190
mod tests {
239
- use cap_std_ext:: cap_std;
240
-
241
191
use super :: * ;
242
192
243
193
#[ test]
@@ -273,15 +223,4 @@ mod tests {
273
223
SignatureSource :: ContainerPolicyAllowInsecure
274
224
) ;
275
225
}
276
-
277
- #[ test]
278
- fn test_open_noxdev ( ) -> Result < ( ) > {
279
- let root = Dir :: open_ambient_dir ( "/" , cap_std:: ambient_authority ( ) ) ?;
280
- // This hard requires the host setup to have /usr/bin on the same filesystem as /
281
- let usr = Dir :: open_ambient_dir ( "/usr" , cap_std:: ambient_authority ( ) ) ?;
282
- assert ! ( open_dir_noxdev( & usr, "bin" ) . unwrap( ) . is_some( ) ) ;
283
- // Requires a mounted /proc, but that also seems ane.
284
- assert ! ( open_dir_noxdev( & root, "proc" ) . unwrap( ) . is_none( ) ) ;
285
- Ok ( ( ) )
286
- }
287
226
}
0 commit comments