mirror of
https://github.com/Yubico/yubico-pam.git
synced 2025-02-08 03:54:18 +01:00
Merge branch 'pr-160'
This commit is contained in:
commit
38e494cd74
17
ykpamcfg.c
17
ykpamcfg.c
@ -39,6 +39,7 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
#include <ykpers.h>
|
#include <ykpers.h>
|
||||||
|
|
||||||
@ -104,7 +105,10 @@ parse_args(int argc, char **argv,
|
|||||||
*slot = 2;
|
*slot = 2;
|
||||||
break;
|
break;
|
||||||
case 'A':
|
case 'A':
|
||||||
strncpy(*action, optarg, ACTION_MAX_LEN);
|
if (snprintf(*action, ACTION_MAX_LEN, "%s", optarg) >= ACTION_MAX_LEN) {
|
||||||
|
fprintf(stderr, "action too long: %s\n", optarg);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
*output_dir = optarg;
|
*output_dir = optarg;
|
||||||
@ -164,8 +168,13 @@ do_add_hmac_chalresp(YK_KEY *yk, uint8_t slot, bool verbose, char *output_dir, u
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (!output_dir){
|
if (!output_dir){
|
||||||
char fullpath[256];
|
char fullpath[PATH_MAX];
|
||||||
snprintf(fullpath, 256,"%s/.yubico",p->pw_dir);
|
int i = snprintf(fullpath, PATH_MAX, "%s/.yubico", p->pw_dir);
|
||||||
|
|
||||||
|
if (i < 0 || i >= PATH_MAX) {
|
||||||
|
fprintf(stderr, "Failed to construct fullpath: %s\n", p->pw_dir);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
//check if directory exists
|
//check if directory exists
|
||||||
if (stat(fullpath,&st)!=0 ){
|
if (stat(fullpath,&st)!=0 ){
|
||||||
@ -283,7 +292,7 @@ main(int argc, char **argv)
|
|||||||
ykp_errno = 0;
|
ykp_errno = 0;
|
||||||
yk_errno = 0;
|
yk_errno = 0;
|
||||||
|
|
||||||
strcpy (action, ACTION_ADD_HMAC_CHALRESP);
|
strncpy(action, ACTION_ADD_HMAC_CHALRESP, ACTION_MAX_LEN);
|
||||||
|
|
||||||
if (! parse_args(argc, argv,
|
if (! parse_args(argc, argv,
|
||||||
&slot, &verbose,
|
&slot, &verbose,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user