mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-21 21:52:10 +02:00
Bug 495836 - Eclipse CDT needs privileged mode for docker containers
This adds a checkbox to the container tab of the container launcher to enable privileged mode. It requires a corresponding change to the linuxtools repo. Change-Id: I3f5fc15490e58304d3f43669fd6b16373a30ef7c Signed-off-by: Nils Carlson <nils.carlson@ludd.ltu.se>
This commit is contained in:
parent
9e1e981b4d
commit
ff412311a7
5 changed files with 40 additions and 2 deletions
|
@ -161,11 +161,15 @@ public class ContainerLaunchConfigurationDelegate extends GdbLaunchDelegate
|
|||
boolean supportStdin = configuration.getAttribute(
|
||||
ILaunchConstants.ATTR_STDIN_SUPPORT, false);
|
||||
|
||||
boolean privilegedMode = configuration.getAttribute(
|
||||
ILaunchConstants.ATTR_PRIVILEGED_MODE, false);
|
||||
|
||||
launcher.launch(DockerLaunchUIPlugin.PLUGIN_ID, null,
|
||||
connectionUri,
|
||||
image, command,
|
||||
commandDir, workingDir, additionalDirs, origEnv,
|
||||
envMap, null, keepContainer, supportStdin);
|
||||
envMap, null, keepContainer, supportStdin,
|
||||
privilegedMode);
|
||||
} else if (mode.equals(ILaunchManager.DEBUG_MODE)) {
|
||||
String gdbserverPortNumber = configuration.getAttribute(
|
||||
ILaunchConstants.ATTR_GDBSERVER_PORT,
|
||||
|
@ -220,6 +224,9 @@ public class ContainerLaunchConfigurationDelegate extends GdbLaunchDelegate
|
|||
boolean supportStdin = configuration.getAttribute(
|
||||
ILaunchConstants.ATTR_STDIN_SUPPORT, false);
|
||||
|
||||
boolean privilegedMode = configuration.getAttribute(
|
||||
ILaunchConstants.ATTR_PRIVILEGED_MODE, false);
|
||||
|
||||
StartGdbServerJob job = new StartGdbServerJob(
|
||||
Messages.Gdbserver_start);
|
||||
job.schedule();
|
||||
|
@ -227,7 +234,8 @@ public class ContainerLaunchConfigurationDelegate extends GdbLaunchDelegate
|
|||
connectionUri,
|
||||
image, command,
|
||||
commandDir, workingDir, additionalDirs, origEnv,
|
||||
envMap, ports, keepContainer, supportStdin);
|
||||
envMap, ports, keepContainer, supportStdin,
|
||||
privilegedMode);
|
||||
|
||||
// wait until gdbserver is started successfully and we have its
|
||||
// ip address or
|
||||
|
|
|
@ -58,6 +58,7 @@ public class ContainerTab extends AbstractLaunchConfigurationTab implements
|
|||
private String connectionUri = "";
|
||||
private Boolean keepValue;
|
||||
private Boolean stdinValue;
|
||||
private Boolean privilegedValue;
|
||||
private IDockerConnection connection;
|
||||
private IDockerConnection[] connections;
|
||||
private IDockerImageListener containerTab;
|
||||
|
@ -66,6 +67,7 @@ public class ContainerTab extends AbstractLaunchConfigurationTab implements
|
|||
private Button removeButton;
|
||||
private Button keepButton;
|
||||
private Button stdinButton;
|
||||
private Button privilegedButton;
|
||||
private Combo imageCombo;
|
||||
private Combo connectionSelector;
|
||||
|
||||
|
@ -263,6 +265,24 @@ public class ContainerTab extends AbstractLaunchConfigurationTab implements
|
|||
}
|
||||
|
||||
});
|
||||
privilegedButton = createCheckButton(group,
|
||||
Messages.ContainerTab_Privileged_Mode_Label);
|
||||
privilegedButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
privilegedValue = false;
|
||||
privilegedButton.addSelectionListener(new SelectionListener() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
if (!privilegedValue.equals(privilegedButton.getSelection()))
|
||||
updateLaunchConfigurationDialog();
|
||||
privilegedValue = privilegedButton.getSelection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void widgetDefaultSelected(SelectionEvent e) {
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private Composite createComposite(Composite parent, int columns, int hspan,
|
||||
|
@ -434,6 +454,9 @@ public class ContainerTab extends AbstractLaunchConfigurationTab implements
|
|||
stdinValue = configuration.getAttribute(
|
||||
ILaunchConstants.ATTR_STDIN_SUPPORT, false);
|
||||
stdinButton.setSelection(stdinValue);
|
||||
privilegedValue = configuration
|
||||
.getAttribute(ILaunchConstants.ATTR_PRIVILEGED_MODE, false);
|
||||
privilegedButton.setSelection(privilegedValue);
|
||||
} catch (CoreException e) {
|
||||
setErrorMessage(Messages.bind(
|
||||
Messages.ContainerTab_Error_Reading_Configuration, e
|
||||
|
@ -455,6 +478,8 @@ public class ContainerTab extends AbstractLaunchConfigurationTab implements
|
|||
keepButton.getSelection());
|
||||
configuration.setAttribute(ILaunchConstants.ATTR_STDIN_SUPPORT,
|
||||
stdinButton.getSelection());
|
||||
configuration.setAttribute(ILaunchConstants.ATTR_PRIVILEGED_MODE,
|
||||
privilegedButton.getSelection());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -33,6 +33,9 @@ public interface ILaunchConstants {
|
|||
public final static String ATTR_STDIN_SUPPORT = DockerLaunchUIPlugin
|
||||
.getUniqueIdentifier() + ".support_std_input"; //$NON-NLS-1$
|
||||
|
||||
public final static String ATTR_PRIVILEGED_MODE = DockerLaunchUIPlugin
|
||||
.getUniqueIdentifier() + ".privileged_mode"; //$NON-NLS-1$
|
||||
|
||||
// Attributes that need to match CDT attribute names
|
||||
public static final String ATTR_GDBSERVER_PORT = DebugPlugin
|
||||
.getUniqueIdentifier() + ".ATTR_GDBSERVER_PORT"; //$NON-NLS-1$
|
||||
|
|
|
@ -38,6 +38,7 @@ public class Messages extends NLS {
|
|||
public static String ContainerTab_Remove_Button;
|
||||
public static String ContainerTab_Keep_Label;
|
||||
public static String ContainerTab_Stdin_Support_Label;
|
||||
public static String ContainerTab_Privileged_Mode_Label;
|
||||
public static String ContainerTab_Error_Reading_Configuration;
|
||||
public static String ContainerTab_Connection_Selector_Label;
|
||||
public static String ContainerTab_Image_Selector_Label;
|
||||
|
|
|
@ -29,6 +29,7 @@ ContainerTab_New_Button=New...
|
|||
ContainerTab_Remove_Button=Remove
|
||||
ContainerTab_Keep_Label=Keep Container after launch
|
||||
ContainerTab_Stdin_Support_Label=Support stdin input
|
||||
ContainerTab_Privileged_Mode_Label=Run in privileged mode
|
||||
ContainerTab_Group_Name=Required host directories
|
||||
ContainerTab_Option_Group_Name=Additional Options
|
||||
ContainerTab_Connection_Selector_Label=Connection:
|
||||
|
|
Loading…
Add table
Reference in a new issue