Skip to content

Commit 0d13996

Browse files
committed
fix Status group parsing on newer kernels (>4.6)
1 parent 909eb96 commit 0d13996

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/parsers.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ pub fn map_result<T>(result: IResult<&[u8], T>) -> Result<T> {
6161
if remaining.is_empty() {
6262
Ok(val)
6363
} else {
64-
Err(Error::new(ErrorKind::InvalidInput, "unable to parse whole input"))
64+
let remaining = str::from_utf8(remaining);
65+
Err(Error::new(ErrorKind::InvalidInput,
66+
format!("unable to parse whole input, remaining: {:?}", remaining)))
6567
}
6668
}
6769
IResult::Error(err) => Err(Error::new(ErrorKind::InvalidInput,

src/pid/status.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::fs::File;
44
use std::io::Result;
55

66
use libc::{gid_t, pid_t, uid_t};
7-
use nom::{IResult, line_ending, not_line_ending, space};
7+
use nom::{IResult, line_ending, multispace, not_line_ending, space};
88

99
use parsers::{
1010
map_result,
@@ -185,7 +185,7 @@ named!(parse_gid<(gid_t, gid_t, gid_t, gid_t)>, chain!(tag!("Gid:\t") ~ real: pa
185185
|| { (real, effective, saved, fs) }));
186186

187187
named!(parse_fd_allocated<u32>, delimited!(tag!("FDSize:\t"), parse_u32, line_ending));
188-
named!(parse_groups<Vec<gid_t> >, delimited!(tag!("Groups:\t"), parse_u32s, line_ending));
188+
named!(parse_groups<Vec<gid_t> >, delimited!(tag!("Groups:\t"), parse_u32s, multispace));
189189

190190
named!(parse_ns_pids<Vec<pid_t> >, delimited!(tag!("NStgid:\t"), parse_i32s, line_ending));
191191
named!(parse_ns_tids<Vec<pid_t> >, delimited!(tag!("NSpid:\t"), parse_i32s, line_ending));
@@ -324,8 +324,6 @@ mod tests {
324324

325325
use std::fs::File;
326326

327-
use libc::gid_t;
328-
329327
use parsers::read_to_end;
330328
use parsers::tests::unwrap;
331329
use super::{SeccompMode, parse_status, status, status_self};
@@ -350,7 +348,7 @@ mod tests {
350348
Uid:\t0\t0\t0\t0\n\
351349
Gid:\t0\t0\t0\t0\n\
352350
FDSize:\t64\n\
353-
Groups:\t\n\
351+
Groups:\t10\t1000\n\
354352
NStgid:\t1\n\
355353
NSpid:\t1\n\
356354
NSpgid:\t1\n\
@@ -406,7 +404,7 @@ mod tests {
406404
assert_eq!(0, status.gid_saved);
407405
assert_eq!(0, status.gid_fs);
408406
assert_eq!(64, status.fd_allocated);
409-
assert_eq!(Vec::<gid_t>::new(), status.groups);
407+
assert_eq!(vec![10, 1000], status.groups);
410408
assert_eq!(vec![1], status.ns_pids);
411409
assert_eq!(vec![1], status.ns_tids);
412410
assert_eq!(vec![1], status.ns_pgids);

0 commit comments

Comments
 (0)