From da33077f0e1b8a342c2db4652b1fdf4b02ee39b9 Mon Sep 17 00:00:00 2001 From: Aleksa Sarai Date: Wed, 9 Oct 2024 08:36:13 +1100 Subject: [PATCH 1/2] *: fix spelling errors Signed-off-by: Aleksa Sarai --- CHANGELOG.md | 2 +- README.md | 2 +- contrib/bindings/python/pathrs/_pathrs.py | 6 +++--- go-pathrs/procfs_linux.go | 2 +- include/pathrs.h | 2 +- src/capi/procfs.rs | 2 +- src/lib.rs | 2 +- src/procfs.rs | 2 +- src/resolvers/opath/impl.rs | 2 +- src/tests/test_procfs.rs | 2 +- src/tests/test_root_ops.rs | 2 +- src/utils/path.rs | 4 ++-- 12 files changed, 15 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f54a2b..c8794fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,7 +43,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). against the system libraries don't need to make any changes. ### Fixed ### -- `Root::mkdir_all` no longer does strict verification that directories craeted +- `Root::mkdir_all` no longer does strict verification that directories created by `mkdir_all` "look right" after opening each component. These checks didn't protect against any practical attack (since an attacker could just get us to use a directory by creating it before `Root::mkdir_all` and we would happily diff --git a/README.md b/README.md index 5d4774b..ed938df 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ totally private `procfs` handle that can be used without worrying about racing mount operations. `libpathrs` will try to use this if it can (this usually requires root). -Here are a few examples of pratical things you might want to do with +Here are a few examples of practical things you might want to do with `libpathrs`'s `procfs` API: ```c diff --git a/contrib/bindings/python/pathrs/_pathrs.py b/contrib/bindings/python/pathrs/_pathrs.py index 801b991..8ed6ef9 100644 --- a/contrib/bindings/python/pathrs/_pathrs.py +++ b/contrib/bindings/python/pathrs/_pathrs.py @@ -190,7 +190,7 @@ def __init__(self, file: FileLike): WrappedFd.leak() to ensure there is only ever one owner of the handle at a given time). - However, for os.fdopen() (or simmilar Pythonic file objects that are + However, for os.fdopen() (or similar Pythonic file objects that are tracked by the GC), we have to create a clone and so the WrappedFd is a copy. """ @@ -649,7 +649,7 @@ def mkdir(self, path: str, mode: int) -> None: A pathrs.Error will be raised if the parent directory doesn't exist, or the path already exists. To create a directory and all of its parent - directories (or just re-use an existing directory) you can use + directories (or just reuse an existing directory) you can use Root.mkdir_all(). """ err = libpathrs_so.pathrs_mkdir(self.fileno(), _cstr(path), mode) @@ -659,7 +659,7 @@ def mkdir(self, path: str, mode: int) -> None: def mkdir_all(self, path: str, mode: int) -> Handle: """ Recursively create a directory and all of its parents at the given path - within the Root (or re-use an existing directory if the path already + within the Root (or reuse an existing directory if the path already exists). This method returns a Handle to the created directory. diff --git a/go-pathrs/procfs_linux.go b/go-pathrs/procfs_linux.go index 08c60d3..562aac2 100644 --- a/go-pathrs/procfs_linux.go +++ b/go-pathrs/procfs_linux.go @@ -149,7 +149,7 @@ func ProcSelfOpen(path string, flags int) (*os.File, error) { // // Because Go can change the running OS thread of your goroutine without notice // (and then subsequently kill the old thread), this method will lock the -// current goroutine to ths OS thread (with runtime.LockOSThread) and the +// current goroutine to the OS thread (with runtime.LockOSThread) and the // caller is responsible for unlocking the the OS thread with the // ProcHandleCloser callback once they are done using the returned file. This // callback MUST be called AFTER you have finished using the returned *os.File. diff --git a/include/pathrs.h b/include/pathrs.h index 7863d60..30e8c6a 100644 --- a/include/pathrs.h +++ b/include/pathrs.h @@ -60,7 +60,7 @@ enum pathrs_proc_base_t { * different CLONE_FS, it is possible for /proc/self to point the wrong * thread and so /proc/thread-self may be necessary. * - * NOTE: Using /proc/thread-self may require care if used from langauges + * NOTE: Using /proc/thread-self may require care if used from languages * where your code can change threads without warning and old threads can * be killed (such as Go -- where you want to use runtime.LockOSThread). */ diff --git a/src/capi/procfs.rs b/src/capi/procfs.rs index 818d073..50359d1 100644 --- a/src/capi/procfs.rs +++ b/src/capi/procfs.rs @@ -53,7 +53,7 @@ pub enum CProcfsBase { /// different CLONE_FS, it is possible for /proc/self to point the wrong /// thread and so /proc/thread-self may be necessary. /// - /// NOTE: Using /proc/thread-self may require care if used from langauges + /// NOTE: Using /proc/thread-self may require care if used from languages /// where your code can change threads without warning and old threads can /// be killed (such as Go -- where you want to use runtime.LockOSThread). PATHRS_PROC_THREAD_SELF = 0x3EAD_5E1F, diff --git a/src/lib.rs b/src/lib.rs index 006ffc7..539d6ce 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -182,6 +182,6 @@ mod capi; mod syscalls; mod utils; -// Library tetss. +// Library tests. #[cfg(test)] mod tests; diff --git a/src/procfs.rs b/src/procfs.rs index 89fb6d5..030c002 100644 --- a/src/procfs.rs +++ b/src/procfs.rs @@ -375,7 +375,7 @@ impl ProcfsHandle { // mount ID from parent. This is necessary because ProcfsHandle::open // might create a brand-new procfs handle with a different mount ID. // However, ProcfsHandle::open already checks that the mount ID and - // fstype are safe, so we can just re-use the mount ID we get without + // fstype are safe, so we can just reuse the mount ID we get without // issue. let parent_mnt_id = utils::fetch_mnt_id(&parent, "")?; diff --git a/src/resolvers/opath/impl.rs b/src/resolvers/opath/impl.rs index d99b226..d7fa0b1 100644 --- a/src/resolvers/opath/impl.rs +++ b/src/resolvers/opath/impl.rs @@ -33,7 +33,7 @@ //! If the check fails, we assume we are being attacked and return an error (and //! the caller can decide to re-try if they want). The kernel implementation //! will fail in fewer cases because it has access to in-kernel locks and other -//! measures, but the final check throgh procfs should block all attack +//! measures, but the final check through procfs should block all attack //! attempts. use crate::{ diff --git a/src/tests/test_procfs.rs b/src/tests/test_procfs.rs index 7ac3343..c4121f2 100644 --- a/src/tests/test_procfs.rs +++ b/src/tests/test_procfs.rs @@ -149,7 +149,7 @@ macro_rules! procfs_tests { // // TODO: Figure out the fd type of GLOBAL_PROCFS_HANDLE. In principle we // would expect to be able to do fsopen(2) (otherwise the fsopen(2) - // tests will fail) but it would be nice to avoid possible spurrious + // tests will fail) but it would be nice to avoid possible spurious // errors. procfs_tests! { @capi-fn [] diff --git a/src/tests/test_root_ops.rs b/src/tests/test_root_ops.rs index 64ea239..72e460a 100644 --- a/src/tests/test_root_ops.rs +++ b/src/tests/test_root_ops.rs @@ -720,7 +720,7 @@ mod utils { ); } RenameFlags::RENAME_WHITEOUT => { - // Verify that there is a whiteout entry where the soure + // Verify that there is a whiteout entry where the source // used to be. let new_lookup = root .resolve_nofollow(src_path) diff --git a/src/utils/path.rs b/src/utils/path.rs index dc03f46..081c060 100644 --- a/src/utils/path.rs +++ b/src/utils/path.rs @@ -100,7 +100,7 @@ pub(crate) fn path_split(path: &'_ Path) -> Result<(&'_ Path, Option<&'_ Path>), Ok((dir, base)) } -/// RawComponents is like [`Components`] execpt that no normalisation is done +/// RawComponents is like [`Components`] except that no normalisation is done /// for any path components ([`Components`] normalises "/./" components), and /// all of the components are simply [`OsStr`]. /// @@ -211,7 +211,7 @@ impl<'p> Iterator for Ancestors<'p> { Some(idx) => idx, }; - // TODO: Skip over mutiple "//" components. + // TODO: Skip over multiple "//" components. // Split the path. // TODO: We probably want to move some of the None handling here to From 65731d481d015a96f36c4d468c00e32616d917d7 Mon Sep 17 00:00:00 2001 From: Aleksa Sarai Date: Wed, 9 Oct 2024 08:36:19 +1100 Subject: [PATCH 2/2] gha: run codespell Signed-off-by: Aleksa Sarai --- .github/workflows/rust.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 92736d5..a2ff6f7 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -30,6 +30,13 @@ env: RUST_MSRV: "1.63" jobs: + codespell: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: pip install codespell==v2.3.0 + - run: codespell -L crate + check: name: cargo check (stable) runs-on: ubuntu-latest