Changeset 685 in openpam


Ignore:
Timestamp:
Jul 11, 2013, 4:33:34 PM (7 years ago)
Author:
Dag-Erling Smørgrav
Message:

Add a command-line option that controls openpam_ttyconv_timeout.

Location:
trunk/bin/pamtest
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/pamtest/pamtest.1

    r648 r685  
    2929.\" $Id$
    3030.\"
    31 .Dd April 14, 2012
     31.Dd July 11, 2013
    3232.Dt PAMTEST 1
    3333.Os
     
    4040.Op Fl H Ar rhost
    4141.Op Fl h Ar host
     42.Op Fl T Ar timeout
    4243.Op Fl t Ar tty
    4344.Op Fl U Ar ruser
     
    137138.Xr pam_close_session 3
    138139primitives.
     140.It Fl T Ar timeout
     141Set the conversation timeout (in seconds) for
     142.Xr openpam_ttyconv 3 .
    139143.It Fl t Ar tty
    140144Specify the name of the tty.
  • trunk/bin/pamtest/pamtest.c

    r665 r685  
    3535
    3636#include <err.h>
     37#include <limits.h>
    3738#include <pwd.h>
    3839#include <stdarg.h>
     
    276277
    277278/*
     279 * Handle an option that takes an int argument and can be used only once
     280 */
     281static void
     282opt_num_once(int opt, long *num, const char *arg)
     283{
     284        char *end;
     285        long l;
     286
     287        l = strtol(arg, &end, 0);
     288        if (end == optarg || *end != '\0') {
     289                fprintf(stderr,
     290                    "The -%c option expects a numeric argument\n", opt);
     291                usage();
     292        }
     293        *num = l;
     294}
     295
     296/*
    278297 * Handle an option that takes a string argument and can be used only once
    279298 */
     
    302321        const char *service = NULL;
    303322        const char *tty = NULL;
     323        long timeout = 0;
    304324        int keepatit = 0;
    305325        int pame;
    306326        int opt;
    307327
    308         while ((opt = getopt(argc, argv, "dH:h:kMPst:U:u:v")) != -1)
     328        while ((opt = getopt(argc, argv, "dH:h:kMPsT:t:U:u:v")) != -1)
    309329                switch (opt) {
    310330                case 'd':
     
    330350                case 's':
    331351                        silent = PAM_SILENT;
     352                        break;
     353                case 'T':
     354                        opt_num_once(opt, &timeout, optarg);
     355                        if (timeout < 0 || timeout > INT_MAX) {
     356                                fprintf(stderr,
     357                                    "Invalid conversation timeout\n");
     358                                usage();
     359                        }
     360                        openpam_ttyconv_timeout = (int)timeout;
    332361                        break;
    333362                case 't':
Note: See TracChangeset for help on using the changeset viewer.