=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/lock/lock.c,v retrieving revision 1.42 retrieving revision 1.43 diff -c -r1.42 -r1.43 *** src/usr.bin/lock/lock.c 2019/07/05 14:11:26 1.42 --- src/usr.bin/lock/lock.c 2019/07/19 18:32:19 1.43 *************** *** 1,4 **** ! /* $OpenBSD: lock.c,v 1.42 2019/07/05 14:11:26 cheloha Exp $ */ /* $NetBSD: lock.c,v 1.8 1996/05/07 18:32:31 jtc Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: lock.c,v 1.43 2019/07/19 18:32:19 cheloha Exp $ */ /* $NetBSD: lock.c,v 1.8 1996/05/07 18:32:31 jtc Exp $ */ /* *************** *** 36,44 **** /* * Lock a terminal up until the given key is entered, until the root * password is entered, or the given interval times out. - * - * Timeout interval is by default TIMEOUT, it can be changed with - * an argument of the form -time where time is in minutes */ #include --- 36,41 ---- *************** *** 59,72 **** #include #include - #define TIMEOUT 15 - void bye(int); void hi(int); void usage(void); ! int custom_timeout; ! int no_timeout; /* lock terminal forever */ int main(int argc, char *argv[]) --- 56,66 ---- #include #include void bye(int); void hi(int); void usage(void); ! int no_timeout = 1; /* lock terminal forever */ int main(int argc, char *argv[]) *************** *** 83,92 **** time_t curtime; login_cap_t *lc; - sectimeout = TIMEOUT; style = NULL; usemine = 0; - custom_timeout = no_timeout = 0; memset(&timeout, 0, sizeof(timeout)); if (pledge("stdio rpath wpath getpw tty proc exec", NULL) == -1) --- 77,84 ---- *************** *** 105,111 **** backoff = login_getcapnum(lc, "login-backoff", 3, 3); } ! while ((ch = getopt(argc, argv, "a:npt:")) != -1) { switch (ch) { case 'a': if (lc) { --- 97,103 ---- backoff = login_getcapnum(lc, "login-backoff", 3, 3); } ! while ((ch = getopt(argc, argv, "a:pt:")) != -1) { switch (ch) { case 'a': if (lc) { *************** *** 118,143 **** usemine = 1; break; case 't': - if (no_timeout) - usage(); sectimeout = strtonum(optarg, 1, INT_MAX, &errstr); if (errstr) errx(1, "timeout %s: %s", errstr, optarg); ! custom_timeout = 1; break; case 'p': usemine = 1; break; - case 'n': - if (custom_timeout) - usage(); - no_timeout = 1; - break; default: usage(); } } - timeout.tv_sec = sectimeout * 60; gethostname(hostname, sizeof(hostname)); if (usemine && lc == NULL) --- 110,127 ---- usemine = 1; break; case 't': sectimeout = strtonum(optarg, 1, INT_MAX, &errstr); if (errstr) errx(1, "timeout %s: %s", errstr, optarg); ! no_timeout = 0; break; case 'p': usemine = 1; break; default: usage(); } } gethostname(hostname, sizeof(hostname)); if (usemine && lc == NULL) *************** *** 173,182 **** signal(SIGTSTP, hi); signal(SIGALRM, bye); ! memset(&ntimer, 0, sizeof(ntimer)); ! ntimer.it_value = timeout; ! if (!no_timeout) setitimer(ITIMER_REAL, &ntimer, &otimer); /* header info */ if (no_timeout) { --- 157,168 ---- signal(SIGTSTP, hi); signal(SIGALRM, bye); ! if (!no_timeout) { ! timeout.tv_sec = (time_t)sectimeout * 60; ! memset(&ntimer, 0, sizeof(ntimer)); ! ntimer.it_value = timeout; setitimer(ITIMER_REAL, &ntimer, &otimer); + } /* header info */ if (no_timeout) { *************** *** 260,266 **** void usage(void) { ! fprintf(stderr, "usage: %s [-np] [-a style] [-t timeout]\n", getprogname()); exit(1); } --- 246,252 ---- void usage(void) { ! fprintf(stderr, "usage: %s [-p] [-a style] [-t timeout]\n", getprogname()); exit(1); }