Revert "Revert "oran-shell-release: release image for F""
[pti/rtp.git] / meta-starlingx / meta-stx-cloud / recipes-devtools / python / files / python-keyring / chmod_keyringlock2.patch
1 Index: keyring-5.3/keyring/backends/file.py
2 ===================================================================
3 --- keyring-5.3.orig/keyring/backends/file.py
4 +++ keyring-5.3/keyring/backends/file.py
5 @@ -68,6 +68,9 @@ class BaseKeyring(FileBacked, KeyringBac
6          service = escape_for_ini(service)
7          username = escape_for_ini(username)
8  
9 +        # ensure the file exists
10 +        self._ensure_file_path()
11 +
12          # load the passwords from the file
13          config = configparser.RawConfigParser()
14          if os.path.exists(self.file_path):
15 @@ -146,12 +149,16 @@ class BaseKeyring(FileBacked, KeyringBac
16              user_read_write = 0o644
17              os.chmod(self.file_path, user_read_write)
18          if not os.path.isfile(lockdir + "/" + lockfile):
19 -             import stat
20 -             with open(lockdir + "/" + lockfile, 'w'):
21 -                 pass
22 -             # must have the lock file with the correct group permissisions g+rw
23 -             os.chmod(lockdir + "/" + lockfile, stat.S_IRWXG | stat.S_IRWXU)
24 -             os.chown(lockdir + "/" + lockfile,-1,345)
25 +            with open(lockdir + "/" + lockfile, 'w'):
26 +                pass
27 +        if os.path.isfile(lockdir + "/" + lockfile):
28 +            import stat
29 +            import grp
30 +            if oct(stat.S_IMODE(os.stat(lockdir + "/" + lockfile).st_mode)) != '0770':
31 +                # Must have the lock file with the correct group and permissisions g+rw
32 +                os.chmod(lockdir + "/" + lockfile, stat.S_IRWXG | stat.S_IRWXU)
33 +                groupinfo = grp.getgrnam('sys_protected')
34 +                os.chown(lockdir + "/" + lockfile,-1,groupinfo.gr_gid)
35  
36  
37      def delete_password(self, service, username):