Add a command-line option that controls openpam_ttyconv_timeout.
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@685 185d5e19-27fe-0310-9dcf-9bff6b9f3609
This commit is contained in:
parent
3ab09a4f26
commit
6950b99458
|
@ -28,7 +28,7 @@
|
|||
.\"
|
||||
.\" $Id$
|
||||
.\"
|
||||
.Dd April 14, 2012
|
||||
.Dd July 11, 2013
|
||||
.Dt PAMTEST 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -39,6 +39,7 @@
|
|||
.Op Fl dkMPsv
|
||||
.Op Fl H Ar rhost
|
||||
.Op Fl h Ar host
|
||||
.Op Fl T Ar timeout
|
||||
.Op Fl t Ar tty
|
||||
.Op Fl U Ar ruser
|
||||
.Op Fl u Ar user
|
||||
|
@ -136,6 +137,9 @@ flag when calling the
|
|||
and
|
||||
.Xr pam_close_session 3
|
||||
primitives.
|
||||
.It Fl T Ar timeout
|
||||
Set the conversation timeout (in seconds) for
|
||||
.Xr openpam_ttyconv 3 .
|
||||
.It Fl t Ar tty
|
||||
Specify the name of the tty.
|
||||
The default is to use the result of calling
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#endif
|
||||
|
||||
#include <err.h>
|
||||
#include <limits.h>
|
||||
#include <pwd.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
@ -274,6 +275,24 @@ usage(void)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle an option that takes an int argument and can be used only once
|
||||
*/
|
||||
static void
|
||||
opt_num_once(int opt, long *num, const char *arg)
|
||||
{
|
||||
char *end;
|
||||
long l;
|
||||
|
||||
l = strtol(arg, &end, 0);
|
||||
if (end == optarg || *end != '\0') {
|
||||
fprintf(stderr,
|
||||
"The -%c option expects a numeric argument\n", opt);
|
||||
usage();
|
||||
}
|
||||
*num = l;
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle an option that takes a string argument and can be used only once
|
||||
*/
|
||||
|
@ -301,11 +320,12 @@ main(int argc, char *argv[])
|
|||
const char *user = NULL;
|
||||
const char *service = NULL;
|
||||
const char *tty = NULL;
|
||||
long timeout = 0;
|
||||
int keepatit = 0;
|
||||
int pame;
|
||||
int opt;
|
||||
|
||||
while ((opt = getopt(argc, argv, "dH:h:kMPst:U:u:v")) != -1)
|
||||
while ((opt = getopt(argc, argv, "dH:h:kMPsT:t:U:u:v")) != -1)
|
||||
switch (opt) {
|
||||
case 'd':
|
||||
openpam_debug++;
|
||||
|
@ -330,6 +350,15 @@ main(int argc, char *argv[])
|
|||
case 's':
|
||||
silent = PAM_SILENT;
|
||||
break;
|
||||
case 'T':
|
||||
opt_num_once(opt, &timeout, optarg);
|
||||
if (timeout < 0 || timeout > INT_MAX) {
|
||||
fprintf(stderr,
|
||||
"Invalid conversation timeout\n");
|
||||
usage();
|
||||
}
|
||||
openpam_ttyconv_timeout = (int)timeout;
|
||||
break;
|
||||
case 't':
|
||||
opt_str_once(opt, &tty, optarg);
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue