Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37564244
en ru br
Репозитории ALT
S:0.17-alt5.1
4.1: 0.17-alt2
4.0: 0.17-ipl9mdk
3.0: 0.17-ipl9mdk
www.altlinux.org/Changes

Группа :: Сети/Удалённый доступ
Пакет: rsh

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: 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 = {
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin