mirror of https://github.com/krallin/tini.git
Embed license and add -l flag to show it
This adds 1k of weight to the resulting binary, which is reasonable (it's less than 5% for the smaller non-static binary), but alleviates legitimate user concern that the license requires being included when Tini is redistributed.
This commit is contained in:
parent
2eeac4cd60
commit
be71d120e7
|
@ -24,6 +24,7 @@ addons:
|
||||||
- python-virtualenv
|
- python-virtualenv
|
||||||
- hardening-includes
|
- hardening-includes
|
||||||
- gnupg
|
- gnupg
|
||||||
|
- vim-common
|
||||||
|
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
|
|
|
@ -51,6 +51,16 @@ set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Bsymbolic-functions
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND xxd -i "LICENSE" "${PROJECT_BINARY_DIR}/tiniLicense.h"
|
||||||
|
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
|
||||||
|
RESULT_VARIABLE xxd_ret
|
||||||
|
)
|
||||||
|
|
||||||
|
if(NOT "${xxd_ret}" EQUAL 0)
|
||||||
|
message(SEND_ERROR "xxd on LICENSE failed: ${xxd_ret}")
|
||||||
|
endif()
|
||||||
|
|
||||||
configure_file (
|
configure_file (
|
||||||
"${PROJECT_SOURCE_DIR}/src/tiniConfig.h.in"
|
"${PROJECT_SOURCE_DIR}/src/tiniConfig.h.in"
|
||||||
"${PROJECT_BINARY_DIR}/tiniConfig.h"
|
"${PROJECT_BINARY_DIR}/tiniConfig.h"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
FROM ubuntu:precise
|
FROM ubuntu:precise
|
||||||
|
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
&& apt-get install --no-install-recommends --yes build-essential git gdb valgrind cmake rpm python-dev libcap-dev python-pip python-virtualenv hardening-includes gnupg \
|
&& apt-get install --no-install-recommends --yes build-essential git gdb valgrind cmake rpm python-dev libcap-dev python-pip python-virtualenv hardening-includes gnupg vim-common \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Pre-install those here for faster local builds.
|
# Pre-install those here for faster local builds.
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
# Should be run from the root dir, or SOURCE_DIR should be set.
|
# Should be run from the root dir, or SOURCE_DIR should be set.
|
||||||
set -o errexit
|
set -o errexit
|
||||||
set -o nounset
|
set -o nounset
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
# Default compiler
|
# Default compiler
|
||||||
: ${CC:="gcc"}
|
: ${CC:="gcc"}
|
||||||
|
@ -54,6 +55,9 @@ for tini in "${BUILD_DIR}/tini" "${BUILD_DIR}/tini-static"; do
|
||||||
echo "Smoke test for $tini"
|
echo "Smoke test for $tini"
|
||||||
"${tini}" -h
|
"${tini}" -h
|
||||||
|
|
||||||
|
echo "Testing $tini for license"
|
||||||
|
"${tini}" -l | grep -i "mit license"
|
||||||
|
|
||||||
echo "Testing $tini with: true"
|
echo "Testing $tini with: true"
|
||||||
"${tini}" -vvv true
|
"${tini}" -vvv true
|
||||||
|
|
||||||
|
|
15
src/tini.c
15
src/tini.c
|
@ -15,6 +15,7 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "tiniConfig.h"
|
#include "tiniConfig.h"
|
||||||
|
#include "tiniLicense.h"
|
||||||
|
|
||||||
#define PRINT_FATAL(...) fprintf(stderr, "[FATAL tini (%i)] ", getpid()); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n");
|
#define PRINT_FATAL(...) fprintf(stderr, "[FATAL tini (%i)] ", getpid()); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n");
|
||||||
#define PRINT_WARNING(...) if (verbosity > 0) { fprintf(stderr, "[WARN tini (%i)] ", getpid()); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n"); }
|
#define PRINT_WARNING(...) if (verbosity > 0) { fprintf(stderr, "[WARN tini (%i)] ", getpid()); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n"); }
|
||||||
|
@ -33,11 +34,11 @@ typedef struct {
|
||||||
|
|
||||||
#ifdef PR_SET_CHILD_SUBREAPER
|
#ifdef PR_SET_CHILD_SUBREAPER
|
||||||
#define HAS_SUBREAPER 1
|
#define HAS_SUBREAPER 1
|
||||||
#define OPT_STRING "hsvg"
|
#define OPT_STRING "hsvgl"
|
||||||
#define SUBREAPER_ENV_VAR "TINI_SUBREAPER"
|
#define SUBREAPER_ENV_VAR "TINI_SUBREAPER"
|
||||||
#else
|
#else
|
||||||
#define HAS_SUBREAPER 0
|
#define HAS_SUBREAPER 0
|
||||||
#define OPT_STRING "hvg"
|
#define OPT_STRING "hvgl"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -151,9 +152,14 @@ void print_usage(char* const name, FILE* const file) {
|
||||||
#endif
|
#endif
|
||||||
fprintf(file, " -v: Generate more verbose output. Repeat up to 3 times.\n");
|
fprintf(file, " -v: Generate more verbose output. Repeat up to 3 times.\n");
|
||||||
fprintf(file, " -g: Send signals to the child's process group.\n");
|
fprintf(file, " -g: Send signals to the child's process group.\n");
|
||||||
|
fprintf(file, " -l: Show license and exit.\n");
|
||||||
fprintf(file, "\n");
|
fprintf(file, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void print_license(FILE* const file) {
|
||||||
|
fwrite(LICENSE, sizeof(char), LICENSE_len, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int parse_args(const int argc, char* const argv[], char* (**child_args_ptr_ptr)[], int* const parse_fail_exitcode_ptr) {
|
int parse_args(const int argc, char* const argv[], char* (**child_args_ptr_ptr)[], int* const parse_fail_exitcode_ptr) {
|
||||||
char* name = argv[0];
|
char* name = argv[0];
|
||||||
|
@ -179,6 +185,11 @@ int parse_args(const int argc, char* const argv[], char* (**child_args_ptr_ptr)[
|
||||||
kill_process_group++;
|
kill_process_group++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'l':
|
||||||
|
print_license(stdout);
|
||||||
|
*parse_fail_exitcode_ptr = 0;
|
||||||
|
return 1;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
print_usage(name, stderr);
|
print_usage(name, stderr);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -24,6 +24,7 @@ addons:
|
||||||
- python-virtualenv
|
- python-virtualenv
|
||||||
- hardening-includes
|
- hardening-includes
|
||||||
- gnupg
|
- gnupg
|
||||||
|
- vim-common
|
||||||
|
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
|
|
Loading…
Reference in New Issue