Print this page
3913 there is no dialup, only zuul


   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */



  25 
  26 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  27 /*        All Rights Reserved   */
  28 
  29 /*
  30  * University Copyright- Copyright (c) 1982, 1986, 1988
  31  * The Regents of the University of California
  32  * All Rights Reserved
  33  *
  34  * University Acknowledgment- Portions of this document are derived from
  35  * software developed by the University of California, Berkeley, and its
  36  * contributors.
  37  * Portions contributed by Juergen Keil, <jk@tools.de>.
  38  */
  39 
  40 
  41 /*
  42  * Common code for halt(1M), poweroff(1M), and reboot(1M).  We use
  43  * argv[0] to determine which behavior to exhibit.
  44  */


1234         cmd_argv[i++] = "update_all";
1235         if (do_fast_reboot)
1236                 cmd_argv[i++] = "fastboot";
1237         cmd_argv[i] = NULL;
1238 
1239         r = posix_spawn(&pid, cmd_argv[0], NULL, NULL, cmd_argv, NULL);
1240 
1241         /* if posix_spawn fails we emit a warning and continue */
1242 
1243         if (r != 0)
1244                 (void) fprintf(stderr, gettext("%s: WARNING, unable to start "
1245                     "boot archive update\n"), cmdname);
1246         else
1247                 while (waitpid(pid, NULL, 0) == -1 && errno == EINTR)
1248                         ;
1249 }
1250 
1251 int
1252 main(int argc, char *argv[])
1253 {
1254         char *ttyn = ttyname(STDERR_FILENO);
1255 
1256         int qflag = 0, needlog = 1, nosync = 0;
1257         int fast_reboot = 0;
1258         int prom_reboot = 0;
1259         uintptr_t mdep = NULL;
1260         int cmd, fcn, c, aval, r;
1261         const char *usage;
1262         const char *optstring;
1263         zoneid_t zoneid = getzoneid();
1264         int need_check_zones = 0;
1265         char bootargs_buf[BOOTARGS_MAX];
1266         char *bootargs_orig = NULL;
1267         char *bename = NULL;
1268 
1269         const char * const resetting = "/etc/svc/volatile/resetting";
1270 
1271         (void) setlocale(LC_ALL, "");
1272         (void) textdomain(TEXT_DOMAIN);
1273 
1274         cmdname = basename(argv[0]);
1275 


1307                 case 'd':
1308                         if (zoneid == GLOBAL_ZONEID)
1309                                 cmd = A_DUMP;
1310                         else {
1311                                 (void) fprintf(stderr,
1312                                     gettext("%s: -d only valid from global"
1313                                     " zone\n"), cmdname);
1314                                 return (1);
1315                         }
1316                         break;
1317                 case 'l':
1318                         needlog = 0;
1319                         break;
1320                 case 'n':
1321                         nosync = 1;
1322                         break;
1323                 case 'q':
1324                         qflag = 1;
1325                         break;
1326                 case 'y':
1327                         ttyn = NULL;


1328                         break;
1329                 case 'f':
1330                         fast_reboot = 1;
1331                         break;
1332                 case 'p':
1333                         prom_reboot = 1;
1334                         break;
1335 #if defined(__i386)
1336                 case 'e':
1337                         bename = optarg;
1338                         break;
1339 #endif
1340                 default:
1341                         /*
1342                          * TRANSLATION_NOTE
1343                          * Don't translate the words "halt" or "reboot"
1344                          */
1345                         (void) fprintf(stderr, usage, cmdname);
1346                         return (1);
1347                 }


1431                         return (rc);
1432                 else if (rc == EINVAL)
1433                         goto fail;
1434                 else if (rc != 0)
1435                         fast_reboot = 0;
1436 
1437                 /*
1438                  * For all the other errors, we continue on in case user
1439                  * user want to force fast reboot, or fall back to regular
1440                  * reboot.
1441                  */
1442                 if (strlen(bootargs_buf) != 0)
1443                         mdep = (uintptr_t)bootargs_buf;
1444         }
1445 
1446 #if 0   /* For debugging */
1447         if (mdep != NULL)
1448                 (void) fprintf(stderr, "mdep = %s\n", (char *)mdep);
1449 #endif
1450 
1451         if (fcn != AD_BOOT && ttyn != NULL &&
1452             strncmp(ttyn, "/dev/term/", strlen("/dev/term/")) == 0) {
1453                 /*
1454                  * TRANSLATION_NOTE
1455                  * Don't translate ``halt -y''
1456                  */
1457                 (void) fprintf(stderr,
1458                     gettext("%s: dangerous on a dialup;"), cmdname);
1459                 (void) fprintf(stderr,
1460                     gettext("use ``%s -y'' if you are really sure\n"), cmdname);
1461                 goto fail;
1462         }
1463 
1464         if (needlog) {
1465                 char *user = getlogin();
1466                 struct passwd *pw;
1467                 char *tty;
1468 
1469                 openlog(cmdname, 0, LOG_AUTH);
1470                 if (user == NULL && (pw = getpwuid(getuid())) != NULL)
1471                         user = pw->pw_name;
1472                 if (user == NULL)
1473                         user = "root";
1474 
1475                 tty = ttyname(1);
1476 
1477                 if (tty == NULL)
1478                         syslog(LOG_CRIT, "initiated by %s", user);
1479                 else
1480                         syslog(LOG_CRIT, "initiated by %s on %s", user, tty);
1481         }
1482 
1483         /*




   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 /*
  26  * Copyright (c) 2013, Joyent, Inc. All rights reserved.
  27  */
  28 
  29 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  30 /*        All Rights Reserved   */
  31 
  32 /*
  33  * University Copyright- Copyright (c) 1982, 1986, 1988
  34  * The Regents of the University of California
  35  * All Rights Reserved
  36  *
  37  * University Acknowledgment- Portions of this document are derived from
  38  * software developed by the University of California, Berkeley, and its
  39  * contributors.
  40  * Portions contributed by Juergen Keil, <jk@tools.de>.
  41  */
  42 
  43 
  44 /*
  45  * Common code for halt(1M), poweroff(1M), and reboot(1M).  We use
  46  * argv[0] to determine which behavior to exhibit.
  47  */


1237         cmd_argv[i++] = "update_all";
1238         if (do_fast_reboot)
1239                 cmd_argv[i++] = "fastboot";
1240         cmd_argv[i] = NULL;
1241 
1242         r = posix_spawn(&pid, cmd_argv[0], NULL, NULL, cmd_argv, NULL);
1243 
1244         /* if posix_spawn fails we emit a warning and continue */
1245 
1246         if (r != 0)
1247                 (void) fprintf(stderr, gettext("%s: WARNING, unable to start "
1248                     "boot archive update\n"), cmdname);
1249         else
1250                 while (waitpid(pid, NULL, 0) == -1 && errno == EINTR)
1251                         ;
1252 }
1253 
1254 int
1255 main(int argc, char *argv[])
1256 {


1257         int qflag = 0, needlog = 1, nosync = 0;
1258         int fast_reboot = 0;
1259         int prom_reboot = 0;
1260         uintptr_t mdep = NULL;
1261         int cmd, fcn, c, aval, r;
1262         const char *usage;
1263         const char *optstring;
1264         zoneid_t zoneid = getzoneid();
1265         int need_check_zones = 0;
1266         char bootargs_buf[BOOTARGS_MAX];
1267         char *bootargs_orig = NULL;
1268         char *bename = NULL;
1269 
1270         const char * const resetting = "/etc/svc/volatile/resetting";
1271 
1272         (void) setlocale(LC_ALL, "");
1273         (void) textdomain(TEXT_DOMAIN);
1274 
1275         cmdname = basename(argv[0]);
1276 


1308                 case 'd':
1309                         if (zoneid == GLOBAL_ZONEID)
1310                                 cmd = A_DUMP;
1311                         else {
1312                                 (void) fprintf(stderr,
1313                                     gettext("%s: -d only valid from global"
1314                                     " zone\n"), cmdname);
1315                                 return (1);
1316                         }
1317                         break;
1318                 case 'l':
1319                         needlog = 0;
1320                         break;
1321                 case 'n':
1322                         nosync = 1;
1323                         break;
1324                 case 'q':
1325                         qflag = 1;
1326                         break;
1327                 case 'y':
1328                         /*
1329                          * Option ignored for backwards compatibility.
1330                          */
1331                         break;
1332                 case 'f':
1333                         fast_reboot = 1;
1334                         break;
1335                 case 'p':
1336                         prom_reboot = 1;
1337                         break;
1338 #if defined(__i386)
1339                 case 'e':
1340                         bename = optarg;
1341                         break;
1342 #endif
1343                 default:
1344                         /*
1345                          * TRANSLATION_NOTE
1346                          * Don't translate the words "halt" or "reboot"
1347                          */
1348                         (void) fprintf(stderr, usage, cmdname);
1349                         return (1);
1350                 }


1434                         return (rc);
1435                 else if (rc == EINVAL)
1436                         goto fail;
1437                 else if (rc != 0)
1438                         fast_reboot = 0;
1439 
1440                 /*
1441                  * For all the other errors, we continue on in case user
1442                  * user want to force fast reboot, or fall back to regular
1443                  * reboot.
1444                  */
1445                 if (strlen(bootargs_buf) != 0)
1446                         mdep = (uintptr_t)bootargs_buf;
1447         }
1448 
1449 #if 0   /* For debugging */
1450         if (mdep != NULL)
1451                 (void) fprintf(stderr, "mdep = %s\n", (char *)mdep);
1452 #endif
1453 













1454         if (needlog) {
1455                 char *user = getlogin();
1456                 struct passwd *pw;
1457                 char *tty;
1458 
1459                 openlog(cmdname, 0, LOG_AUTH);
1460                 if (user == NULL && (pw = getpwuid(getuid())) != NULL)
1461                         user = pw->pw_name;
1462                 if (user == NULL)
1463                         user = "root";
1464 
1465                 tty = ttyname(1);
1466 
1467                 if (tty == NULL)
1468                         syslog(LOG_CRIT, "initiated by %s", user);
1469                 else
1470                         syslog(LOG_CRIT, "initiated by %s on %s", user, tty);
1471         }
1472 
1473         /*