summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2010-08-22 20:00:46 +0200
committerVolker Lendecke <vl@samba.org>2010-08-22 22:42:21 +0200
commit8531921e3d4bba30ed6d10bf671b0b70d2f4f3f7 (patch)
tree5f684527812a1d76d6a87f16827faa364758e39a
parent177e394f93278407557702d9f53bae65fd5fc434 (diff)
downloadsamba-8531921e3d4bba30ed6d10bf671b0b70d2f4f3f7.tar.gz
samba-8531921e3d4bba30ed6d10bf671b0b70d2f4f3f7.tar.bz2
samba-8531921e3d4bba30ed6d10bf671b0b70d2f4f3f7.zip
s3: Turn two macros into functions
-rw-r--r--source3/auth/pampass.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/source3/auth/pampass.c b/source3/auth/pampass.c
index 69a746747a..f2e30b2c63 100644
--- a/source3/auth/pampass.c
+++ b/source3/auth/pampass.c
@@ -62,8 +62,22 @@ typedef int (*smb_pam_conv_fn)(int, const struct pam_message **, struct pam_resp
/*
* Macros to help make life easy
*/
-#define COPY_STRING(s) (s) ? SMB_STRDUP(s) : NULL
-#define COPY_FSTRING(s) (s[0]) ? SMB_STRDUP(s) : NULL
+
+static char *smb_pam_copy_string(const char *s)
+{
+ if (s == NULL) {
+ return NULL;
+ }
+ return SMB_STRDUP(s);
+}
+
+static char *smb_pam_copy_fstring(const char *s)
+{
+ if (s[0] == '\0') {
+ return NULL;
+ }
+ return SMB_STRDUP(s);
+}
/*******************************************************************
PAM error handler.
@@ -143,13 +157,15 @@ static int smb_pam_conv(int num_msg,
switch (msg[replies]->msg_style) {
case PAM_PROMPT_ECHO_ON:
reply[replies].resp_retcode = PAM_SUCCESS;
- reply[replies].resp = COPY_STRING(udp->PAM_username);
+ reply[replies].resp = smb_pam_copy_string(
+ udp->PAM_username);
/* PAM frees resp */
break;
case PAM_PROMPT_ECHO_OFF:
reply[replies].resp_retcode = PAM_SUCCESS;
- reply[replies].resp = COPY_STRING(udp->PAM_password);
+ reply[replies].resp = smb_pam_copy_string(
+ udp->PAM_password);
/* PAM frees resp */
break;
@@ -327,7 +343,8 @@ static int smb_pam_passchange_conv(int num_msg,
DEBUG(100,("smb_pam_passchange_conv: PAM_PROMPT_ECHO_ON: We actualy sent: %s\n", current_reply));
#endif
reply[replies].resp_retcode = PAM_SUCCESS;
- reply[replies].resp = COPY_FSTRING(current_reply);
+ reply[replies].resp = smb_pam_copy_fstring(
+ current_reply);
found = True;
break;
}
@@ -355,7 +372,8 @@ static int smb_pam_passchange_conv(int num_msg,
DEBUG(10,("smb_pam_passchange_conv: PAM_PROMPT_ECHO_OFF: We sent: %s\n", current_reply));
pwd_sub(current_reply, udp->PAM_username, udp->PAM_password, udp->PAM_newpassword);
reply[replies].resp_retcode = PAM_SUCCESS;
- reply[replies].resp = COPY_FSTRING(current_reply);
+ reply[replies].resp = smb_pam_copy_fstring(
+ current_reply);
#ifdef DEBUG_PASSWORD
DEBUG(100,("smb_pam_passchange_conv: PAM_PROMPT_ECHO_OFF: We actualy sent: %s\n", current_reply));
#endif