public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Mike Frysinger" <vapier@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/sandbox:master commit in: src/
Date: Fri,  5 Nov 2021 10:25:02 +0000 (UTC)	[thread overview]
Message-ID: <1636104535.f0fd6d2e4884177af599416d1cca0423d1b7df08.vapier@gentoo> (raw)

commit:     f0fd6d2e4884177af599416d1cca0423d1b7df08
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Fri Nov  5 09:28:55 2021 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri Nov  5 09:28:55 2021 +0000
URL:        https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=f0fd6d2e

sandbox: add --debug option to control SANDBOX_DEBUG

Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>

 src/environ.c |  2 +-
 src/options.c | 14 +++++++++++++-
 src/sandbox.h |  1 +
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/environ.c b/src/environ.c
index 1535f06..81a3e5f 100644
--- a/src/environ.c
+++ b/src/environ.c
@@ -303,7 +303,7 @@ char **setup_environ(struct sandbox_info_t *sandbox_info, bool interactive)
 	if (!getenv(ENV_SANDBOX_VERBOSE))
 		sb_setenv(&new_environ, ENV_SANDBOX_VERBOSE, "1");
 	if (!getenv(ENV_SANDBOX_DEBUG))
-		sb_setenv(&new_environ, ENV_SANDBOX_DEBUG, "0");
+		sb_setenv(&new_environ, ENV_SANDBOX_DEBUG, opt_debug ? "1" : "0");
 	if (!getenv(ENV_NOCOLOR))
 		sb_setenv(&new_environ, ENV_NOCOLOR, "no");
 	if (!getenv(ENV_SANDBOX_METHOD))

diff --git a/src/options.c b/src/options.c
index 64cd750..5332318 100644
--- a/src/options.c
+++ b/src/options.c
@@ -21,6 +21,7 @@ int opt_use_ns_time = -1;
 int opt_use_ns_user = -1;
 int opt_use_ns_uts = -1;
 bool opt_use_bash = false;
+int opt_debug = -1;
 
 static const struct {
 	const char *name;
@@ -38,6 +39,7 @@ static const struct {
 	{ "NAMESPACE_TIME_ENABLE",   &opt_use_ns_time,    false, },
 	{ "NAMESPACE_USER_ENABLE",   &opt_use_ns_user,    false, },
 	{ "NAMESPACE_UTS_ENABLE",    &opt_use_ns_uts,     false, },
+	{ "SANDBOX_DEBUG",           &opt_debug,          false, },
 };
 
 static void read_config(void)
@@ -77,7 +79,7 @@ static void show_version(void)
 	exit(0);
 }
 
-#define PARSE_FLAGS "+chV"
+#define PARSE_FLAGS "+cdhV"
 #define a_argument required_argument
 static struct option const long_opts[] = {
 	{"ns-on",         no_argument, &opt_use_namespaces, true},
@@ -101,6 +103,7 @@ static struct option const long_opts[] = {
 	{"ns-uts-on",     no_argument, &opt_use_ns_uts, true},
 	{"ns-uts-off",    no_argument, &opt_use_ns_uts, false},
 	{"bash",          no_argument, NULL, 'c'},
+	{"debug",         no_argument, NULL, 'd'},
 	{"help",          no_argument, NULL, 'h'},
 	{"version",       no_argument, NULL, 'V'},
 	{"run-configure", no_argument, NULL, 0x800},
@@ -128,6 +131,7 @@ static const char * const opts_help[] = {
 	"Enable  the use of UTS (hostname/uname) namespaces",
 	"Disable the use of UTS (hostname/uname) namespaces",
 	"Run command through bash shell",
+	"Enable debug output",
 	"Print this help and exit",
 	"Print version and exit",
 	"Run local sandbox configure in same way and exit (developer only)",
@@ -207,6 +211,12 @@ void parseargs(int argc, char *argv[])
 		case 'c':
 			opt_use_bash = true;
 			break;
+		case 'd':
+			if (opt_debug <= 0)
+				opt_debug = 1;
+			else
+				++opt_debug;
+			break;
 		case 'V':
 			show_version();
 		case 'h':
@@ -215,6 +225,8 @@ void parseargs(int argc, char *argv[])
 			run_configure(argc, argv);
 		case '?':
 			show_usage(1);
+		default:
+			sb_ebort("ISE: unhandled CLI option %c\n", i);
 		}
 	}
 

diff --git a/src/sandbox.h b/src/sandbox.h
index 0c0430f..28961f5 100644
--- a/src/sandbox.h
+++ b/src/sandbox.h
@@ -53,5 +53,6 @@ extern int opt_use_ns_time;
 extern int opt_use_ns_user;
 extern int opt_use_ns_uts;
 extern bool opt_use_bash;
+extern int opt_debug;
 
 #endif


             reply	other threads:[~2021-11-05 10:25 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-05 10:25 Mike Frysinger [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-08-08 15:30 [gentoo-commits] proj/sandbox:master commit in: src/ Mike Gilbert
2023-08-05 23:38 Mike Gilbert
2023-08-05 23:38 Mike Gilbert
2021-11-05 10:25 Mike Frysinger
2021-11-03  4:55 Mike Frysinger
2021-11-02  4:28 Mike Frysinger
2021-11-02  4:28 Mike Frysinger
2021-11-01 18:31 Mike Frysinger
2021-10-29  5:37 Mike Frysinger
2021-10-28  9:56 Mike Frysinger
2016-03-29 12:24 Mike Frysinger
2015-09-11  7:53 Mike Frysinger
2015-09-11  7:53 Mike Frysinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1636104535.f0fd6d2e4884177af599416d1cca0423d1b7df08.vapier@gentoo \
    --to=vapier@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox