From e245e3419d0338b99f4c89dcdf64a5c3c58f8ae0 Mon Sep 17 00:00:00 2001 From: weishu Date: Mon, 24 Feb 2025 16:45:24 +0800 Subject: [PATCH] ksud: upgrade nom to 8.0 --- userspace/ksud/Cargo.lock | 11 ++--------- userspace/ksud/Cargo.toml | 4 ++-- userspace/ksud/src/sepolicy.rs | 27 +++++++++++++-------------- 3 files changed, 17 insertions(+), 25 deletions(-) diff --git a/userspace/ksud/Cargo.lock b/userspace/ksud/Cargo.lock index 6e1fa192..095973d0 100644 --- a/userspace/ksud/Cargo.lock +++ b/userspace/ksud/Cargo.lock @@ -935,12 +935,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" - [[package]] name = "miniz_oxide" version = "0.8.5" @@ -952,12 +946,11 @@ dependencies = [ [[package]] name = "nom" -version = "7.1.3" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405" dependencies = [ "memchr", - "minimal-lexical", ] [[package]] diff --git a/userspace/ksud/Cargo.toml b/userspace/ksud/Cargo.toml index 9381f61c..0d4e3853 100644 --- a/userspace/ksud/Cargo.toml +++ b/userspace/ksud/Cargo.toml @@ -27,7 +27,7 @@ libc = "0.2" extattr = "1" jwalk = "0.8" is_executable = "1" -nom = "=7" +nom = "8" derive-new = "0.7" rust-embed = { version = "8", features = [ "debug-embed", @@ -59,4 +59,4 @@ android_logger = { version = "0.14", default-features = false } strip = true opt-level = "z" lto = true -codegen-units = 1 \ No newline at end of file +codegen-units = 1 diff --git a/userspace/ksud/src/sepolicy.rs b/userspace/ksud/src/sepolicy.rs index c8a412fc..62dedd42 100644 --- a/userspace/ksud/src/sepolicy.rs +++ b/userspace/ksud/src/sepolicy.rs @@ -3,20 +3,16 @@ use derive_new::new; use nom::{ branch::alt, bytes::complete::{tag, take_while, take_while1, take_while_m_n}, - character::{ - complete::{space0, space1}, - is_alphanumeric, - }, + character::complete::{space0, space1}, combinator::map, - sequence::Tuple, - IResult, Parser, + AsChar, IResult, Parser, }; use std::{ffi, path::Path, vec}; type SeObject<'a> = Vec<&'a str>; fn is_sepolicy_char(c: char) -> bool { - is_alphanumeric(c as u8) || c == '_' || c == '-' + c.is_alphanum() || c == '_' || c == '-' } fn parse_single_word(input: &str) -> IResult<&str, &str> { @@ -173,7 +169,8 @@ impl<'a> SeObjectParser<'a> for NormalPerm<'a> { tag("deny"), tag("auditallow"), tag("dontaudit"), - ))(input)?; + )) + .parse(input)?; let (input, _) = space0(input)?; let (input, source) = parse_seobj(input)?; @@ -193,7 +190,8 @@ impl<'a> SeObjectParser<'a> for XPerm<'a> { tag("allowxperm"), tag("auditallowxperm"), tag("dontauditxperm"), - ))(input)?; + )) + .parse(input)?; let (input, _) = space0(input)?; let (input, source) = parse_seobj(input)?; @@ -215,7 +213,7 @@ impl<'a> SeObjectParser<'a> for XPerm<'a> { impl<'a> SeObjectParser<'a> for TypeState<'a> { fn parse(input: &'a str) -> IResult<&'a str, Self> { - let (input, op) = alt((tag("permissive"), tag("enforce")))(input)?; + let (input, op) = alt((tag("permissive"), tag("enforce"))).parse(input)?; let (input, _) = space1(input)?; let (input, stype) = parse_seobj_no_star(input)?; @@ -243,7 +241,7 @@ impl<'a> SeObjectParser<'a> for Type<'a> { impl<'a> SeObjectParser<'a> for TypeAttr<'a> { fn parse(input: &'a str) -> IResult<&'a str, Self> { - let (input, _) = alt((tag("typeattribute"), tag("attradd")))(input)?; + let (input, _) = alt((tag("typeattribute"), tag("attradd"))).parse(input)?; let (input, _) = space1(input)?; let (input, stype) = parse_seobj_no_star(input)?; let (input, _) = space1(input)?; @@ -265,7 +263,7 @@ impl<'a> SeObjectParser<'a> for Attr<'a> { impl<'a> SeObjectParser<'a> for TypeTransition<'a> { fn parse(input: &'a str) -> IResult<&'a str, Self> { - let (input, _) = alt((tag("type_transition"), tag("name_transition")))(input)?; + let (input, _) = alt((tag("type_transition"), tag("name_transition"))).parse(input)?; let (input, _) = space1(input)?; let (input, source) = parse_single_word(input)?; let (input, _) = space1(input)?; @@ -294,7 +292,7 @@ impl<'a> SeObjectParser<'a> for TypeTransition<'a> { impl<'a> SeObjectParser<'a> for TypeChange<'a> { fn parse(input: &'a str) -> IResult<&'a str, Self> { - let (input, op) = alt((tag("type_change"), tag("type_member")))(input)?; + let (input, op) = alt((tag("type_change"), tag("type_member"))).parse(input)?; let (input, _) = space1(input)?; let (input, source) = parse_single_word(input)?; let (input, _) = space1(input)?; @@ -337,7 +335,8 @@ impl<'a> PolicyStatement<'a> { map(TypeTransition::parse, PolicyStatement::TypeTransition), map(TypeChange::parse, PolicyStatement::TypeChange), map(GenFsCon::parse, PolicyStatement::GenFsCon), - ))(input)?; + )) + .parse(input)?; let (input, _) = space0(input)?; let (input, _) = take_while(|c| c == ';')(input)?; let (input, _) = space0(input)?;