rpms/rsh/devel netkit-rsh-0.17-pam-conv.patch, NONE, 1.1 rsh.spec, 1.20, 1.21

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Fri Oct 14 11:11:44 UTC 2005


Author: kzak

Update of /cvs/dist/rpms/rsh/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv5245

Modified Files:
	rsh.spec 
Added Files:
	netkit-rsh-0.17-pam-conv.patch 
Log Message:
fix ugly rexecd PAM_conv()

netkit-rsh-0.17-pam-conv.patch:
 rexecd.c |   86 ++++++++++++++++++++++++++++++++-------------------------------
 1 files changed, 45 insertions(+), 41 deletions(-)

--- NEW FILE netkit-rsh-0.17-pam-conv.patch ---
--- netkit-rsh-0.17/rexecd/rexecd.c.pam-conv	2005-10-13 18:42:54.000000000 +0200
+++ netkit-rsh-0.17/rexecd/rexecd.c	2005-10-13 18:45:30.000000000 +0200
@@ -178,47 +178,51 @@
 static char *PAM_username;
 static char *PAM_password;
 
-static int PAM_conv (int num_msg,
-		     const struct pam_message **msg,
-		     struct pam_response **resp,
-		     void *appdata_ptr) {
-  int count = 0, replies = 0;
-  struct pam_response *reply = NULL;
-  int size = sizeof(struct pam_response);
-
-  #define GET_MEM if (reply) realloc(reply, size); else reply = malloc(size); \
-  if (!reply) return PAM_CONV_ERR; \
-  size += sizeof(struct pam_response)
-  #define COPY_STRING(s) (s) ? strdup(s) : NULL
-
-  for (count = 0; count < num_msg; count++) {
-    GET_MEM;
-    switch (msg[count]->msg_style) {
-      case PAM_PROMPT_ECHO_ON:
-	reply[replies].resp_retcode = PAM_SUCCESS;
-	reply[replies++].resp = COPY_STRING(PAM_username);
-	  /* PAM frees resp */
-	break;
-      case PAM_PROMPT_ECHO_OFF:
-	reply[replies].resp_retcode = PAM_SUCCESS;
-	reply[replies++].resp = COPY_STRING(PAM_password);
-	  /* PAM frees resp */
-	break;
-      case PAM_TEXT_INFO:
-	reply[replies].resp_retcode = PAM_SUCCESS;
-	reply[replies++].resp = NULL;
-	/* ignore it... */
-	break;
-      case PAM_ERROR_MSG:
-	reply[replies].resp_retcode = PAM_SUCCESS;
-	reply[replies++].resp = NULL;
-	/* Must be an error of some sort... */
-      default:
-	return PAM_CONV_ERR;
-    }
-  }
-  if (reply) *resp = reply;
-  return PAM_SUCCESS;
+static int
+PAM_conv(int num_msg, const struct pam_message **msg, 
+		struct pam_response **response, void *appdata_ptr)
+{
+	struct pam_response *pr;
+	const struct pam_message *pm;
+	int n;
+
+	if ((*response = malloc(num_msg * sizeof(struct pam_response))) == NULL)
+		return(PAM_CONV_ERR);
+	memset(*response, 0, num_msg * sizeof(struct pam_response));
+
+	for (pr = *response, pm = *msg, n = num_msg; n--; pr++, pm++) 
+	{
+		switch (pm->msg_style) {
+		case PAM_PROMPT_ECHO_ON:
+			/* XXX: why not pam_set_item(PAM_RUSER) ? */
+			pr->resp_retcode = PAM_SUCCESS;
+			pr->resp = PAM_username ? strdup(PAM_username) : NULL;
+			/* PAM frees resp */
+			break;
+		case PAM_PROMPT_ECHO_OFF:
+			pr->resp_retcode = PAM_SUCCESS;
+			pr->resp = PAM_password ? strdup(PAM_password) : NULL;
+			/* PAM frees resp */
+			break;
+		case PAM_TEXT_INFO:
+		case PAM_ERROR_MSG:
+			/* ignore it... */
+			pr->resp_retcode = PAM_SUCCESS;
+			pr->resp = NULL;
+			break;
+		default:
+			/* Zero and free allocated memory and return an error. */
+			for (pr = *response, n = num_msg; n--; pr++) 
+			{
+				if (pr->resp)
+					free(pr->resp);
+			}
+			free(*response);
+			*response = NULL;
+			return(PAM_CONV_ERR);
+		}
+	}
+	return PAM_SUCCESS;
 }
 
 static struct pam_conv PAM_conversation = {


Index: rsh.spec
===================================================================
RCS file: /cvs/dist/rpms/rsh/devel/rsh.spec,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- rsh.spec	13 Oct 2005 14:11:10 -0000	1.20
+++ rsh.spec	14 Oct 2005 11:11:39 -0000	1.21
@@ -1,7 +1,7 @@
 Summary: Clients for remote access commands (rsh, rlogin, rcp).
 Name: rsh
 Version: 0.17
-Release: 30
+Release: 31
 License: BSD
 Group: Applications/Internet
 
@@ -43,6 +43,7 @@
 Patch23: netkit-rsh-0.17-nohost.patch
 Patch24: netkit-rsh-0.17-ignchld.patch
 Patch25: netkit-rsh-0.17-checkdir.patch
+Patch26: netkit-rsh-0.17-pam-conv.patch
 
 %description
 The rsh package contains a set of programs which allow users to run
@@ -100,6 +101,7 @@
 %patch23 -p1 -b .nohost
 %patch24 -p1 -b .ignchld
 %patch25 -p1 -b .checkdir
+%patch26 -p1 -b .pam-conv
 
 
 # No, I don't know what this is doing in the tarball.
@@ -169,6 +171,9 @@
 %{_mandir}/man8/*.8*
 
 %changelog
+* Thu Oct 13 2005 Karel Zak <kzak at redhat.com> 0.17-31
+- rewrite rexecd PAM_conversation()
+
 * Thu Oct 13 2005 Karel Zak <kzak at redhat.com> 0.17-30
 - replace pam_stack with "include"
 




More information about the fedora-cvs-commits mailing list