---
 src/user.c |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

Index: accountsservice-0.6.35/src/user.c
===================================================================
--- accountsservice-0.6.35.orig/src/user.c	2013-11-13 15:16:46.892125154 +0100
+++ accountsservice-0.6.35/src/user.c	2013-11-13 15:16:46.888125154 +0100
@@ -1824,6 +1824,21 @@
                                 return;
                         }
 
+                        if (mode == PASSWORD_MODE_NONE) {
+                                argv[0] = "/usr/bin/gpasswd";
+                                argv[1] = "-a";
+                                argv[2] = user->user_name;
+                                argv[3] = "nopasswdlogin";
+                                argv[4] = NULL;
+
+                                error = NULL;
+                                if (!spawn_with_login_uid (context, argv, &error)) {
+                                        throw_error (context, ERROR_FAILED, "running '%s' failed: %s", argv[0], error->message);
+                                        g_error_free (error);
+                                        return;
+                                }
+                        }
+
                         if (mode == PASSWORD_MODE_SET_AT_LOGIN) {
                                 argv[0] = "/usr/bin/chage";
                                 argv[1] = "-d";
@@ -1871,6 +1886,23 @@
                         g_object_notify (G_OBJECT (user), "locked");
                 }
 
+                /* Remember to remove user from nopasswdlogin group if we're
+                   switching away from no-password mode */
+                if (user->password_mode == PASSWORD_MODE_NONE) {
+                        argv[0] = "/usr/bin/gpasswd";
+                        argv[1] = "-d";
+                        argv[2] = user->user_name;
+                        argv[3] = "nopasswdlogin";
+                        argv[4] = NULL;
+
+                        error = NULL;
+                        if (!spawn_with_login_uid (context, argv, &error)) {
+                                throw_error (context, ERROR_FAILED, "running '%s' failed: %s", argv[0], error->message);
+                                g_error_free (error);
+                                return;
+                        }
+                }
+
                 user->password_mode = mode;
 
                 g_object_notify (G_OBJECT (user), "password-mode");
@@ -1938,6 +1970,20 @@
 
         error = NULL;
         if (!spawn_with_login_uid (context, argv, &error)) {
+                throw_error (context, ERROR_FAILED, "running '%s' failed: %s", argv[0], error->message);
+                g_error_free (error);
+                return;
+        }
+
+        /* Drop user from nopasswdlogin group */
+        argv[0] = "/usr/bin/gpasswd";
+        argv[1] = "-d";
+        argv[2] = user->user_name;
+        argv[3] = "nopasswdlogin";
+        argv[4] = NULL;
+
+        error = NULL;
+        if (!spawn_with_login_uid (context, argv, &error)) {
                 throw_error (context, ERROR_FAILED, "running '%s' failed: %s", argv[0], error->message);
                 g_error_free (error);
                 return;
