int r, in_fd, out_fd;
bool got_hello = false;
bool is_unix;
+ struct ucred ucred = {};
+ _cleanup_free_ char *peersec = NULL;
log_set_target(LOG_TARGET_JOURNAL_OR_KMSG);
log_parse_environment();
in_fd = SD_LISTEN_FDS_START;
out_fd = SD_LISTEN_FDS_START;
} else {
- log_error("Illegal number of file descriptors passed\n");
+ log_error("Illegal number of file descriptors passed");
goto finish;
}
sd_is_socket(in_fd, AF_UNIX, 0, 0) > 0 &&
sd_is_socket(out_fd, AF_UNIX, 0, 0) > 0;
+ if (is_unix) {
+ getpeercred(in_fd, &ucred);
+ getpeersec(in_fd, &peersec);
+ }
+
r = sd_bus_new(&a);
if (r < 0) {
log_error("Failed to allocate bus: %s", strerror(-r));
goto finish;
}
+ if (ucred.pid > 0) {
+ a->fake_creds.pid = ucred.pid;
+ a->fake_creds.uid = ucred.uid;
+ a->fake_creds.gid = ucred.gid;
+ a->fake_creds_valid = true;
+ }
+
+ if (peersec) {
+ a->fake_label = peersec;
+ peersec = NULL;
+ }
+
r = sd_bus_start(a);
if (r < 0) {
log_error("Failed to start bus client: %s", strerror(-r));
log_debug("Failed to rename process: %s", strerror(-r));
if (a->is_kernel) {
- _cleanup_free_ char *match;
+ _cleanup_free_ char *match = NULL;
const char *unique;
r = sd_bus_get_unique_name(a, &unique);