~diwic/ubuntu/lucid/pulseaudio/bugfixes

« back to all changes in this revision

Viewing changes to src/daemon/polkit.c

  • Committer: Bazaar Package Importer
  • Author(s): Luke Yelavich
  • Date: 2008-11-04 15:46:00 UTC
  • mfrom: (1.2.1 upstream) (1.1.6 lenny)
  • Revision ID: james.westby@ubuntu.com-20081104154600-hlzknpcazaam0nxm
Tags: 0.9.13-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Don't build against, and create jack package. Jack is not in main.
  - Remove --disable-per-user-esound-socket from configure flags, as we still
    want per user esound sockets.
  - Remove stop links from rc0 and rc6.
  - Change default resample algorithm and bubffer size.
  - Add alsa configuration files to route alsa applications via pulseaudio.
  - Move libasound2-plugins from Recommends to Depends.
* debian/pulseaudio.preinst: When upgrading from intrepid, remove
  /etc/X11/Xsession.d/70pulseaudio, as this was used to minimize a race
  condition when starting GNOME in intrepid. This race should not exist in
  jaunty once libcanberra is built to use pulseaudio as a backend.
* Do not spawn a pulseaudio server if clients fail to find a running server.
* Remove explicit version dependency for libspeex-dev to allow the package
  to be built for now.
* Regenerate autotools files to work with Ubuntu's newer libtool/libltdl.
* debian/control: libpulsecore5 -> libpulsecore8 to match the library
  soname.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id$ */
2
 
 
3
1
/***
4
2
  This file is part of PulseAudio.
5
3
 
33
31
#include <dbus/dbus.h>
34
32
#include <polkit-dbus/polkit-dbus.h>
35
33
 
 
34
#include <pulse/i18n.h>
 
35
 
36
36
#include <pulsecore/log.h>
37
37
#include <pulsecore/macro.h>
38
38
 
52
52
    dbus_error_init(&dbus_error);
53
53
 
54
54
    if (!(bus = dbus_bus_get(DBUS_BUS_SYSTEM, &dbus_error))) {
55
 
        pa_log_error("Cannot connect to system bus: %s", dbus_error.message);
 
55
        pa_log_error(_("Cannot connect to system bus: %s"), dbus_error.message);
56
56
        goto finish;
57
57
    }
58
58
 
 
59
    /* There seems to be a bug in some versions of D-Bus that causes
 
60
     * dbus_shutdown() to call exit() when a connection without this
 
61
     * flag disabled was created during runtime.*/
 
62
    dbus_connection_set_exit_on_disconnect(bus, FALSE);
 
63
 
59
64
    if (!(caller = polkit_caller_new_from_pid(bus, getpid(), &dbus_error))) {
60
 
        pa_log_error("Cannot get caller from PID: %s", dbus_error.message);
 
65
        pa_log_error(_("Cannot get caller from PID: %s"), dbus_error.message);
61
66
        goto finish;
62
67
    }
63
68
 
69
74
     * -- an not the EUID or any other user id. */
70
75
 
71
76
    if (!(polkit_caller_set_uid(caller, getuid()))) {
72
 
        pa_log_error("Cannot set UID on caller object.");
 
77
        pa_log_error(_("Cannot set UID on caller object."));
73
78
        goto finish;
74
79
    }
75
80
 
76
81
    if (!(polkit_caller_get_ck_session(caller, &session))) {
77
 
        pa_log_error("Failed to get CK session.");
 
82
        pa_log_error(_("Failed to get CK session."));
78
83
        goto finish;
79
84
    }
80
85
 
82
87
     * object */
83
88
 
84
89
    if (!(polkit_session_set_uid(session, getuid()))) {
85
 
        pa_log_error("Cannot set UID on session object.");
 
90
        pa_log_error(_("Cannot set UID on session object."));
86
91
        goto finish;
87
92
    }
88
93
 
89
94
    if (!(action = polkit_action_new())) {
90
 
        pa_log_error("Cannot allocate PolKitAction.");
 
95
        pa_log_error(_("Cannot allocate PolKitAction."));
91
96
        goto finish;
92
97
    }
93
98
 
94
99
    if (!polkit_action_set_action_id(action, action_id)) {
95
 
        pa_log_error("Cannot set action_id");
 
100
        pa_log_error(_("Cannot set action_id"));
96
101
        goto finish;
97
102
    }
98
103
 
99
104
    if (!(context = polkit_context_new())) {
100
 
        pa_log_error("Cannot allocate PolKitContext.");
 
105
        pa_log_error(_("Cannot allocate PolKitContext."));
101
106
        goto finish;
102
107
    }
103
108
 
104
109
    if (!polkit_context_init(context, &polkit_error)) {
105
 
        pa_log_error("Cannot initialize PolKitContext: %s", polkit_error_get_error_message(polkit_error));
 
110
        pa_log_error(_("Cannot initialize PolKitContext: %s"), polkit_error_get_error_message(polkit_error));
106
111
        goto finish;
107
112
    }
108
113
 
111
116
        polkit_result = polkit_context_is_caller_authorized(context, action, caller, TRUE, &polkit_error);
112
117
 
113
118
        if (polkit_error_is_set(polkit_error)) {
114
 
            pa_log_error("Could not determine whether caller is authorized: %s", polkit_error_get_error_message(polkit_error));
 
119
            pa_log_error(_("Could not determine whether caller is authorized: %s"), polkit_error_get_error_message(polkit_error));
115
120
            goto finish;
116
121
        }
117
122
 
131
136
            }
132
137
 
133
138
            if (dbus_error_is_set(&dbus_error)) {
134
 
                pa_log_error("Cannot obtain auth: %s", dbus_error.message);
 
139
                pa_log_error(_("Cannot obtain auth: %s"), dbus_error.message);
135
140
                goto finish;
136
141
            }
137
142
        }
140
145
    }
141
146
 
142
147
    if (polkit_result != POLKIT_RESULT_YES && polkit_result != POLKIT_RESULT_NO)
143
 
        pa_log_warn("PolicyKit responded with '%s'", polkit_result_to_string_representation(polkit_result));
 
148
        pa_log_warn(_("PolicyKit responded with '%s'"), polkit_result_to_string_representation(polkit_result));
144
149
 
145
150
    ret = polkit_result == POLKIT_RESULT_YES;
146
151