| 1 |
/*
|
| 2 |
* get_sandbox_log.c
|
| 3 |
*
|
| 4 |
* Util functions.
|
| 5 |
*
|
| 6 |
* Copyright 1999-2008 Gentoo Foundation
|
| 7 |
* Licensed under the GPL-2
|
| 8 |
*
|
| 9 |
* Some parts might have Copyright:
|
| 10 |
* Copyright (C) 2002 Brad House <brad@mainstreetsoftworks.com>
|
| 11 |
*/
|
| 12 |
|
| 13 |
#include "headers.h"
|
| 14 |
#include "sbutil.h"
|
| 15 |
|
| 16 |
static void _get_sb_log(char *path, const char *env, const char *prefix)
|
| 17 |
{
|
| 18 |
char *sandbox_log_env = NULL;
|
| 19 |
|
| 20 |
save_errno();
|
| 21 |
|
| 22 |
sandbox_log_env = getenv(env);
|
| 23 |
|
| 24 |
/* THIS CHUNK BREAK THINGS BY DOING THIS:
|
| 25 |
* SANDBOX_LOG=/tmp/sandbox-app-admin/superadduser-1.0.7-11063.log
|
| 26 |
*/
|
| 27 |
if ((NULL != sandbox_log_env) &&
|
| 28 |
(NULL != strchr(sandbox_log_env, '/')))
|
| 29 |
sandbox_log_env = NULL;
|
| 30 |
|
| 31 |
snprintf(path, SB_PATH_MAX, "%s%s%s%s%d%s",
|
| 32 |
SANDBOX_LOG_LOCATION, prefix,
|
| 33 |
(sandbox_log_env == NULL ? "" : sandbox_log_env),
|
| 34 |
(sandbox_log_env == NULL ? "" : "-"),
|
| 35 |
getpid(), LOG_FILE_EXT);
|
| 36 |
|
| 37 |
restore_errno();
|
| 38 |
}
|
| 39 |
|
| 40 |
void get_sandbox_log(char *path)
|
| 41 |
{
|
| 42 |
_get_sb_log(path, ENV_SANDBOX_LOG, LOG_FILE_PREFIX);
|
| 43 |
}
|
| 44 |
|
| 45 |
void get_sandbox_debug_log(char *path)
|
| 46 |
{
|
| 47 |
_get_sb_log(path, ENV_SANDBOX_DEBUG_LOG, DEBUG_LOG_FILE_PREFIX);
|
| 48 |
}
|