19 Commits

Author SHA1 Message Date
Dmitry Baryshkov
18bae8dec9 cdba: remove unnecessary initialisation
Silence Clang warning by removing unused '0' from struct initialisation.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2023-11-06 12:21:18 +00:00
Dmitry Baryshkov
a0de781e1b cdba-server: sanitise file descriptors before device_close()
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>
2023-10-02 17:33:13 +03:00
Dmitry Baryshkov
771910e186 cdba-server: extract message-sending helper
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>
2023-09-29 00:45:25 +03:00
Dmitry Baryshkov
3ea8df6c70 device: implement access control to the boards
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>
2023-09-23 16:50:11 +03:00
Konrad Dybcio
5850ee756d cdba-server: Remove dead code
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>
2023-09-21 09:24:24 +02:00
Krzysztof Kozlowski
7e577538fc cdba-server: fix -Wpointer-arith
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>
2023-05-08 15:02:37 -05:00
Krzysztof Kozlowski
ca2d4b08dd cdba-server: correct cast to fix -Wcast-qual
Fixes:

  cdba-server.c: In function ‘fastboot_info’:
  cdba-server.c:98:33: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
     98 |         fprintf(stderr, "%s\n", (char *)buf);
        |                                 ^

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-05-08 15:02:37 -05:00
Dmitry Baryshkov
42f8108e7c cdba-server: notify users when fastboot connection is opened
Notify users of cdba-server when fastboot connection is opened to ease
remote debugging of issues.

Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
2022-02-08 09:09:13 -08:00
Bjorn Andersson
7c231568aa cdba-server: Don't close what wasn't opened
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>
2021-01-25 18:49:21 -06:00
Bjorn Andersson
840b737c14 cdba-server: Disconnect USB as well on exit
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>
2021-01-25 17:32:07 -06:00
Bjorn Andersson
1abac8b200 device: Combine power_on/power_off througout
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>
2021-01-22 18:52:03 -06:00
Bjorn Andersson
decff00617 cdba-server: Change watch timers to ms
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>
2020-10-29 23:44:18 -05:00
Bjorn Andersson
7dbd49c4d2 device: Add fastboot_key_timeout
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>
2020-10-29 18:18:56 -05:00
Bjorn Andersson
b823fa0172 cdba-server: Add support for oneshot timers
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>
2020-10-29 18:17:43 -05:00
Bjorn Andersson
4cabc1c827 Support device "description"
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>
2020-06-29 01:02:57 -07:00
Bjorn Andersson
a2a11706df device_parser: Fall back to read /etc/cdba
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>
2020-06-29 00:07:16 -07:00
Bjorn Andersson
d094208e7c cdba: Add support for listing boards
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>
2020-06-28 23:47:56 -07:00
Bjorn Andersson
ee62217745 cdba-server: Move tty_open() to common file
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>
2020-06-27 22:35:13 -07:00
Amit Kucheria
c5cbe74df2 bad: Rename to cdba-server
cdba-server more accurately reflects its purpose now.

Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
2020-06-10 10:10:23 -07:00