Commit 20110790 authored by Alex Xu's avatar Alex Xu
Browse files

fs-mistrust: BadPermission(_, _) -> BadPermission(..)

Next commit adds another parameter to Error::BadPermission.
parent ea80f124
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -280,7 +280,7 @@ mod test {
        #[cfg(target_family = "unix")]
        {
            let e = sd.make_directory("d/sub2").unwrap_err();
            assert!(matches!(e, Error::BadPermission(_, _)));
            assert!(matches!(e, Error::BadPermission(..)));
        }

        // Try opening a file that exists.
@@ -289,9 +289,9 @@ mod test {
        #[cfg(target_family = "unix")]
        {
            let e = sd.open("c/f2", OpenOptions::new().read(true)).unwrap_err();
            assert!(matches!(e, Error::BadPermission(_, _)));
            assert!(matches!(e, Error::BadPermission(..)));
            let e = sd.open("d/f3", OpenOptions::new().read(true)).unwrap_err();
            assert!(matches!(e, Error::BadPermission(_, _)));
            assert!(matches!(e, Error::BadPermission(..)));
        }

        // Try creating a file.
@@ -306,7 +306,7 @@ mod test {
            let e = sd
                .open("d/f-new", OpenOptions::new().write(true).create(true))
                .unwrap_err();
            assert!(matches!(e, Error::BadPermission(_, _)));
            assert!(matches!(e, Error::BadPermission(..)));
        }
    }

+2 −2
Original line number Diff line number Diff line
@@ -134,7 +134,7 @@ impl Error {
        Some(
            match self {
                Error::NotFound(pb) => pb,
                Error::BadPermission(pb, _) => pb,
                Error::BadPermission(pb, ..) => pb,
                Error::BadOwner(pb, _) => pb,
                Error::BadType(pb) => pb,
                Error::CouldNotInspect(pb, _) => pb,
@@ -162,7 +162,7 @@ impl Error {
    /// us from looking at permissions in the first place)
    pub fn is_bad_permission(&self) -> bool {
        match self {
            Error::BadPermission(_, _) | Error::BadOwner(_, _) | Error::BadType(_) => true,
            Error::BadPermission(..) | Error::BadOwner(_, _) | Error::BadType(_) => true,

            Error::NotFound(_)
            | Error::CouldNotInspect(_, _)
+6 −6
Original line number Diff line number Diff line
@@ -809,10 +809,10 @@ mod test {

        // These will fail, since the file or directory is readable.
        let e = m.verifier().check(d.path("a/b")).unwrap_err();
        assert!(matches!(e, Error::BadPermission(_, _)));
        assert!(matches!(e, Error::BadPermission(..)));
        assert_eq!(e.path().unwrap(), d.path("a/b").canonicalize().unwrap());
        let e = m.verifier().check(d.path("a/b/c")).unwrap_err();
        assert!(matches!(e, Error::BadPermission(_, _)));
        assert!(matches!(e, Error::BadPermission(..)));
        assert_eq!(e.path().unwrap(), d.path("a/b/c").canonicalize().unwrap());

        // Now allow readable targets.
@@ -855,7 +855,7 @@ mod test {
        assert!(matches!(e, Error::Multiple(_)));
        let errs: Vec<_> = e.errors().collect();
        assert_eq!(2, errs.len());
        assert!(matches!(&errs[0], Error::BadPermission(_, _)));
        assert!(matches!(&errs[0], Error::BadPermission(..)));
        assert!(matches!(&errs[1], Error::NotFound(_)));
    }

@@ -906,7 +906,7 @@ mod test {
        // By default, we shouldn't be accept this directory, since it is
        // group-writable.
        let e = m.check_directory(d.path("a/b")).unwrap_err();
        assert!(matches!(e, Error::BadPermission(_, _)));
        assert!(matches!(e, Error::BadPermission(..)));

        // But we can make the group trusted, which will make it okay for the
        // directory to be group-writable.
@@ -927,7 +927,7 @@ mod test {
            .unwrap();

        let e = m.check_directory(d.path("a/b")).unwrap_err();
        assert!(matches!(e, Error::BadPermission(_, _)));
        assert!(matches!(e, Error::BadPermission(..)));
    }

    #[test]
@@ -945,7 +945,7 @@ mod test {
            // Try once with bad permissions.
            d.chmod("a", 0o777);
            let e = m.make_directory(d.path("a/b/c/d")).unwrap_err();
            assert!(matches!(e, Error::BadPermission(_, _)));
            assert!(matches!(e, Error::BadPermission(..)));

            // Now make the permissions correct.
            d.chmod("a", 0o0700);