chiark / gitweb /
bus: expose installer functions
[elogind.git] / src / dbus-execute.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #ifndef foodbusexecutehfoo
4 #define foodbusexecutehfoo
5
6 /***
7   This file is part of systemd.
8
9   Copyright 2010 Lennart Poettering
10
11   systemd is free software; you can redistribute it and/or modify it
12   under the terms of the GNU General Public License as published by
13   the Free Software Foundation; either version 2 of the License, or
14   (at your option) any later version.
15
16   systemd is distributed in the hope that it will be useful, but
17   WITHOUT ANY WARRANTY; without even the implied warranty of
18   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19   General Public License for more details.
20
21   You should have received a copy of the GNU General Public License
22   along with systemd; If not, see <http://www.gnu.org/licenses/>.
23 ***/
24
25 #include <dbus/dbus.h>
26
27 #include "manager.h"
28
29 #define BUS_EXEC_STATUS_INTERFACE(prefix)                               \
30         "  <property name=\"" prefix "StartTimestamp\" type=\"t\" access=\"read\"/>\n" \
31         "  <property name=\"" prefix "StartTimestampMonotonic\" type=\"t\" access=\"read\"/>\n" \
32         "  <property name=\"" prefix "ExitTimestamp\" type=\"t\" access=\"read\"/>\n" \
33         "  <property name=\"" prefix "ExitTimestampMonotonic\" type=\"t\" access=\"read\"/>\n" \
34         "  <property name=\"" prefix "PID\" type=\"u\" access=\"read\"/>\n" \
35         "  <property name=\"" prefix "Code\" type=\"i\" access=\"read\"/>\n" \
36         "  <property name=\"" prefix "Status\" type=\"i\" access=\"read\"/>\n"
37
38 #define BUS_EXEC_CONTEXT_INTERFACE                                      \
39         "  <property name=\"Environment\" type=\"as\" access=\"read\"/>\n" \
40         "  <property name=\"UMask\" type=\"u\" access=\"read\"/>\n"     \
41         "  <property name=\"LimitCPU\" type=\"t\" access=\"read\"/>\n"  \
42         "  <property name=\"LimitFSIZE\" type=\"t\" access=\"read\"/>\n" \
43         "  <property name=\"LimitDATA\" type=\"t\" access=\"read\"/>\n" \
44         "  <property name=\"LimitSTACK\" type=\"t\" access=\"read\"/>\n" \
45         "  <property name=\"LimitCORE\" type=\"t\" access=\"read\"/>\n" \
46         "  <property name=\"LimitRSS\" type=\"t\" access=\"read\"/>\n"  \
47         "  <property name=\"LimitNOFILE\" type=\"t\" access=\"read\"/>\n" \
48         "  <property name=\"LimitAS\" type=\"t\" access=\"read\"/>\n"   \
49         "  <property name=\"LimitNPROC\" type=\"t\" access=\"read\"/>\n" \
50         "  <property name=\"LimitMEMLOCK\" type=\"t\" access=\"read\"/>\n" \
51         "  <property name=\"LimitLOCKS\" type=\"t\" access=\"read\"/>\n" \
52         "  <property name=\"LimitSIGPENDING\" type=\"t\" access=\"read\"/>\n" \
53         "  <property name=\"LimitMSGQUEUE\" type=\"t\" access=\"read\"/>\n" \
54         "  <property name=\"LimitNICE\" type=\"t\" access=\"read\"/>\n" \
55         "  <property name=\"LimitRTPRIO\" type=\"t\" access=\"read\"/>\n" \
56         "  <property name=\"LimitRTTIME\" type=\"t\" access=\"read\"/>\n" \
57         "  <property name=\"WorkingDirectory\" type=\"s\" access=\"read\"/>\n" \
58         "  <property name=\"RootDirectory\" type=\"s\" access=\"read\"/>\n" \
59         "  <property name=\"OOMScoreAdjust\" type=\"i\" access=\"read\"/>\n" \
60         "  <property name=\"Nice\" type=\"i\" access=\"read\"/>\n" \
61         "  <property name=\"IOScheduling\" type=\"i\" access=\"read\"/>\n" \
62         "  <property name=\"CPUSchedulingPolicy\" type=\"i\" access=\"read\"/>\n" \
63         "  <property name=\"CPUSchedulingPriority\" type=\"i\" access=\"read\"/>\n" \
64         "  <property name=\"CPUAffinity\" type=\"ay\" access=\"read\"/>\n" \
65         "  <property name=\"TimerSlackNS\" type=\"t\" access=\"read\"/>\n" \
66         "  <property name=\"CPUSchedulingResetOnFork\" type=\"b\" access=\"read\"/>\n" \
67         "  <property name=\"NonBlocking\" type=\"b\" access=\"read\"/>\n" \
68         "  <property name=\"StandardInput\" type=\"s\" access=\"read\"/>\n" \
69         "  <property name=\"StandardOutput\" type=\"s\" access=\"read\"/>\n" \
70         "  <property name=\"StandardError\" type=\"s\" access=\"read\"/>\n" \
71         "  <property name=\"TTYPath\" type=\"s\" access=\"read\"/>\n"   \
72         "  <property name=\"TTYReset\" type=\"b\" access=\"read\"/>\n"   \
73         "  <property name=\"TTYVHangup\" type=\"b\" access=\"read\"/>\n"   \
74         "  <property name=\"TTYVTDisallocate\" type=\"b\" access=\"read\"/>\n"   \
75         "  <property name=\"SyslogPriority\" type=\"i\" access=\"read\"/>\n" \
76         "  <property name=\"SyslogIdentifier\" type=\"s\" access=\"read\"/>\n" \
77         "  <property name=\"SyslogLevelPrefix\" type=\"b\" access=\"read\"/>\n" \
78         "  <property name=\"Capabilities\" type=\"s\" access=\"read\"/>\n" \
79         "  <property name=\"SecureBits\" type=\"i\" access=\"read\"/>\n" \
80         "  <property name=\"CapabilityBoundingSet\" type=\"t\" access=\"read\"/>\n" \
81         "  <property name=\"User\" type=\"s\" access=\"read\"/>\n"      \
82         "  <property name=\"Group\" type=\"s\" access=\"read\"/>\n"     \
83         "  <property name=\"SupplementaryGroups\" type=\"as\" access=\"read\"/>\n" \
84         "  <property name=\"TCPWrapName\" type=\"s\" access=\"read\"/>\n" \
85         "  <property name=\"PAMName\" type=\"s\" access=\"read\"/>\n"   \
86         "  <property name=\"ReadWriteDirectories\" type=\"as\" access=\"read\"/>\n" \
87         "  <property name=\"ReadOnlyDirectories\" type=\"as\" access=\"read\"/>\n" \
88         "  <property name=\"InaccessibleDirectories\" type=\"as\" access=\"read\"/>\n" \
89         "  <property name=\"MountFlags\" type=\"t\" access=\"read\"/>\n" \
90         "  <property name=\"PrivateTmp\" type=\"b\" access=\"read\"/>\n" \
91         "  <property name=\"SameProcessGroup\" type=\"b\" access=\"read\"/>\n" \
92         "  <property name=\"KillMode\" type=\"s\" access=\"read\"/>\n"  \
93         "  <property name=\"KillSignal\" type=\"i\" access=\"read\"/>\n" \
94         "  <property name=\"UtmpIdentifier\" type=\"s\" access=\"read\"/>\n" \
95         "  <property name=\"ControlGroupModify\" type=\"b\" access=\"read\"/>\n"
96
97 #define BUS_EXEC_COMMAND_INTERFACE(name)                             \
98         "  <property name=\"" name "\" type=\"a(sasbttuii)\" access=\"read\"/>\n"
99
100 #define BUS_EXEC_CONTEXT_PROPERTIES(interface, context)                 \
101         { interface, "Environment",                   bus_property_append_strv,   "as",    (context).environment                   }, \
102         { interface, "EnvironmentFiles",              bus_execute_append_env_files, "a(sb)", (context).environment_files           }, \
103         { interface, "UMask",                         bus_property_append_mode,   "u",     &(context).umask                        }, \
104         { interface, "LimitCPU",                      bus_execute_append_rlimits, "t",     &(context)                              }, \
105         { interface, "LimitFSIZE",                    bus_execute_append_rlimits, "t",     &(context)                              }, \
106         { interface, "LimitDATA",                     bus_execute_append_rlimits, "t",     &(context)                              }, \
107         { interface, "LimitSTACK",                    bus_execute_append_rlimits, "t",     &(context)                              }, \
108         { interface, "LimitCORE",                     bus_execute_append_rlimits, "t",     &(context)                              }, \
109         { interface, "LimitRSS",                      bus_execute_append_rlimits, "t",     &(context)                              }, \
110         { interface, "LimitNOFILE",                   bus_execute_append_rlimits, "t",     &(context)                              }, \
111         { interface, "LimitAS",                       bus_execute_append_rlimits, "t",     &(context)                              }, \
112         { interface, "LimitNPROC",                    bus_execute_append_rlimits, "t",     &(context)                              }, \
113         { interface, "LimitMEMLOCK",                  bus_execute_append_rlimits, "t",     &(context)                              }, \
114         { interface, "LimitLOCKS",                    bus_execute_append_rlimits, "t",     &(context)                              }, \
115         { interface, "LimitSIGPENDING",               bus_execute_append_rlimits, "t",     &(context)                              }, \
116         { interface, "LimitMSGQUEUE",                 bus_execute_append_rlimits, "t",     &(context)                              }, \
117         { interface, "LimitNICE",                     bus_execute_append_rlimits, "t",     &(context)                              }, \
118         { interface, "LimitRTPRIO",                   bus_execute_append_rlimits, "t",     &(context)                              }, \
119         { interface, "LimitRTTIME",                   bus_execute_append_rlimits, "t",     &(context)                              }, \
120         { interface, "WorkingDirectory",              bus_property_append_string, "s",     (context).working_directory             }, \
121         { interface, "RootDirectory",                 bus_property_append_string, "s",     (context).root_directory                }, \
122         { interface, "OOMScoreAdjust",                bus_execute_append_oom_score_adjust, "i", &(context)                         }, \
123         { interface, "Nice",                          bus_execute_append_nice,    "i",     &(context)                              }, \
124         { interface, "IOScheduling",                  bus_execute_append_ioprio,  "i",     &(context)                              }, \
125         { interface, "CPUSchedulingPolicy",           bus_execute_append_cpu_sched_policy, "i", &(context)                         }, \
126         { interface, "CPUSchedulingPriority",         bus_execute_append_cpu_sched_priority, "i", &(context)                       }, \
127         { interface, "CPUAffinity",                   bus_execute_append_affinity,"ay",    &(context)                              }, \
128         { interface, "TimerSlackNSec",                bus_execute_append_timer_slack_nsec, "t", &(context)                         }, \
129         { interface, "CPUSchedulingResetOnFork",      bus_property_append_bool,   "b",     &(context).cpu_sched_reset_on_fork      }, \
130         { interface, "NonBlocking",                   bus_property_append_bool,   "b",     &(context).non_blocking                 }, \
131         { interface, "StandardInput",                 bus_execute_append_input,   "s",     &(context).std_input                    }, \
132         { interface, "StandardOutput",                bus_execute_append_output,  "s",     &(context).std_output                   }, \
133         { interface, "StandardError",                 bus_execute_append_output,  "s",     &(context).std_error                    }, \
134         { interface, "TTYPath",                       bus_property_append_string, "s",     (context).tty_path                      }, \
135         { interface, "TTYReset",                      bus_property_append_bool,   "b",     &(context).tty_reset                    }, \
136         { interface, "TTYVHangup",                    bus_property_append_bool,   "b",     &(context).tty_vhangup                  }, \
137         { interface, "TTYVTDisallocate",              bus_property_append_bool,   "b",     &(context).tty_vt_disallocate           }, \
138         { interface, "SyslogPriority",                bus_property_append_int,    "i",     &(context).syslog_priority              }, \
139         { interface, "SyslogIdentifier",              bus_property_append_string, "s",     (context).syslog_identifier             }, \
140         { interface, "SyslogLevelPrefix",             bus_property_append_bool,   "b",     &(context).syslog_level_prefix          }, \
141         { interface, "Capabilities",                  bus_execute_append_capabilities, "s",&(context)                              }, \
142         { interface, "SecureBits",                    bus_property_append_int,    "i",     &(context).secure_bits                  }, \
143         { interface, "CapabilityBoundingSet",         bus_execute_append_capability_bs, "t", &(context).capability_bounding_set_drop }, \
144         { interface, "User",                          bus_property_append_string, "s",     (context).user                          }, \
145         { interface, "Group",                         bus_property_append_string, "s",     (context).group                         }, \
146         { interface, "SupplementaryGroups",           bus_property_append_strv,   "as",    (context).supplementary_groups          }, \
147         { interface, "TCPWrapName",                   bus_property_append_string, "s",     (context).tcpwrap_name                  }, \
148         { interface, "PAMName",                       bus_property_append_string, "s",     (context).pam_name                      }, \
149         { interface, "ReadWriteDirectories",          bus_property_append_strv,   "as",    (context).read_write_dirs               }, \
150         { interface, "ReadOnlyDirectories",           bus_property_append_strv,   "as",    (context).read_only_dirs                }, \
151         { interface, "InaccessibleDirectories",       bus_property_append_strv,   "as",    (context).inaccessible_dirs             }, \
152         { interface, "MountFlags",                    bus_property_append_ul,     "t",     &(context).mount_flags                  }, \
153         { interface, "PrivateTmp",                    bus_property_append_bool,   "b",     &(context).private_tmp                  }, \
154         { interface, "SameProcessGroup",              bus_property_append_bool,   "b",     &(context).same_pgrp                    }, \
155         { interface, "KillMode",                      bus_execute_append_kill_mode, "s",   &(context).kill_mode                    }, \
156         { interface, "KillSignal",                    bus_property_append_int,    "i",     &(context).kill_signal                  }, \
157         { interface, "UtmpIdentifier",                bus_property_append_string, "s",     (context).utmp_id                       }, \
158         { interface, "ControlGroupModify",            bus_property_append_bool,   "b",     &(context).control_group_modify         }
159
160 #define BUS_EXEC_STATUS_PROPERTIES(interface, estatus, prefix)           \
161         { interface, prefix "StartTimestamp",         bus_property_append_usec,   "t",     &(estatus).start_timestamp.realtime     }, \
162         { interface, prefix "StartTimestampMonotonic",bus_property_append_usec,   "t",     &(estatus).start_timestamp.monotonic    }, \
163         { interface, prefix "ExitTimestamp",          bus_property_append_usec,   "t",     &(estatus).start_timestamp.realtime     }, \
164         { interface, prefix "ExitTimestampMonotonic", bus_property_append_usec,   "t",     &(estatus).start_timestamp.monotonic    }, \
165         { interface, prefix "PID",                    bus_property_append_pid,    "u",     &(estatus).pid                          }, \
166         { interface, prefix "Code",                   bus_property_append_int,    "i",     &(estatus).code                         }, \
167         { interface, prefix "Status",                 bus_property_append_int,    "i",     &(estatus).status                       }
168
169 #define BUS_EXEC_COMMAND_PROPERTY(interface, command, name)             \
170         { interface, name, bus_execute_append_command, "a(sasbttttuii)", (command) }
171
172 int bus_execute_append_output(DBusMessageIter *i, const char *property, void *data);
173 int bus_execute_append_input(DBusMessageIter *i, const char *property, void *data);
174 int bus_execute_append_oom_score_adjust(DBusMessageIter *i, const char *property, void *data);
175 int bus_execute_append_nice(DBusMessageIter *i, const char *property, void *data);
176 int bus_execute_append_ioprio(DBusMessageIter *i, const char *property, void *data);
177 int bus_execute_append_cpu_sched_policy(DBusMessageIter *i, const char *property, void *data);
178 int bus_execute_append_cpu_sched_priority(DBusMessageIter *i, const char *property, void *data);
179 int bus_execute_append_affinity(DBusMessageIter *i, const char *property, void *data);
180 int bus_execute_append_timer_slack_nsec(DBusMessageIter *i, const char *property, void *data);
181 int bus_execute_append_capabilities(DBusMessageIter *i, const char *property, void *data);
182 int bus_execute_append_capability_bs(DBusMessageIter *i, const char *property, void *data);
183 int bus_execute_append_rlimits(DBusMessageIter *i, const char *property, void *data);
184 int bus_execute_append_command(DBusMessageIter *u, const char *property, void *data);
185 int bus_execute_append_kill_mode(DBusMessageIter *i, const char *property, void *data);
186 int bus_execute_append_env_files(DBusMessageIter *i, const char *property, void *data);
187
188 #endif