Skip to content

Commit

Permalink
fixed cvat startup process (#2293)
Browse files Browse the repository at this point in the history
* fixed cvat startup process

* updated readme

* updated license header

* updated CHANGELOG

Co-authored-by: Boris Sekachev <[email protected]>
  • Loading branch information
Andrey Zhavoronkov and bsekachev authored Oct 12, 2020
1 parent d4129f2 commit 796a8d3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed issues from #2112 (<https://github.com/openvinotoolkit/cvat/pull/2217>)
- Git application name (renamed to dataset_repo) (<https://github.com/openvinotoolkit/cvat/pull/2243>)
- A problem in exporting of tracks, where tracks could be truncated (<https://github.com/openvinotoolkit/cvat/issues/2129>)

- Fixed CVAT startup process if the user has `umask 077` in .bashrc file (<https://github.com/openvinotoolkit/cvat/pull/2293>)

### Security

Expand Down
17 changes: 15 additions & 2 deletions cvat/settings/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2018-2019 Intel Corporation
# Copyright (C) 2018-2020 Intel Corporation
#
# SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -50,10 +50,22 @@ def generate_ssh_keys():
ssh_dir = '{}/.ssh'.format(os.getenv('HOME'))
pidfile = os.path.join(ssh_dir, 'ssh.pid')

def add_ssh_keys():
IGNORE_FILES = ('README.md', 'ssh.pid')
keys_to_add = [entry.name for entry in os.scandir(ssh_dir) if entry.name not in IGNORE_FILES]
keys_to_add = ' '.join(os.path.join(ssh_dir, f) for f in keys_to_add)
subprocess.run(['ssh-add {}'.format(keys_to_add)],
shell = True,
stderr = subprocess.PIPE,
# lets set the timeout if ssh-add requires a input passphrase for key
# otherwise the process will be freezed
timeout=30,
)

with open(pidfile, "w") as pid:
fcntl.flock(pid, fcntl.LOCK_EX)
try:
subprocess.run(['ssh-add {}/*'.format(ssh_dir)], shell = True, stderr = subprocess.PIPE)
add_ssh_keys()
keys = subprocess.run(['ssh-add -l'], shell = True,
stdout = subprocess.PIPE).stdout.decode('utf-8').split('\n')
if 'has no identities' in keys[0]:
Expand Down Expand Up @@ -440,3 +452,4 @@ def generate_ssh_keys():
}

USE_CACHE = True

1 change: 1 addition & 0 deletions ssh/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Put your SSH keys and SSH config here and they will be installed to the CVAT container.
Please do not use encrypted keys that require a passphrase - these keys will not be used.

If you have any problems with a git repository cloning inside the CVAT:
* Make sure that SSH keys have been added to the CVAT container:
Expand Down

0 comments on commit 796a8d3

Please sign in to comment.