1
0
mirror of https://github.com/Yubico/yubico-pam.git synced 2025-01-20 19:52:16 +01:00

183 Commits

Author SHA1 Message Date
Larhard
1d62bec277 add nullok support to challenge-response mode 2017-04-09 03:36:40 +02:00
Mickaël Thomas
fc3b1e0076 Compare OTP IDs against yubi_attr only
Currently we trust the LDAP server to only return the `yubi_attr`
attribute, yet we loop over all possible attributes when there should
only be one.

Since the bundled test LDAP server ignores the requested attributes list,
we must make sure to only match against the `yubi_attr` attibute as
opposed to "all of them".

This also fixes an issue where AUTH_NOT_FOUND was returned instead
of AUTH_NO_TOKENS when there were no values returned for `yubi_attr`
but another attribute's value was considered as a candidate token.
2017-02-27 00:21:15 +01:00
Mickaël Thomas
7b6aad719a Return early if the user has no authorized tokens
Currently, if a user has no associated tokens, we still prompt for an
OTP challenge and attempt to verify it.

This adds a check earlier to avoid the useless prompt in that case.

The `nullok` option is also added. It changes the return value from
PAM_USER_UNKNOWN to PAM_IGNORE. (fixes #97)

Finally, some constants have been turned to symbolic form for clarity
and debugging output is improved.
2017-02-27 00:21:07 +01:00
Mickaël Thomas
0ce0e63d26 Perform OTP validation only if token is authorized
When using `try_first_pass` or `use_first_pass`, the password we inherit
from PAM might not actually be an OTP challenge.

Currently, we happily leak it to the validation server without first
checking if it matches an authorized token ID.

This postpones sending the actual request until we know the token ID is
authorized.
2017-02-26 21:32:24 +01:00
Simon Josefsson
02e520c906
Fix typo. 2016-08-09 09:34:47 +02:00
Klas Lindfors
174b09e298 let debug_accept stdout. also check that file exists and is regular 2016-06-22 10:19:53 +02:00
Klas Lindfors
8850659b5f Merge branch 'debug_refactor' 2016-06-16 13:17:10 +02:00
Klas Lindfors
f7a9fc5169 print debug_file when printing configuration 2016-06-16 12:35:18 +02:00
Klas Lindfors
2cab7ac03e open debug file with "a" not "a+" 2016-06-16 11:06:41 +02:00
Klas Lindfors
ead5337be1 fix typo 1 -> i 2016-06-16 10:26:30 +02:00
Klas Lindfors
5b36567820 cleanup debug_file after we're done 2016-06-16 10:07:56 +02:00
Klas Lindfors
fc9a4255f0 refactor the debug mode
add a debug_file option for where to write debug info (default to stdout)
stop compiling with DEBUG_PAM and PAM_DEBUG
make debugging behave the same way on linux-pam and openpam
2016-06-16 09:02:49 +02:00
Klas Lindfors
4fb0be3870 add tests for empty OTP validation
also fix around so ldap case checks with length of the authorized token,
not the length of the passed in id.
2016-06-13 11:08:09 +02:00
Klas Lindfors
fee0bcc231 drop check for OTP length, should trigger error later anyways.
relates #97
2016-06-13 10:45:30 +02:00
Klas Lindfors
a21a20cb65 only process results of OTP check after user is found
relates #97
2016-06-13 10:45:30 +02:00
Klas Lindfors
2343b25d23 Merge branch 'chalresp_ownership' 2016-04-01 09:35:19 +02:00
Klas Lindfors
051dd2a5b2 switch pam_modutils_getpwnam()/getpwnam() to always use getpwnam_r() 2016-03-31 09:51:22 +02:00
Klas Lindfors
155b485ba7 copy ownership and modes of old challenge file when creating a new one
fixes #92
2016-03-30 08:59:06 +02:00
Klas Lindfors
a6ea0e7053 pass cfg->debug to check_firmware_version() and let it use D macro 2016-02-19 11:03:52 +01:00
王邈
2b33aafdb9 add check for NULL conv 2016-02-16 20:05:50 +08:00
mikemn
6b46103dbc Add proxy support via Curl 2015-11-16 09:07:49 +01:00
Klas Lindfors
0bd785cf3a use correct modifier for size_t print 2015-10-08 10:29:08 +02:00
Klas Lindfors
83cccf3e12 reset yk_errno when we're happy with the result 2015-09-14 13:14:51 +02:00
Klas Lindfors
056dac4794 correct fchmod() return check 2015-09-14 13:14:30 +02:00
Klas Lindfors
dd96aa71dc switch i to size_t to match usage 2015-09-14 10:34:06 +02:00
Klas Lindfors
344d1b4384 fix initialization of msg to not warn
apparently this is gcc bug 53119
2015-09-14 10:30:01 +02:00
Klas Lindfors
ec84a78453 make yubi_attr_prefix_len a size_t 2015-09-14 10:29:49 +02:00
Klas Lindfors
0eb2f8cec3 mark unused parameter with __attribute__((unused)) 2015-09-14 10:27:14 +02:00
Klas Lindfors
bc93b62489 use mkstemp() to get the tempfile instead
unfortunately means we have to fchmod() it afterwards to be sure
2015-09-14 10:24:05 +02:00
madRat
3d22ed0c15 do_chalendge needs drop privs twice at reading and writing 2015-09-11 16:50:51 +03:00
Klas Lindfors
1036873b95 in the challenge-response case only drop privileges for user dir
This allows the module to work in a case where the directory is only
writable to root.

fixes #77
2015-09-11 13:56:14 +02:00
Klas Lindfors
70f27b98a2 include pwd.h in util.h 2015-09-09 08:24:57 +02:00
Klas Lindfors
237ed18b9f use pam_modutil_getpwnam() if it's available
also refactor to pass in a passwd struct to the util functions
2015-09-08 09:15:07 +02:00
Klas Lindfors
50ce40bbb1 free message at end of function
it was possible message was never freed if the sprintf() call failed
2015-07-08 16:11:42 +02:00
Klas Lindfors
9a132bcd07 add cainfo option to allow usage of a cabundle instead of path
path submitted by github user @Mrten
reportedly this is needed if curl is linked with gnutls
fixes #6
2015-06-15 10:25:56 +02:00
Klas Lindfors
11326d023d add debug print for last url used 2015-04-27 11:03:34 +02:00
Clemens Lang
ac5bb65013 Use unsigned, fix printf conversion spec warnings
Some of the printf conversion specifications were wrong when used on
size_t, causing

> pam_yubico.c:957:57: warning: format specifies type 'int' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
>       DBG (("OTP too short to be considered : %i < %i", password_len, (cfg->token_id_length + TOKEN_OTP_LEN)));
>                                               ~~        ^~~~~~~~~~~~
>                                               %zu
> pam_yubico.c:132:36: note: expanded from macro 'DBG'
> #define DBG(x) if (cfg->debug) { D(x); }
>                                    ^
> ./util.h:47:12: note: expanded from macro 'D'
>     printf x;                                                           \
>            ^

and

> pam_yubico.c:967:14: warning: format specifies type 'int' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
>         skip_bytes, password_len, cfg->token_id_length, TOKEN_OTP_LEN));
>                     ^~~~~~~~~~~~
> pam_yubico.c:132:36: note: expanded from macro 'DBG'
> #define DBG(x) if (cfg->debug) { D(x); }
>                                    ^
> ./util.h:47:12: note: expanded from macro 'D'
>     printf x;                                                           \
>            ^

Fix these by using the appropriate %zu conversions for size_t. While
looking through the code, there are a couple more places where format
string specifiers could be improved, e.g. using %zu instead of casting
the result of sizeof(x) or strlen(x) to unsigned long.

In addition, convert TOKEN_OTP_LEN, MAX_TOKEN_ID_LEN and
DEFAULT_TOKEN_ID_LEN to unsigned numbers, because negative values would
not make any sense for those.
2015-03-30 13:54:37 +02:00
Clemens Lang
c1f61bae0f Fix warning if pam_message.msg isn't constant
On OS X and FreeBSD, struct pam_message does not declare its msg member
as constant. This causes a warning when assigning a constant string to
it:

pam_yubico.c:403:14: warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
  msg[0].msg = message;
             ^ ~~~~~~~
2015-03-30 13:54:36 +02:00
Klas Lindfors
252f582712 change datatypes to unsigned
avoiding warnings about sign conversion
2015-03-04 14:52:28 +01:00
Klas Lindfors
8241cd0423 Merge branch 'feature/ldap_refactor'
Conflicts:
	pam_yubico.c
2015-03-04 14:40:57 +01:00
Klas Lindfors
71339bb8a1 allow ldap search with no base 2015-03-04 11:12:53 +01:00
Klas Lindfors
c75a3f0496 move debug print (and dereference of resp) inside null check 2015-03-04 10:20:40 +01:00
Klas Lindfors
77c152df6f move protocol inside HAVE_LIBLDAP
to avoid warning of unused variable
2015-03-04 09:57:22 +01:00
Klas Lindfors
336351188b drop password parameter for authorized_user_token_ldap() 2015-03-04 09:27:21 +01:00
Klas Lindfors
5709a4479a drop the ldap_bind_no_anonymous feature
Sending the users password out in another direction is scary and
requires more thought. Ideally this should be solved by using ldap
GSSAPI or similar instead of sending a cleartext password over the
network.
2015-03-04 09:14:53 +01:00
Klas Lindfors
0d3a4f4f75 consider all success as valid session 2015-03-04 09:14:14 +01:00
Klas Lindfors
f6e1ec9483 don't throw const away in cast 2015-03-04 09:11:09 +01:00
Klas Lindfors
311958093d client_id is supposed to be unsigned 2015-03-04 08:59:55 +01:00
Klas Lindfors
6c121c8da3 make sure rc is initialized before using 2015-03-04 08:50:08 +01:00
Klas Lindfors
663fa9a8a4 don't use c++ style comments 2015-03-04 08:47:11 +01:00