~ubuntu-branches/ubuntu/trusty/systemd/trusty

« back to all changes in this revision

Viewing changes to src/cgroups-agent.c

  • Committer: Package Import Robot
  • Author(s): Michael Biebl, Michael Biebl, Michael Stapelberg, Daniel Schaal, Ondrej Balaz
  • Date: 2013-09-12 00:13:11 UTC
  • mfrom: (1.1.11) (9.1.2 experimental)
  • mto: This revision was merged to the branch mainline in revision 53.
  • Revision ID: package-import@ubuntu.com-20130912001311-dz35it34wr2lbday
Tags: 204-3
[ Michael Biebl ]
* Upload to unstable.
* Use /bin/bash in debug-shell.service as Debian doesn't have /sbin/sushell.
* Only import net.ifaces cmdline property for network devices.
* Generate strict dependencies between the binary packages using a
  shlibs.local file and add an explicit versioned dependency on
  libsystemd-login0 to systemd to ensure packages are upgraded in sync.
  Closes: #719444
* Drop obsolete Replaces: libudev0 from udev package.
* Use correct paths for various binaries, like /sbin/quotaon, which are
  installed in / and not /usr in Debian.  Closes: #721347
* Don't install kernel-install(8) man page since we don't install the
  corresponding binary either.  Closes: #722180
* Cherry-pick upstream fixes to make switching runlevels and starting
  reboot via ctrl-alt-del more robust.
* Cherry-pick upstream fix to properly apply ACLs to Journal files.

[ Michael Stapelberg ]
* Make systemctl enable|disable call update-rc.d for SysV init scripts.
  Closes: #709780
* Don't mount /tmp as tmpfs by default and make it possible to enable this
  feature via "systemctl enable tmp.mount".

[ Daniel Schaal ]
* Add bug-script to systemd and udev.  Closes: #711245

[ Ondrej Balaz ]
* Recognize discard option in /etc/crypttab.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
 
 
3
 
/***
4
 
  This file is part of systemd.
5
 
 
6
 
  Copyright 2010 Lennart Poettering
7
 
 
8
 
  systemd is free software; you can redistribute it and/or modify it
9
 
  under the terms of the GNU General Public License as published by
10
 
  the Free Software Foundation; either version 2 of the License, or
11
 
  (at your option) any later version.
12
 
 
13
 
  systemd is distributed in the hope that it will be useful, but
14
 
  WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
 
  General Public License for more details.
17
 
 
18
 
  You should have received a copy of the GNU General Public License
19
 
  along with systemd; If not, see <http://www.gnu.org/licenses/>.
20
 
***/
21
 
 
22
 
#include <dbus/dbus.h>
23
 
 
24
 
#include <stdlib.h>
25
 
 
26
 
#include "log.h"
27
 
#include "dbus-common.h"
28
 
 
29
 
int main(int argc, char *argv[]) {
30
 
        DBusError error;
31
 
        DBusConnection *bus = NULL;
32
 
        DBusMessage *m = NULL;
33
 
        int r = EXIT_FAILURE;
34
 
 
35
 
        dbus_error_init(&error);
36
 
 
37
 
        if (argc != 2) {
38
 
                log_error("Incorrect number of arguments.");
39
 
                goto finish;
40
 
        }
41
 
 
42
 
        log_set_target(LOG_TARGET_AUTO);
43
 
        log_parse_environment();
44
 
        log_open();
45
 
 
46
 
        /* We send this event to the private D-Bus socket and then the
47
 
         * system instance will forward this to the system bus. We do
48
 
         * this to avoid an activation loop when we start dbus when we
49
 
         * are called when the dbus service is shut down. */
50
 
 
51
 
        if (!(bus = dbus_connection_open_private("unix:path=/run/systemd/private", &error))) {
52
 
#ifndef LEGACY
53
 
                dbus_error_free(&error);
54
 
 
55
 
                /* Retry with the pre v21 socket name, to ease upgrades */
56
 
                if (!(bus = dbus_connection_open_private("unix:abstract=/org/freedesktop/systemd1/private", &error))) {
57
 
#endif
58
 
                        log_error("Failed to get D-Bus connection: %s", bus_error_message(&error));
59
 
                        goto finish;
60
 
                }
61
 
#ifndef LEGACY
62
 
        }
63
 
#endif
64
 
 
65
 
        if (bus_check_peercred(bus) < 0) {
66
 
                log_error("Bus owner not root.");
67
 
                goto finish;
68
 
        }
69
 
 
70
 
        if (!(m = dbus_message_new_signal("/org/freedesktop/systemd1/agent", "org.freedesktop.systemd1.Agent", "Released"))) {
71
 
                log_error("Could not allocate signal message.");
72
 
                goto finish;
73
 
        }
74
 
 
75
 
        if (!dbus_message_append_args(m,
76
 
                                      DBUS_TYPE_STRING, &argv[1],
77
 
                                      DBUS_TYPE_INVALID)) {
78
 
                log_error("Could not attach group information to signal message.");
79
 
                goto finish;
80
 
        }
81
 
 
82
 
        if (!dbus_connection_send(bus, m, NULL)) {
83
 
                log_error("Failed to send signal message on private connection.");
84
 
                goto finish;
85
 
        }
86
 
 
87
 
        r = EXIT_SUCCESS;
88
 
 
89
 
finish:
90
 
        if (bus) {
91
 
                dbus_connection_flush(bus);
92
 
                dbus_connection_close(bus);
93
 
                dbus_connection_unref(bus);
94
 
        }
95
 
 
96
 
        if (m)
97
 
                dbus_message_unref(m);
98
 
 
99
 
        dbus_error_free(&error);
100
 
        return r;
101
 
}