mirror of https://github.com/apache/jclouds.git
JCLOUDS-973 Extending the sudo's configuration
- Adding env_reset to the default configuration in /etc/sudoers - Adding secure_path to the default configuration in /etc/sudoers - secure_path value is "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
This commit is contained in:
parent
a585440e70
commit
c6f2d84611
|
@ -204,6 +204,8 @@ END_OF_JCLOUDS_SCRIPT
|
|||
rm -f $INSTANCE_HOME/rc
|
||||
trap 'echo $?>$INSTANCE_HOME/rc' 0 1 2 3 15
|
||||
cat > /etc/sudoers <<-'END_OF_JCLOUDS_FILE'
|
||||
Defaults env_reset
|
||||
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
root ALL = (ALL) ALL
|
||||
%wheel ALL = (ALL) NOPASSWD:ALL
|
||||
END_OF_JCLOUDS_FILE
|
||||
|
|
|
@ -204,6 +204,8 @@ END_OF_JCLOUDS_SCRIPT
|
|||
rm -f $INSTANCE_HOME/rc
|
||||
trap 'echo $?>$INSTANCE_HOME/rc' 0 1 2 3 15
|
||||
cat > /etc/sudoers <<-'END_OF_JCLOUDS_FILE'
|
||||
Defaults env_reset
|
||||
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
root ALL = (ALL) ALL
|
||||
%wheel ALL = (ALL) NOPASSWD:ALL
|
||||
END_OF_JCLOUDS_FILE
|
||||
|
|
|
@ -85,6 +85,8 @@ END_OF_JCLOUDS_SCRIPT
|
|||
rm -f $INSTANCE_HOME/rc
|
||||
trap 'echo $?>$INSTANCE_HOME/rc' 0 1 2 3 15
|
||||
cat > /etc/sudoers <<-'END_OF_JCLOUDS_FILE'
|
||||
Defaults env_reset
|
||||
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
root ALL = (ALL) ALL
|
||||
%wheel ALL = (ALL) NOPASSWD:ALL
|
||||
END_OF_JCLOUDS_FILE
|
||||
|
|
|
@ -41,7 +41,12 @@ public class Sudoers implements Statement {
|
|||
if (family == OsFamily.WINDOWS)
|
||||
throw new UnsupportedOperationException("windows not yet implemented");
|
||||
Builder<Statement> statements = ImmutableList.builder();
|
||||
statements.add(createOrOverwriteFile(sudoers, ImmutableSet.of("root ALL = (ALL) ALL", "%wheel ALL = (ALL) NOPASSWD:ALL")));
|
||||
statements.add(createOrOverwriteFile(sudoers, ImmutableSet.of(
|
||||
"Defaults env_reset",
|
||||
"Defaults secure_path=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\"",
|
||||
"root ALL = (ALL) ALL",
|
||||
"%wheel ALL = (ALL) NOPASSWD:ALL"))
|
||||
);
|
||||
statements.add(exec("chmod 0440 " + sudoers));
|
||||
return new StatementList(statements.build()).render(family);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@ public class SudoStatementsTest {
|
|||
assertEquals(
|
||||
SudoStatements.createWheel().render(OsFamily.UNIX),
|
||||
"cat > /etc/sudoers <<-'END_OF_JCLOUDS_FILE'\n" +
|
||||
"\tDefaults env_reset\n" +
|
||||
"\tDefaults secure_path=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\"\n" +
|
||||
"\troot ALL = (ALL) ALL\n" +
|
||||
"\t%wheel ALL = (ALL) NOPASSWD:ALL\n" +
|
||||
"END_OF_JCLOUDS_FILE\n" +
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
rm /etc/sudoers
|
||||
cat >> /etc/sudoers <<'END_OF_FILE'
|
||||
Defaults env_reset
|
||||
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
root ALL = (ALL) ALL
|
||||
%wheel ALL = (ALL) NOPASSWD:ALL
|
||||
END_OF_FILE
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
cat > /etc/sudoers <<-'END_OF_JCLOUDS_FILE'
|
||||
Defaults env_reset
|
||||
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
root ALL = (ALL) ALL
|
||||
%wheel ALL = (ALL) NOPASSWD:ALL
|
||||
END_OF_JCLOUDS_FILE
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
cat > /etc/sudoers <<-'END_OF_JCLOUDS_FILE'
|
||||
Defaults env_reset
|
||||
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
root ALL = (ALL) ALL
|
||||
%wheel ALL = (ALL) NOPASSWD:ALL
|
||||
END_OF_JCLOUDS_FILE
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
cat > /etc/sudoers <<-'END_OF_JCLOUDS_FILE'
|
||||
Defaults env_reset
|
||||
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
root ALL = (ALL) ALL
|
||||
%wheel ALL = (ALL) NOPASSWD:ALL
|
||||
END_OF_JCLOUDS_FILE
|
||||
|
|
Loading…
Reference in New Issue