本文整理汇总了C++中pam_end函数的典型用法代码示例。如果您正苦于以下问题:C++ pam_end函数的具体用法?C++ pam_end怎么用?C++ pam_end使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pam_end函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: quit
static void
quit(struct weston_launch *wl, int status)
{
struct vt_mode mode = { 0 };
int err;
close(wl->signalfd);
close(wl->sock[0]);
if (wl->new_user) {
err = pam_close_session(wl->ph, 0);
if (err)
fprintf(stderr, "pam_close_session failed: %d: %s\n",
err, pam_strerror(wl->ph, err));
pam_end(wl->ph, err);
}
if (ioctl(wl->tty, KDSKBMUTE, 0) &&
ioctl(wl->tty, KDSKBMODE, wl->kb_mode))
fprintf(stderr, "failed to restore keyboard mode: %m\n");
if (ioctl(wl->tty, KDSETMODE, KD_TEXT))
fprintf(stderr, "failed to set KD_TEXT mode on tty: %m\n");
/* We have to drop master before we switch the VT back in
* VT_AUTO, so we don't risk switching to a VT with another
* display server, that will then fail to set drm master. */
drmDropMaster(wl->drm_fd);
mode.mode = VT_AUTO;
if (ioctl(wl->tty, VT_SETMODE, &mode) < 0)
fprintf(stderr, "could not reset vt handling\n");
exit(status);
}
开发者ID:rzr,项目名称:weston-ivi-shell,代码行数:35,代码来源:weston-launch.c
示例2: sftppam_exit_ev
static void sftppam_exit_ev(const void *event_data, void *user_data) {
/* Close the PAM session */
if (sftppam_pamh != NULL) {
int res;
#ifdef PAM_CRED_DELETE
res = pam_setcred(sftppam_pamh, PAM_CRED_DELETE);
#else
res = pam_setcred(sftppam_pamh, PAM_DELETE_CRED);
#endif
if (res != PAM_SUCCESS) {
pr_trace_msg(trace_channel, 9, "PAM error setting PAM_DELETE_CRED: %s",
pam_strerror(sftppam_pamh, res));
}
res = pam_close_session(sftppam_pamh, PAM_SILENT);
pam_end(sftppam_pamh, res);
sftppam_pamh = NULL;
}
if (sftppam_user != NULL) {
free(sftppam_user);
sftppam_user = NULL;
sftppam_userlen = 0;
}
}
开发者ID:proftpd,项目名称:proftpd,代码行数:28,代码来源:mod_sftp_pam.c
示例3: loginpam_acct
static void loginpam_acct(struct login_context *cxt)
{
int rc;
pam_handle_t *pamh = cxt->pamh;
rc = pam_acct_mgmt(pamh, 0);
if (rc == PAM_NEW_AUTHTOK_REQD)
rc = pam_chauthtok(pamh, PAM_CHANGE_EXPIRED_AUTHTOK);
if (is_pam_failure(rc))
loginpam_err(pamh, rc);
/*
* Grab the user information out of the password file for future use.
* First get the username that we are actually using, though.
*/
rc = loginpam_get_username(pamh, &cxt->username);
if (is_pam_failure(rc))
loginpam_err(pamh, rc);
if (!cxt->username || !*cxt->username) {
warnx(_("\nSession setup problem, abort."));
syslog(LOG_ERR, _("NULL user name in %s:%d. Abort."),
__FUNCTION__, __LINE__);
pam_end(pamh, PAM_SYSTEM_ERR);
sleepexit(EXIT_FAILURE);
}
}
开发者ID:sebras,项目名称:util-linux,代码行数:29,代码来源:login.c
示例4: main
int
main (int argc, char **argv)
{
pam_handle_t *pamh;
int rc;
for (loop = 0; loop < sizeof (tv) / sizeof (tv[0]); loop++)
{
rc = pam_start ("pam_oath1", tv[loop].user, &conv, &pamh);
if (rc != PAM_SUCCESS)
{
printf ("pam_start failed loop %ld rc %d: %s\n", loop, rc,
pam_strerror (pamh, rc));
return 1;
}
rc = pam_authenticate (pamh, 0);
if (rc != tv[loop].expectrc)
{
printf ("pam_authenticate failed loop %ld rc %d: %s\n", loop, rc,
pam_strerror (pamh, rc));
return 1;
}
rc = pam_end (pamh, rc);
if (rc != PAM_SUCCESS)
{
printf ("pam_end failed loop %ld rc %d: %s\n", loop, rc,
pam_strerror (pamh, rc));
return 1;
}
}
return 0;
}
开发者ID:tluyben,项目名称:oath-toolkit-9-digits,代码行数:35,代码来源:test-pam_oath-root.c
示例5: close_pam_handle
static gboolean
close_pam_handle (int status)
{
if (pam_handle != NULL) {
int status2;
status2 = pam_end (pam_handle, status);
pam_handle = NULL;
if (gs_auth_get_verbose ()) {
g_message (" pam_end (...) ==> %d (%s)",
status2,
(status2 == PAM_SUCCESS ? "Success" : "Failure"));
}
}
if (message_handled_condition != NULL) {
g_cond_free (message_handled_condition);
message_handled_condition = NULL;
}
if (message_handler_mutex != NULL) {
g_mutex_free (message_handler_mutex);
message_handler_mutex = NULL;
}
return TRUE;
}
开发者ID:solus-project,项目名称:budgie-screensaver,代码行数:29,代码来源:gs-auth-pam.c
示例6: checkpw_cleanup
static void checkpw_cleanup (pam_handle_t *hdl)
{
#if 0 /* see checkpw() for why this is #if 0 */
pam_close_session (hdl,NIL); /* close session [uw]tmp */
#endif
pam_setcred (hdl,PAM_DELETE_CRED);
pam_end (hdl,PAM_SUCCESS);
}
开发者ID:Distrotech,项目名称:pine,代码行数:8,代码来源:ckp_pam.c
示例7: pam_close_session
PAMAuthenticator::~PAMAuthenticator(void)
{
if (this->m_ph) {
int res = pam_close_session(this->m_ph, 0);
pam_end(this->m_ph, res);
this->m_ph = 0;
}
}
开发者ID:sjinks,项目名称:repwatch_proxy,代码行数:8,代码来源:pamauthenticator.cpp
示例8: AuthPAMClose
void AuthPAMClose()
{
if (pamh)
{
pam_close_session(pamh, 0);
pam_end(pamh,PAM_SUCCESS);
}
}
开发者ID:ColumPaget,项目名称:MetaFTPD,代码行数:8,代码来源:Authenticate.c
示例9: pam_end
void context::close() noexcept
{
if(_M_pamh)
{
pam_end(_M_pamh, _M_code);
_M_pamh = nullptr;
}
}
开发者ID:dimitry-ishenko,项目名称:camel,代码行数:8,代码来源:pam.cpp
示例10: do_pam_authenticate
static auth_result_t do_pam_authenticate(const char* service, const char *username,
const char *password,
error_handler_t *error_handler)
{
#ifdef JUTI_NO_PAM
error_handler->error(MSG_AUTHUSER_PAM_NOT_AVAILABLE);
return JUTI_AUTH_ERROR;
#else
auth_result_t ret;
int status;
pam_handle_t *pamh; /* pam handle */
struct pam_conv pamconv; /* pam init structure */
struct app_pam_data app_data; /* pam application data */
pamh = NULL;
/*
* app_data gets passed through the framework
* to "login_conv". Set the password for use in login_conv
* and set up the pam_conv data with the conversation
* function and the application data pointer.
*/
app_data.password = password;
pamconv.conv = login_conv;
pamconv.appdata_ptr = &app_data;
/* pam start session */
status = pam_start(service, username, &pamconv, &pamh);
if(status != PAM_SUCCESS) {
ret = JUTI_AUTH_ERROR;
goto error;
}
status = pam_authenticate(pamh, PAM_SILENT);
if(status != PAM_SUCCESS) {
ret = JUTI_AUTH_FAILED;
goto error;
}
/* check if the authenicated user is allowed to use machine */
status = pam_acct_mgmt(pamh, PAM_SILENT);
if (status != PAM_SUCCESS) {
ret = JUTI_AUTH_FAILED;
goto error;
}
ret = JUTI_AUTH_SUCCESS;
error:
if (status != PAM_SUCCESS) {
const char *pam_err_msg = pam_strerror(pamh, status);
error_handler->error(MSG_AUTHUSER_PAM_ERROR_S, pam_err_msg);
}
/* end pam session */
if (pamh != NULL) {
pam_end(pamh, status == PAM_SUCCESS ? PAM_SUCCESS : PAM_ABORT);
}
return ret;
#endif
}
开发者ID:ricrogz,项目名称:gridscheduler,代码行数:58,代码来源:authuser.c
示例11: authenticate_user
int authenticate_user(const char *user, const char *pass)
{
pam_handle_t *pamh;
tAppdata appdata = {user, pass};
struct pam_conv pam_conv = {&pam_exchange, &appdata};
if ((pam_start (PAM_SERVICE_NAME, NULL, &pam_conv, &pamh) != PAM_SUCCESS) ||
(pam_authenticate (pamh,PAM_SILENT) != PAM_SUCCESS) ||
(pam_acct_mgmt (pamh,0) != PAM_SUCCESS) ||
(pam_setcred (pamh,PAM_ESTABLISH_CRED) != PAM_SUCCESS))
{
pam_end (pamh,PAM_AUTH_ERR);
return 0;
}
pam_end (pamh,PAM_SUCCESS);
return 1;
}
开发者ID:yavdr,项目名称:yavdr-webfrontend,代码行数:18,代码来源:auth.c
示例12: main
int
main(void)
{
pam_handle_t *pamh;
struct pam_args *args;
struct pam_conv conv = { NULL, NULL };
char *expected;
struct output *seen;
#ifdef HAVE_KRB5
krb5_error_code code;
krb5_principal princ;
#endif
plan(27);
if (pam_start("test", NULL, &conv, &pamh) != PAM_SUCCESS)
sysbail("Fake PAM initialization failed");
args = putil_args_new(pamh, 0);
if (args == NULL)
bail("cannot create PAM argument struct");
TEST(putil_crit, LOG_CRIT, "putil_crit");
TEST(putil_err, LOG_ERR, "putil_err");
putil_debug(args, "%s", "foo");
ok(pam_output() == NULL, "putil_debug without debug on");
args->debug = true;
TEST(putil_debug, LOG_DEBUG, "putil_debug");
args->debug = false;
TEST_PAM(putil_crit_pam, PAM_SYSTEM_ERR, LOG_CRIT, "putil_crit_pam S");
TEST_PAM(putil_crit_pam, PAM_BUF_ERR, LOG_CRIT, "putil_crit_pam B");
TEST_PAM(putil_crit_pam, PAM_SUCCESS, LOG_CRIT, "putil_crit_pam ok");
TEST_PAM(putil_err_pam, PAM_SYSTEM_ERR, LOG_ERR, "putil_err_pam");
putil_debug_pam(args, PAM_SYSTEM_ERR, "%s", "bar");
ok(pam_output() == NULL, "putil_debug_pam without debug on");
args->debug = true;
TEST_PAM(putil_debug_pam, PAM_SYSTEM_ERR, LOG_DEBUG, "putil_debug_pam");
TEST_PAM(putil_debug_pam, PAM_SUCCESS, LOG_DEBUG, "putil_debug_pam ok");
args->debug = false;
#ifdef HAVE_KRB5
TEST_KRB5(putil_crit_krb5, LOG_CRIT, "putil_crit_krb5");
TEST_KRB5(putil_err_krb5, LOG_ERR, "putil_err_krb5");
code = krb5_parse_name(args->ctx, "[email protected]@EXAMPLE.COM", &princ);
putil_debug_krb5(args, code, "%s", "krb");
ok(pam_output() == NULL, "putil_debug_krb5 without debug on");
args->debug = true;
TEST_KRB5(putil_debug_krb5, LOG_DEBUG, "putil_debug_krb5");
args->debug = false;
#else
skip_block(4, "not built with Kerberos support");
#endif
putil_args_free(args);
pam_end(pamh, 0);
return 0;
}
开发者ID:HenryJacques,项目名称:pam-krb5,代码行数:57,代码来源:logging-t.c
示例13: create_pamh
/* Creates a pam handle for the auto login */
static gboolean
create_pamh (MdmDisplay *d,
const char *service,
const char *login,
struct pam_conv *conv,
const char *display,
int *pamerr)
{
if (display == NULL) {
mdm_error ("Cannot setup pam handle with null display");
return FALSE;
}
if (pamh != NULL) {
mdm_error ("create_pamh: Stale pamh around, cleaning up");
pam_end (pamh, PAM_SUCCESS);
}
/* init things */
pamh = NULL;
opened_session = FALSE;
did_setcred = FALSE;
/* Initialize a PAM session for the user */
if ((*pamerr = pam_start (service, login, conv, &pamh)) != PAM_SUCCESS) {
pamh = NULL; /* be anal */
if (mdm_slave_action_pending ())
mdm_error ("Unable to establish service %s: %s\n", service, pam_strerror (NULL, *pamerr));
return FALSE;
}
/* Inform PAM of the user's tty */
if ((*pamerr = pam_set_item (pamh, PAM_TTY, display)) != PAM_SUCCESS) {
if (mdm_slave_action_pending ())
mdm_error ("Can't set PAM_TTY=%s", display);
return FALSE;
}
if ( ! d->attached) {
/* Only set RHOST if host is remote */
/* From the host of the display */
if ((*pamerr = pam_set_item (pamh, PAM_RHOST,
d->hostname)) != PAM_SUCCESS) {
if (mdm_slave_action_pending ())
mdm_error ("Can't set PAM_RHOST=%s", d->hostname);
return FALSE;
}
}
// Preselect the previous user
if (do_we_need_to_preset_the_username) {
do_we_need_to_preset_the_username = FALSE;
mdm_preselect_user(pamerr);
}
return TRUE;
}
开发者ID:ActusOS,项目名称:mdm,代码行数:58,代码来源:verify-pam.c
示例14: mdm_verify_cleanup
void
mdm_verify_cleanup (MdmDisplay *d)
{
gid_t groups[1] = { 0 };
cur_mdm_disp = d;
if (pamh != NULL) {
gint pamerr;
pam_handle_t *tmp_pamh;
gboolean old_opened_session;
gboolean old_did_setcred;
mdm_debug ("Running mdm_verify_cleanup and pamh != NULL");
mdm_sigterm_block_push ();
mdm_sigchld_block_push ();
tmp_pamh = pamh;
pamh = NULL;
old_opened_session = opened_session;
opened_session = FALSE;
old_did_setcred = did_setcred;
did_setcred = FALSE;
mdm_sigchld_block_pop ();
mdm_sigterm_block_pop ();
pamerr = PAM_SUCCESS;
/* Close the users session */
if (old_opened_session) {
mdm_debug ("Running pam_close_session");
pamerr = pam_close_session (tmp_pamh, 0);
}
/* Throw away the credentials */
if (old_did_setcred) {
mdm_debug ("Running pam_setcred with PAM_DELETE_CRED");
pamerr = pam_setcred (tmp_pamh, PAM_DELETE_CRED);
}
pam_end (tmp_pamh, pamerr);
/* Workaround to avoid mdm messages being logged as PAM_pwdb */
mdm_log_shutdown ();
mdm_log_init ();
}
/* Clear the group setup */
setgid (0);
/* this will get rid of any suplementary groups etc... */
setgroups (1, groups);
cur_mdm_disp = NULL;
/* reset limits */
mdm_reset_limits ();
}
开发者ID:ActusOS,项目名称:mdm,代码行数:56,代码来源:verify-pam.c
示例15: pam_stopSession
void XProcess::pam_shutdown(){
if(pam_session_open){
pam_stopSession();
pam_session_open = FALSE;
}
if(pam_started){
pam_end(pamh,0);
pam_started = FALSE;
}
}
开发者ID:KdeOs,项目名称:pcbsd,代码行数:10,代码来源:pcdm-xprocess.cpp
示例16: pam_end
void AuthHandle::destroy()
{
// only act on it if it was actually set (avoid issues with auth challenge)
if (0 != hdl)
{
pam_end((pam_handle_t*) hdl,0);
// Call to pam_end with value of hdl
hdl = 0;
}
}
开发者ID:brunolauze,项目名称:pegasus,代码行数:10,代码来源:AuthHandle.cpp
示例17: check_password
void check_password(void)
{
static struct pam_conv conv =
{
ulock_conv,
NULL
};
pam_handle_t *pamh;
char username[1 << 8];
username[0] = '\0';
strncat(username, getpwuid(getuid())->pw_name, (sizeof username) - 1);
pam_start("ulock", username, &conv, &pamh);
writes(STDOUT_FILENO, "The terminal is now locked. Please enter the password to unlock it.\n");
char *username2 = username;
for (int i = 0; ; i++)
{
int pam_error;
writes(STDOUT_FILENO, username2);
writes(STDOUT_FILENO, "'s password: ");
pam_error = pam_set_item(pamh, PAM_USER, username2);
if (pam_error != PAM_SUCCESS)
break;
pam_error = pam_fail_delay(pamh, FAIL_DELAY);
if (pam_error != PAM_SUCCESS)
break;
pam_error = pam_authenticate(pamh, 0);
if (pam_error == PAM_SUCCESS)
{
pam_end(pamh, PAM_SUCCESS);
return;
}
if (pam_error == PAM_ABORT)
break;
if (pam_error == PAM_MAXTRIES)
{
writes(STDOUT_FILENO, "Erm, one minute penalty...\n");
sleep(60);
}
username2 = (username2 == username) ? "root" : username;
}
pam_end(pamh, PAM_SUCCESS);
fatal("Something went *SERIOUSLY* wrong\n");
}
开发者ID:jwilk,项目名称:ulock,代码行数:43,代码来源:ulock.c
示例18: _pamtest_conv
enum pamtest_err _pamtest_conv(const char *service,
const char *user,
pam_conv_fn conv_fn,
void *conv_userdata,
struct pam_testcase test_cases[],
size_t num_test_cases)
{
int rv;
pam_handle_t *ph;
struct pam_conv conv;
size_t tcindex;
struct pam_testcase *tc = NULL;
bool call_pam_end = true;
conv.conv = conv_fn;
conv.appdata_ptr = conv_userdata;
if (test_cases == NULL) {
return PAMTEST_ERR_INTERNAL;
}
rv = pam_start(service, user, &conv, &ph);
if (rv != PAM_SUCCESS) {
return PAMTEST_ERR_START;
}
for (tcindex = 0; tcindex < num_test_cases; tcindex++) {
tc = &test_cases[tcindex];
rv = run_test_case(ph, tc);
if (rv == PAMTEST_ERR_KEEPHANDLE) {
call_pam_end = false;
continue;
} else if (rv != PAMTEST_ERR_OK) {
return PAMTEST_ERR_INTERNAL;
}
if (tc->op_rv != tc->expected_rv) {
break;
}
}
if (call_pam_end == true && tc != NULL) {
rv = pam_end(ph, tc->op_rv);
if (rv != PAM_SUCCESS) {
return PAMTEST_ERR_END;
}
}
if (tcindex < num_test_cases) {
return PAMTEST_ERR_CASE;
}
return PAMTEST_ERR_OK;
}
开发者ID:encukou,项目名称:samba,代码行数:55,代码来源:libpamtest.c
示例19: pam_start
bool PAMAuthenticator::authenticate(void)
{
pam_conv c;
c.conv = PAMAuthenticator::conv;
c.appdata_ptr = this;
int res = pam_start("repwatchproxy", 0, &c, &this->m_ph);
if (res == PAM_SUCCESS) {
res = pam_set_item(this->m_ph, PAM_RUSER, this->m_user.constData());
if (res != PAM_SUCCESS) {
goto getout;
}
res = pam_set_item(this->m_ph, PAM_RHOST, this->m_host.constData());
if (res != PAM_SUCCESS) {
goto getout;
}
res = pam_authenticate(this->m_ph, 0);
if (res != PAM_SUCCESS) {
goto getout;
}
res = pam_acct_mgmt(this->m_ph, 0);
if (PAM_NEW_AUTHTOK_REQD == res) {
res = pam_chauthtok(this->m_ph, PAM_CHANGE_EXPIRED_AUTHTOK);
}
if (res != PAM_SUCCESS) {
goto getout;
}
res = pam_setcred(this->m_ph, PAM_ESTABLISH_CRED);
if (res != PAM_SUCCESS) {
goto getout;
}
res = pam_open_session(this->m_ph, 0);
if (res != PAM_SUCCESS) {
goto getout;
}
return true;
getout:
qWarning("%s: %s", Q_FUNC_INFO, pam_strerror(this->m_ph, res));
pam_end(this->m_ph, res);
}
else {
qCritical("PAM initialization failed");
}
this->m_ph = 0;
return false;
}
开发者ID:sjinks,项目名称:repwatch_proxy,代码行数:55,代码来源:pamauthenticator.cpp
示例20: main
int main(int argc, char *argv[])
{
unsigned char lb[2];
unsigned char buf[BUFSIZ];
char *user;
char *pwd;
char *mode;
int sid;
int rval;
struct session *sessp;
// test clause
if (argc == 4 ) {
/* ./epam authmodule user passwd */
printf("testing service=%s u=%s pwd=%s\n", argv[1],argv[2], argv[3]);
do_auth(argv[1], argv[2], argv[3], "AS", 33);
exit(0);
}
wstart();
while (1) {
if (read_fill(0, lb, 2) != 2)
exit(1);
rval = get_int16(lb);
if (read_fill(0, buf, rval) != rval)
exit(1);
switch (buf[0]) {
case 'a':
// auth a user
user = (char *)&buf[1];
pwd = user + strlen(user) + 1;
mode= pwd + strlen(pwd) + 1;
sid = atoi(mode + strlen(mode) + 1);
do_auth(argv[1], user, pwd, mode, sid);
break;
case 'c':
// close session
sid = atoi((char *)&buf[1]);
if ((sessp = del_session(&sessions, sid)) == NULL) {
fprintf(stderr, "Couldn't find session %d\r\n", sid);
break;
}
if (sessp->session_mode == 1) {
pam_close_session(sessp->pamh, 0);
/*fprintf(stderr, "did ok close sess \n\r");*/
}
pam_end(sessp->pamh, PAM_SUCCESS);
free(sessp);
break;
default:
fprintf(stderr, "Bad op \n\r");
}
}
}
开发者ID:AugustoFernandes,项目名称:yaws,代码行数:54,代码来源:epam.c
注:本文中的pam_end函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论