aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/otputil.c6
-rw-r--r--src/otputil.h11
-rw-r--r--src/widget-hotp.c8
-rw-r--r--src/widget-totp.c8
4 files changed, 10 insertions, 23 deletions
diff --git a/src/otputil.c b/src/otputil.c
index 3685716..ba84f81 100644
--- a/src/otputil.c
+++ b/src/otputil.c
@@ -132,10 +132,6 @@ otputil_widget_version(
132///////////////// 132/////////////////
133#pragma mark - Variables 133#pragma mark - Variables
134 134
135#pragma mark otputil_pass
136const char * otputil_pass = NULL;
137
138
139#pragma mark otputil_widget_map[] 135#pragma mark otputil_widget_map[]
140static otputil_widget_t otputil_widget_map[] = 136static otputil_widget_t otputil_widget_map[] =
141{ 137{
@@ -374,7 +370,7 @@ otputil_arguments(
374 break; 370 break;
375 371
376 case 'p': 372 case 'p':
377 otputil_pass = otputil_getpass("Enter code: ", NULL, 0); 373 cnf->pass = otputil_getpass("Enter code: ", NULL, 0);
378 break; 374 break;
379 375
380 case 'T': 376 case 'T':
diff --git a/src/otputil.h b/src/otputil.h
index 5f80223..989adb3 100644
--- a/src/otputil.h
+++ b/src/otputil.h
@@ -89,20 +89,11 @@ struct _otputil_cli_config
89 int argc; 89 int argc;
90 char ** argv; 90 char ** argv;
91 const char * prog_name; 91 const char * prog_name;
92 const char * pass;
92 const otputil_widget_t * widget; 93 const otputil_widget_t * widget;
93}; 94};
94 95
95 96
96/////////////////
97// //
98// Variables //
99// //
100/////////////////
101#pragma mark - Variables
102
103extern const char * otputil_pass;
104
105
106////////////////// 97//////////////////
107// // 98// //
108// Prototypes // 99// Prototypes //
diff --git a/src/widget-hotp.c b/src/widget-hotp.c
index 7e6a991..92d383d 100644
--- a/src/widget-hotp.c
+++ b/src/widget-hotp.c
@@ -107,15 +107,15 @@ otputil_widget_hotp(
107 // initial processing of cli arguments 107 // initial processing of cli arguments
108 if ((rc = otputil_arguments(cnf, cnf->argc, cnf->argv)) != 0) 108 if ((rc = otputil_arguments(cnf, cnf->argc, cnf->argv)) != 0)
109 return((rc == -1) ? 0 : 1); 109 return((rc == -1) ? 0 : 1);
110 if ( ((otputil_pass)) && (cnf->argc > optind) ) 110 if ( ((cnf->pass)) && (cnf->argc > optind) )
111 { 111 {
112 fprintf(stderr, "%s: cannot specify code and use `-p'\n", cnf->prog_name); 112 fprintf(stderr, "%s: cannot specify code and use `-p'\n", cnf->prog_name);
113 fprintf(stderr, "Try `%s --help' for more information.\n", cnf->prog_name); 113 fprintf(stderr, "Try `%s --help' for more information.\n", cnf->prog_name);
114 return(1); 114 return(1);
115 }; 115 };
116 otputil_pass = (cnf->argc > optind) ? cnf->argv[optind] : otputil_pass; 116 cnf->pass = (cnf->argc > optind) ? cnf->argv[optind] : cnf->pass;
117 117
118 if ((otputil_pass)) 118 if ((cnf->pass))
119 otputil_widget_hotp_verify(cnf); 119 otputil_widget_hotp_verify(cnf);
120 120
121 if ((code = otputil_str(NULL, buff, sizeof(buff))) == NULL) 121 if ((code = otputil_str(NULL, buff, sizeof(buff))) == NULL)
@@ -164,7 +164,7 @@ otputil_widget_hotp_verify(
164 return(1); 164 return(1);
165 }; 165 };
166 166
167 if ((strcasecmp(otputil_pass, code))) 167 if ((strcasecmp(cnf->pass, code)))
168 { 168 {
169 printf("%s\n", "invalid code"); 169 printf("%s\n", "invalid code");
170 return(2); 170 return(2);
diff --git a/src/widget-totp.c b/src/widget-totp.c
index b3f552f..fd0ee5d 100644
--- a/src/widget-totp.c
+++ b/src/widget-totp.c
@@ -105,15 +105,15 @@ otputil_widget_totp(
105 // initial processing of cli arguments 105 // initial processing of cli arguments
106 if ((rc = otputil_arguments(cnf, cnf->argc, cnf->argv)) != 0) 106 if ((rc = otputil_arguments(cnf, cnf->argc, cnf->argv)) != 0)
107 return((rc == -1) ? 0 : 1); 107 return((rc == -1) ? 0 : 1);
108 if ( ((otputil_pass)) && (cnf->argc > optind) ) 108 if ( ((cnf->pass)) && (cnf->argc > optind) )
109 { 109 {
110 fprintf(stderr, "%s: cannot specify code and use `-p'\n", cnf->prog_name); 110 fprintf(stderr, "%s: cannot specify code and use `-p'\n", cnf->prog_name);
111 fprintf(stderr, "Try `%s --help' for more information.\n", cnf->prog_name); 111 fprintf(stderr, "Try `%s --help' for more information.\n", cnf->prog_name);
112 return(1); 112 return(1);
113 }; 113 };
114 otputil_pass = (cnf->argc > optind) ? cnf->argv[optind] : otputil_pass; 114 cnf->pass = (cnf->argc > optind) ? cnf->argv[optind] : cnf->pass;
115 115
116 if ((otputil_pass)) 116 if ((cnf->pass))
117 return(otputil_widget_totp_verify(cnf)); 117 return(otputil_widget_totp_verify(cnf));
118 118
119 return(otputil_widget_totp_code(cnf)); 119 return(otputil_widget_totp_code(cnf));
@@ -171,7 +171,7 @@ otputil_widget_totp_verify(
171 return(1); 171 return(1);
172 }; 172 };
173 173
174 if ((strcasecmp(otputil_pass, code))) 174 if ((strcasecmp(cnf->pass, code)))
175 { 175 {
176 printf("%s\n", "invalid code"); 176 printf("%s\n", "invalid code");
177 return(2); 177 return(2);