[Lldb-commits] [PATCH] D85237: [lldb] Add an option to inherit TCC permissions from parent.

2020-08-05 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG249a1d4f1bed: [lldb] Add an option to inherit TCC 
permissions from parent. (authored by JDevlieghere).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85237/new/

https://reviews.llvm.org/D85237

Files:
  lldb/include/lldb/Target/Target.h
  lldb/include/lldb/lldb-enumerations.h
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Host/macosx/objcxx/Host.mm
  lldb/source/Target/Target.cpp
  lldb/source/Target/TargetProperties.td
  lldb/test/Shell/lit-lldb-init.in

Index: lldb/test/Shell/lit-lldb-init.in
===
--- lldb/test/Shell/lit-lldb-init.in
+++ lldb/test/Shell/lit-lldb-init.in
@@ -4,3 +4,4 @@
 settings set interpreter.echo-comment-commands false
 settings set symbols.clang-modules-cache-path "@LLDB_TEST_MODULE_CACHE_LLDB@"
 settings set target.auto-apply-fixits false
+settings set target.inherit-tcc true
Index: lldb/source/Target/TargetProperties.td
===
--- lldb/source/Target/TargetProperties.td
+++ lldb/source/Target/TargetProperties.td
@@ -111,6 +111,9 @@
   def DisableSTDIO: Property<"disable-stdio", "Boolean">,
 DefaultFalse,
 Desc<"Disable stdin/stdout for process (e.g. for a GUI application)">;
+  def InheritTCC: Property<"inherit-tcc", "Boolean">,
+DefaultFalse,
+Desc<"Inherit the TCC permissions from the inferior's parent instead of making the process itself responsible.">;
   def InlineStrategy: Property<"inline-breakpoint-strategy", "Enum">,
 DefaultEnumValue<"eInlineBreakpointsAlways">,
 EnumValues<"OptionEnumValues(g_inline_breakpoint_enums)">,
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -3430,6 +3430,8 @@
 });
 m_collection_sp->SetValueChangedCallback(
 ePropertyDisableASLR, [this] { DisableASLRValueChangedCallback(); });
+m_collection_sp->SetValueChangedCallback(
+ePropertyInheritTCC, [this] { InheritTCCValueChangedCallback(); });
 m_collection_sp->SetValueChangedCallback(
 ePropertyDisableSTDIO, [this] { DisableSTDIOValueChangedCallback(); });
 
@@ -3468,6 +3470,7 @@
   ErrorPathValueChangedCallback();
   DetachOnErrorValueChangedCallback();
   DisableASLRValueChangedCallback();
+  InheritTCCValueChangedCallback();
   DisableSTDIOValueChangedCallback();
 }
 
@@ -3550,6 +3553,17 @@
   m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
 }
 
+bool TargetProperties::GetInheritTCC() const {
+  const uint32_t idx = ePropertyInheritTCC;
+  return m_collection_sp->GetPropertyAtIndexAsBoolean(
+  nullptr, idx, g_target_properties[idx].default_uint_value != 0);
+}
+
+void TargetProperties::SetInheritTCC(bool b) {
+  const uint32_t idx = ePropertyInheritTCC;
+  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
+}
+
 bool TargetProperties::GetDetachOnError() const {
   const uint32_t idx = ePropertyDetachOnError;
   return m_collection_sp->GetPropertyAtIndexAsBoolean(
@@ -3941,6 +3955,8 @@
   }
   SetDetachOnError(launch_info.GetFlags().Test(lldb::eLaunchFlagDetachOnError));
   SetDisableASLR(launch_info.GetFlags().Test(lldb::eLaunchFlagDisableASLR));
+  SetInheritTCC(
+  launch_info.GetFlags().Test(lldb::eLaunchFlagInheritTCCFromParent));
   SetDisableSTDIO(launch_info.GetFlags().Test(lldb::eLaunchFlagDisableSTDIO));
 }
 
@@ -4004,6 +4020,13 @@
 m_launch_info.GetFlags().Clear(lldb::eLaunchFlagDisableASLR);
 }
 
+void TargetProperties::InheritTCCValueChangedCallback() {
+  if (GetInheritTCC())
+m_launch_info.GetFlags().Set(lldb::eLaunchFlagInheritTCCFromParent);
+  else
+m_launch_info.GetFlags().Clear(lldb::eLaunchFlagInheritTCCFromParent);
+}
+
 void TargetProperties::DisableSTDIOValueChangedCallback() {
   if (GetDisableSTDIO())
 m_launch_info.GetFlags().Set(lldb::eLaunchFlagDisableSTDIO);
Index: lldb/source/Host/macosx/objcxx/Host.mm
===
--- lldb/source/Host/macosx/objcxx/Host.mm
+++ lldb/source/Host/macosx/objcxx/Host.mm
@@ -1095,10 +1095,11 @@
 is_graphical = session_attributes & sessionHasGraphicAccess;
 #endif
 
-  //  When lldb is ran through a graphical session, this makes the debuggee
-  //  process responsible for the TCC prompts. Otherwise, lldb will use the
-  //  launching process privileges.
-  if (is_graphical && launch_info.GetFlags().Test(eLaunchFlagDebug)) {
+  //  When lldb is ran through a graphical session, make the debuggee process
+  //  responsible for its own TCC permissions instead of inheriting them from
+  //  its parent.
+  if (is_graphical && launch_info.GetFlags().Test(eLaunchFlagDebug) &&
+  

[Lldb-commits] [PATCH] D85237: [lldb] Add an option to inherit TCC permissions from parent.

2020-08-04 Thread Frederic Riss via Phabricator via lldb-commits
friss accepted this revision.
friss added a comment.
This revision is now accepted and ready to land.

LGTM


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85237/new/

https://reviews.llvm.org/D85237

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D85237: [lldb] Add an option to inherit TCC permissions from parent.

2020-08-04 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 283057.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85237/new/

https://reviews.llvm.org/D85237

Files:
  lldb/include/lldb/Target/Target.h
  lldb/include/lldb/lldb-enumerations.h
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Host/macosx/objcxx/Host.mm
  lldb/source/Target/Target.cpp
  lldb/source/Target/TargetProperties.td
  lldb/test/Shell/lit-lldb-init.in

Index: lldb/test/Shell/lit-lldb-init.in
===
--- lldb/test/Shell/lit-lldb-init.in
+++ lldb/test/Shell/lit-lldb-init.in
@@ -4,3 +4,4 @@
 settings set interpreter.echo-comment-commands false
 settings set symbols.clang-modules-cache-path "@LLDB_TEST_MODULE_CACHE_LLDB@"
 settings set target.auto-apply-fixits false
+settings set target.inherit-tcc true
Index: lldb/source/Target/TargetProperties.td
===
--- lldb/source/Target/TargetProperties.td
+++ lldb/source/Target/TargetProperties.td
@@ -111,6 +111,9 @@
   def DisableSTDIO: Property<"disable-stdio", "Boolean">,
 DefaultFalse,
 Desc<"Disable stdin/stdout for process (e.g. for a GUI application)">;
+  def InheritTCC: Property<"inherit-tcc", "Boolean">,
+DefaultFalse,
+Desc<"Inherit the TCC permissions from the inferior's parent instead of making the process itself responsible.">;
   def InlineStrategy: Property<"inline-breakpoint-strategy", "Enum">,
 DefaultEnumValue<"eInlineBreakpointsAlways">,
 EnumValues<"OptionEnumValues(g_inline_breakpoint_enums)">,
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -3430,6 +3430,8 @@
 });
 m_collection_sp->SetValueChangedCallback(
 ePropertyDisableASLR, [this] { DisableASLRValueChangedCallback(); });
+m_collection_sp->SetValueChangedCallback(
+ePropertyInheritTCC, [this] { InheritTCCValueChangedCallback(); });
 m_collection_sp->SetValueChangedCallback(
 ePropertyDisableSTDIO, [this] { DisableSTDIOValueChangedCallback(); });
 
@@ -3468,6 +3470,7 @@
   ErrorPathValueChangedCallback();
   DetachOnErrorValueChangedCallback();
   DisableASLRValueChangedCallback();
+  InheritTCCValueChangedCallback();
   DisableSTDIOValueChangedCallback();
 }
 
@@ -3550,6 +3553,17 @@
   m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
 }
 
+bool TargetProperties::GetInheritTCC() const {
+  const uint32_t idx = ePropertyInheritTCC;
+  return m_collection_sp->GetPropertyAtIndexAsBoolean(
+  nullptr, idx, g_target_properties[idx].default_uint_value != 0);
+}
+
+void TargetProperties::SetInheritTCC(bool b) {
+  const uint32_t idx = ePropertyInheritTCC;
+  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
+}
+
 bool TargetProperties::GetDetachOnError() const {
   const uint32_t idx = ePropertyDetachOnError;
   return m_collection_sp->GetPropertyAtIndexAsBoolean(
@@ -3941,6 +3955,8 @@
   }
   SetDetachOnError(launch_info.GetFlags().Test(lldb::eLaunchFlagDetachOnError));
   SetDisableASLR(launch_info.GetFlags().Test(lldb::eLaunchFlagDisableASLR));
+  SetInheritTCC(
+  launch_info.GetFlags().Test(lldb::eLaunchFlagInheritTCCFromParent));
   SetDisableSTDIO(launch_info.GetFlags().Test(lldb::eLaunchFlagDisableSTDIO));
 }
 
@@ -4004,6 +4020,13 @@
 m_launch_info.GetFlags().Clear(lldb::eLaunchFlagDisableASLR);
 }
 
+void TargetProperties::InheritTCCValueChangedCallback() {
+  if (GetInheritTCC())
+m_launch_info.GetFlags().Set(lldb::eLaunchFlagInheritTCCFromParent);
+  else
+m_launch_info.GetFlags().Clear(lldb::eLaunchFlagInheritTCCFromParent);
+}
+
 void TargetProperties::DisableSTDIOValueChangedCallback() {
   if (GetDisableSTDIO())
 m_launch_info.GetFlags().Set(lldb::eLaunchFlagDisableSTDIO);
Index: lldb/source/Host/macosx/objcxx/Host.mm
===
--- lldb/source/Host/macosx/objcxx/Host.mm
+++ lldb/source/Host/macosx/objcxx/Host.mm
@@ -1095,10 +1095,11 @@
 is_graphical = session_attributes & sessionHasGraphicAccess;
 #endif
 
-  //  When lldb is ran through a graphical session, this makes the debuggee
-  //  process responsible for the TCC prompts. Otherwise, lldb will use the
-  //  launching process privileges.
-  if (is_graphical && launch_info.GetFlags().Test(eLaunchFlagDebug)) {
+  //  When lldb is ran through a graphical session, make the debuggee process
+  //  responsible for its own TCC permissions instead of inheriting them from
+  //  its parent.
+  if (is_graphical && launch_info.GetFlags().Test(eLaunchFlagDebug) &&
+  !launch_info.GetFlags().Test(eLaunchFlagInheritTCCFromParent)) {
 error.SetError(setup_posix_spawn_responsible_flag(), eErrorTypePOSIX);
 if (error.Fail()) {
   LLDB_LOG(log, "error: {0}, 

[Lldb-commits] [PATCH] D85237: [lldb] Add an option to inherit TCC permissions from parent.

2020-08-04 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 283054.
JDevlieghere retitled this revision from "[lldb] Add an option to disable TCC" 
to "[lldb] Add an option to inherit TCC permissions from parent.".
JDevlieghere edited the summary of this revision.
JDevlieghere added a comment.

Make it clear that TCC cannot be disabled but instead we're inheriting the 
permissions.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85237/new/

https://reviews.llvm.org/D85237

Files:
  lldb/include/lldb/Target/Target.h
  lldb/include/lldb/lldb-enumerations.h
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Host/macosx/objcxx/Host.mm
  lldb/source/Target/Target.cpp
  lldb/source/Target/TargetProperties.td
  lldb/test/Shell/lit-lldb-init.in

Index: lldb/test/Shell/lit-lldb-init.in
===
--- lldb/test/Shell/lit-lldb-init.in
+++ lldb/test/Shell/lit-lldb-init.in
@@ -4,3 +4,4 @@
 settings set interpreter.echo-comment-commands false
 settings set symbols.clang-modules-cache-path "@LLDB_TEST_MODULE_CACHE_LLDB@"
 settings set target.auto-apply-fixits false
+settings set target.inherit-tcc true
Index: lldb/source/Target/TargetProperties.td
===
--- lldb/source/Target/TargetProperties.td
+++ lldb/source/Target/TargetProperties.td
@@ -111,6 +111,9 @@
   def DisableSTDIO: Property<"disable-stdio", "Boolean">,
 DefaultFalse,
 Desc<"Disable stdin/stdout for process (e.g. for a GUI application)">;
+  def DisableTCC: Property<"inherit-tcc", "Boolean">,
+DefaultFalse,
+Desc<"Inherit the TCC permissions from the inferior's parent instead of making the process itself responsible.">;
   def InlineStrategy: Property<"inline-breakpoint-strategy", "Enum">,
 DefaultEnumValue<"eInlineBreakpointsAlways">,
 EnumValues<"OptionEnumValues(g_inline_breakpoint_enums)">,
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -3430,6 +3430,8 @@
 });
 m_collection_sp->SetValueChangedCallback(
 ePropertyDisableASLR, [this] { DisableASLRValueChangedCallback(); });
+m_collection_sp->SetValueChangedCallback(
+ePropertyInheritTCC, [this] { InheritTCCValueChangedCallback(); });
 m_collection_sp->SetValueChangedCallback(
 ePropertyDisableSTDIO, [this] { DisableSTDIOValueChangedCallback(); });
 
@@ -3468,6 +3470,7 @@
   ErrorPathValueChangedCallback();
   DetachOnErrorValueChangedCallback();
   DisableASLRValueChangedCallback();
+  InheritTCCValueChangedCallback();
   DisableSTDIOValueChangedCallback();
 }
 
@@ -3550,6 +3553,17 @@
   m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
 }
 
+bool TargetProperties::GetInheritTCC() const {
+  const uint32_t idx = ePropertyInheritTCC;
+  return m_collection_sp->GetPropertyAtIndexAsBoolean(
+  nullptr, idx, g_target_properties[idx].default_uint_value != 0);
+}
+
+void TargetProperties::SetInheritTCC(bool b) {
+  const uint32_t idx = ePropertyInheritTCC;
+  m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
+}
+
 bool TargetProperties::GetDetachOnError() const {
   const uint32_t idx = ePropertyDetachOnError;
   return m_collection_sp->GetPropertyAtIndexAsBoolean(
@@ -3941,6 +3955,8 @@
   }
   SetDetachOnError(launch_info.GetFlags().Test(lldb::eLaunchFlagDetachOnError));
   SetDisableASLR(launch_info.GetFlags().Test(lldb::eLaunchFlagDisableASLR));
+  SetInheritTCC(
+  launch_info.GetFlags().Test(lldb::eLaunchFlagDisableInferiorTCC));
   SetDisableSTDIO(launch_info.GetFlags().Test(lldb::eLaunchFlagDisableSTDIO));
 }
 
@@ -4004,6 +4020,13 @@
 m_launch_info.GetFlags().Clear(lldb::eLaunchFlagDisableASLR);
 }
 
+void TargetProperties::InheritTCCValueChangedCallback() {
+  if (GetInheritTCC())
+m_launch_info.GetFlags().Set(lldb::eLaunchFlagInheritTCCFromParent);
+  else
+m_launch_info.GetFlags().Clear(lldb::eLaunchFlagInheritTCCFromParent);
+}
+
 void TargetProperties::DisableSTDIOValueChangedCallback() {
   if (GetDisableSTDIO())
 m_launch_info.GetFlags().Set(lldb::eLaunchFlagDisableSTDIO);
Index: lldb/source/Host/macosx/objcxx/Host.mm
===
--- lldb/source/Host/macosx/objcxx/Host.mm
+++ lldb/source/Host/macosx/objcxx/Host.mm
@@ -1095,10 +1095,11 @@
 is_graphical = session_attributes & sessionHasGraphicAccess;
 #endif
 
-  //  When lldb is ran through a graphical session, this makes the debuggee
-  //  process responsible for the TCC prompts. Otherwise, lldb will use the
-  //  launching process privileges.
-  if (is_graphical && launch_info.GetFlags().Test(eLaunchFlagDebug)) {
+  //  When lldb is ran through a graphical session, make the debuggee process
+  //  responsible for its own TCC permissions instead of inheriting them from
+  //  its