Commit graph

35 commits

Author SHA1 Message Date
Sergey Poznyakoff
a52fff3061 Avoild name clash in on ldap_connect 2023-03-11 10:53:52 +02:00
Sergey Poznyakoff
b4fb52526e Bugfix 2022-05-09 11:05:08 +03:00
Sergey Poznyakoff
f3b7c048b8 Update copyright years 2022-02-04 09:38:17 +02:00
Sergey Poznyakoff
da41d2aec4 Update copyright years 2021-01-06 18:15:52 +02:00
Sergey Poznyakoff
b6c720096e Use wordsplit for keyword expansion.
* .gitmodules: Add wordsplit
* configure.ac: Likewise.
* lib/Makefile.am: Likewise.
* lib/graypam.h (gray_expand_argv): Remove.
(gray_expand_string): Change prototype.
* lib/vartab.c (gray_expand_argv): Remove.
(gray_expand_string): Rewrite using wordsplit.
* pam_ldaphome/pam_ldaphome.c (import_public_key): Assume
sshPublicKey as a default attribute.
* pam_log/pam_log.c (_pam_parse): Take two return arguments.
(echo): Use gray_expand_string.
* pam_sql/pam_mysql.c: Update gray_expand_string usage.
* pam_sql/pam_pgsql.c: Likewise.
* pam_sql/pam_sql.c: Likewise.
* pam_sql/pam_sql.h (gpam_sql_get_query): Change signature.
* pam_umotd/pam_umotd.c (pam_sm_open_session): Update
gray_expand_string usage.
2020-03-29 17:39:54 +03:00
Sergey Poznyakoff
7a40b7873b Major cleanup
* lib/graypam.h (gray_pam_init)
(gray_raise,gray_malloc,gray_zalloc,gray_calloc)
(gray_realloc,gray_strdup): Remove.
(gray_slist_err,gray_slist_clrerr): New functions.
(gray_slist_append,gray_slist_append_char): Return ssize_t.
(gray_slist_coalesce): Likewise.
(gray_slist_grow_backslash_num)
(gray_slist_grow_backslash): Return int.
(errno_to_pam): New function.
(gray_set_transform_expr): Return int.
* lib/mem.c (gray_raise,gray_malloc,gray_zalloc,gray_calloc)
(gray_realloc,gray_strdup): Remove.
(gray_2nrealloc): Rewrite.
* lib/base64.c: Check return from gray_slist_append_char
* lib/env.c: Check return values from gray_slist functions
* lib/ldappass.c: Likewise.
* lib/slist.c (gray_slist_bucket) <ec>: New member.
(gray_slist_err,gray_slist_clrerr): New functions.
(gray_slist_append,gray_slist_append_char): Return ssize_t.
(gray_slist_coalesce): Likewise.
(gray_slist_grow_backslash_num)
(gray_slist_grow_backslash): Return int.
* lib/transform.c: Use standard memory allocation functions.
* pam_ldaphome/pam_ldaphome.c: Likewise.
* pam_innetgr/pam_innetgr.c: Likewise.
* pam_log/pam_log.c: Likewise.
* pam_regex/pam_regex.c: Likewise.
* pam_sql/pam_mysql.c: Likewise.
* pam_sql/pam_pgsql.c: Likewise.
2018-08-15 22:22:31 +03:00
Sergey Poznyakoff
c20d0e4bf3 Happy GNU Year 2018-01-01 11:22:40 +02:00
Sergey Poznyakoff
7974dd9073 Version 2.0
* NEWS: Update version number
* configure.ac: Likewise.
* doc/pam-modules.texi: Fix a typo.
* doc/pam_ldaphome.8in: Likewise.
* pamck/pamck.c: Update copyright years.

* pam_fshadow/pam_fshadow.c: Suppress cc warnings.
* pam_groupmember/pam_groupmember.c: Likewise.
* pam_ldaphome/pam_ldaphome.c: Likewise.
* pam_log/pam_log.c: Likewise.
* pam_regex/pam_regex.c: Likewise.
2015-02-26 11:22:00 +02:00
Sergey Poznyakoff
946c85c169 Update copyright dates. 2015-01-28 16:54:21 +02:00
Sergey Poznyakoff
947e0c2f8a pam_ldaphome: run initrc command as user.
* examples/usergitconfig: Documentation formatting change.
* lib/graypam.h (gray_2nrealloc): New function.
* lib/mem.c (gray_2nrealloc): New function.
* pam_fshadow/pam_fshadow.c (fgetpwent): Skip malformed entries.
* pam_ldaphome/pam_ldaphome.c (runas): New finction.
(run_prog): Switch to user privileges unless initrc-root is true.

* NEWS: Update.
* doc/pam-modules.texi: Update.
* doc/pam_ldaphome.8in: Update.
2015-01-28 16:42:52 +02:00
Sergey Poznyakoff
e094d80820 Implement audit option
Audit is equivalent to debug=100, i.e. it enables logging
maximum debugging output.
2014-12-04 17:25:44 +02:00
Sergey Poznyakoff
44ee01dd4d pam_ldaphome: Make user-specific key boundary configurable.
* pam_ldaphome/pam_ldaphome.c (store_pubkeys): Use the value of the
user-keys-boundary option as the boundary of user-specific key section.
2014-09-16 11:40:26 +03:00
Sergey Poznyakoff
a792777294 Provide a way to keep user-defined pubkeys in file.
A user can add his public keys to the authorized_keys file without disturbing
the key synchronization from the LDAP database.  The #:end comment in the file
marks the end of area synchronized with LDAP.  Everything below this comment
is preserved intact.

* pam_ldaphome/pam_ldaphome.c (pubkeyfile): New struct.
(pubkeyfile_open,pubkeyfile_read,pubkeyfile_init)
(pubkeyfile_write,pubkeyfile_remove_lines)
(pubkeyfile_alloc_lines,pubkeyfile_insert_lines)
(pubkeyfile_close): New functions.
(store_pubkeys): Use pubkeyfile functions to operate on
the authorized_keys file.
2014-09-12 10:27:43 +03:00
Sergey Poznyakoff
05bf037ee1 Bugfixes
* pam_ldaphome/pam_ldaphome.c (check_groups): Take into account primary
group.
* doc/pam_regex.8: Fix escaping.
2014-09-11 20:16:59 +03:00
Sergey Poznyakoff
b4a27a9c7a pam_ldaphome: read /etc/ldap.conf file.
* lib/env.c (gray_env_read_tr): New function.
(gray_env_read): Rewrite using gray_env_read_tr.
(gray_env_merge): New function.
* lib/escape.c (gray_escape_string): Remove useless typecasts.
* lib/graypam.h (gray_env_read_tr)
(gray_env_merge): New protos.
* pam_ldaphome/pam_ldaphome.c (ldap_config_name): New variable.
(ldap_connect): Use 'ssl' keyword, if 'tls' is not defined.
(ldaphome_main): New keyword ldap-config

* doc/pam-modules.texi: Document reading system-wide ldap.conf
* doc/pam_ldaphome.8in: Likewise.
2014-07-25 15:37:28 +03:00
Sergey Poznyakoff
c1059e0398 pam_ldaphome: provide an option to specify CA certificate file for TLS
* pam_ldaphome/pam_ldaphome.c (ldap_connect): New option tls-cacert
* doc/pam-modules.texi: Document tls-cacert
* doc/pam_ldaphome.8in: Likewise.
2014-07-24 17:33:10 +03:00
Sergey Poznyakoff
66dcf254f5 Remove deprecated use of INCLUDES from Makefiles.
* Make.rules: Use AM_CPPFLAGS instead of INCLUDES.
* Makefile.am (SUBDIRS): Add examples.
(dist-hook): Remove.
* configure.ac: Build examples/Makefile.
* examples/Makefile.am: New file.
* pam_fshadow/Makefile.am: Include Make.rules on top.
Use += to set AM_CPPFLAGS
* pam_groupmember/Makefile.am: Likewise.
* pam_ldaphome/Makefile.am: Likewise.
* pam_log/Makefile.am: Likewise.
* pam_regex/Makefile.am: Likewise.
* pam_sql/Makefile.am: Likewise.
* pam_umotd/Makefile.am: Likewise.
2014-05-21 12:48:53 +03:00
Sergey Poznyakoff
f664b904fd pam_ldaphome: don't run initrc program if the home dir already exists.
* pam_ldaphome/pam_ldaphome.c (create_exists): New return code.
(create_home_dir): Return create_exists if the directory already
exists.
(ldaphome_main): Run initrc only after creating the home dir.
2014-05-20 14:38:37 +03:00
Sergey Poznyakoff
7636fa3e7b New utility "ldappubkey".
* NEWS: Document new features.
* doc/pam-modules.texi: Document usergitconfig.
* doc/pam_ldaphome.8in: Update.
* examples/ldappubkey: New file.
* examples/usergitconfig: Refer to perldoc on error.
* lib/env.c (gray_env_get_bool): New function.
* lib/graypam.h (gray_env_get_bool): New proto.
* pam_ldaphome/pam_ldaphome.c (import_public_key): Do nothing if
"import-public-keys" is set to "no".
(pam_sm_authenticate): New function.
2014-05-19 14:01:21 +03:00
Sergey Poznyakoff
867eaccec7 Allow to modify environment of initrc-command
* pam_ldaphome/pam_ldaphome.c (find_env,locate_unset)
(env_concat,parsenv,env_setup): New statics.
(run_prog): Use execve and env_setup to set up the
environment.

* doc/pam-modules.texi: Document new statements.
* doc/pam_ldaphome.8in: Likewise.
2014-05-11 11:20:58 +03:00
Sergey Poznyakoff
ebda1d26ab pam_ldaphome: optionally run external program after populating home directory.
This allows for dynamic modifications of the initial directory contents,
depending on the login name of the user.  The name of the external program
is given with the initrc-command configuration statement.  It is invoked
with the single argument, specifying the login name.  The standard input
is closed, standard output is diverted to standard error.  Standard error
can be diverted to a file using the initrc-log statement.

* Makefile.am (EXTRA_DIST): Add examples.
* examples/usergitconfig: New file.
* pam_ldaphome/pam_ldaphome.c (run_prog, run_initrc): New statics.
(pam_sm_authenticate): Call run_initrc prior to calling
import_public_key.
2014-05-10 22:58:46 +03:00
Sergey Poznyakoff
db866c50c4 Update copyright years, set version 1.7.92 2014-02-11 15:06:09 +02:00
Sergey Poznyakoff
2e14f21631 pam_ldaphome: control where home directories can be created
* pam_ldaphome/pam_ldaphome.c (create_interdir): Fail if unable to chown,
(store_pubkeys): Log error if fchown or ftruncate fails.
(dir_in_path): New static function.
(create_home_dir): Return enum create_status.
If allow-home-dir statement is present, create directory only if
it is located in one of the directories listed in it, otherwise
return create_skip.
(pam_sm_authenticate): Import keys only if home dir exists.
* doc/pam-modules.texi: Document allow-home-dir.
2014-02-11 15:00:48 +02:00
Sergey Poznyakoff
99ed51a2da Bugfixes.
* configure.ac: Do not call PM_ENABLE within a conditional.
* pam_ldaphome/pam_ldaphome.c (import_public_key): Exit
gracefully if keys == NULL.
2013-04-16 22:04:40 +03:00
Sergey Poznyakoff
d211d9ec0c Improve pam_ldaphome
New keywords: bindpwfile and keyfile-mode.

* doc/pam-modules.texi: Document bindpwfile and keyfile-mode.
* pam_ldaphome/pam_ldaphome.c (ldap_bind): Read password from
file, if bindpwfile is given.
(store_pubkeys): Optionally enforce file mode, given by the
keyfile-mode configuration statement.
* pamck/pamck.c (main): Fix a typo.
2012-08-01 21:14:22 +03:00
Sergey Poznyakoff
dc43cd8ee7 Update copyright years. 2012-07-04 13:10:06 +03:00
Sergey Poznyakoff
affd4768a7 Bugfixes.
* configure.ac: Version 1.7.90.
* NEWS: Update.
* doc/Makefile.am (EXTRA_DIST): Remove leftover files.
* pam_ldaphome/pam_ldaphome.c (ldap_connect): Set LDAP version
before enforcing TLS.
2012-05-23 16:10:11 +03:00
Sergey Poznyakoff
29916f8fc7 Enable fine-grained control over TLS.
* doc/pam-modules.texi: Document new tls values.
* pam_ldaphome/pam_ldaphome.c (ldap_connect): The tls
keyword is tri-state.  Allowed values are: "yes", "no"
and "only".
2012-05-18 18:22:52 +03:00
Sergey Poznyakoff
b47a46aefd Improve configuration for pam_ldaphome.
* doc/pam-modules.texi: Document new configuration keywords.
* pam_ldaphome/pam_ldaphome.c (get_intval): Take additional
"base" argument. Return 1 if the requested keyword is not
present in the database, -1 on error and 0 on success.
(ldap_connect): Consult the "ldap-version" configuration
variable for the LDAP version to use.
(create_home_dir): Read mode for the home directory from
the configuration variable "home-dir-mode".
2012-05-18 17:26:38 +03:00
Sergey Poznyakoff
58d86b04e6 Minor improvements.
* pam_ldaphome/pam_ldaphome.c (get_ldap_attrs): restore pubkey
debug output.
(pam_sm_authenticate): New keyword "authorized_keys"
2012-05-16 00:14:56 +03:00
Sergey Poznyakoff
e9aabc7e71 Improve handling of multiple keys.
* pam_ldaphome/pam_ldaphome.c (get_ldap_attrs): return array of values.
(store_pubkeys): Fix key comparison.
2012-05-15 23:00:51 +03:00
Sergey Poznyakoff
8a9a1ee295 Allow for multiple authorized keys.
* pam_ldaphome/pam_ldaphome.c (argcvz_free,trimnl): New functions.
(get_ldap_attr): Trim trailing newlines from the return value.
(ldap_search): Rename to get_pubkeys. Return null-terminated array
of sorted lexicographically keys.
(store_pubkey): Rename to store_pubkeys, take char ** as its
first argument. Store all keys unless the file already contains
exactly that set of keys.
(import_public_key): Call store_pubkeys. Use argcvz_free to
free the keys.
2012-05-15 18:22:08 +03:00
Sergey Poznyakoff
381fbf3365 Bugfixes.
* pam_ldaphome/pam_ldaphome.c (argcv_free): Fix multiple free
(argcv_concat): Fix overly conservative size calculation and
concatenation loop.
(parse_ldap_uri): Fix URI reconstruction.
(dir_copy_loop): Remove unused variable.
(store_pubkey): Return meaningful error code.
(import_public_key): Propagate return code from store_pubkey.
(create_home_dir): Return meaningful error code.
(pam_sm_authenticate): Propagate return code from create_home_dir
and import_public_key to the caller.
* pam_log/Makefile.am: Remove BUILD_PAM_LOG substitution
(complements 1a80b647).
2012-05-15 17:23:31 +03:00
Sergey Poznyakoff
996f020583 pam_ldaphome: implement populate_homedir. 2012-05-15 08:51:53 +03:00
Sergey Poznyakoff
1a80b647d6 Revamp build system. Add pam_ldaphome module.
* configure.ac: Test for ldap.
(AC_OUTPUT): Create pam_ldaphome/Makefile.
* acinclude.m4 (PM_ENABLE): Declare PAM_COND_<item>
conditional in addition to BUILD_PAM_<item> substitution
variable.
* Makefile.am (SUBDIRS): Include most modules via
conditionally defined Makefile variables.

* lib/graypam.h (gray_env): New struct.
(gray_env_get,gray_env_free,gray_env_read)
(gray_boolean_true_p): New protos.
* lib/env.c: New file.
* lib/Makefile.am (libgraypam_la_SOURCES): Add env.c

* pam_fshadow/Makefile.am: Remove BUILD_PAM_FSHADOW
substitution.
* pam_regex/Makefile.am: Remove BUILD_PAM_REGEX
substitution.
* pam_sql/pam_sql.c (free_config, boolean_true_p)
(read_config): Remove. Use gray_env_* functions
instead. All uses updated.
* pam_regex/pam_regex.c: Fix typo.

* pam_ldaphome/Makefile.am: New file.


git-svn-id: file:///svnroot/pam-modules/trunk@118 56984be4-0537-0410-a56c-fcb268c96130
2012-05-13 09:48:57 +00:00