Skip to content

Commit

Permalink
Detach from tty to avoid interactive package installs
Browse files Browse the repository at this point in the history
  • Loading branch information
radujipa committed Jul 6, 2018
1 parent 70842e0 commit 2ff72a5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
5 changes: 4 additions & 1 deletion bin/kano-updater-internal
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ from kano_updater.status import UpdaterStatus
from kano_updater.utils import make_low_prio, is_running, \
remove_pid_file, pause_notifications, resume_notifications, show_kano_dialog, \
run_bg, enable_power_button, disable_power_button, verify_kit_is_plugged, \
clear_tracking_uuid
clear_tracking_uuid, detach_from_tty
from kano_updater.return_codes import RC, RCState
import kano_updater.priority as Priority

Expand Down Expand Up @@ -184,6 +184,9 @@ def main():
msg = _('Administrator priviledges are required to perform this operation')
enforce_root(u"{}: {}".format(_('ERROR'), msg))

# Detach from tty to avoid packages trying to run interactive commands
detach_from_tty()

args = docopt.docopt(__doc__, version=str(get_target_version()))
_g_gui_mode = args['--gui']
_g_keep_uuid = args['--keep-uuid']
Expand Down
3 changes: 2 additions & 1 deletion debian/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ kano-updater (4.0.0-0) unstable; urgency=low
* Fix GTK compatibility for Stretch release
* Add support for CKT
* Support expanding the filesystem of images with recovery partitions
* Detach from tty to avoid interactive package installs

-- Team Kano <[email protected]> Thu, 23 Apr 2018 11:48:00 +0100
-- Team Kano <[email protected]> Fri, 6 Jul 2018 11:48:00 +0100

kano-updater (3.15.0-0) unstable; urgency=low

Expand Down
15 changes: 15 additions & 0 deletions kano_updater/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import grp
import signal
import traceback
import fcntl
import termios

from kano.logging import logger
from kano.utils.shell import run_cmd, run_bg, run_cmd_log
Expand Down Expand Up @@ -625,3 +627,16 @@ def clear_tracking_uuid():
remove_tracking_uuid(TRACKING_UUID_KEY)
except:
logger.error('Unexpected error:\n{}'.format(traceback.format_exc()))


def detach_from_tty():
"""
Detach from controlling tty
"""
try:
myTTY = os.open("/dev/tty", os.O_RDWR)

fcntl.ioctl(myTTY, termios.TIOCNOTTY, 0)
os.close(myTTY)
except:
logger.error("Failed to close controlling terminal")

0 comments on commit 2ff72a5

Please sign in to comment.