aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2009-02-15 01:08:00 -0500
committerMike Frysinger <vapier@gentoo.org>2009-02-15 01:08:00 -0500
commitc2eee93088aad4876c2f25fcb78d67ad18ffa425 (patch)
tree992578dace40f636257459f16bfcc09194896daa
parentlibsandbox: make sure all mknod symbols are wrapped (diff)
downloadsandbox-c2eee93088aad4876c2f25fcb78d67ad18ffa425.tar.gz
sandbox-c2eee93088aad4876c2f25fcb78d67ad18ffa425.tar.bz2
sandbox-c2eee93088aad4876c2f25fcb78d67ad18ffa425.zip
libsandbox: calculate longest symbol name dynamically
The longest wrapped symbol name has hit the hard limit of 10 chars, so rather than manually bump it up, calculate it on the fly with the awk scripts. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rw-r--r--libsandbox/Makefile.am2
-rw-r--r--libsandbox/libsandbox.c19
-rw-r--r--scripts/gen_symbol_header.awk7
3 files changed, 16 insertions, 12 deletions
diff --git a/libsandbox/Makefile.am b/libsandbox/Makefile.am
index e38cc29..97d8864 100644
--- a/libsandbox/Makefile.am
+++ b/libsandbox/Makefile.am
@@ -53,7 +53,7 @@ symbols.h: $(SYMBOLS_FILE) $(SYMBOLS_WRAPPERS) $(GEN_HEADER_SCRIPT)
SB_NR_FILE = $(srcdir)/sb_nr.h.in
sb_nr.h: symbols.h $(SB_NR_FILE)
- $(EGREP) -h '^\#define SB_NR_' $^ > $@
+ $(EGREP) -h '^\#define SB_' $^ > $@
EXTRA_DIST = $(SYMBOLS_FILE) $(SYMBOLS_WRAPPERS) $(SB_NR_FILE)
diff --git a/libsandbox/libsandbox.c b/libsandbox/libsandbox.c
index ffda996..758b9e5 100644
--- a/libsandbox/libsandbox.c
+++ b/libsandbox/libsandbox.c
@@ -744,17 +744,14 @@ static int check_syscall(sbcontext_t *sbcontext, int sb_nr, const char *func, co
result = check_access(sbcontext, sb_nr, func, absolute_path, resolved_path);
- if (1 == verbose) {
- if ((0 == result) && (1 == sbcontext->show_access_violation)) {
- SB_EERROR("ACCESS DENIED", " %s:%*s%s\n",
- func, (int)(10 - strlen(func)), "", absolute_path);
- } else if ((1 == debug) && (1 == sbcontext->show_access_violation)) {
- SB_EINFO("ACCESS ALLOWED", " %s:%*s%s\n",
- func, (int)(10 - strlen(func)), "", absolute_path);
- } else if ((1 == debug) && (0 == sbcontext->show_access_violation)) {
- SB_EWARN("ACCESS PREDICTED", " %s:%*s%s\n",
- func, (int)(10 - strlen(func)), "", absolute_path);
- }
+ if (verbose) {
+ int sym_len = SB_MAX_STRING_LEN + 1 - strlen(func);
+ if (!result && sbcontext->show_access_violation)
+ SB_EERROR("ACCESS DENIED", " %s:%*s%s\n", func, sym_len, "", absolute_path);
+ else if (debug && sbcontext->show_access_violation)
+ SB_EINFO("ACCESS ALLOWED", " %s:%*s%s\n", func, sym_len, "", absolute_path);
+ else if (debug && !sbcontext->show_access_violation)
+ SB_EWARN("ACCESS PREDICTED", " %s:%*s%s\n", func, sym_len, "", absolute_path);
}
if ((0 == result) && (1 == sbcontext->show_access_violation))
diff --git a/scripts/gen_symbol_header.awk b/scripts/gen_symbol_header.awk
index 826d75c..e7ee2ab 100644
--- a/scripts/gen_symbol_header.awk
+++ b/scripts/gen_symbol_header.awk
@@ -82,11 +82,16 @@ END {
printf("#define __symbols_h\n\n");
printf("#define SB_NR_UNDEF -99999\n\n");
+ SB_MAX_STRING_LEN = 0
+
# We use the order in SYMBOLS, as some wrappers depends on others ...
for (i = 1; i <= COUNT; ++i) {
sym_index = SYMBOLS[i];
full_count = split(SYMBOL_LIST[sym_index], sym_full_names);
+ if (length(sym_index) > SB_MAX_STRING_LEN)
+ SB_MAX_STRING_LEN = length(sym_index);
+
if (full_count == 0)
printf("#define SB_NR_%s SB_NR_UNDEF\n", toupper(sym_index));
@@ -170,5 +175,7 @@ END {
}
}
+ printf("#define SB_MAX_STRING_LEN %i\n\n", SB_MAX_STRING_LEN);
+
printf("#endif /* __symbols_h */\n");
}