ui: better handling of IO errors at device creation

This commit is contained in:
Peter F. Patel-Schneider 2022-12-14 10:53:59 -05:00
parent 7215022089
commit fc1b72faa1
1 changed files with 13 additions and 13 deletions

View File

@ -16,6 +16,7 @@
## with this program; if not, write to the Free Software Foundation, Inc., ## with this program; if not, write to the Free Software Foundation, Inc.,
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import errno as _errno
import time import time
from collections import namedtuple from collections import namedtuple
@ -389,21 +390,20 @@ def _process_receiver_event(action, device_info):
l.stop() l.stop()
if action == 'add': if action == 'add':
# a new receiver device was detected # a new device was detected
try: try:
_start(device_info) _start(device_info)
except OSError: except OSError as e:
# permission error, ignore this path for now if e.errno == _errno.EACCES:
# If receiver has extended ACL but not writable then it is for another seat.
# (It would be easier to use pylibacl but adding the pylibacl dependencies
# for this special case is not good.)
try: try:
import re
import subprocess import subprocess
output = subprocess.check_output(['/usr/bin/getfacl', '-p', device_info.path]) output = subprocess.check_output(['/usr/bin/getfacl', '-p', device_info.path], text=True)
if not re.search(b'user:.+:', output): if _log.isEnabledFor(_WARNING):
_error_callback('permissions', device_info.path) _log.warning('Missing permissions on %s\n%s.', device_info.path, output)
except Exception: except Exception:
pass
_error_callback('permissions', device_info.path) _error_callback('permissions', device_info.path)
else:
_error_callback('nodevice', device_info.path)
except _base.NoReceiver: except _base.NoReceiver:
_error_callback('nodevice', device_info.path) _error_callback('nodevice', device_info.path)