Skip to content
Snippets Groups Projects
Commit b8fe7a31 authored by Martyn Welch's avatar Martyn Welch
Browse files

Add in original messages


Signed-off-by: default avatarMartyn Welch <martyn@welchs.me.uk>
parent 897f42ee
No related branches found
No related tags found
No related merge requests found
......@@ -137,20 +137,27 @@ static const sd_bus_vtable test_vtable[] = {
SD_BUS_VTABLE_END
};
#define BUF_SIZE 10
int main(int argc, char *argv[]) {
sd_bus_slot *slot = NULL;
sd_bus *bus = NULL;
int r;
FILE *fp;
char *rp;
char buf[BUF_SIZE];
app_name = argv[0];
/* Connect to the user bus this time */
r = sd_bus_open_user(&bus);
if (r < 0) {
fprintf(stderr, "Failed to connect to system bus: %s\n", strerror(-r));
fprintf(stderr, "Failed to connect to session bus: %s\n", strerror(-r));
goto finish;
}
say("Starting");
/* Install the object */
r = sd_bus_add_object_vtable(bus,
&slot,
......@@ -163,6 +170,27 @@ int main(int argc, char *argv[]) {
goto finish;
}
printf("%s:AppArmor context: ", app_name);
fp = fopen("/proc/self/attr/current", "r");
if (!fp) {
fprintf(stderr, "Failed to open AppArmor context: %s\n", strerror(errno));
goto finish;
}
while( 1 ) {
rp = fgets(buf, BUF_SIZE, fp);
if (!r)
break;
printf(buf);
}
printf("\n");
fclose(fp);
say("service ready");
say("Obtaining bus name");
/* Take a well-known service name so that clients can find us */
r = sd_bus_request_name(bus, "org.Test", 0);
if (r < 0) {
......@@ -170,6 +198,8 @@ int main(int argc, char *argv[]) {
goto finish;
}
say("Entering main loop");
for (;;) {
/* Process requests */
r = sd_bus_process(bus, NULL);
......@@ -188,6 +218,8 @@ int main(int argc, char *argv[]) {
}
}
say("Leaving main loop");
finish:
sd_bus_slot_unref(slot);
sd_bus_unref(bus);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment