To prevent the request freed in req->process().
This also makes a request that is not requested by a link detached on failure.
Otherwise, the request may periodically processed and failed forever.
Let's rename return parameters to ret_xyz, and let's guarantee the usual
rule to initialize all return parameters on success, and not touch any
on failure.
Don't recalculate the overall offset entirely each time we process
another header. Instead, if we already validated an earlier offset, just
reuse the result, it's readily available in 'p'.
No change in behaviour, just a bit of code simplification.
A positive return value means "access granted", hence if we already
reply to the method call don't accidentally return positive.
Follow-up for: d04c1a1c8e
varlink_server_listen_auto() is supposed to be the one-stop solution for
turning simple command line tools into IPC services. They aren't easy to
test/debug however, since you have to invoke them through a service
manager.
Let's make this easier: if the SYSTEMD_VARLINK_LISTEN env var is set,
let's listen on the socket specified therein. This makes things easier
to gdb: just run the service from the cmdline.
Let's improve debuggability of varlink IPC transactions, and separate
out log messages triggered by the IPC info from others, by prefixing
them with a specific prefix.
If a nexthop is removed, dependent nexthops are silently removed by the
kernel. Hence, networkd may be confused that nexthops that depends on the
nexthop still exist, and may fail to configure other routes or so.
Also, this renames 'req' -> 'm', and makes the function unconditionally
set route type and route metric, and override type later if necessary.
Should not change any effective behavior. Just refactoring.
We would use alloca to extend the format string with "\n". We do this
automatically in order to not forget appending the newline everywhere.
We can simplify the whole thing by using a macro to append the newline instead,
which means that we don't need to copy the string.
Because we concatenate the string argument with another literal string, we know
it must a literal string. Thus it's not a problem that it is "evaluated" two
times.
Quoting Hristo Venev:
> Since commit f5e757f1ce, mhd_respond() adds a
> newline to its argument before passing it on to mhd_respond_internal(). This
> is done via an alloca()-allocated buffer. However, MHD_RESPMEM_PERSISTENT is
> given as a flag to MHD_create_response_from_buffer(), leading to a
> use-after-free later when the response is sent. Replacing
> MHD_RESPMEM_PERSISTENT with MHD_RESPMEM_MUST_COPY appears to fix the issue.
MHD_RESPMEM_MUST_COPY would work, but we also use mhd_respond() for mhd_oom(),
and we don't want to allocate in an oom scenario in order to maximize the
possibility that an answer will be delivered. Using the macro magic makes this
nicer and we get rid of the code doing alloca.
Fixes an issue reported by Hristo Venev.
Fixes https://github.com/systemd/systemd/issues/9858.
The previous wording of the components could mean that we should only
watch directories, not the socket itself. Reword so that we clearly
mention that all components of the path are watched, including the
socket itself.
With the `--image` option, the `running_in_chroot` check is not enough. E.g.:
```
> build/systemctl --image /tmp/20240108-openSUSE.raw is-system-running
running
```
A MultipathRoute object is always owned by a Network object, and the
interface matching with its name specified in a MultipathRoute= setting
may be removed, and re-added later with a different ifindex.