}
static int change_uid_gid(const Context *context) {
+ int r;
+
+ assert(context);
+
uid_t uid = context->uid;
gid_t gid = context->gid;
- int r;
if (uid_is_system(uid)) {
const char *user = "systemd-coredump";
* what we want to send, and the second one contains
* the trailing dots. */
copy[0] = iovw->iovec[i];
- copy[1] = IOVEC_MAKE(((char[]){'.', '.', '.'}), 3);
+ copy[1] = IOVEC_MAKE(((const char[]){'.', '.', '.'}), 3);
mh.msg_iov = copy;
mh.msg_iovlen = 2;
Context *context,
int argc, char **argv) {
- _cleanup_free_ char *free_timestamp = NULL;
int r, signo;
- char *t;
assert(iovw);
assert(context);
argc, _META_ARGV_MAX);
for (int i = 0; i < _META_ARGV_MAX; i++) {
-
- t = argv[i];
+ _cleanup_free_ char *buf = NULL;
+ const char *t = argv[i];
switch (i) {
* zeroes, so that the kernel-supplied 1s granularity timestamps
* becomes 1μs granularity, i.e. the granularity systemd usually
* operates in. */
- t = free_timestamp = strjoin(argv[i], "000000");
- if (!t)
+ buf = strjoin(argv[i], "000000");
+ if (!buf)
return log_oom();
+
+ t = buf;
break;
case META_ARGV_SIGNAL:
return save_context(context, iovw);
}
-static int send_ucred(int transport_fd, struct ucred *ucred) {
+static int send_ucred(int transport_fd, const struct ucred *ucred) {
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct ucred))) control = {};
struct msghdr mh = {
.msg_control = &control,
struct cmsghdr *cmsg;
assert(transport_fd >= 0);
+ assert(ucred);
cmsg = CMSG_FIRSTHDR(&mh);
*cmsg = (struct cmsghdr) {
struct ucred *ucred = NULL;
ssize_t n;
+ assert(transport_fd >= 0);
assert(ret_ucred);
n = recvmsg_safe(transport_fd, &mh, 0);
char buf[DECIMAL_STR_MAX(pid_t)];
const char *t = context->meta[i];
+ /* Patch some of the fields with the translated ucred data */
switch (i) {
case META_ARGV_PID:
xsprintf(buf, PID_FMT, ucred.pid);
t = buf;
-
break;
case META_ARGV_UID:
char *message;
int r;
+ assert(argc >= 2);
+
log_debug("Processing backtrace on stdin...");
iovw = iovw_new();