[apparmor] [patch] Let the parser reject ambiguous unit 'm' for rlimit rttime

Steve Beattie steve at nxnw.org
Fri Jul 10 19:34:28 UTC 2015


On Fri, Jul 10, 2015 at 11:50:12AM -0700, Steve Beattie wrote:
> On Thu, Jul 09, 2015 at 04:22:52AM -0700, John Johansen wrote:
> > move convert_time_units to parser_misc.c and add unit tests
> > add "sec" abreviation of secons
> > optionally allow whitespace between rlimit value and unit
> > allow time the unit to be optional, but output a warning
> > update man page to add a note about 'cpu' using units >= seconds
> > fix "else" error by using else if (tmp < 0)
> > fix "weekss"
> > 
> > ---
> > 
> > commit 5ee47621cc28b745d508b0c69046ce1b3776f8b4
> > Author: John Johansen <john.johansen at canonical.com>
> > Date:   Thu Jun 18 02:22:42 2015 -0700
> > 
> >     fix: rlimit unit parsing for time
> >     
> >     currently the parser supports ambiguous units like m for time,
> >     which could mean minutes or milliseconds. Fix this and refactor the
> >     time parsing into a single routine.
> >     
> >     Signed-off-by: John Johansen <john.johansen at canonical.com>
> 
> Acked-by: Steve Beattie <steve at nxnw.org> with a couple of bits:
> 
> > +	TIME_TEST(1LL, 1LL, NULL, 1LL);
> > +	TIME_TEST(12345LL, 1LL, NULL, 12345LL);
> > +	TIME_TEST(10LL, 10LL, NULL, 10LL);
> > +	TIME_TEST(123450LL, 10LL, NULL, 123450LL);
> > +
> > +        TIME_TEST(12345LL, 1LL, "us", 12345LL);
> 
> Please fix the whitespace breakage above (spaces v tab) before
> committing,
> 
> > +	TIME_TEST(12345LL, 1LL, "microsecond", 12345LL);
> > +	TIME_TEST(12345LL, 1LL, "microseconds", 12345LL);
> 
> and I'd like an ack on the following:
> 
> Subject: parser: add rlimit data units equality tests
> 
> Signed-off-by: Steve Beattie <steve at nxnw.org>

Bleah, I'm not very good at following other's examples. v2:
---
 parser/tst/equality.sh |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

Index: b/parser/tst/equality.sh
===================================================================
--- a/parser/tst/equality.sh
+++ b/parser/tst/equality.sh
@@ -464,6 +464,31 @@ verify_binary_equality "change_profile =
 		       "/t { change_profile /**, }" \
 		       "/t { change_profile /** -> **, }"
 
+# verify rlimit data conversions
+verify_binary_equality "set rlimit rttime <= 12 weeks" \
+                       "/t { set rlimit rttime <= 12 weeks, }" \
+                       "/t { set rlimit rttime <= $((12 * 7)) days, }" \
+                       "/t { set rlimit rttime <= $((12 * 7 * 24)) hours, }" \
+                       "/t { set rlimit rttime <= $((12 * 7 * 24 * 60)) minutes, }" \
+                       "/t { set rlimit rttime <= $((12 * 7 * 24 * 60 * 60)) seconds, }" \
+                       "/t { set rlimit rttime <= $((12 * 7 * 24 * 60 * 60 * 1000)) ms, }" \
+                       "/t { set rlimit rttime <= $((12 * 7 * 24 * 60 * 60 * 1000 * 1000)) us, }" \
+                       "/t { set rlimit rttime <= $((12 * 7 * 24 * 60 * 60 * 1000 * 1000)), }"
+
+verify_binary_equality "set rlimit cpu <= 42 weeks" \
+                       "/t { set rlimit cpu <= 42 weeks, }" \
+                       "/t { set rlimit cpu <= $((42 * 7)) days, }" \
+                       "/t { set rlimit cpu <= $((42 * 7 * 24)) hours, }" \
+                       "/t { set rlimit cpu <= $((42 * 7 * 24 * 60)) minutes, }" \
+                       "/t { set rlimit cpu <= $((42 * 7 * 24 * 60 * 60)) seconds, }" \
+                       "/t { set rlimit cpu <= $((42 * 7 * 24 * 60 * 60)), }"
+
+verify_binary_equality "set rlimit memlock <= 2GB" \
+                       "/t { set rlimit memlock <= 2GB, }" \
+                       "/t { set rlimit memlock <= $((2 * 1024)) MB, }" \
+                       "/t { set rlimit memlock <= $((2 * 1024 * 1024)) KB, }" \
+                       "/t { set rlimit memlock <= $((2 * 1024 * 1024 * 1024)) , }" \
+
 if [ $fails -ne 0 -o $errors -ne 0 ]
 then
 	printf "ERRORS: %d\nFAILS: %d\n" $errors $fails 2>&1
-- 
Steve Beattie
<sbeattie at ubuntu.com>
http://NxNW.org/~steve/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20150710/4c71531f/attachment.pgp>


More information about the AppArmor mailing list