[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Wed Sep 22 16:42:53 MDT 2010


The branch, master has been updated
       via  54f0da3 s3: Use asprintf where appropriate
       via  7ba5855 s3: Fix pam_smbpass logging on FreeBSD
      from  fe4576d s3-registry: fix some c++ build warnings.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 54f0da368f35ce7d7fd4b093b865ffea284d826b
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Sep 22 14:10:03 2010 +0200

    s3: Use asprintf where appropriate

commit 7ba5855a734037cf7308007b953ce0a92b050173
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Sep 21 21:16:31 2010 +0200

    s3: Fix pam_smbpass logging on FreeBSD

-----------------------------------------------------------------------

Summary of changes:
 source3/pam_smbpass/general.h        |    1 -
 source3/pam_smbpass/pam_smb_passwd.c |   17 ++++++-----------
 source3/pam_smbpass/support.c        |   19 +++++++------------
 3 files changed, 13 insertions(+), 24 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/pam_smbpass/general.h b/source3/pam_smbpass/general.h
index 4607620..f6b3e67 100644
--- a/source3/pam_smbpass/general.h
+++ b/source3/pam_smbpass/general.h
@@ -118,7 +118,6 @@ static const SMB_Ctrls smb_args[SMB_CTRLS_] = {
  * to authenticate themself.
  */
 
-#define FAIL_PREFIX			"-SMB-FAIL-"
 #define SMB_MAX_RETRIES			3
 
 struct _pam_failed_auth {
diff --git a/source3/pam_smbpass/pam_smb_passwd.c b/source3/pam_smbpass/pam_smb_passwd.c
index 473a55e..8fc2cf3 100644
--- a/source3/pam_smbpass/pam_smb_passwd.c
+++ b/source3/pam_smbpass/pam_smb_passwd.c
@@ -176,17 +176,12 @@ int pam_sm_chauthtok(pam_handle_t *pamh, int flags,
         if (getuid() != 0 && !(flags & PAM_CHANGE_EXPIRED_AUTHTOK)) {
 
             /* tell user what is happening */
-#define greeting "Changing password for "
-            Announce = SMB_MALLOC_ARRAY(char, sizeof(greeting)+strlen(user));
-            if (Announce == NULL) {
-                _log_err(pamh, LOG_CRIT, "password: out of memory");
-                TALLOC_FREE(sampass);
-                CatchSignal(SIGPIPE, oldsig_handler);
-                return PAM_BUF_ERR;
-            }
-            strncpy( Announce, greeting, sizeof(greeting) );
-            strncpy( Announce+sizeof(greeting)-1, user, strlen(user)+1 );
-#undef greeting
+		if (asprintf(&Announce, "Changing password for %s", user) == -1) {
+			_log_err(pamh, LOG_CRIT, "password: out of memory");
+			TALLOC_FREE(sampass);
+			CatchSignal(SIGPIPE, oldsig_handler);
+			return PAM_BUF_ERR;
+		}
 
             set( SMB__OLD_PASSWD, ctrl );
             retval = _smb_read_password( pamh, ctrl, Announce, "Current SMB password: ",
diff --git a/source3/pam_smbpass/support.c b/source3/pam_smbpass/support.c
index 715a0f4..79f92a8 100644
--- a/source3/pam_smbpass/support.c
+++ b/source3/pam_smbpass/support.c
@@ -93,22 +93,20 @@ void _log_err( pam_handle_t *pamh, int err, const char *format, ... )
 void _log_err( pam_handle_t *pamh, int err, const char *format, ... )
 {
 	va_list args;
-	const char tag[] = "(pam_smbpass) ";
 	char *mod_format;
 
-	mod_format = SMB_MALLOC_ARRAY(char, sizeof(tag) + strlen(format));
-	/* try really, really hard to log something, since this may have
-	   been a message about a malloc() failure... */
-	if (mod_format == NULL) {
+	if (asprintf(&mod_format, "(pam_smbpass) %s", format) == -1) {
+		/*
+		 * try really, really hard to log something, since
+		 * this may have been a message about a malloc()
+		 * failure...
+		 */
 		va_start(args, format);
 		vsyslog(err | LOG_AUTH, format, args);
 		va_end(args);
 		return;
 	}
 
-	strncpy(mod_format, tag, strlen(tag)+1);
-	strlcat(mod_format, format, strlen(format)+1);
-
 	va_start(args, format);
 	vsyslog(err | LOG_AUTH, mod_format, args);
 	va_end(args);
@@ -381,13 +379,10 @@ int _smb_verify_password( pam_handle_t * pamh, struct samu *sampass,
         }
     }
 
-    data_name = SMB_MALLOC_ARRAY(char, sizeof(FAIL_PREFIX) + strlen( name ));
-    if (data_name == NULL) {
+    if (asprintf(&data_name, "-SMB-FAIL- %s", name) == -1) {
         _log_err(pamh, LOG_CRIT, "no memory for data-name" );
         return PAM_AUTH_ERR;
     }
-    strncpy( data_name, FAIL_PREFIX, sizeof(FAIL_PREFIX) );
-    strncpy( data_name + sizeof(FAIL_PREFIX) - 1, name, strlen( name ) + 1 );
 
     /*
      * The password we were given wasn't an encrypted password, or it


-- 
Samba Shared Repository


More information about the samba-cvs mailing list