aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2008-11-16 01:40:28 +0000
committerMike Frysinger <vapier@gentoo.org>2008-11-16 01:40:28 +0000
commit373b9bcf101988405419ac4032818b3531f75934 (patch)
treefff9cd4ec7c584b749929d86de757a6212780950 /libsbutil
parenttests: initial test framework (diff)
downloadsandbox-373b9bcf101988405419ac4032818b3531f75934.tar.gz
sandbox-373b9bcf101988405419ac4032818b3531f75934.tar.bz2
sandbox-373b9bcf101988405419ac4032818b3531f75934.zip
libsbutil: unify duplicate log debug functions
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'libsbutil')
-rw-r--r--libsbutil/Makefile.am1
-rw-r--r--libsbutil/get_sandbox_debug_log.c38
-rw-r--r--libsbutil/get_sandbox_log.c16
3 files changed, 13 insertions, 42 deletions
diff --git a/libsbutil/Makefile.am b/libsbutil/Makefile.am
index 2f3f4a5..f8ad02d 100644
--- a/libsbutil/Makefile.am
+++ b/libsbutil/Makefile.am
@@ -16,7 +16,6 @@ libsbutil_la_SOURCES = \
get_sandbox_lib.c \
get_sandbox_rc.c \
get_sandbox_log.c \
- get_sandbox_debug_log.c \
get_tmp_dir.c \
is_env_on.c \
is_env_off.c \
diff --git a/libsbutil/get_sandbox_debug_log.c b/libsbutil/get_sandbox_debug_log.c
deleted file mode 100644
index 6a1b4fa..0000000
--- a/libsbutil/get_sandbox_debug_log.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * get_sandbox_debug_log.c
- *
- * Util functions.
- *
- * Copyright 1999-2008 Gentoo Foundation
- * Licensed under the GPL-2
- *
- * Some parts might have Copyright:
- * Copyright (C) 2002 Brad House <brad@mainstreetsoftworks.com>
- */
-
-#include "headers.h"
-#include "sbutil.h"
-
-void get_sandbox_debug_log(char *path)
-{
- char *sandbox_debug_log_env = NULL;
-
- save_errno();
-
- sandbox_debug_log_env = getenv(ENV_SANDBOX_DEBUG_LOG);
-
- /* THIS CHUNK BREAK THINGS BY DOING THIS:
- * SANDBOX_DEBUG_LOG=/tmp/sandbox-app-admin/superadduser-1.0.7-11063.log
- */
- if ((NULL != sandbox_debug_log_env) &&
- (NULL != strchr(sandbox_debug_log_env, '/')))
- sandbox_debug_log_env = NULL;
-
- snprintf(path, SB_PATH_MAX, "%s%s%s%s%d%s",
- SANDBOX_LOG_LOCATION, DEBUG_LOG_FILE_PREFIX,
- (sandbox_debug_log_env == NULL ? "" : sandbox_debug_log_env),
- (sandbox_debug_log_env == NULL ? "" : "-"),
- getpid(), LOG_FILE_EXT);
-
- restore_errno();
-}
diff --git a/libsbutil/get_sandbox_log.c b/libsbutil/get_sandbox_log.c
index 2811737..3fa0835 100644
--- a/libsbutil/get_sandbox_log.c
+++ b/libsbutil/get_sandbox_log.c
@@ -13,13 +13,13 @@
#include "headers.h"
#include "sbutil.h"
-void get_sandbox_log(char *path)
+static void _get_sb_log(char *path, const char *env, const char *prefix)
{
char *sandbox_log_env = NULL;
save_errno();
- sandbox_log_env = getenv(ENV_SANDBOX_LOG);
+ sandbox_log_env = getenv(env);
/* THIS CHUNK BREAK THINGS BY DOING THIS:
* SANDBOX_LOG=/tmp/sandbox-app-admin/superadduser-1.0.7-11063.log
@@ -29,10 +29,20 @@ void get_sandbox_log(char *path)
sandbox_log_env = NULL;
snprintf(path, SB_PATH_MAX, "%s%s%s%s%d%s",
- SANDBOX_LOG_LOCATION, LOG_FILE_PREFIX,
+ SANDBOX_LOG_LOCATION, prefix,
(sandbox_log_env == NULL ? "" : sandbox_log_env),
(sandbox_log_env == NULL ? "" : "-"),
getpid(), LOG_FILE_EXT);
restore_errno();
}
+
+void get_sandbox_log(char *path)
+{
+ _get_sb_log(path, ENV_SANDBOX_LOG, LOG_FILE_PREFIX);
+}
+
+void get_sandbox_debug_log(char *path)
+{
+ _get_sb_log(path, ENV_SANDBOX_DEBUG_LOG, DEBUG_LOG_FILE_PREFIX);
+}