If we got to device_close(), the parent SSH might have been exited,
making standard file descriptors unusable. Rebind them to /dev/null, so
that any output during device_close (both from the cdba server and the
helpers) doesn't cause SIGPIPE.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Instad of hand-coding message sending, create a single wrapper that
sends messages to the client.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Limit access control to the boards according to the passed username. If
the user has no access, the board becoms completely invisible: it is not
listed, it is not possible to fetch board description, etc.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Don't count the timers, as it's not used anywhere. Clang is unhappy with that:
cdba-server.c:307:6: warning: variable 'count' set but not used [-Wunused-but-set-variable]
int count = 0;
Signed-off-by: Konrad Dybcio <konradybcio@kernel.org>
Pointer arithmetic should not be done on void pointers.
cdba-server.c:146:21: warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith]
146 | memcpy(newp + fastboot_size, data, len);
| ^
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Notify users of cdba-server when fastboot connection is opened to ease
remote debugging of issues.
Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
In the case that we quit without actually having opened a device this
would dereference a NULL pointer, so check the device before doing so.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
As cdba-server exits it turns off power, which used to cut VBUS as well,
but since the refactoring only cuts power. Reintroduce the VBUS toggle
to ensure the device doesn't stay powered through USB after use.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Squash the power_on and power_off into a single "power" function, to
harmonize the code wrt the USB handling.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
In order to sleep for fractions of a second in alpaca, change the
timeout from seconds to milliseconds.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Make the fastboot key handling a property of the device configuration
and use the newly introduced timeout mechanism for handling it.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
It's useful to be able to invoke some operation in the future, such as
releasing a key. Add support for registering and executing callbacks in
the future.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Add a new keyword "description" to the config file, add the necessary
wire protocol to acquire this string for a given device and introduce
the "-i" option to cdba to trigger its retrieval.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
After attempting to read .cdba, fall back to read /etc/cdba - to make it
possible to provide system wide configuration for a multiple users.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Add a new argument '-l' which in combination with '-h' will connect to
said server and list the attached devices, then exit.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
The cdb_assist implementation of tty_open() can be reused by other
files, so let's move it to cdba-server.c.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>