Skip to content

Commit 45e4d4f

Browse files
author
John Kinsella
committed
Summary: Updated sudoers approved commands for cloud user
Detail: Previously the cloud user has full password-less sudo access. This commit changes that to only allow access to a specific list of commands. Been tested in production on ACS 4.0 and 4.2 mangement servers. BUG-ID: CLOUDSTACK-967 Bugfix-for: Reviewed-by: Reported-by: Signed-off-by: John Kinsella <[email protected]> 1382560936 -0700
1 parent 5133812 commit 45e4d4f

8 files changed

Lines changed: 8 additions & 8 deletions

File tree

python/lib/cloudutils/serviceConfig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ def __init__(self, syscfg):
727727
def config(self):
728728
try:
729729
cfo = configFileOps("/etc/sudoers", self)
730-
cfo.addEntry("cloud ALL ", "NOPASSWD : ALL")
730+
cfo.addEntry("cloud ALL ", "NOPASSWD : /bin/chmod, /bin/cp, /bin/mkdir, /bin/mount, /bin/umount")
731731
cfo.rmEntry("Defaults", "requiretty", " ")
732732
cfo.save()
733733
return True

server/conf/cloudstack-sudoers.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@
1818
# The CloudStack management server needs sudo permissions
1919
# without a password.
2020

21-
@MSUSER@ ALL =NOPASSWD : ALL
21+
@MSUSER@ ALL =NOPASSWD : /bin/chmod, /bin/cp, /bin/mkdir, /bin/mount, /bin/umount
2222

tools/appliance/definitions/devcloud/base.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ apt-get -y update
66
apt-get -y install curl unzip
77
apt-get clean
88

9-
echo 'cloud ALL=NOPASSWD:ALL' > /etc/sudoers.d/cloud
9+
echo 'cloud ALL=NOPASSWD:/bin/chmod, /bin/cp, /bin/mkdir, /bin/mount, /bin/umount' > /etc/sudoers.d/cloud
1010

1111
# Tweak sshd to prevent DNS resolution (speed up logins)
1212
echo 'UseDNS no' >> /etc/ssh/sshd_config

tools/appliance/definitions/systemvm64template/base.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ apt-get -y update
55
apt-get -y install curl unzip
66

77
# Set up sudo
8-
echo 'vagrant ALL=NOPASSWD:ALL' > /etc/sudoers.d/vagrant
8+
echo 'vagrant ALL=NOPASSWD:/bin/chmod, /bin/cp, /bin/mkdir, /bin/mount, /bin/umount' > /etc/sudoers.d/vagrant
99

1010
# Tweak sshd to prevent DNS resolution (speed up logins)
1111
echo 'UseDNS no' >> /etc/ssh/sshd_config

tools/appliance/definitions/systemvm64template/postinstall.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ setup_accounts() {
105105
echo "root:$ROOTPW" | chpasswd
106106
echo "cloud:`openssl rand -base64 32`" | chpasswd
107107
sed -i -e '/Defaults\s\+env_reset/a Defaults\texempt_group=admin' /etc/sudoers
108-
sed -i -e 's/%admin ALL=(ALL) ALL/%admin ALL=NOPASSWD:ALL/g' /etc/sudoers
108+
sed -i -e 's/%admin ALL=(ALL) ALL/%admin ALL=NOPASSWD:/bin/chmod, /bin/cp, /bin/mkdir, /bin/mount, /bin/umount/g' /etc/sudoers
109109
# Disable password based authentication via ssh, this will take effect on next reboot
110110
sed -i -e 's/^.*PasswordAuthentication .*$/PasswordAuthentication no/g' /etc/ssh/sshd_config
111111
# Secure ~/.ssh

tools/appliance/definitions/systemvmtemplate/base.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ apt-get -y install curl unzip
77
apt-get clean
88

99
# Set up sudo, TODO: Check security concerns
10-
echo 'cloud ALL=NOPASSWD:ALL' > /etc/sudoers.d/cloud
10+
echo 'cloud ALL=NOPASSWD:/bin/chmod, /bin/cp, /bin/mkdir, /bin/mount, /bin/umount' > /etc/sudoers.d/cloud
1111

1212
# Tweak sshd to prevent DNS resolution (speed up logins)
1313
echo 'UseDNS no' >> /etc/ssh/sshd_config

tools/appliance/definitions/systemvmtemplate/postinstall.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ setup_accounts() {
104104
echo "root:$ROOTPW" | chpasswd
105105
echo "cloud:`openssl rand -base64 32`" | chpasswd
106106
sed -i -e '/Defaults\s\+env_reset/a Defaults\texempt_group=admin' /etc/sudoers
107-
sed -i -e 's/%admin ALL=(ALL) ALL/%admin ALL=NOPASSWD:ALL/g' /etc/sudoers
107+
sed -i -e 's/%admin ALL=(ALL) ALL/%admin ALL=NOPASSWD:/bin/chmod, /bin/cp, /bin/mkdir, /bin/mount, /bin/umount/g' /etc/sudoers
108108
# Disable password based authentication via ssh, this will take effect on next reboot
109109
sed -i -e 's/^.*PasswordAuthentication .*$/PasswordAuthentication no/g' /etc/ssh/sshd_config
110110
# Secure ~/.ssh

tools/devcloud/src/deps/boxes/basebox-build/postinstall.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ groupadd -r admin
2828
usermod -a -G admin devcloud
2929
echo "root:password" | chpasswd
3030
sed -i -e '/Defaults\s\+env_reset/a Defaults\texempt_group=admin' /etc/sudoers
31-
sed -i -e 's/%admin ALL=(ALL) ALL/%admin ALL=NOPASSWD:ALL/g' /etc/sudoers
31+
sed -i -e 's/%admin ALL=(ALL) ALL/%admin ALL=NOPASSWD:/bin/chmod, /bin/cp, /bin/mkdir, /bin/mount, /bin/umount/g' /etc/sudoers
3232

3333
mkdir /home/devcloud/.ssh
3434
chmod 700 /home/devcloud/.ssh

0 commit comments

Comments
 (0)