[linux-pam] pam_succeed_if: Fix copy&paste error in rhost and tty values.
by Tomáš Mráz
commit 5df44a328abe4befc4479e16ce7fd86ff2caedcc
Author: Tomas Mraz <tmraz(a)fedoraproject.org>
Date: Fri Oct 17 08:39:58 2014 +0200
pam_succeed_if: Fix copy&paste error in rhost and tty values.
modules/pam_succeed_if/pam_succeed_if.c (evaluate): Use PAM_RHOST
and PAM_TTY properly for the rhost and tty values.
modules/pam_succeed_if/pam_succeed_if.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/modules/pam_succeed_if/pam_succeed_if.c b/modules/pam_succeed_if/pam_succeed_if.c
index 98a8474..aa828fc 100644
--- a/modules/pam_succeed_if/pam_succeed_if.c
+++ b/modules/pam_succeed_if/pam_succeed_if.c
@@ -298,7 +298,7 @@ evaluate(pam_handle_t *pamh, int debug,
}
if (strcasecmp(left, "rhost") == 0) {
const void *rhost;
- if (pam_get_item(pamh, PAM_SERVICE, &rhost) != PAM_SUCCESS ||
+ if (pam_get_item(pamh, PAM_RHOST, &rhost) != PAM_SUCCESS ||
rhost == NULL)
rhost = "";
snprintf(buf, sizeof(buf), "%s", (const char *)rhost);
@@ -306,7 +306,7 @@ evaluate(pam_handle_t *pamh, int debug,
}
if (strcasecmp(left, "tty") == 0) {
const void *tty;
- if (pam_get_item(pamh, PAM_SERVICE, &tty) != PAM_SUCCESS ||
+ if (pam_get_item(pamh, PAM_TTY, &tty) != PAM_SUCCESS ||
tty == NULL)
tty = "";
snprintf(buf, sizeof(buf), "%s", (const char *)tty);
9 years, 6 months
[linux-pam] pam_succeed_if: Use long long type for numeric values
by Tomáš Mráz
commit 3ad8ed87726d5c3a6a9f15a5c2dce2ce8aca06b6
Author: Tomas Mraz <tmraz(a)fedoraproject.org>
Date: Fri Oct 17 08:34:24 2014 +0200
pam_succeed_if: Use long long type for numeric values
The currently used long with additional conversion to int is
too small for uids and gids.
modules/pam_succeed_if/pam_succeed_if.c (evaluate_num): Replace
strtol() with strtoll() and int with long long in the parameters
of comparison functions.
modules/pam_succeed_if/pam_succeed_if.c | 20 ++++++++++----------
1 files changed, 10 insertions(+), 10 deletions(-)
---
diff --git a/modules/pam_succeed_if/pam_succeed_if.c b/modules/pam_succeed_if/pam_succeed_if.c
index 32a7373..98a8474 100644
--- a/modules/pam_succeed_if/pam_succeed_if.c
+++ b/modules/pam_succeed_if/pam_succeed_if.c
@@ -68,20 +68,20 @@
* PAM_SERVICE_ERR if the arguments can't be parsed as numbers. */
static int
evaluate_num(const pam_handle_t *pamh, const char *left,
- const char *right, int (*cmp)(int, int))
+ const char *right, int (*cmp)(long long, long long))
{
- long l, r;
+ long long l, r;
char *p;
int ret = PAM_SUCCESS;
errno = 0;
- l = strtol(left, &p, 0);
+ l = strtoll(left, &p, 0);
if ((p == NULL) || (*p != '\0') || errno) {
pam_syslog(pamh, LOG_INFO, "\"%s\" is not a number", left);
ret = PAM_SERVICE_ERR;
}
- r = strtol(right, &p, 0);
+ r = strtoll(right, &p, 0);
if ((p == NULL) || (*p != '\0') || errno) {
pam_syslog(pamh, LOG_INFO, "\"%s\" is not a number", right);
ret = PAM_SERVICE_ERR;
@@ -96,32 +96,32 @@ evaluate_num(const pam_handle_t *pamh, const char *left,
/* Simple numeric comparison callbacks. */
static int
-eq(int i, int j)
+eq(long long i, long long j)
{
return i == j;
}
static int
-ne(int i, int j)
+ne(long long i, long long j)
{
return i != j;
}
static int
-lt(int i, int j)
+lt(long long i, long long j)
{
return i < j;
}
static int
-le(int i, int j)
+le(long long i, long long j)
{
return lt(i, j) || eq(i, j);
}
static int
-gt(int i, int j)
+gt(long long i, long long j)
{
return i > j;
}
static int
-ge(int i, int j)
+ge(long long i, long long j)
{
return gt(i, j) || eq(i, j);
}
9 years, 6 months