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
|
||||
- hardening-includes
|
||||
- gnupg
|
||||
- vim-common
|
||||
|
||||
env:
|
||||
global:
|
||||
|
|
|
@ -51,6 +51,16 @@ set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Bsymbolic-functions
|
|||
|
||||
# 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 (
|
||||
"${PROJECT_SOURCE_DIR}/src/tiniConfig.h.in"
|
||||
"${PROJECT_BINARY_DIR}/tiniConfig.h"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
FROM ubuntu:precise
|
||||
|
||||
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/*
|
||||
|
||||
# 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.
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
# Default compiler
|
||||
: ${CC:="gcc"}
|
||||
|
@ -54,6 +55,9 @@ for tini in "${BUILD_DIR}/tini" "${BUILD_DIR}/tini-static"; do
|
|||
echo "Smoke test for $tini"
|
||||
"${tini}" -h
|
||||
|
||||
echo "Testing $tini for license"
|
||||
"${tini}" -l | grep -i "mit license"
|
||||
|
||||
echo "Testing $tini with: true"
|
||||
"${tini}" -vvv true
|
||||
|
||||
|
|
15
src/tini.c
15
src/tini.c
|
@ -15,6 +15,7 @@
|
|||
#include <stdbool.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_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
|
||||
#define HAS_SUBREAPER 1
|
||||
#define OPT_STRING "hsvg"
|
||||
#define OPT_STRING "hsvgl"
|
||||
#define SUBREAPER_ENV_VAR "TINI_SUBREAPER"
|
||||
#else
|
||||
#define HAS_SUBREAPER 0
|
||||
#define OPT_STRING "hvg"
|
||||
#define OPT_STRING "hvgl"
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -151,9 +152,14 @@ void print_usage(char* const name, FILE* const file) {
|
|||
#endif
|
||||
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, " -l: Show license and exit.\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) {
|
||||
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++;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
print_license(stdout);
|
||||
*parse_fail_exitcode_ptr = 0;
|
||||
return 1;
|
||||
|
||||
case '?':
|
||||
print_usage(name, stderr);
|
||||
return 1;
|
||||
|
|
|
@ -24,6 +24,7 @@ addons:
|
|||
- python-virtualenv
|
||||
- hardening-includes
|
||||
- gnupg
|
||||
- vim-common
|
||||
|
||||
env:
|
||||
global:
|
||||
|
|
Loading…
Reference in New Issue