]> git.armaanb.net Git - opendoas.git/blobdiff - doas.c
doas: remove v flag, not neccessary, upstream doesn't have it and __DATE__ is bad...
[opendoas.git] / doas.c
diff --git a/doas.c b/doas.c
index b7248f0cf7145276bea201884020519f43a940eb..cee1aecf9fb964778a3155c006ccd3d2f3d7afa8 100644 (file)
--- a/doas.c
+++ b/doas.c
 
 #include "doas.h"
 
-static void __dead
-version(void)
-{
-       fprintf(stderr, "doas: version %s built %s\n", VERSION, __DATE__);
-       exit(1);
-}
-
 static void __dead
 usage(void)
 {
-       fprintf(stderr, "usage: doas [-Lnsv] "
+       fprintf(stderr, "usage: doas [-Lns] "
 #ifdef HAVE_BSD_AUTH_H
            "[-a style] "
 #endif
@@ -261,7 +254,17 @@ authuser(const char *myname, const char *login_style, int persist)
        struct passwd *pw;
 
        (void)login_style;
+
+#ifdef PERSIST_TIMESTAMP
+       int fd = -1;
+       int valid;
+       if (persist)
+               fd = persist_open(&valid, 5 * 60);
+       if (fd != -1 && valid)
+               goto good;
+#else
        (void)persist;
+#endif
 
        if (!(pw = getpwnam(myname)))
                err(1, "getpwnam");
@@ -296,6 +299,13 @@ authuser(const char *myname, const char *login_style, int persist)
                errx(1, "Authorization failed");
        }
        explicit_bzero(rbuf, sizeof(rbuf));
+#ifdef PERSIST_TIMESTAMP
+good:
+       if (fd != -1) {
+               persist_set(fd, 5 * 60);
+               close(fd);
+       }
+#endif
 }
 #endif /* HAVE_BSD_AUTH_H */
 
@@ -319,11 +329,12 @@ main(int argc, char **argv)
        int i, ch;
        int sflag = 0;
        int nflag = 0;
-       int vflag = 0;
        char cwdpath[PATH_MAX];
        const char *cwd;
        char **envp;
+#ifdef HAVE_BSD_AUTH_H
        char *login_style = NULL;
+#endif
 
        setprogname("doas");
 
@@ -353,6 +364,8 @@ main(int argc, char **argv)
                        if (i != -1)
                                ioctl(i, TIOCCLRVERAUTH);
                        exit(i == -1);
+#elif PERSIST_TIMESTAMP
+                       exit(persist_clear() != 0);
 #endif
                case 'u':
                        if (parseuid(optarg, &target) != 0)
@@ -364,9 +377,6 @@ main(int argc, char **argv)
                case 's':
                        sflag = 1;
                        break;
-               case 'v':
-                       vflag = 1;
-                       break;
                default:
                        usage();
                        break;
@@ -375,9 +385,6 @@ main(int argc, char **argv)
        argv += optind;
        argc -= optind;
 
-       if (vflag)
-               version();
-
        if (confpath) {
                if (sflag)
                        usage();