Merge "trusty: rpmb_dev: Use socket from init and update init script" into main

This commit is contained in:
Treehugger Robot 2024-03-19 21:28:30 +00:00 committed by Gerrit Code Review
commit f52256ea25
3 changed files with 36 additions and 25 deletions

View file

@ -24,6 +24,7 @@ cc_binary {
],
shared_libs: [
"libc",
"libcutils",
"liblog",
"libcrypto",
],

View file

@ -19,6 +19,7 @@
#include "rpmb_protocol.h"
#include <assert.h>
#include <cutils/sockets.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
@ -613,20 +614,24 @@ int main(int argc, char** argv) {
return EXIT_FAILURE;
}
cmdres_sock = socket(AF_UNIX, SOCK_STREAM, 0);
cmdres_sock = android_get_control_socket(socket_path);
if (cmdres_sock < 0) {
ALOGE("rpmb_dev: Failed to create command/response socket: %s\n", strerror(errno));
return EXIT_FAILURE;
}
ALOGW("android_get_control_socket(%s) failed, fall back to create it\n", socket_path);
cmdres_sock = socket(AF_UNIX, SOCK_STREAM, 0);
if (cmdres_sock < 0) {
ALOGE("rpmb_dev: Failed to create command/response socket: %s\n", strerror(errno));
return EXIT_FAILURE;
}
cmdres_sockaddr.sun_family = AF_UNIX;
strncpy(cmdres_sockaddr.sun_path, socket_path, sizeof(cmdres_sockaddr.sun_path));
cmdres_sockaddr.sun_family = AF_UNIX;
strncpy(cmdres_sockaddr.sun_path, socket_path, sizeof(cmdres_sockaddr.sun_path));
ret = bind(cmdres_sock, (struct sockaddr*)&cmdres_sockaddr, sizeof(struct sockaddr_un));
if (ret < 0) {
ALOGE("rpmb_dev: Failed to bind command/response socket: %s: %s\n", socket_path,
strerror(errno));
return EXIT_FAILURE;
ret = bind(cmdres_sock, (struct sockaddr*)&cmdres_sockaddr, sizeof(struct sockaddr_un));
if (ret < 0) {
ALOGE("rpmb_dev: Failed to bind command/response socket: %s: %s\n", socket_path,
strerror(errno));
return EXIT_FAILURE;
}
}
ret = listen(cmdres_sock, 1);

View file

@ -1,29 +1,34 @@
# RPMB Mock
on post-fs-data
mkdir /data/vendor/ss
chown root system /data/vendor/ss
chmod 0770 /data/vendor/ss
rm /data/vendor/ss/rpmb_sock
start rpmb_mock_init
on post-fs
mkdir /mnt/vendor/persist/ss 0770 root system
exec_start rpmb_mock_init
start rpmb_mock
on post-fs-data
mkdir /data/vendor/ss 0770 root system
symlink /mnt/vendor/persist/ss /data/vendor/ss/persist
chown root system /data/vendor/ss/persist
chmod 0770 /data/vendor/ss/persist
# Storage proxy
start storageproxyd
restart storageproxyd
service storageproxyd /vendor/bin/storageproxyd -d /dev/trusty-ipc-dev0 \
-r /data/vendor/ss/rpmb_sock -p /data/vendor/ss -t sock
class main
disabled
user root
service storageproxyd /vendor/bin/storageproxyd -d ${ro.hardware.trusty_ipc_dev:-/dev/trusty-ipc-dev0} \
-r /dev/socket/rpmb_mock -p /data/vendor/ss -t sock
class early_hal
user system
group system
service rpmb_mock_init /vendor/bin/rpmb_dev --dev /data/vendor/ss/RPMB_DATA --init --size 2048
service rpmb_mock_init /vendor/bin/rpmb_dev --dev /mnt/vendor/persist/ss/RPMB_DATA --init --size 2048
disabled
user system
group system
oneshot
service rpmb_mock /vendor/bin/rpmb_dev --dev /data/vendor/ss/RPMB_DATA --sock /data/vendor/ss/rpmb_sock
service rpmb_mock /vendor/bin/rpmb_dev --dev /mnt/vendor/persist/ss/RPMB_DATA \
--sock rpmb_mock
class main
disabled
user system
group system
socket rpmb_mock stream 660 system system