In pam_*env(3), set errno as the corresponding POSIX functions would.
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@914 185d5e19-27fe-0310-9dcf-9bff6b9f3609
This commit is contained in:
parent
e936857588
commit
c5a320988e
4 changed files with 14 additions and 3 deletions
|
@ -39,6 +39,7 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <security/pam_appl.h>
|
#include <security/pam_appl.h>
|
||||||
|
@ -63,6 +64,7 @@ openpam_findenv(pam_handle_t *pamh,
|
||||||
if (strncmp(pamh->env[i], name, len) == 0 &&
|
if (strncmp(pamh->env[i], name, len) == 0 &&
|
||||||
pamh->env[i][len] == '=')
|
pamh->env[i][len] == '=')
|
||||||
RETURNN(i);
|
RETURNN(i);
|
||||||
|
errno = ENOENT;
|
||||||
RETURNN(-1);
|
RETURNN(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -61,8 +62,10 @@ pam_getenv(pam_handle_t *pamh,
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
ENTERS(name);
|
ENTERS(name);
|
||||||
if (strchr(name, '=') != NULL)
|
if (strchr(name, '=') != NULL) {
|
||||||
|
errno = EINVAL;
|
||||||
RETURNS(NULL);
|
RETURNS(NULL);
|
||||||
|
}
|
||||||
if ((i = openpam_findenv(pamh, name, strlen(name))) < 0)
|
if ((i = openpam_findenv(pamh, name, strlen(name))) < 0)
|
||||||
RETURNS(NULL);
|
RETURNS(NULL);
|
||||||
if ((str = strchr(pamh->env[i], '=')) == NULL)
|
if ((str = strchr(pamh->env[i], '=')) == NULL)
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -64,8 +65,10 @@ pam_putenv(pam_handle_t *pamh,
|
||||||
ENTER();
|
ENTER();
|
||||||
|
|
||||||
/* sanity checks */
|
/* sanity checks */
|
||||||
if ((p = strchr(namevalue, '=')) == NULL)
|
if ((p = strchr(namevalue, '=')) == NULL) {
|
||||||
|
errno = EINVAL;
|
||||||
RETURNC(PAM_SYSTEM_ERR);
|
RETURNC(PAM_SYSTEM_ERR);
|
||||||
|
}
|
||||||
|
|
||||||
/* see if the variable is already in the environment */
|
/* see if the variable is already in the environment */
|
||||||
if ((i = openpam_findenv(pamh, namevalue, p - namevalue)) >= 0) {
|
if ((i = openpam_findenv(pamh, namevalue, p - namevalue)) >= 0) {
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -67,8 +68,10 @@ pam_setenv(pam_handle_t *pamh,
|
||||||
ENTER();
|
ENTER();
|
||||||
|
|
||||||
/* sanity checks */
|
/* sanity checks */
|
||||||
if (*name == '\0' || strchr(name, '=') != NULL)
|
if (*name == '\0' || strchr(name, '=') != NULL) {
|
||||||
|
errno = EINVAL;
|
||||||
RETURNC(PAM_SYSTEM_ERR);
|
RETURNC(PAM_SYSTEM_ERR);
|
||||||
|
}
|
||||||
|
|
||||||
/* is it already there? */
|
/* is it already there? */
|
||||||
if (!overwrite && openpam_findenv(pamh, name, strlen(name)) >= 0)
|
if (!overwrite && openpam_findenv(pamh, name, strlen(name)) >= 0)
|
||||||
|
|
Loading…
Reference in a new issue