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. try:
# (It would be easier to use pylibacl but adding the pylibacl dependencies import subprocess
# for this special case is not good.) output = subprocess.check_output(['/usr/bin/getfacl', '-p', device_info.path], text=True)
try: if _log.isEnabledFor(_WARNING):
import re _log.warning('Missing permissions on %s\n%s.', device_info.path, output)
import subprocess except Exception:
output = subprocess.check_output(['/usr/bin/getfacl', '-p', device_info.path]) pass
if not re.search(b'user:.+:', output):
_error_callback('permissions', device_info.path)
except Exception:
_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)