diff options
author | des <des@FreeBSD.org> | 2003-12-11 13:55:16 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2003-12-11 13:55:16 +0000 |
commit | 9c38a557979e384e5fc0e3b85507242bee98321f (patch) | |
tree | 79f074d7b6c050b037a9004caf920936f5c2abf9 /lib/libpam | |
parent | 0b146f01b2bf8034a394e4136235609dddda45bf (diff) | |
download | FreeBSD-src-9c38a557979e384e5fc0e3b85507242bee98321f.zip FreeBSD-src-9c38a557979e384e5fc0e3b85507242bee98321f.tar.gz |
Fix strict aliasing breakage in PAM modules (except pam_krb5, which needs
more work than the others). This should make most modules build with -O2.
Diffstat (limited to 'lib/libpam')
-rw-r--r-- | lib/libpam/modules/pam_echo/pam_echo.c | 5 | ||||
-rw-r--r-- | lib/libpam/modules/pam_group/pam_group.c | 5 | ||||
-rw-r--r-- | lib/libpam/modules/pam_lastlog/pam_lastlog.c | 15 | ||||
-rw-r--r-- | lib/libpam/modules/pam_login_access/pam_login_access.c | 10 | ||||
-rw-r--r-- | lib/libpam/modules/pam_opieaccess/pam_opieaccess.c | 8 | ||||
-rw-r--r-- | lib/libpam/modules/pam_radius/pam_radius.c | 6 | ||||
-rw-r--r-- | lib/libpam/modules/pam_rhosts/pam_rhosts.c | 7 | ||||
-rw-r--r-- | lib/libpam/modules/pam_securetty/pam_securetty.c | 7 | ||||
-rw-r--r-- | lib/libpam/modules/pam_unix/pam_unix.c | 23 |
9 files changed, 44 insertions, 42 deletions
diff --git a/lib/libpam/modules/pam_echo/pam_echo.c b/lib/libpam/modules/pam_echo/pam_echo.c index 48882f6..ff00859 100644 --- a/lib/libpam/modules/pam_echo/pam_echo.c +++ b/lib/libpam/modules/pam_echo/pam_echo.c @@ -48,7 +48,8 @@ _pam_echo(pam_handle_t *pamh, int flags, int argc, const char *argv[]) { char msg[PAM_MAX_MSG_SIZE]; - const char *str, *p, *q; + const void *str; + const char *p, *q; int err, i, item; size_t len; @@ -89,7 +90,7 @@ _pam_echo(pam_handle_t *pamh, int flags, } if (item == -1) continue; - err = pam_get_item(pamh, item, (const void **)&str); + err = pam_get_item(pamh, item, &str); if (err != PAM_SUCCESS) return (err); if (str == NULL) diff --git a/lib/libpam/modules/pam_group/pam_group.c b/lib/libpam/modules/pam_group/pam_group.c index 381f21b..a9d5fc3 100644 --- a/lib/libpam/modules/pam_group/pam_group.c +++ b/lib/libpam/modules/pam_group/pam_group.c @@ -56,7 +56,8 @@ PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh, int flags __unused, int argc __unused, const char *argv[] __unused) { - const char *group, *user, *ruser; + const char *group, *user; + const void *ruser; char *const *list; struct passwd *pwd; struct group *grp; @@ -69,7 +70,7 @@ pam_sm_authenticate(pam_handle_t *pamh, int flags __unused, return (PAM_IGNORE); /* get applicant */ - if (pam_get_item(pamh, PAM_RUSER, (const void **)&ruser) != PAM_SUCCESS + if (pam_get_item(pamh, PAM_RUSER, &ruser) != PAM_SUCCESS || ruser == NULL || (pwd = getpwnam(ruser)) == NULL) return (PAM_AUTH_ERR); diff --git a/lib/libpam/modules/pam_lastlog/pam_lastlog.c b/lib/libpam/modules/pam_lastlog/pam_lastlog.c index 200f489..9a1daf2 100644 --- a/lib/libpam/modules/pam_lastlog/pam_lastlog.c +++ b/lib/libpam/modules/pam_lastlog/pam_lastlog.c @@ -72,7 +72,8 @@ pam_sm_open_session(pam_handle_t *pamh, int flags, struct utmp utmp; struct lastlog ll; time_t t; - const char *rhost, *user, *tty; + const char *user; + const void *rhost, *tty; off_t llpos; int fd, pam_err; @@ -83,10 +84,10 @@ pam_sm_open_session(pam_handle_t *pamh, int flags, return (PAM_SERVICE_ERR); PAM_LOG("Got user: %s", user); - pam_err = pam_get_item(pamh, PAM_RHOST, (const void **)&rhost); + pam_err = pam_get_item(pamh, PAM_RHOST, &rhost); if (pam_err != PAM_SUCCESS) goto err; - pam_err = pam_get_item(pamh, PAM_TTY, (const void **)&tty); + pam_err = pam_get_item(pamh, PAM_TTY, &tty); if (pam_err != PAM_SUCCESS) goto err; if (tty == NULL) { @@ -94,8 +95,8 @@ pam_sm_open_session(pam_handle_t *pamh, int flags, goto err; } if (strncmp(tty, _PATH_DEV, strlen(_PATH_DEV)) == 0) - tty += strlen(_PATH_DEV); - if (*tty == '\0') + tty = (const char *)tty + strlen(_PATH_DEV); + if (*(const char *)tty == '\0') return (PAM_SERVICE_ERR); fd = open(_PATH_LASTLOG, O_RDWR|O_CREAT, 0644); @@ -129,7 +130,7 @@ pam_sm_open_session(pam_handle_t *pamh, int flags, /* note: does not need to be NUL-terminated */ strncpy(ll.ll_line, tty, sizeof(ll.ll_line)); - if (rhost != NULL && *rhost != '\0') + if (rhost != NULL && *(const char *)rhost != '\0') /* note: does not need to be NUL-terminated */ strncpy(ll.ll_host, rhost, sizeof(ll.ll_host)); @@ -145,7 +146,7 @@ pam_sm_open_session(pam_handle_t *pamh, int flags, utmp.ut_time = time(NULL); /* note: does not need to be NUL-terminated */ strncpy(utmp.ut_name, user, sizeof(utmp.ut_name)); - if (rhost != NULL && *rhost != '\0') + if (rhost != NULL && *(const char *)rhost != '\0') strncpy(utmp.ut_host, rhost, sizeof(utmp.ut_host)); (void)strncpy(utmp.ut_line, tty, sizeof(utmp.ut_line)); login(&utmp); diff --git a/lib/libpam/modules/pam_login_access/pam_login_access.c b/lib/libpam/modules/pam_login_access/pam_login_access.c index f41326b..05ffe94 100644 --- a/lib/libpam/modules/pam_login_access/pam_login_access.c +++ b/lib/libpam/modules/pam_login_access/pam_login_access.c @@ -56,11 +56,11 @@ PAM_EXTERN int pam_sm_acct_mgmt(pam_handle_t *pamh, int flags __unused, int argc __unused, const char *argv[] __unused) { - const char *rhost, *tty, *user; + const void *rhost, *tty, *user; char hostname[MAXHOSTNAMELEN]; int pam_err; - pam_err = pam_get_item(pamh, PAM_USER, (const void **)&user); + pam_err = pam_get_item(pamh, PAM_USER, &user); if (pam_err != PAM_SUCCESS) return (pam_err); @@ -69,17 +69,17 @@ pam_sm_acct_mgmt(pam_handle_t *pamh, int flags __unused, PAM_LOG("Got user: %s", user); - pam_err = pam_get_item(pamh, PAM_RHOST, (const void **)&rhost); + pam_err = pam_get_item(pamh, PAM_RHOST, &rhost); if (pam_err != PAM_SUCCESS) return (pam_err); - pam_err = pam_get_item(pamh, PAM_TTY, (const void **)&tty); + pam_err = pam_get_item(pamh, PAM_TTY, &tty); if (pam_err != PAM_SUCCESS) return (pam_err); gethostname(hostname, sizeof hostname); - if (rhost == NULL || *rhost == '\0') { + if (rhost == NULL || *(const char *)rhost == '\0') { PAM_LOG("Checking login.access for user %s on tty %s", user, tty); if (login_access(user, tty) != 0) diff --git a/lib/libpam/modules/pam_opieaccess/pam_opieaccess.c b/lib/libpam/modules/pam_opieaccess/pam_opieaccess.c index 61a97bf..5294080 100644 --- a/lib/libpam/modules/pam_opieaccess/pam_opieaccess.c +++ b/lib/libpam/modules/pam_opieaccess/pam_opieaccess.c @@ -57,10 +57,10 @@ pam_sm_authenticate(pam_handle_t *pamh, int flags __unused, { struct opie opie; struct passwd *pwent; - const char *luser, *rhost; + const void *luser, *rhost; int r; - r = pam_get_item(pamh, PAM_USER, (const void **)&luser); + r = pam_get_item(pamh, PAM_USER, &luser); if (r != PAM_SUCCESS) return (r); if (luser == NULL) @@ -70,10 +70,10 @@ pam_sm_authenticate(pam_handle_t *pamh, int flags __unused, if (pwent == NULL || opielookup(&opie, __DECONST(char *, luser)) != 0) return (PAM_SUCCESS); - r = pam_get_item(pamh, PAM_RHOST, (const void **)&rhost); + r = pam_get_item(pamh, PAM_RHOST, &rhost); if (r != PAM_SUCCESS) return (r); - if (rhost == NULL || *rhost == '\0') + if (rhost == NULL || *(const char *)rhost == '\0') rhost = openpam_get_option(pamh, "allow_local") ? "" : "localhost"; diff --git a/lib/libpam/modules/pam_radius/pam_radius.c b/lib/libpam/modules/pam_radius/pam_radius.c index cf81951..f6e1dc7 100644 --- a/lib/libpam/modules/pam_radius/pam_radius.c +++ b/lib/libpam/modules/pam_radius/pam_radius.c @@ -245,7 +245,8 @@ pam_sm_authenticate(pam_handle_t *pamh, int flags __unused, int argc __unused, const char *argv[] __unused) { struct rad_handle *radh; - const char *user, *tmpuser, *pass; + const char *user, *pass; + const void *tmpuser; const char *conf_file, *template_user, *nas_id, *nas_ipaddr; int retval; int e; @@ -310,8 +311,7 @@ pam_sm_authenticate(pam_handle_t *pamh, int flags __unused, * to the value given in the "template_user" * option. */ - retval = pam_get_item(pamh, PAM_USER, - (const void **)&tmpuser); + retval = pam_get_item(pamh, PAM_USER, &tmpuser); if (retval != PAM_SUCCESS) return (retval); if (getpwnam(tmpuser) == NULL) { diff --git a/lib/libpam/modules/pam_rhosts/pam_rhosts.c b/lib/libpam/modules/pam_rhosts/pam_rhosts.c index ab42224..4ba6ade 100644 --- a/lib/libpam/modules/pam_rhosts/pam_rhosts.c +++ b/lib/libpam/modules/pam_rhosts/pam_rhosts.c @@ -54,7 +54,8 @@ pam_sm_authenticate(pam_handle_t *pamh, int flags __unused, int argc __unused, const char *argv[] __unused) { struct passwd *pw; - const char *user, *ruser, *rhost; + const char *user; + const void *ruser, *rhost; int err, superuser; err = pam_get_user(pamh, &user, NULL); @@ -67,11 +68,11 @@ pam_sm_authenticate(pam_handle_t *pamh, int flags __unused, openpam_get_option(pamh, OPT_ALLOW_ROOT) == NULL) return (PAM_AUTH_ERR); - err = pam_get_item(pamh, PAM_RUSER, (const void **)&ruser); + err = pam_get_item(pamh, PAM_RUSER, &ruser); if (err != PAM_SUCCESS) return (PAM_AUTH_ERR); - err = pam_get_item(pamh, PAM_RHOST, (const void **)&rhost); + err = pam_get_item(pamh, PAM_RHOST, &rhost); if (err != PAM_SUCCESS) return (PAM_AUTH_ERR); diff --git a/lib/libpam/modules/pam_securetty/pam_securetty.c b/lib/libpam/modules/pam_securetty/pam_securetty.c index 5dd7c90..edb6f3b 100644 --- a/lib/libpam/modules/pam_securetty/pam_securetty.c +++ b/lib/libpam/modules/pam_securetty/pam_securetty.c @@ -57,7 +57,8 @@ pam_sm_acct_mgmt(pam_handle_t *pamh __unused, int flags __unused, { struct passwd *pwd; struct ttyent *ty; - const char *user, *tty; + const char *user; + const void *tty; int pam_err; pam_err = pam_get_user(pamh, &user, NULL); @@ -72,7 +73,7 @@ pam_sm_acct_mgmt(pam_handle_t *pamh __unused, int flags __unused, if (pwd->pw_uid != 0) return (PAM_SUCCESS); - pam_err = pam_get_item(pamh, PAM_TTY, (const void **)&tty); + pam_err = pam_get_item(pamh, PAM_TTY, &tty); if (pam_err != PAM_SUCCESS) return (pam_err); @@ -81,7 +82,7 @@ pam_sm_acct_mgmt(pam_handle_t *pamh __unused, int flags __unused, /* Ignore any "/dev/" on the PAM_TTY item */ if (tty != NULL && strncmp(TTY_PREFIX, tty, sizeof(TTY_PREFIX)) == 0) { PAM_LOG("WARNING: PAM_TTY starts with " TTY_PREFIX); - tty += sizeof(TTY_PREFIX) - 1; + tty = (const char *)tty + sizeof(TTY_PREFIX) - 1; } if (tty != NULL && (ty = getttynam(tty)) != NULL && diff --git a/lib/libpam/modules/pam_unix/pam_unix.c b/lib/libpam/modules/pam_unix/pam_unix.c index 705e3a4..26e4365 100644 --- a/lib/libpam/modules/pam_unix/pam_unix.c +++ b/lib/libpam/modules/pam_unix/pam_unix.c @@ -151,7 +151,8 @@ pam_sm_acct_mgmt(pam_handle_t *pamh, int flags __unused, login_cap_t *lc; time_t warntime; int retval; - const char *rhost, *tty, *user; + const char *user; + const void *rhost, *tty; char rhostip[MAXHOSTNAMELEN] = ""; retval = pam_get_user(pamh, &user, NULL); @@ -163,11 +164,11 @@ pam_sm_acct_mgmt(pam_handle_t *pamh, int flags __unused, PAM_LOG("Got user: %s", user); - retval = pam_get_item(pamh, PAM_RHOST, (const void **)&rhost); + retval = pam_get_item(pamh, PAM_RHOST, &rhost); if (retval != PAM_SUCCESS) return (retval); - retval = pam_get_item(pamh, PAM_TTY, (const void **)&tty); + retval = pam_get_item(pamh, PAM_TTY, &tty); if (retval != PAM_SUCCESS) return (retval); @@ -224,7 +225,7 @@ pam_sm_acct_mgmt(pam_handle_t *pamh, int flags __unused, * PAM_NEW_AUTHTOK_REQD. */ - if (rhost && *rhost) { + if (rhost && *(const char *)rhost != '\0') { memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; if (getaddrinfo(rhost, NULL, &hints, &res) == 0) { @@ -261,7 +262,7 @@ pam_sm_chauthtok(pam_handle_t *pamh, int flags, { #ifdef YP struct ypclnt *ypclnt; - const char *yp_domain, *yp_server; + const void *yp_domain, *yp_server; #endif char salt[SALTSIZE + 1]; login_cap_t * lc; @@ -297,10 +298,8 @@ pam_sm_chauthtok(pam_handle_t *pamh, int flags, (pwd->pw_fields & _PWF_SOURCE) == _PWF_NIS) { yp_domain = yp_server = NULL; - (void)pam_get_data(pamh, - "yp_domain", (const void **)&yp_domain); - (void)pam_get_data(pamh, - "yp_server", (const void **)&yp_server); + (void)pam_get_data(pamh, "yp_domain", &yp_domain); + (void)pam_get_data(pamh, "yp_server", &yp_server); ypclnt = ypclnt_new(yp_domain, "passwd.byname", yp_server); if (ypclnt == NULL) @@ -402,10 +401,8 @@ pam_sm_chauthtok(pam_handle_t *pamh, int flags, break; case _PWF_NIS: yp_domain = yp_server = NULL; - (void)pam_get_data(pamh, - "yp_domain", (const void **)&yp_domain); - (void)pam_get_data(pamh, - "yp_server", (const void **)&yp_server); + (void)pam_get_data(pamh, "yp_domain", &yp_domain); + (void)pam_get_data(pamh, "yp_server", &yp_server); ypclnt = ypclnt_new(yp_domain, "passwd.byname", yp_server); if (ypclnt == NULL) { |