~ubuntu-branches/ubuntu/trusty/gdm/trusty-proposed

« back to all changes in this revision

Viewing changes to .pc/ubuntu_daemon_autologin_tracking.patch/daemon/gdm-static-display.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha, Tim Lunn, Jeremy Bicha, Robert Ancell
  • Date: 2013-05-31 22:36:08 UTC
  • mfrom: (1.4.55)
  • Revision ID: package-import@ubuntu.com-20130531223608-33uo85niksee5460
Tags: 3.8.1.1-0ubuntu1
[ Tim Lunn ]
* New upstream release
* debian/patches/ubuntu_dont_catch_sigsegv.patch:
  - Dropped, obsolete
* debian/rules:
  - Don't rename gdm binary since that's already been
    done in the new version

[ Jeremy Bicha ]
* debian/control.in: Bump minimum glib
* debian/watch: Watch for unstable releases
* debian/patches/00git_logind_check.patch:
  - Dropped, applied in new release
* debian/patches/08_frequent-users_greeter.patch: Refreshed

[ Robert Ancell ]
* New upstream release
* debian/patches/ubuntu_daemon_autologin_tracking.patch:
* debian/patches/ubuntu_ensure_dirs.patch:
* debian/patches/ubuntu_slave-only-set-up-autologin.patch:
  - Applied upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2
 
 *
3
 
 * Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
4
 
 *
5
 
 * This program is free software; you can redistribute it and/or modify
6
 
 * it under the terms of the GNU General Public License as published by
7
 
 * the Free Software Foundation; either version 2 of the License, or
8
 
 * (at your option) any later version.
9
 
 *
10
 
 * This program is distributed in the hope that it will be useful,
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 * GNU General Public License for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU General Public License
16
 
 * along with this program; if not, write to the Free Software
17
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
 
 *
19
 
 */
20
 
 
21
 
#include "config.h"
22
 
 
23
 
#include <errno.h>
24
 
#include <stdlib.h>
25
 
#include <stdio.h>
26
 
#include <fcntl.h>
27
 
#include <pwd.h>
28
 
#include <unistd.h>
29
 
#include <string.h>
30
 
#include <signal.h>
31
 
#include <sys/stat.h>
32
 
#include <sys/types.h>
33
 
#include <sys/socket.h>
34
 
 
35
 
#include <glib.h>
36
 
#include <glib/gi18n.h>
37
 
#include <glib-object.h>
38
 
 
39
 
#include "gdm-common.h"
40
 
#include "gdm-display.h"
41
 
#include "gdm-static-display.h"
42
 
#include "gdm-static-display-glue.h"
43
 
 
44
 
#define GDM_STATIC_DISPLAY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_STATIC_DISPLAY, GdmStaticDisplayPrivate))
45
 
 
46
 
struct GdmStaticDisplayPrivate
47
 
{
48
 
        GdmDBusStaticDisplay *skeleton;
49
 
        gboolean first_login;
50
 
};
51
 
 
52
 
static void     gdm_static_display_class_init   (GdmStaticDisplayClass *klass);
53
 
static void     gdm_static_display_init         (GdmStaticDisplay      *static_display);
54
 
 
55
 
G_DEFINE_TYPE (GdmStaticDisplay, gdm_static_display, GDM_TYPE_DISPLAY)
56
 
 
57
 
static gboolean
58
 
gdm_static_display_create_authority (GdmDisplay *display)
59
 
{
60
 
        g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
61
 
 
62
 
        GDM_DISPLAY_CLASS (gdm_static_display_parent_class)->create_authority (display);
63
 
 
64
 
        return TRUE;
65
 
}
66
 
 
67
 
static gboolean
68
 
gdm_static_display_add_user_authorization (GdmDisplay *display,
69
 
                                           const char *username,
70
 
                                           char      **filename,
71
 
                                           GError    **error)
72
 
{
73
 
        return GDM_DISPLAY_CLASS (gdm_static_display_parent_class)->add_user_authorization (display, username, filename, error);
74
 
}
75
 
 
76
 
static gboolean
77
 
gdm_static_display_remove_user_authorization (GdmDisplay *display,
78
 
                                              const char *username,
79
 
                                              GError    **error)
80
 
{
81
 
        return GDM_DISPLAY_CLASS (gdm_static_display_parent_class)->remove_user_authorization (display, username, error);
82
 
}
83
 
 
84
 
static gboolean
85
 
gdm_static_display_manage (GdmDisplay *display)
86
 
{
87
 
        g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
88
 
 
89
 
        GDM_DISPLAY_CLASS (gdm_static_display_parent_class)->manage (display);
90
 
 
91
 
        return TRUE;
92
 
}
93
 
 
94
 
static gboolean
95
 
gdm_static_display_finish (GdmDisplay *display)
96
 
{
97
 
        int status;
98
 
 
99
 
        g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
100
 
 
101
 
        /* Don't call parent's finish since we don't ever
102
 
           want to be put in the FINISHED state */
103
 
 
104
 
        /* restart static displays */
105
 
        gdm_display_unmanage (display);
106
 
 
107
 
        status = gdm_display_get_status (display);
108
 
        if (status != GDM_DISPLAY_FAILED) {
109
 
                gdm_display_manage (display);
110
 
        }
111
 
 
112
 
        return TRUE;
113
 
}
114
 
 
115
 
static gboolean
116
 
gdm_static_display_unmanage (GdmDisplay *display)
117
 
{
118
 
        g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
119
 
 
120
 
        GDM_STATIC_DISPLAY (display)->priv->first_login = FALSE;
121
 
 
122
 
        GDM_DISPLAY_CLASS (gdm_static_display_parent_class)->unmanage (display);
123
 
 
124
 
        return TRUE;
125
 
}
126
 
 
127
 
static void
128
 
gdm_static_display_get_timed_login_details (GdmDisplay *display,
129
 
                                            gboolean   *enabledp,
130
 
                                            char      **usernamep,
131
 
                                            int        *delayp)
132
 
{
133
 
        GDM_DISPLAY_CLASS (gdm_static_display_parent_class)->get_timed_login_details (display, enabledp, usernamep, delayp);
134
 
 
135
 
        if (!GDM_STATIC_DISPLAY (display)->priv->first_login) {
136
 
                /* if this is autologin but not timed login, then disable
137
 
                 * autologin after the first one */
138
 
                if (*enabledp && *delayp == 0) {
139
 
                        *enabledp = FALSE;
140
 
                }
141
 
        }
142
 
}
143
 
 
144
 
static GObject *
145
 
gdm_static_display_constructor (GType                  type,
146
 
                                   guint                  n_construct_properties,
147
 
                                   GObjectConstructParam *construct_properties)
148
 
{
149
 
        GdmStaticDisplay      *display;
150
 
 
151
 
        display = GDM_STATIC_DISPLAY (G_OBJECT_CLASS (gdm_static_display_parent_class)->constructor (type,
152
 
                                                                                                           n_construct_properties,
153
 
                                                                                                           construct_properties));
154
 
 
155
 
        display->priv->skeleton = GDM_DBUS_STATIC_DISPLAY (gdm_dbus_static_display_skeleton_new ());
156
 
 
157
 
        g_dbus_object_skeleton_add_interface (gdm_display_get_object_skeleton (GDM_DISPLAY (display)),
158
 
                                              G_DBUS_INTERFACE_SKELETON (display->priv->skeleton));
159
 
 
160
 
        return G_OBJECT (display);
161
 
}
162
 
 
163
 
static void
164
 
gdm_static_display_finalize (GObject *object)
165
 
{
166
 
        GdmStaticDisplay *display = GDM_STATIC_DISPLAY (object);
167
 
 
168
 
        g_clear_object (&display->priv->skeleton);
169
 
 
170
 
        G_OBJECT_CLASS (gdm_static_display_parent_class)->finalize (object);
171
 
}
172
 
 
173
 
static void
174
 
gdm_static_display_class_init (GdmStaticDisplayClass *klass)
175
 
{
176
 
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
177
 
        GdmDisplayClass *display_class = GDM_DISPLAY_CLASS (klass);
178
 
 
179
 
        object_class->constructor = gdm_static_display_constructor;
180
 
        object_class->finalize = gdm_static_display_finalize;
181
 
 
182
 
        display_class->create_authority = gdm_static_display_create_authority;
183
 
        display_class->add_user_authorization = gdm_static_display_add_user_authorization;
184
 
        display_class->remove_user_authorization = gdm_static_display_remove_user_authorization;
185
 
        display_class->manage = gdm_static_display_manage;
186
 
        display_class->finish = gdm_static_display_finish;
187
 
        display_class->unmanage = gdm_static_display_unmanage;
188
 
        display_class->get_timed_login_details = gdm_static_display_get_timed_login_details;
189
 
 
190
 
        g_type_class_add_private (klass, sizeof (GdmStaticDisplayPrivate));
191
 
}
192
 
 
193
 
static void
194
 
gdm_static_display_init (GdmStaticDisplay *static_display)
195
 
{
196
 
 
197
 
        static_display->priv = GDM_STATIC_DISPLAY_GET_PRIVATE (static_display);
198
 
 
199
 
        static_display->priv->first_login = TRUE;
200
 
}
201
 
 
202
 
GdmDisplay *
203
 
gdm_static_display_new (int display_number)
204
 
{
205
 
        GObject *object;
206
 
        char    *x11_display;
207
 
 
208
 
        x11_display = g_strdup_printf (":%d", display_number);
209
 
        object = g_object_new (GDM_TYPE_STATIC_DISPLAY,
210
 
                               "x11-display-number", display_number,
211
 
                               "x11-display-name", x11_display,
212
 
                               NULL);
213
 
        g_free (x11_display);
214
 
 
215
 
        return GDM_DISPLAY (object);
216
 
}