Skip to content

Commit 29a3703

Browse files
Revert "Tighten file permissions for virtual MFA bootstrap output (#10193)"
This reverts commit cb89b7d.
1 parent 794c5f3 commit 29a3703

3 files changed

Lines changed: 2 additions & 40 deletions

File tree

.changes/next-release/bugfix-iam-84710.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

awscli/customizations/iamvirtmfa.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
"""
2525

2626
import base64
27-
import os
2827

29-
from awscli.compat import compat_open
3028
from awscli.customizations.arguments import (
3129
StatefulArgument,
3230
is_parsed_result_successful,
@@ -83,9 +81,7 @@ def _save_file(self, parsed, **kwargs):
8381
outfile = self._outfile.value
8482
if method in parsed['VirtualMFADevice']:
8583
body = parsed['VirtualMFADevice'][method]
86-
with compat_open(outfile, 'wb', access_permissions=0o600) as fp:
87-
if hasattr(os, 'fchmod'):
88-
os.fchmod(fp.fileno(), 0o600)
84+
with open(outfile, 'wb') as fp:
8985
fp.write(base64.b64decode(body))
9086
for choice in CHOICES:
9187
if choice in parsed['VirtualMFADevice']:

tests/functional/iam/test_create_virtual_mfa_device.py

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# language governing permissions and limitations under the License.
1414
import os
1515

16-
from awscli.testutils import BaseAWSCommandParamsTest, skip_if_windows
16+
from awscli.testutils import BaseAWSCommandParamsTest
1717

1818

1919
class TestCreateVirtualMFADevice(BaseAWSCommandParamsTest):
@@ -161,32 +161,3 @@ def test_bad_response(self):
161161
stderr_contains=self.parsed_response['Error']['Message'],
162162
expected_rc=254,
163163
)
164-
165-
@skip_if_windows("Permissions test not valid on Windows.")
166-
def test_output_file_permissions(self):
167-
outfile = self.getpath('fiebaz_perms.b32')
168-
self.addCleanup(self.remove_file_if_exists, outfile)
169-
cmdline = self.prefix
170-
cmdline += ' --virtual-mfa-device-name fiebaz'
171-
cmdline += (
172-
' --outfile %s --bootstrap-method Base32StringSeed' % outfile
173-
)
174-
result = {"VirtualMFADeviceName": 'fiebaz'}
175-
self.assert_params_for_cmd(cmdline, result)
176-
self.assertEqual(os.stat(outfile).st_mode & 0xFFF, 0o600)
177-
178-
@skip_if_windows("Permissions test not valid on Windows.")
179-
def test_output_file_permissions_existing_file(self):
180-
outfile = self.getpath('fiebaz_perms_existing.b32')
181-
self.addCleanup(self.remove_file_if_exists, outfile)
182-
with open(outfile, 'wb') as f:
183-
f.write(b'existing')
184-
os.chmod(outfile, 0o644)
185-
cmdline = self.prefix
186-
cmdline += ' --virtual-mfa-device-name fiebaz'
187-
cmdline += (
188-
' --outfile %s --bootstrap-method Base32StringSeed' % outfile
189-
)
190-
result = {"VirtualMFADeviceName": 'fiebaz'}
191-
self.assert_params_for_cmd(cmdline, result)
192-
self.assertEqual(os.stat(outfile).st_mode & 0xFFF, 0o600)

0 commit comments

Comments
 (0)