sd_bus_creds_get_audit_login_uid;
sd_bus_creds_get_unique_name;
sd_bus_creds_get_well_known_names;
+ sd_bus_creds_get_connection_name;
/* Error structures */
sd_bus_error_free;
cmd = alloca0(size);
strcpy(cmd->name, name);
}
- cmd->flags = KDBUS_ATTACH_NAMES;
cmd->size = size;
+ kdbus_translate_attach_flags(mask, (uint64_t*) &cmd->flags);
+
r = ioctl(bus->input_fd, KDBUS_CMD_CONN_INFO, cmd);
if (r < 0)
return -errno;
c->mask |= SD_BUS_CREDS_WELL_KNOWN_NAMES;
}
break;
+
+ case KDBUS_ITEM_CONN_NAME:
+ if ((mask & SD_BUS_CREDS_CONNECTION_NAME)) {
+ c->conn_name = strdup(item->str);
+ if (!c->conn_name) {
+ r = -ENOMEM;
+ goto fail;
+ }
+
+ c->mask |= SD_BUS_CREDS_CONNECTION_NAME;
+ }
+ break;
}
}
free(c->label);
free(c->unique_name);
free(c->cgroup_root);
+ free(c->conn_name);
free(c);
}
} else {
return 0;
}
+_public_ int sd_bus_creds_get_connection_name(sd_bus_creds *c, const char **ret) {
+ assert_return(c, -EINVAL);
+ assert_return(ret, -EINVAL);
+
+ if (!(c->mask & SD_BUS_CREDS_CONNECTION_NAME))
+ return -ENODATA;
+
+ assert(c->conn_name);
+ *ret = c->conn_name;
+ return 0;
+}
+
static int has_cap(sd_bus_creds *c, unsigned offset, int capability) {
size_t sz;
char **well_known_names;
char *cgroup_root;
+
+ char *conn_name;
};
sd_bus_creds* bus_creds_new(void);
fprintf(f, " TIDComm=%s", c->tid_comm);
if (c->mask & SD_BUS_CREDS_SELINUX_CONTEXT)
fprintf(f, " Label=%s", c->label);
+ if (c->mask & SD_BUS_CREDS_CONNECTION_NAME)
+ fprintf(f, " ConnectionName=%s", c->conn_name);
- if (c->mask & (SD_BUS_CREDS_EXE|SD_BUS_CREDS_COMM|SD_BUS_CREDS_TID_COMM|SD_BUS_CREDS_SELINUX_CONTEXT))
+ if (c->mask & (SD_BUS_CREDS_EXE|SD_BUS_CREDS_COMM|SD_BUS_CREDS_TID_COMM|SD_BUS_CREDS_SELINUX_CONTEXT|SD_BUS_CREDS_CONNECTION_NAME))
fputs("\n", f);
if (sd_bus_creds_get_cmdline(c, &cmdline) >= 0) {
goto fail;
break;
+ case KDBUS_ITEM_CONN_NAME:
+ m->creds.conn_name = d->str;
+ m->creds.mask |= SD_BUS_CREDS_CONNECTION_NAME & bus->creds_mask;
+ break;
+
case KDBUS_ITEM_FDS:
case KDBUS_ITEM_SECLABEL:
break;
if (mask & SD_BUS_CREDS_WELL_KNOWN_NAMES)
m |= KDBUS_ATTACH_NAMES;
+ if (mask & SD_BUS_CREDS_CONNECTION_NAME)
+ m |= KDBUS_ATTACH_CONN_NAME;
+
*kdbus_mask = m;
return 0;
}
SD_BUS_CREDS_AUDIT_LOGIN_UID = 1ULL << 21,
SD_BUS_CREDS_UNIQUE_NAME = 1ULL << 22,
SD_BUS_CREDS_WELL_KNOWN_NAMES = 1ULL << 23,
- _SD_BUS_CREDS_ALL = (1ULL << 24) -1,
+ SD_BUS_CREDS_CONNECTION_NAME = 1ULL << 24,
+ _SD_BUS_CREDS_ALL = (1ULL << 25) -1,
};
enum {
int sd_bus_creds_get_audit_login_uid(sd_bus_creds *c, uid_t *loginuid);
int sd_bus_creds_get_unique_name(sd_bus_creds *c, const char **name);
int sd_bus_creds_get_well_known_names(sd_bus_creds *c, char ***names);
+int sd_bus_creds_get_connection_name(sd_bus_creds *c, const char **name);
/* Error structures */