예제 #1
0
파일: accounts.c 프로젝트: magcius/cockpit
static void
create_account_done (ActUserManager *manager,
                     GAsyncResult *res,
                     CallData *data)
{
  CockpitAccounts *object = data->object;
  GDBusMethodInvocation *invocation = data->invocation;
  gs_free gchar *password = data->password;
  gboolean locked = data->locked;
  g_free (data);

  GError *error = NULL;
  ActUser *user = act_user_manager_create_user_finish (manager, res, &error);
  if (user == NULL)
    {
      g_dbus_method_invocation_return_error (invocation,
                                             COCKPIT_ERROR, COCKPIT_ERROR_FAILED,
                                             "Failed to create user account: %s", error->message);
      g_error_free (error);
      return;
    }

  if (password && *password)
    {
      act_user_set_password_mode (user, ACT_USER_PASSWORD_MODE_REGULAR);
      act_user_set_password (user, password, "");
    }

  act_user_set_locked (user, locked);

  cockpit_accounts_complete_create_account (object, invocation);
}
예제 #2
0
static void
gis_password_page_save_data (GisPage *gis_page)
{
  GisPasswordPage *page = GIS_PASSWORD_PAGE (gis_page);
  GisPasswordPagePrivate *priv = gis_password_page_get_instance_private (page);
  ActUser *act_user;
  UmAccountMode account_mode;
  const gchar *password;

  if (gis_page->driver == NULL)
    return;

  account_mode = gis_driver_get_account_mode (gis_page->driver);

  if (account_mode == UM_ENTERPRISE)
    return;

  gis_driver_get_user_permissions (gis_page->driver, &act_user, &password);

  password = gtk_entry_get_text (GTK_ENTRY (priv->password_entry));

  if (strlen (password) == 0)
    act_user_set_password_mode (act_user, ACT_USER_PASSWORD_MODE_NONE);
  else
    act_user_set_password (act_user, password, "");

  gis_driver_set_user_permissions (gis_page->driver, act_user, password);

  gis_update_login_keyring_password (password);
}
static void
accept_password_dialog (GtkButton        *button,
                        UmPasswordDialog *um)
{
        const gchar *password;

        password = gtk_entry_get_text (GTK_ENTRY (um->password_entry));

        switch (um->password_mode) {
                act_user_set_password_mode (um->user, ACT_USER_PASSWORD_MODE_REGULAR);
                case ACT_USER_PASSWORD_MODE_REGULAR:
                        if (act_user_get_uid (um->user) == getuid ()) {
                                GdkDisplay *display;
                                GdkCursor *cursor;

                                /* When setting a password for the current user,
                                 * use passwd directly, to preserve the audit trail
                                 * and to e.g. update the keyring password.
                                 */
                                passwd_change_password (um->passwd_handler, password,
                                                        (PasswdCallback) password_changed_cb, um);
                                gtk_widget_set_sensitive (um->dialog, FALSE);
                                display = gtk_widget_get_display (um->dialog);
                                cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
                                gdk_window_set_cursor (gtk_widget_get_window (um->dialog), cursor);
                                gdk_display_flush (display);
                                g_object_unref (cursor);
                                return;
                        }

                        act_user_set_password (um->user, password, "");
                        break;

                case ACT_USER_PASSWORD_MODE_SET_AT_LOGIN:
                        act_user_set_password_mode (um->user,  um->password_mode);
                        act_user_set_automatic_login (um->user, FALSE);
                        break;

                default:
                        g_assert_not_reached ();
        }

        finish_password_change (um);
}
예제 #4
0
파일: account.c 프로젝트: magcius/cockpit
static gboolean
handle_set_password (CockpitAccount *object,
                     GDBusMethodInvocation *invocation,
                     const gchar *arg_password)
{
  Account *acc = ACCOUNT (object);

  if (!account_auth_check (object, invocation, acc))
    return TRUE;

  if (acc->u)
    {
      act_user_set_password_mode (acc->u, ACT_USER_PASSWORD_MODE_REGULAR);
      act_user_set_password (acc->u, arg_password, "");
    }

  cockpit_account_complete_set_password (object, invocation);
  return TRUE;
}
static void
accept_password_dialog (GtkButton        *button,
                        UmPasswordDialog *um)
{
        GtkTreeModel *model;
        GtkTreeIter iter;
        gint mode;
        const gchar *hint;
        const gchar *password;

        model = gtk_combo_box_get_model (GTK_COMBO_BOX (um->action_combo));
        gtk_combo_box_get_active_iter (GTK_COMBO_BOX (um->action_combo), &iter);
        gtk_tree_model_get (model, &iter, 1, &mode, -1);

        password = gtk_entry_get_text (GTK_ENTRY (um->password_entry));
        hint = NULL;

        switch (mode) {
                case UM_PASSWORD_DIALOG_MODE_NORMAL:
                        if (act_user_get_uid (um->user) == getuid ()) {
                                GdkDisplay *display;
                                GdkCursor *cursor;

                                /* When setting a password for the current user,
                                 * use passwd directly, to preserve the audit trail
                                 * and to e.g. update the keyring password.
                                 */
                                passwd_change_password (um->passwd_handler, password,
                                                        (PasswdCallback) password_changed_cb, um);
                                gtk_widget_set_sensitive (um->dialog, FALSE);
                                display = gtk_widget_get_display (um->dialog);
                                cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
                                gdk_window_set_cursor (gtk_widget_get_window (um->dialog), cursor);
                                gdk_display_flush (display);
                                g_object_unref (cursor);
                                return;
                        }

                        act_user_set_password (um->user, password, hint);
                        break;

                case UM_PASSWORD_DIALOG_MODE_SET_AT_LOGIN:
                        act_user_set_password_mode (um->user, ACT_USER_PASSWORD_MODE_SET_AT_LOGIN);
                        break;

                case UM_PASSWORD_DIALOG_MODE_NO_PASSWORD:
                        act_user_set_password_mode (um->user, ACT_USER_PASSWORD_MODE_NONE);
                        break;

                case UM_PASSWORD_DIALOG_MODE_LOCK_ACCOUNT:
                        act_user_set_locked (um->user, TRUE);
                        break;

                case UM_PASSWORD_DIALOG_MODE_UNLOCK_ACCOUNT:
                        act_user_set_locked (um->user, FALSE);
                        break;

                default:
                        g_assert_not_reached ();
        }

        finish_password_change (um);
}