Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Detach tty #302

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")