+ exit(EXIT_OPTION_ERROR);
+
+ /* scan command line and options files to find device name */
+ prepass = 1;
+ parse_args(argc-1, argv+1);
+ prepass = 0;
+
+ /*
+ * Work out the device name, if it hasn't already been specified.
+ */
+ using_pty = notty || ptycommand != NULL;
+ if (!using_pty && default_device) {
+ char *p;
+ if (!isatty(0) || (p = ttyname(0)) == NULL) {
+ option_error("no device specified and stdin is not a tty");
+ exit(EXIT_OPTION_ERROR);
+ }
+ strlcpy(devnam, p, sizeof(devnam));
+ if (stat(devnam, &devstat) < 0)
+ fatal("Couldn't stat default device %s: %m", devnam);
+ }
+
+ /*
+ * Parse the tty options file and the command line.
+ * The per-tty options file should not change
+ * ptycommand, notty or devnam.
+ */
+ if (!using_pty) {
+ int save_defdev = default_device;
+
+ default_device = 1;
+ if (!options_for_tty())
+ exit(EXIT_OPTION_ERROR);
+ if (notty || ptycommand != NULL) {
+ option_error("%s option may not be used in per-tty options file",
+ notty? "notty": "pty");
+ exit(EXIT_OPTION_ERROR);
+ }
+ if (!default_device) {
+ option_error("per-tty options file may not specify device name");
+ exit(EXIT_OPTION_ERROR);
+ }
+ default_device = save_defdev;
+ }
+
+ if (!parse_args(argc-1, argv+1))
+ exit(EXIT_OPTION_ERROR);
+
+ /*
+ * Check that we are running as root.
+ */
+ if (geteuid() != 0) {
+ option_error("must be root to run %s, since it is not setuid-root",
+ argv[0]);
+ exit(EXIT_NOT_ROOT);
+ }