Skip to content

Commit e245e34

Browse files
committed
ksud: upgrade nom to 8.0
1 parent bcdc860 commit e245e34

File tree

3 files changed

+17
-25
lines changed

3 files changed

+17
-25
lines changed

userspace/ksud/Cargo.lock

+2-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

userspace/ksud/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ libc = "0.2"
2727
extattr = "1"
2828
jwalk = "0.8"
2929
is_executable = "1"
30-
nom = "=7"
30+
nom = "8"
3131
derive-new = "0.7"
3232
rust-embed = { version = "8", features = [
3333
"debug-embed",
@@ -59,4 +59,4 @@ android_logger = { version = "0.14", default-features = false }
5959
strip = true
6060
opt-level = "z"
6161
lto = true
62-
codegen-units = 1
62+
codegen-units = 1

userspace/ksud/src/sepolicy.rs

+13-14
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,16 @@ use derive_new::new;
33
use nom::{
44
branch::alt,
55
bytes::complete::{tag, take_while, take_while1, take_while_m_n},
6-
character::{
7-
complete::{space0, space1},
8-
is_alphanumeric,
9-
},
6+
character::complete::{space0, space1},
107
combinator::map,
11-
sequence::Tuple,
12-
IResult, Parser,
8+
AsChar, IResult, Parser,
139
};
1410
use std::{ffi, path::Path, vec};
1511

1612
type SeObject<'a> = Vec<&'a str>;
1713

1814
fn is_sepolicy_char(c: char) -> bool {
19-
is_alphanumeric(c as u8) || c == '_' || c == '-'
15+
c.is_alphanum() || c == '_' || c == '-'
2016
}
2117

2218
fn parse_single_word(input: &str) -> IResult<&str, &str> {
@@ -173,7 +169,8 @@ impl<'a> SeObjectParser<'a> for NormalPerm<'a> {
173169
tag("deny"),
174170
tag("auditallow"),
175171
tag("dontaudit"),
176-
))(input)?;
172+
))
173+
.parse(input)?;
177174

178175
let (input, _) = space0(input)?;
179176
let (input, source) = parse_seobj(input)?;
@@ -193,7 +190,8 @@ impl<'a> SeObjectParser<'a> for XPerm<'a> {
193190
tag("allowxperm"),
194191
tag("auditallowxperm"),
195192
tag("dontauditxperm"),
196-
))(input)?;
193+
))
194+
.parse(input)?;
197195

198196
let (input, _) = space0(input)?;
199197
let (input, source) = parse_seobj(input)?;
@@ -215,7 +213,7 @@ impl<'a> SeObjectParser<'a> for XPerm<'a> {
215213

216214
impl<'a> SeObjectParser<'a> for TypeState<'a> {
217215
fn parse(input: &'a str) -> IResult<&'a str, Self> {
218-
let (input, op) = alt((tag("permissive"), tag("enforce")))(input)?;
216+
let (input, op) = alt((tag("permissive"), tag("enforce"))).parse(input)?;
219217

220218
let (input, _) = space1(input)?;
221219
let (input, stype) = parse_seobj_no_star(input)?;
@@ -243,7 +241,7 @@ impl<'a> SeObjectParser<'a> for Type<'a> {
243241

244242
impl<'a> SeObjectParser<'a> for TypeAttr<'a> {
245243
fn parse(input: &'a str) -> IResult<&'a str, Self> {
246-
let (input, _) = alt((tag("typeattribute"), tag("attradd")))(input)?;
244+
let (input, _) = alt((tag("typeattribute"), tag("attradd"))).parse(input)?;
247245
let (input, _) = space1(input)?;
248246
let (input, stype) = parse_seobj_no_star(input)?;
249247
let (input, _) = space1(input)?;
@@ -265,7 +263,7 @@ impl<'a> SeObjectParser<'a> for Attr<'a> {
265263

266264
impl<'a> SeObjectParser<'a> for TypeTransition<'a> {
267265
fn parse(input: &'a str) -> IResult<&'a str, Self> {
268-
let (input, _) = alt((tag("type_transition"), tag("name_transition")))(input)?;
266+
let (input, _) = alt((tag("type_transition"), tag("name_transition"))).parse(input)?;
269267
let (input, _) = space1(input)?;
270268
let (input, source) = parse_single_word(input)?;
271269
let (input, _) = space1(input)?;
@@ -294,7 +292,7 @@ impl<'a> SeObjectParser<'a> for TypeTransition<'a> {
294292

295293
impl<'a> SeObjectParser<'a> for TypeChange<'a> {
296294
fn parse(input: &'a str) -> IResult<&'a str, Self> {
297-
let (input, op) = alt((tag("type_change"), tag("type_member")))(input)?;
295+
let (input, op) = alt((tag("type_change"), tag("type_member"))).parse(input)?;
298296
let (input, _) = space1(input)?;
299297
let (input, source) = parse_single_word(input)?;
300298
let (input, _) = space1(input)?;
@@ -337,7 +335,8 @@ impl<'a> PolicyStatement<'a> {
337335
map(TypeTransition::parse, PolicyStatement::TypeTransition),
338336
map(TypeChange::parse, PolicyStatement::TypeChange),
339337
map(GenFsCon::parse, PolicyStatement::GenFsCon),
340-
))(input)?;
338+
))
339+
.parse(input)?;
341340
let (input, _) = space0(input)?;
342341
let (input, _) = take_while(|c| c == ';')(input)?;
343342
let (input, _) = space0(input)?;

0 commit comments

Comments
 (0)