Reduce the scidi specific code to bare minimum

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@400 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
aet 2002-03-26 23:06:47 +00:00
parent 2d017e7f02
commit 86a47efdec
2 changed files with 14 additions and 136 deletions

View File

@ -374,72 +374,6 @@ void p15_eid_deinit(void)
ctx = NULL;
}
int p15_eid_open_session(int argc, const char **argv, const char *user)
{
struct passwd *userstr = NULL;
#ifdef PCSCLITE_SERVER_PATH
uid_t useruid = 65534, uid = 65534;
gid_t gid = 65534;
int r;
#endif
if (!user) {
scam_fw_p15_eid.printmsg("No user.\n");
return SCAM_FAILED;
}
userstr = getpwnam(user);
if (!userstr) {
scam_fw_p15_eid.printmsg("Can't get user structure. (%s)", user);
return SCAM_FAILED;
}
#ifdef PCSCLITE_SERVER_PATH
useruid = userstr->pw_uid;
r = GetIdentity(&uid, &gid);
if (r < 0) {
scam_fw_p15_eid.logmsg("Could not get uid/gid for pcscd.\n");
return SCAM_FAILED;
}
r = chown(PCSCLITE_SERVER_PATH, useruid, gid);
if (r < 0) {
scam_fw_p15_eid.printmsg("Opening session failed, cannot chown socket to user %.", user);
return SCAM_FAILED;
}
#endif
return SCAM_SUCCESS;
}
int p15_eid_close_session(int argc, const char **argv, const char *user)
{
#ifdef PCSCLITE_SERVER_PATH
uid_t uid = 65534;
gid_t gid = 65534;
int r;
#endif
if (!user) {
scam_fw_p15_eid.printmsg("No user.\n");
return SCAM_FAILED;
}
#ifdef PCSCLITE_SERVER_PATH
r = GetIdentity(&uid, &gid);
if (r < 0) {
scam_fw_p15_eid.logmsg("Could not get uid/gid for pcscd.\n");
return SCAM_FAILED;
}
r = chown(PCSCLITE_SERVER_PATH, uid, gid);
if (r < 0) {
scam_fw_p15_eid.printmsg("Closing session failed, cannot chown socket to smartcard user.");
return SCAM_SUCCESS;
}
r = CleanupClientSockets();
if (r == -1) {
scam_fw_p15_eid.logmsg("CleanupClientSockets failed.\n");
return SCAM_FAILED;
}
#endif
return SCAM_SUCCESS;
}
#ifdef ATR_SUPPORT
static const char *p15_eid_atrs[] =
{
@ -463,8 +397,13 @@ struct scam_framework_ops scam_fw_p15_eid =
p15_eid_qualify, /* qualify */
p15_eid_auth, /* auth */
p15_eid_deinit, /* deinit */
p15_eid_open_session, /* open_session */
p15_eid_close_session /* close_session */
#ifndef HAVE_SCIDI
NULL, /* open_session */
NULL /* close_session */
#else
sp_open_session, /* open_session */
sp_close_session /* close_session */
#endif
};
#endif

View File

@ -314,72 +314,6 @@ void p15_ldap_deinit(void)
ctx = NULL;
}
int p15_ldap_open_session(int argc, const char **argv, const char *user)
{
struct passwd *userstr = NULL;
#ifdef PCSCLITE_SERVER_PATH
uid_t useruid = 65534, uid = 65534;
gid_t gid = 65534;
int r;
#endif
if (!user) {
scam_fw_p15_ldap.printmsg("No user.\n");
return SCAM_FAILED;
}
userstr = getpwnam(user);
if (!userstr) {
scam_fw_p15_ldap.printmsg("Can't get user structure. (%s)", user);
return SCAM_FAILED;
}
#ifdef PCSCLITE_SERVER_PATH
useruid = userstr->pw_uid;
r = GetIdentity(&uid, &gid);
if (r < 0) {
scam_fw_p15_ldap.logmsg("Could not get uid/gid for pcscd.\n");
return SCAM_FAILED;
}
r = chown(PCSCLITE_SERVER_PATH, useruid, gid);
if (r < 0) {
scam_fw_p15_ldap.printmsg("Opening session failed, cannot chown socket to user %.", user);
return SCAM_FAILED;
}
#endif
return SCAM_SUCCESS;
}
int p15_ldap_close_session(int argc, const char **argv, const char *user)
{
#ifdef PCSCLITE_SERVER_PATH
uid_t uid = 65534;
gid_t gid = 65534;
int r;
#endif
if (!user) {
scam_fw_p15_ldap.printmsg("No user.\n");
return SCAM_FAILED;
}
#ifdef PCSCLITE_SERVER_PATH
r = GetIdentity(&uid, &gid);
if (r < 0) {
scam_fw_p15_ldap.logmsg("Could not get uid/gid for pcscd.\n");
return SCAM_FAILED;
}
r = chown(PCSCLITE_SERVER_PATH, uid, gid);
if (r < 0) {
scam_fw_p15_ldap.printmsg("Closing session failed, cannot chown socket to smartcard user.");
return SCAM_SUCCESS;
}
r = CleanupClientSockets();
if (r == -1) {
scam_fw_p15_ldap.logmsg("CleanupClientSockets failed.\n");
return SCAM_FAILED;
}
#endif
return SCAM_SUCCESS;
}
#ifdef ATR_SUPPORT
static const char *p15_ldap_atrs[] =
{
@ -403,8 +337,13 @@ struct scam_framework_ops scam_fw_p15_ldap =
p15_ldap_qualify, /* qualify */
p15_ldap_auth, /* auth */
p15_ldap_deinit, /* deinit */
p15_ldap_open_session, /* open_session */
p15_ldap_close_session /* close_session */
#ifndef HAVE_SCIDI
NULL, /* open_session */
NULL /* close_session */
#else
sp_open_session, /* open_session */
sp_close_session /* close_session */
#endif
};
#endif