Whole file

GoogleCloudPlatform/compute-image-packages

The author described this change as Fix the group and user modification commands. (#460). It counts as a record because the checks below fail on the code as it stood at 15f8a66da and pass on a5287d1f8, with nothing else changed between the two runs.

Fix saved2017-08-16
Sharing licenceApache-2.0 · LICENSE
Change size+5 6

What the code was meant to do, written into the code itself as a save note

Fix the group and user modification commands. (#460)

The change

8787 """Create a Linux group for Google added sudo user accounts."""
8888 if not self._GetGroup(self.google_sudoers_group):
8989 try:
90- subprocess.check_call(
91- self.groupadd_cmd.format(group=self.google_sudoers_group),
92- shell=True)
90+ command = self.groupadd_cmd.format(group=self.google_sudoers_group)
91+ subprocess.check_call(command.split(' '))
9392 except subprocess.CalledProcessError as e:
9493 self.logger.warning('Could not create the sudoers group. %s.', str(e))
9594
135134
136135 command = self.useradd_cmd.format(user=user)
137136 try:
138- subprocess.check_call(command, shell=True)
137+ subprocess.check_call(command.split(' '))
139138 except subprocess.CalledProcessError as e:
140139 self.logger.warning('Could not create user %s. %s.', user, str(e))
141140 return False
157156 self.logger.debug('Updating user %s with groups %s.', user, groups)
158157 command = self.usermod_cmd.format(user=user, groups=groups)
159158 try:
160- subprocess.check_call(command, shell=True)
159+ subprocess.check_call(command.split(' '))
161160 except subprocess.CalledProcessError as e:
162161 self.logger.warning('Could not update user %s. %s.', user, str(e))
163162 return False
333332 if self.remove:
334333 command = self.userdel_cmd.format(user=user)
335334 try:
336- subprocess.check_call(command, shell=True)
335+ subprocess.check_call(command.split(' '))
337336 except subprocess.CalledProcessError as e:
338337 self.logger.warning('Could not remove user %s. %s.', user, str(e))
339338 else:

The check that tells the two apart

failpass·google_compute_engine/accounts/tests/accounts_utils_test.py::AccountsUtilsTest::testCreateSudoersGroup
failpass·google_compute_engine/accounts/tests/accounts_utils_test.py::AccountsUtilsTest::testCreateSudoersGroupError

Check file google_compute_engine/accounts/tests/accounts_utils_test.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it15f8a66da3d763502d4d2c6f5e1c0e219e083759
Broken version dated2017-08-16
Modulegoogle_compute_engine.accounts.accounts_utils
Units changedAccountsUtils
Fingerprintfffed48586033cfc
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in GoogleCloudPlatform/compute-image-packages