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
| 87 | 87 | """Create a Linux group for Google added sudo user accounts.""" | |
| 88 | 88 | if not self._GetGroup(self.google_sudoers_group): | |
| 89 | 89 | 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(' ')) | |
| 93 | 92 | except subprocess.CalledProcessError as e: | |
| 94 | 93 | self.logger.warning('Could not create the sudoers group. %s.', str(e)) | |
| 95 | 94 | ||
| ⋯ | |||
| 135 | 134 | ||
| 136 | 135 | command = self.useradd_cmd.format(user=user) | |
| 137 | 136 | try: | |
| 138 | - | subprocess.check_call(command, shell=True) | |
| 137 | + | subprocess.check_call(command.split(' ')) | |
| 139 | 138 | except subprocess.CalledProcessError as e: | |
| 140 | 139 | self.logger.warning('Could not create user %s. %s.', user, str(e)) | |
| 141 | 140 | return False | |
| ⋯ | |||
| 157 | 156 | self.logger.debug('Updating user %s with groups %s.', user, groups) | |
| 158 | 157 | command = self.usermod_cmd.format(user=user, groups=groups) | |
| 159 | 158 | try: | |
| 160 | - | subprocess.check_call(command, shell=True) | |
| 159 | + | subprocess.check_call(command.split(' ')) | |
| 161 | 160 | except subprocess.CalledProcessError as e: | |
| 162 | 161 | self.logger.warning('Could not update user %s. %s.', user, str(e)) | |
| 163 | 162 | return False | |
| ⋯ | |||
| 333 | 332 | if self.remove: | |
| 334 | 333 | command = self.userdel_cmd.format(user=user) | |
| 335 | 334 | try: | |
| 336 | - | subprocess.check_call(command, shell=True) | |
| 335 | + | subprocess.check_call(command.split(' ')) | |
| 337 | 336 | except subprocess.CalledProcessError as e: | |
| 338 | 337 | self.logger.warning('Could not remove user %s. %s.', user, str(e)) | |
| 339 | 338 | else: | |
The check that tells the two apart
fail→pass·google_compute_engine/accounts/tests/accounts_utils_test.py::AccountsUtilsTest::testCreateSudoersGroup
fail→pass·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
- 2016-08-26IpForwardingUtils
- 2016-08-22Fix user account management on Python 3. (#327)