Print this page
5700 add zlogin -d option to allow graceful disconnect when zone is halted
Reviewed by: Andrew Gabriel <illumos@cucumber.demon.co.uk>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
*** 20,30 ****
*/
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2013 DEY Storage Systems, Inc.
* Copyright (c) 2014 Gary Mills
! * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
/*
* zlogin provides three types of login which allow users in the global
* zone to access non-global zones.
--- 20,30 ----
*/
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2013 DEY Storage Systems, Inc.
* Copyright (c) 2014 Gary Mills
! * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
*/
/*
* zlogin provides three types of login which allow users in the global
* zone to access non-global zones.
*** 102,111 ****
--- 102,112 ----
static int interactive = 0;
static priv_set_t *dropprivs;
static int nocmdchar = 0;
static int failsafe = 0;
+ static int disconnect = 0;
static char cmdchar = '~';
static int quiet = 0;
static int pollerr = 0;
*** 150,160 ****
#define CANONIFY_LEN 5
static void
usage(void)
{
! (void) fprintf(stderr, gettext("usage: %s [ -nQCES ] [ -e cmdchar ] "
"[-l user] zonename [command [args ...] ]\n"), pname);
exit(2);
}
static const char *
--- 151,161 ----
#define CANONIFY_LEN 5
static void
usage(void)
{
! (void) fprintf(stderr, gettext("usage: %s [ -dnQCES ] [ -e cmdchar ] "
"[-l user] zonename [command [args ...] ]\n"), pname);
exit(2);
}
static const char *
*** 276,287 ****
zperror(gettext("Could not connect to zone console"));
goto bad;
}
masterfd = sockfd;
! msglen = snprintf(clientid, sizeof (clientid), "IDENT %lu %s\n",
! getpid(), setlocale(LC_MESSAGES, NULL));
if (msglen >= sizeof (clientid) || msglen < 0) {
zerror("protocol error");
goto bad;
}
--- 277,288 ----
zperror(gettext("Could not connect to zone console"));
goto bad;
}
masterfd = sockfd;
! msglen = snprintf(clientid, sizeof (clientid), "IDENT %lu %s %d\n",
! getpid(), setlocale(LC_MESSAGES, NULL), disconnect);
if (msglen >= sizeof (clientid) || msglen < 0) {
zerror("protocol error");
goto bad;
}
*** 1751,1761 ****
(void) textdomain(TEXT_DOMAIN);
(void) getpname(argv[0]);
username = get_username();
! while ((arg = getopt(argc, argv, "nECR:Se:l:Q")) != EOF) {
switch (arg) {
case 'C':
console = 1;
break;
case 'E':
--- 1752,1762 ----
(void) textdomain(TEXT_DOMAIN);
(void) getpname(argv[0]);
username = get_username();
! while ((arg = getopt(argc, argv, "dnECR:Se:l:Q")) != EOF) {
switch (arg) {
case 'C':
console = 1;
break;
case 'E':
*** 1777,1786 ****
--- 1778,1790 ----
quiet = 1;
break;
case 'S':
failsafe = 1;
break;
+ case 'd':
+ disconnect = 1;
+ break;
case 'e':
set_cmdchar(optarg);
break;
case 'l':
login = optarg;
*** 1824,1833 ****
--- 1828,1843 ----
if (failsafe != 0 && lflag != 0) {
zerror(gettext("-l may not be specified for failsafe login"));
usage();
}
+
+ if (!console && disconnect != 0) {
+ zerror(gettext(
+ "-d may only be specified with console login"));
+ usage();
+ }
if (optind == (argc - 1)) {
/*
* zone name, no process name; this should be an interactive
* as long as STDIN is really a tty.