Start irq_affinity and run starterd as root
irq_affinity needs to run as root, but all our software needs to run as
the pi. Setup starter to run as root, and then have it start everything
as the pi user.
Change-Id: I2d09c33345f125ba47bf8d89b921ef5b45aa2826
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/aos/starter/starter.sh b/aos/starter/starter.sh
index 9bc7605..d4281c5 100755
--- a/aos/starter/starter.sh
+++ b/aos/starter/starter.sh
@@ -14,7 +14,7 @@
# We have systemd configured to handle restarting, so just exec.
export PATH="${PATH}:/home/pi/bin"
rm -rf /dev/shm/aos
- exec starterd
+ exec starterd --user=pi
else
ROBOT_CODE="${HOME}/bin"
fi
diff --git a/aos/starter/starterd.cc b/aos/starter/starterd.cc
index f284819..54f1bb4 100644
--- a/aos/starter/starterd.cc
+++ b/aos/starter/starterd.cc
@@ -31,7 +31,7 @@
constexpr int kUnchanged = -1;
if (setresgid(/* ruid */ gid, /* euid */ gid,
/* suid */ kUnchanged) != 0) {
- PLOG(FATAL) << "Failed to change GID to " << FLAGS_user;
+ PLOG(FATAL) << "Failed to change GID to " << FLAGS_user << ", group " << gid;
}
if (setresuid(/* ruid */ uid, /* euid */ uid,
diff --git a/frc971/downloader/downloader.py b/frc971/downloader/downloader.py
index bed72b9..f45a162 100644
--- a/frc971/downloader/downloader.py
+++ b/frc971/downloader/downloader.py
@@ -103,7 +103,8 @@
# permissions or the executables won't be visible to init.
os.chmod(temp_dir, 0o775)
# Starter needs to be SUID so we transition from lvuser to admin.
- os.chmod(os.path.join(temp_dir, "starterd"), 0o775 | stat.S_ISUID)
+ if args.type != "pi":
+ os.chmod(os.path.join(temp_dir, "starterd"), 0o775 | stat.S_ISUID)
rsync_cmd = ([
"external/rsync/usr/bin/rsync",
diff --git a/y2023/BUILD b/y2023/BUILD
index c90f0e6..60764ce 100644
--- a/y2023/BUILD
+++ b/y2023/BUILD
@@ -21,6 +21,7 @@
"//aos/network:message_bridge_client",
"//aos/network:message_bridge_server",
"//aos/network:web_proxy_main",
+ "//aos/starter:irq_affinity",
"//y2023/vision:camera_reader",
],
target_compatible_with = ["//tools/platforms/hardware:raspberry_pi"],
diff --git a/y2023/y2023_pi_template.json b/y2023/y2023_pi_template.json
index 20e6c1c..2bf45bb 100644
--- a/y2023/y2023_pi_template.json
+++ b/y2023/y2023_pi_template.json
@@ -275,13 +275,24 @@
"name": "message_bridge_client",
"executable_name": "message_bridge_client",
"args": ["--rt_priority=16"],
+ "user": "pi",
"nodes": [
"pi{{ NUM }}"
]
},
{
+ "name": "irq_affinity",
+ "executable_name": "irq_affinity",
+ "user": "root",
+ "args": ["--user=pi"],
+ "nodes": [
+ "pi{{ NUM }}"
+ ]
+ },
+ {
"name": "message_bridge_server",
"executable_name": "message_bridge_server",
+ "user": "pi",
"nodes": [
"pi{{ NUM }}"
]
@@ -289,6 +300,7 @@
{
"name": "web_proxy",
"executable_name": "web_proxy_main",
+ "user": "pi",
"nodes": [
"pi{{ NUM }}"
]
@@ -297,6 +309,7 @@
"name": "camera_reader",
"executable_name": "camera_reader",
"args": ["--enable_ftrace"],
+ "user": "pi",
"nodes": [
"pi{{ NUM }}"
]