diff --git a/README b/README index 441217d..e97e3d3 100644 --- a/README +++ b/README @@ -1,19 +1,19 @@ -Это файл README для библиотеки pam_keystore. -Библиотека pam_keystore предназначена для сохранения пользовательских паролей -в службу хранения ключей ядра Linux. +This is the README file for the library pam_keystore. +Library pam_keystore designed to store user passwords +in the service of storing keys kernel Linux. -Необходимые программы +Tools Needed --------------------- -keyutils версии 1.0 и выше +keyutils version 1.0 and above -Инсталяция +Installation ---------- make make install -Удаление +Delete -------- make uninstall \ No newline at end of file diff --git a/pam_keystore.c b/pam_keystore.c index 417bc88..1a02569 100644 --- a/pam_keystore.c +++ b/pam_keystore.c @@ -1,4 +1,4 @@ -//Copyright 2009 Calculate Pack, http://www.calculate-linux.ru +// Copyright 2007-2010 Mir Calculate Ltd. http://www.calculate-linux.org // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -39,7 +39,7 @@ // if (strcmp(arg, "@a" ) == 0) return KEY_SPEC_REQKEY_AUTH_KEY; -//Функция аутенфикации +// Authentication function PAM_EXTERN int pam_sm_authenticate(pam_handle_t * pamh, int flags ,int argc, const char **argv) { @@ -49,17 +49,17 @@ const char *name, *p; char *token; -// Достаем имя пользователя +// Get username retval = pam_get_user(pamh, &name, "login: "); if (retval!=PAM_SUCCESS) {return PAM_AUTH_ERR;}; -// Структура для пам функций +// Structure for pam-functions struct pam_conv *conv; -// Структура для пам сообщений +// Structure for pam-messages struct pam_message *pmsg[3],msg[3]; -// Структура для храения ответов пам +// Structure for pam-pesponse struct pam_response *response; -// Получаем функцию для доставания пароля +// Get the function to obtain a password retval = pam_get_item( pamh, PAM_CONV, (const void **) &conv ); if (retval!=PAM_SUCCESS) {return PAM_AUTH_ERR;} @@ -76,42 +76,41 @@ int flag = 0; }; if (flag == 0){ - //Инициализируем структуру сообщений + // Initialize the structure for pam-messages pmsg[0] = &msg[0]; msg[0].msg_style = PAM_PROMPT_ECHO_OFF; msg[0].msg="Password:"; - //Получаем указатель на ответ пама + // Get a pointer to the answer pam retval = conv->conv(1, ( const struct pam_message ** ) pmsg, &response, conv->appdata_ptr); if (retval!=PAM_SUCCESS) {return PAM_AUTH_ERR;}; - //Получаем password + // Get Password p = response->resp; }; -//Если пользователь root то не пишем файл +// Ignore the root user if (strcmp(name,"root")){ key_serial_t dest; int ret; - // идентификатор пользователя + // User id and gid uid_t uid, gid; - // получаем id и группу пользователя + // Get user id and gid uid = getuid(); gid = getgid(); if (uid==0 && gid==0){ - // Получаем id пользовательског ключа + // Get id (user key) dest = KEY_SPEC_USER_SESSION_KEYRING; - //printf("DEST=%d\n",dest); - // записываем ключ в пространство root + // Write the key in the keystore kernel (space of root) ret = add_key("user", name, p, strlen(p), dest); }; } if (p) { - //Копируем password для передачи следующему модулю + // Copy password for send to next module token = strdup(p); p=NULL; - // Передаем password cледующему модулю + // Send password to next module retval = pam_set_item (pamh, PAM_AUTHTOK, (const void *) token); if (retval == PAM_SUCCESS) {return PAM_SUCCESS;} } @@ -119,7 +118,7 @@ if (strcmp(name,"root")){ } -// Функция ничего не делает но нужна для корректной работы +// Empty function, necessary for pam-module PAM_EXTERN int pam_sm_setcred(pam_handle_t * pamh, int flags ,int argc, const char **argv) {