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
496e27f1af
commit
d45f08e82e
|
@ -204,6 +204,8 @@ END_OF_JCLOUDS_SCRIPT
|
||||||
rm -f $INSTANCE_HOME/rc
|
rm -f $INSTANCE_HOME/rc
|
||||||
trap 'echo $?>$INSTANCE_HOME/rc' 0 1 2 3 15
|
trap 'echo $?>$INSTANCE_HOME/rc' 0 1 2 3 15
|
||||||
cat > /etc/sudoers <<-'END_OF_JCLOUDS_FILE'
|
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
|
root ALL = (ALL) ALL
|
||||||
%wheel ALL = (ALL) NOPASSWD:ALL
|
%wheel ALL = (ALL) NOPASSWD:ALL
|
||||||
END_OF_JCLOUDS_FILE
|
END_OF_JCLOUDS_FILE
|
||||||
|
|
|
@ -204,6 +204,8 @@ END_OF_JCLOUDS_SCRIPT
|
||||||
rm -f $INSTANCE_HOME/rc
|
rm -f $INSTANCE_HOME/rc
|
||||||
trap 'echo $?>$INSTANCE_HOME/rc' 0 1 2 3 15
|
trap 'echo $?>$INSTANCE_HOME/rc' 0 1 2 3 15
|
||||||
cat > /etc/sudoers <<-'END_OF_JCLOUDS_FILE'
|
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
|
root ALL = (ALL) ALL
|
||||||
%wheel ALL = (ALL) NOPASSWD:ALL
|
%wheel ALL = (ALL) NOPASSWD:ALL
|
||||||
END_OF_JCLOUDS_FILE
|
END_OF_JCLOUDS_FILE
|
||||||
|
|
|
@ -85,6 +85,8 @@ END_OF_JCLOUDS_SCRIPT
|
||||||
rm -f $INSTANCE_HOME/rc
|
rm -f $INSTANCE_HOME/rc
|
||||||
trap 'echo $?>$INSTANCE_HOME/rc' 0 1 2 3 15
|
trap 'echo $?>$INSTANCE_HOME/rc' 0 1 2 3 15
|
||||||
cat > /etc/sudoers <<-'END_OF_JCLOUDS_FILE'
|
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
|
root ALL = (ALL) ALL
|
||||||
%wheel ALL = (ALL) NOPASSWD:ALL
|
%wheel ALL = (ALL) NOPASSWD:ALL
|
||||||
END_OF_JCLOUDS_FILE
|
END_OF_JCLOUDS_FILE
|
||||||
|
|
|
@ -41,7 +41,12 @@ public class Sudoers implements Statement {
|
||||||
if (family == OsFamily.WINDOWS)
|
if (family == OsFamily.WINDOWS)
|
||||||
throw new UnsupportedOperationException("windows not yet implemented");
|
throw new UnsupportedOperationException("windows not yet implemented");
|
||||||
Builder<Statement> statements = ImmutableList.builder();
|
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));
|
statements.add(exec("chmod 0440 " + sudoers));
|
||||||
return new StatementList(statements.build()).render(family);
|
return new StatementList(statements.build()).render(family);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@ public class SudoStatementsTest {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
SudoStatements.createWheel().render(OsFamily.UNIX),
|
SudoStatements.createWheel().render(OsFamily.UNIX),
|
||||||
"cat > /etc/sudoers <<-'END_OF_JCLOUDS_FILE'\n" +
|
"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" +
|
"\troot ALL = (ALL) ALL\n" +
|
||||||
"\t%wheel ALL = (ALL) NOPASSWD:ALL\n" +
|
"\t%wheel ALL = (ALL) NOPASSWD:ALL\n" +
|
||||||
"END_OF_JCLOUDS_FILE\n" +
|
"END_OF_JCLOUDS_FILE\n" +
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
rm /etc/sudoers
|
rm /etc/sudoers
|
||||||
cat >> /etc/sudoers <<'END_OF_FILE'
|
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
|
root ALL = (ALL) ALL
|
||||||
%wheel ALL = (ALL) NOPASSWD:ALL
|
%wheel ALL = (ALL) NOPASSWD:ALL
|
||||||
END_OF_FILE
|
END_OF_FILE
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
cat > /etc/sudoers <<-'END_OF_JCLOUDS_FILE'
|
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
|
root ALL = (ALL) ALL
|
||||||
%wheel ALL = (ALL) NOPASSWD:ALL
|
%wheel ALL = (ALL) NOPASSWD:ALL
|
||||||
END_OF_JCLOUDS_FILE
|
END_OF_JCLOUDS_FILE
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
cat > /etc/sudoers <<-'END_OF_JCLOUDS_FILE'
|
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
|
root ALL = (ALL) ALL
|
||||||
%wheel ALL = (ALL) NOPASSWD:ALL
|
%wheel ALL = (ALL) NOPASSWD:ALL
|
||||||
END_OF_JCLOUDS_FILE
|
END_OF_JCLOUDS_FILE
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
cat > /etc/sudoers <<-'END_OF_JCLOUDS_FILE'
|
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
|
root ALL = (ALL) ALL
|
||||||
%wheel ALL = (ALL) NOPASSWD:ALL
|
%wheel ALL = (ALL) NOPASSWD:ALL
|
||||||
END_OF_JCLOUDS_FILE
|
END_OF_JCLOUDS_FILE
|
||||||
|
|
Loading…
Reference in New Issue