Skip to content

Commit

Permalink
ksud: upgrade nom to 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tiann authored and 723593223 committed Mar 3, 2025
1 parent 5a1ac3c commit 381d024
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 22 deletions.
15 changes: 9 additions & 6 deletions userspace/ksud/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions userspace/ksud/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -58,4 +58,4 @@ android_logger = { version = "0.14", default-features = false }
strip = true
opt-level = "z"
lto = true
codegen-units = 1
codegen-units = 1
27 changes: 13 additions & 14 deletions userspace/ksud/src/sepolicy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -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)?;
Expand All @@ -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)?;
Expand All @@ -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)?;
Expand Down Expand Up @@ -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)?;
Expand All @@ -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)?;
Expand Down Expand Up @@ -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)?;
Expand Down Expand Up @@ -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)?;
Expand Down

0 comments on commit 381d024

Please sign in to comment.