diff --git a/libpam/pam_modutil_searchkey.c b/libpam/pam_modutil_searchkey.c
index 4e56597..ba023e5 100644
--- a/libpam/pam_modutil_searchkey.c
+++ b/libpam/pam_modutil_searchkey.c
@@ -113,7 +113,7 @@ pam_modutil_search_key(pam_handle_t *pamh UNUSED,
 			while (isspace((int)*cp) || *cp == '=')
 				++cp;
 		else
-			cp = "";
+			cp = buf + n;   /* empty string */
 
 		if (strcasecmp(tmp, key) == 0) {
 			retval = strdup(cp);
diff --git a/modules/pam_env/pam_env.c b/modules/pam_env/pam_env.c
index 3846e35..0cc955f 100644
--- a/modules/pam_env/pam_env.c
+++ b/modules/pam_env/pam_env.c
@@ -699,7 +699,7 @@ static const char * _pam_get_item_byname(pam_handle_t *pamh, const char *name)
 
   if (itemval && (strcmp(name, "HOME") == 0 || strcmp(name, "SHELL") == 0)) {
     struct passwd *user_entry;
-    user_entry = pam_modutil_getpwnam (pamh, (char *) itemval);
+    user_entry = pam_modutil_getpwnam (pamh, itemval);
     if (!user_entry) {
       pam_syslog(pamh, LOG_ERR, "No such user!?");
       return NULL;
diff --git a/modules/pam_filter/pam_filter.c b/modules/pam_filter/pam_filter.c
index de8c35a..314a97a 100644
--- a/modules/pam_filter/pam_filter.c
+++ b/modules/pam_filter/pam_filter.c
@@ -253,7 +253,7 @@ static void free_evp(char *evp[])
 
 static int
 set_filter (pam_handle_t *pamh, int flags UNUSED, int ctrl,
-	    const char **evp, const char *filtername)
+	    char * const evp[], const char *filtername)
 {
     int status=-1;
     char* terminal = NULL;
@@ -632,8 +632,7 @@ static int need_a_filter(pam_handle_t *pamh
     }
 
     if (retval == PAM_SUCCESS && (ctrl & which_run)) {
-	retval = set_filter(pamh, flags, ctrl
-			    , (const char **)evp, filterfile);
+	retval = set_filter(pamh, flags, ctrl, evp, filterfile);
     }
 
     if (retval == PAM_SUCCESS
diff --git a/modules/pam_mkhomedir/Makefile.am b/modules/pam_mkhomedir/Makefile.am
index e0be030..1f0ecb5 100644
--- a/modules/pam_mkhomedir/Makefile.am
+++ b/modules/pam_mkhomedir/Makefile.am
@@ -23,6 +23,7 @@ AM_CFLAGS = -I$(top_srcdir)/libpam/include -I$(top_srcdir)/libpamc/include \
 securelib_LTLIBRARIES = pam_mkhomedir.la
 pam_mkhomedir_la_SOURCES = pam_mkhomedir.c
 pam_mkhomedir_la_LIBADD = $(top_builddir)/libpam/libpam.la
+pam_mkhomedir_la_CFLAGS = $(AM_CFLAGS) -Wno-cast-qual
 pam_mkhomedir_la_LDFLAGS = -no-undefined -avoid-version -module
 if HAVE_VERSIONING
   pam_mkhomedir_la_LDFLAGS += -Wl,--version-script=$(srcdir)/../modules.map
diff --git a/modules/pam_mkhomedir/pam_mkhomedir.c b/modules/pam_mkhomedir/pam_mkhomedir.c
index 84c922f..aec1e7e 100644
--- a/modules/pam_mkhomedir/pam_mkhomedir.c
+++ b/modules/pam_mkhomedir/pam_mkhomedir.c
@@ -143,7 +143,7 @@ create_homedir (pam_handle_t *pamh, options_t *opt,
 	args[2] = opt->umask;
 	args[3] = opt->skeldir;
 
-	execve(MKHOMEDIR_HELPER, (char *const *) args, envp);
+	execve(MKHOMEDIR_HELPER, (char **)args, envp);
 
 	/* should not get here: exit with error */
 	D(("helper binary is not available"));
diff --git a/modules/pam_namespace/Makefile.am b/modules/pam_namespace/Makefile.am
index d69ca08..3cfc728 100644
--- a/modules/pam_namespace/Makefile.am
+++ b/modules/pam_namespace/Makefile.am
@@ -35,6 +35,7 @@ if HAVE_UNSHARE
   securelib_LTLIBRARIES = pam_namespace.la
   pam_namespace_la_SOURCES = pam_namespace.c md5.c argv_parse.c
   pam_namespace_la_LIBADD = $(top_builddir)/libpam/libpam.la @LIBSELINUX@
+  pam_namespace_la_CFLAGS = $(AM_CFLAGS) -Wno-cast-qual
 
   secureconf_DATA = namespace.conf
   secureconf_SCRIPTS = namespace.init
diff --git a/modules/pam_namespace/pam_namespace.c b/modules/pam_namespace/pam_namespace.c
index 660c7a1..8806a85 100644
--- a/modules/pam_namespace/pam_namespace.c
+++ b/modules/pam_namespace/pam_namespace.c
@@ -2177,7 +2177,7 @@ int pam_sm_close_session(pam_handle_t *pamh, int flags UNUSED,
 {
     int i, retval;
     struct instance_data idata;
-    void *polyptr;
+    const void *polyptr;
 
     /* init instance data */
     idata.flags = 0;
@@ -2225,12 +2225,12 @@ int pam_sm_close_session(pam_handle_t *pamh, int flags UNUSED,
     if (retval != PAM_SUCCESS)
 	return retval;
 
-    retval = pam_get_data(idata.pamh, NAMESPACE_POLYDIR_DATA, (const void **)&polyptr);
+    retval = pam_get_data(idata.pamh, NAMESPACE_POLYDIR_DATA, &polyptr);
     if (retval != PAM_SUCCESS || polyptr == NULL)
 	/* nothing to reset */
 	return PAM_SUCCESS;
 
-    idata.polydirs_ptr = polyptr;
+    idata.polydirs_ptr = (void *)polyptr;
 
     if (idata.flags & PAMNS_DEBUG)
         pam_syslog(idata.pamh, LOG_DEBUG, "Resetting namespace for pid %d",
diff --git a/modules/pam_tally2/pam_tally2.c b/modules/pam_tally2/pam_tally2.c
index ce7f5ae..48282a3 100644
--- a/modules/pam_tally2/pam_tally2.c
+++ b/modules/pam_tally2/pam_tally2.c
@@ -893,7 +893,7 @@ static void
 print_one(const struct tallylog *tally, uid_t uid)
 {
    static int once;
-   char *cp = "[UNKNOWN]";
+   const char *cp = "[UNKNOWN]";
    time_t fail_time;
    struct tm *tm;
    struct passwd *pwent;
diff --git a/modules/pam_tty_audit/Makefile.am b/modules/pam_tty_audit/Makefile.am
index ef5ac80..cf1481a 100644
--- a/modules/pam_tty_audit/Makefile.am
+++ b/modules/pam_tty_audit/Makefile.am
@@ -23,6 +23,7 @@ if HAVE_VERSIONING
 endif
 
 if HAVE_AUDIT_TTY_STATUS
+  pam_tty_audit_la_CFLAGS = $(AM_CFLAGS) -Wno-cast-qual
   pam_tty_audit_la_LIBADD = $(top_builddir)/libpam/libpam.la
   securelib_LTLIBRARIES = pam_tty_audit.la
 endif
diff --git a/modules/pam_unix/Makefile.am b/modules/pam_unix/Makefile.am
index 3b0f528..e000458 100644
--- a/modules/pam_unix/Makefile.am
+++ b/modules/pam_unix/Makefile.am
@@ -19,7 +19,7 @@ secureconfdir = $(SCONFIGDIR)
 AM_CFLAGS = -I$(top_srcdir)/libpam/include -I$(top_srcdir)/libpamc/include \
 	-DCHKPWD_HELPER=\"$(sbindir)/unix_chkpwd\" \
 	-DUPDATE_HELPER=\"$(sbindir)/unix_update\" \
-	@TIRPC_CFLAGS@ @NSL_CFLAGS@ $(WARN_CFLAGS)
+	@TIRPC_CFLAGS@ @NSL_CFLAGS@ $(WARN_CFLAGS) -Wno-cast-qual
 
 if HAVE_LIBSELINUX
   AM_CFLAGS += -D"WITH_SELINUX"
diff --git a/modules/pam_xauth/Makefile.am b/modules/pam_xauth/Makefile.am
index 0691504..4510d58 100644
--- a/modules/pam_xauth/Makefile.am
+++ b/modules/pam_xauth/Makefile.am
@@ -24,6 +24,7 @@ endif
 
 securelib_LTLIBRARIES = pam_xauth.la
 pam_xauth_la_LIBADD = $(top_builddir)/libpam/libpam.la @LIBSELINUX@
+pam_xauth_la_CFLAGS = $(AM_CFLAGS) -Wno-cast-qual
 
 if ENABLE_REGENERATE_MAN
 noinst_DATA = README
