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$
|
.\" $Id$
|
||||||
.\"
|
.\"
|
||||||
.Dd April 14, 2012
|
.Dd July 11, 2013
|
||||||
.Dt PAMTEST 1
|
.Dt PAMTEST 1
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
|
@ -39,6 +39,7 @@
|
||||||
.Op Fl dkMPsv
|
.Op Fl dkMPsv
|
||||||
.Op Fl H Ar rhost
|
.Op Fl H Ar rhost
|
||||||
.Op Fl h Ar host
|
.Op Fl h Ar host
|
||||||
|
.Op Fl T Ar timeout
|
||||||
.Op Fl t Ar tty
|
.Op Fl t Ar tty
|
||||||
.Op Fl U Ar ruser
|
.Op Fl U Ar ruser
|
||||||
.Op Fl u Ar user
|
.Op Fl u Ar user
|
||||||
|
@ -136,6 +137,9 @@ flag when calling the
|
||||||
and
|
and
|
||||||
.Xr pam_close_session 3
|
.Xr pam_close_session 3
|
||||||
primitives.
|
primitives.
|
||||||
|
.It Fl T Ar timeout
|
||||||
|
Set the conversation timeout (in seconds) for
|
||||||
|
.Xr openpam_ttyconv 3 .
|
||||||
.It Fl t Ar tty
|
.It Fl t Ar tty
|
||||||
Specify the name of the tty.
|
Specify the name of the tty.
|
||||||
The default is to use the result of calling
|
The default is to use the result of calling
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
#include <limits.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -274,6 +275,24 @@ usage(void)
|
||||||
exit(1);
|
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
|
* 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 *user = NULL;
|
||||||
const char *service = NULL;
|
const char *service = NULL;
|
||||||
const char *tty = NULL;
|
const char *tty = NULL;
|
||||||
|
long timeout = 0;
|
||||||
int keepatit = 0;
|
int keepatit = 0;
|
||||||
int pame;
|
int pame;
|
||||||
int opt;
|
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) {
|
switch (opt) {
|
||||||
case 'd':
|
case 'd':
|
||||||
openpam_debug++;
|
openpam_debug++;
|
||||||
|
@ -330,6 +350,15 @@ main(int argc, char *argv[])
|
||||||
case 's':
|
case 's':
|
||||||
silent = PAM_SILENT;
|
silent = PAM_SILENT;
|
||||||
break;
|
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':
|
case 't':
|
||||||
opt_str_once(opt, &tty, optarg);
|
opt_str_once(opt, &tty, optarg);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue