$OpenBSD: patch-capplets_about-me_mate-about-me-password_c,v 1.2 2021/08/29 16:38:39 robert Exp $

Index: capplets/about-me/mate-about-me-password.c
--- capplets/about-me/mate-about-me-password.c.orig
+++ capplets/about-me/mate-about-me-password.c
@@ -156,10 +156,26 @@ passdlg_refresh_password_state (PasswordDialog *pdialo
 static void
 child_watch_cb (GPid pid, gint status, PasswordDialog *pdialog)
 {
+#if defined(__OpenBSD__)
+	gchar		*msg = NULL;		/* Status error message */
+#endif
+
 	if (WIFEXITED (status)) {
 		if (WEXITSTATUS (status) >= 255) {
 			g_warning (_("Child exited unexpectedly"));
 		}
+#if defined(__OpenBSD__)
+		if (pdialog->authenticated) {
+			passdlg_set_busy (pdialog, FALSE);
+			passdlg_clear (pdialog);
+			/* On success, OpenBSD passwd(1)'s exit status is 0. */
+			if (WEXITSTATUS (status) != 0) {
+				msg = g_strdup_printf (_("Unknown system error"));
+				passdlg_set_status (pdialog, msg);
+				g_free (msg);
+			}
+		}
+#endif
 	}
 
 	free_passwd_resources (pdialog);
@@ -190,7 +206,11 @@ spawn_passwd (PasswordDialog *pdialog, GError **error)
 								   argv,						/* Argument vector */
 								   envp,						/* Environment */
 								   G_SPAWN_DO_NOT_REAP_CHILD,	/* Flags */
+#if defined(__OpenBSD__)
+								   (void *)setsid,					/* Child setup */
+#else
 								   NULL,						/* Child setup */
+#endif
 								   NULL,						/* Data to child setup */
 								   &pdialog->backend_pid,		/* PID */
 								   &my_stdin,						/* Stdin */
@@ -452,11 +472,11 @@ io_watch_stdout (GIOChannel *source, GIOCondition cond
 		case PASSWD_STATE_AUTH:
 			/* Passwd is asking for our current password */
 
-			if (is_string_complete (str->str, "assword: ", "failure", "wrong", "error", NULL)) {
+			if (is_string_complete (str->str, "assword:", "failure", "wrong", "error", "denied", NULL)) {
 				/* Which response did we get? */
 				passdlg_set_busy (pdialog, FALSE);
 
-				if (g_strrstr (str->str, "assword: ") != NULL) {
+				if (g_strrstr (str->str, "assword:") != NULL) {
 					/* Authentication successful */
 
 					authenticated_user (pdialog);
@@ -486,7 +506,7 @@ io_watch_stdout (GIOChannel *source, GIOCondition cond
 		case PASSWD_STATE_NEW:
 			/* Passwd is asking for our new password */
 
-			if (is_string_complete (str->str, "assword: ", NULL)) {
+			if (is_string_complete (str->str, "assword:", NULL)) {
 				/* Advance to next state */
 				pdialog->backend_state = PASSWD_STATE_RETYPE;
 
@@ -515,6 +535,7 @@ io_watch_stdout (GIOChannel *source, GIOCondition cond
 							  "match",
 							  "1 numeric or special",
 							  "failure",
+							  "another",
 							  NULL)) {
 
 				/* What response did we get? */
@@ -531,7 +552,8 @@ io_watch_stdout (GIOChannel *source, GIOCondition cond
 					/* Focus new password */
 					gtk_widget_grab_focus (GTK_WIDGET (pdialog->new_password));
 
-					if (g_strrstr (str->str, "recovered") != NULL) {
+					if (g_strrstr (str->str, "recovered") != NULL ||
+					    g_strrstr (str->str, "another") != NULL) {
 						/* What does this indicate?
 						 * "Authentication information cannot be recovered?" from libpam? */
 						msg = g_strdup_printf (_("System error: %s."), str->str);
@@ -582,7 +604,7 @@ io_watch_stdout (GIOChannel *source, GIOCondition cond
 			break;
 		case PASSWD_STATE_NONE:
 			/* Passwd is not asking for anything yet */
-			if (is_string_complete (str->str, "assword: ", NULL)) {
+			if (is_string_complete (str->str, "assword:", NULL)) {
 
 				/* If the user does not have a password set,
 				 * passwd will immediately ask for the new password,
