#include "../lib/nuclient.h"#include <sys/resource.h>#include <stdio.h>#include <locale.h>#include <langinfo.h>#include <syslog.h>#include <pwd.h>#include <signal.h>#include <stdlib.h>#include "security.h"#include <security/pam_modules.h>#include <security/_pam_macros.h>Include dependency graph for pam_nufw.c:

Go to the source code of this file.
Data Structures | |
| struct | pam_nufw_s |
| struct | user_info_s |
Defines | |
| #define | _GNU_SOURCE |
| #define | PAM_SM_AUTH |
| #define | PAM_SM_ACCOUNT |
| #define | PAM_SM_SESSION |
| #define | PAM_SM_PASSWORD |
| #define | NUAUTH_SRV "192.168.12.1" |
| #define | NUAUTH_PORT "4129" |
| #define | FILE_LOCK ".pam_nufw" |
| #define | MAX_RETRY_TIME 30 |
| #define | MAX_NOAUTH_USERS 10 |
Functions | |
| static char * | _init_pam_nufw_s (struct pam_nufw_s *pn_s) |
| static int | _pam_parse (int argc, const char **argv, struct pam_nufw_s *pn) |
| char * | _get_runpid (struct pam_nufw_s *pn_s, char *home) |
| static int | _kill_nuclient (char *runpid) |
| void | exit_client () |
| int | do_auth_on_user (const char *username) |
| nuauth_session_t * | do_connect (char *username, char *password, nuclient_error_t *err) |
| static void | main_loop (struct pam_nufw_s *pn_s) |
| static void | clear_user_info (struct user_info_s *user_info) |
| static int | nufw_client_func (struct pam_nufw_s *pn_s, struct user_info_s *user_info) |
| static int | read_user_info (struct user_info_s *user_info, pam_handle_t *pamh, int argc, const char **argv, int *pam_result) |
| PAM_EXTERN int | pam_sm_authenticate (pam_handle_t *pamh, int flags, int argc, const char **argv) |
| PAM_EXTERN int | pam_sm_setcred (pam_handle_t *pamh, int flags, int argc, const char **argv) |
| PAM_EXTERN int | pam_sm_acct_mgmt (pam_handle_t *pamh, int flags, int argc, const char **argv) |
| PAM_EXTERN int | pam_sm_chauthtok (pam_handle_t *pamh, int flags, int argc, const char **argv) |
| PAM_EXTERN int | pam_sm_open_session (pam_handle_t *pamh, int flags, int argc, const char **argv) |
| PAM_EXTERN int | pam_sm_close_session (pam_handle_t *pamh, int flags, int argc, const char **argv) |
Variables | |
| const char * | DEFAULT_USER = "nobody" |
| char ** | no_auth_users = NULL |
| pam_nufw_s | pn_s |
| nuauth_session_t * | session = NULL |
| char * | locale_charset = NULL |
| #define _GNU_SOURCE |
Definition at line 24 of file pam_nufw.c.
| #define FILE_LOCK ".pam_nufw" |
| #define MAX_NOAUTH_USERS 10 |
| #define MAX_RETRY_TIME 30 |
Definition at line 56 of file pam_nufw.c.
| #define NUAUTH_PORT "4129" |
| #define NUAUTH_SRV "192.168.12.1" |
| #define PAM_SM_ACCOUNT |
Definition at line 44 of file pam_nufw.c.
| #define PAM_SM_AUTH |
Definition at line 43 of file pam_nufw.c.
| #define PAM_SM_PASSWORD |
Definition at line 46 of file pam_nufw.c.
| #define PAM_SM_SESSION |
Definition at line 45 of file pam_nufw.c.
| char* _get_runpid | ( | struct pam_nufw_s * | pn_s, | |
| char * | home | |||
| ) |
Definition at line 150 of file pam_nufw.c.
References pam_nufw_s::file_lock, nu_get_home_dir(), and pn_s.
Referenced by exit_client(), nufw_client_func(), and pam_sm_close_session().
Here is the call graph for this function:

| static char* _init_pam_nufw_s | ( | struct pam_nufw_s * | pn_s | ) | [static] |
Definition at line 79 of file pam_nufw.c.
References FILE_LOCK, locale_charset, NUAUTH_PORT, NUAUTH_SRV, pn_s, and SECURE_STRNCPY.
Referenced by pam_sm_authenticate(), and pam_sm_close_session().
| static int _kill_nuclient | ( | char * | runpid | ) | [static] |
| static int _pam_parse | ( | int | argc, | |
| const char ** | argv, | |||
| struct pam_nufw_s * | pn | |||
| ) | [static] |
Definition at line 114 of file pam_nufw.c.
References pam_nufw_s::file_lock, MAX_NOAUTH_USERS, pam_nufw_s::no_auth_cpt, pam_nufw_s::no_auth_users, no_auth_users, pam_nufw_s::nuauth_port, pam_nufw_s::nuauth_srv, and SECURE_STRNCPY.
Referenced by pam_sm_close_session(), and read_user_info().
| static void clear_user_info | ( | struct user_info_s * | user_info | ) | [static] |
Definition at line 332 of file pam_nufw.c.
Referenced by nufw_client_func(), and pam_sm_authenticate().
| int do_auth_on_user | ( | const char * | username | ) |
Definition at line 232 of file pam_nufw.c.
References pam_nufw_s::no_auth_cpt, pam_nufw_s::no_auth_users, and pn_s.
Referenced by pam_sm_close_session(), and read_user_info().
| nuauth_session_t* do_connect | ( | char * | username, | |
| char * | password, | |||
| nuclient_error_t * | err | |||
| ) |
Try to connect to nuauth.
Definition at line 251 of file pam_nufw.c.
References nuauth_session::debug_mode, err, nu_client_connect(), nu_client_delete(), nu_client_new(), nu_client_set_debug(), pam_nufw_s::nuauth_port, pam_nufw_s::nuauth_srv, pn_s, and session.
Here is the call graph for this function:

| void exit_client | ( | ) |
Definition at line 215 of file pam_nufw.c.
References _get_runpid(), pam_nufw_s::err, nu_client_delete(), nu_client_error_destroy(), nu_client_global_deinit(), pn_s, and session.
Referenced by main_loop(), and nufw_client_func().
Here is the call graph for this function:

| static void main_loop | ( | struct pam_nufw_s * | pn_s | ) | [static] |
Definition at line 281 of file pam_nufw.c.
References BAD_CREDENTIALS_ERR, pam_nufw_s::err, nuclient_error_t::error, exit_client(), MAX_RETRY_TIME, nu_client_check(), nu_client_connect(), nu_client_reset(), nu_client_strerror(), pam_nufw_s::nuauth_port, pam_nufw_s::nuauth_srv, pn_s, and session.
Here is the call graph for this function:

| static int nufw_client_func | ( | struct pam_nufw_s * | pn_s, | |
| struct user_info_s * | user_info | |||
| ) | [static] |
Definition at line 337 of file pam_nufw.c.
References _get_runpid(), clear_user_info(), do_connect(), pam_nufw_s::err, exit_client(), user_info_s::gid, user_info_s::home_dir, locale_charset, main_loop(), nu_client_error_init(), nu_client_global_init(), nu_client_strerror(), nu_client_to_utf8(), pam_nufw_s::nuauth_srv, user_info_s::password, pn_s, session, user_info_s::uid, and user_info_s::username.
Referenced by pam_sm_authenticate().
Here is the call graph for this function:

| PAM_EXTERN int pam_sm_acct_mgmt | ( | pam_handle_t * | pamh, | |
| int | flags, | |||
| int | argc, | |||
| const char ** | argv | |||
| ) |
Definition at line 550 of file pam_nufw.c.
| PAM_EXTERN int pam_sm_authenticate | ( | pam_handle_t * | pamh, | |
| int | flags, | |||
| int | argc, | |||
| const char ** | argv | |||
| ) |
Definition at line 472 of file pam_nufw.c.
References _init_pam_nufw_s(), clear_user_info(), pam_nufw_s::file_lock, nu_check_version(), nu_get_version(), NUCLIENT_VERSION, nufw_client_func(), pn_s, and read_user_info().
Here is the call graph for this function:

| PAM_EXTERN int pam_sm_chauthtok | ( | pam_handle_t * | pamh, | |
| int | flags, | |||
| int | argc, | |||
| const char ** | argv | |||
| ) |
Definition at line 559 of file pam_nufw.c.
| PAM_EXTERN int pam_sm_close_session | ( | pam_handle_t * | pamh, | |
| int | flags, | |||
| int | argc, | |||
| const char ** | argv | |||
| ) |
Definition at line 581 of file pam_nufw.c.
References _get_runpid(), _init_pam_nufw_s(), _kill_nuclient(), _pam_parse(), do_auth_on_user(), and pn_s.
Here is the call graph for this function:

| PAM_EXTERN int pam_sm_open_session | ( | pam_handle_t * | pamh, | |
| int | flags, | |||
| int | argc, | |||
| const char ** | argv | |||
| ) |
Definition at line 569 of file pam_nufw.c.
| PAM_EXTERN int pam_sm_setcred | ( | pam_handle_t * | pamh, | |
| int | flags, | |||
| int | argc, | |||
| const char ** | argv | |||
| ) |
Definition at line 541 of file pam_nufw.c.
| static int read_user_info | ( | struct user_info_s * | user_info, | |
| pam_handle_t * | pamh, | |||
| int | argc, | |||
| const char ** | argv, | |||
| int * | pam_result | |||
| ) | [static] |
Definition at line 415 of file pam_nufw.c.
References _pam_parse(), DEFAULT_USER, do_auth_on_user(), user_info_s::gid, user_info_s::home_dir, user_info_s::password, pn_s, user_info_s::uid, and user_info_s::username.
Referenced by pam_sm_authenticate().
Here is the call graph for this function:

| const char* DEFAULT_USER = "nobody" |
| char* locale_charset = NULL |
| char** no_auth_users = NULL |
| struct pam_nufw_s pn_s |
Definition at line 64 of file pam_nufw.c.
Referenced by _get_runpid(), _init_pam_nufw_s(), do_auth_on_user(), do_connect(), exit_client(), main_loop(), nufw_client_func(), pam_sm_authenticate(), pam_sm_close_session(), and read_user_info().
| nuauth_session_t* session = NULL |
Definition at line 65 of file pam_nufw.c.
1.4.7