Fix starter permissions for deployment
Change-Id: I6ec93304c6979051d7c561d5bf2bc98ca612d4bf
diff --git a/aos/starter/BUILD b/aos/starter/BUILD
index 52fd62a..8ad3dbf 100644
--- a/aos/starter/BUILD
+++ b/aos/starter/BUILD
@@ -5,7 +5,8 @@
name = "starter",
srcs = [
"starter.sh",
- "starter_exe",
+ "starterd",
+ "starter_cmd",
],
visibility = ["//visibility:public"],
)
diff --git a/aos/starter/starter.sh b/aos/starter/starter.sh
index e140351..72f69a4 100755
--- a/aos/starter/starter.sh
+++ b/aos/starter/starter.sh
@@ -16,5 +16,5 @@
cd "${ROBOT_CODE}"
export PATH="${PATH}:${ROBOT_CODE}"
while true; do
- starter_exe $ROBOT_CODE/start_list.txt 2>&1
+ starterd 2>&1
done
diff --git a/aos/starter/starterd_lib.cc b/aos/starter/starterd_lib.cc
index 5c64201..1c32be3 100644
--- a/aos/starter/starterd_lib.cc
+++ b/aos/starter/starterd_lib.cc
@@ -84,7 +84,7 @@
}
if (user_) {
- if (seteuid(*user_) == -1 || setfsuid(*user_) == -1) {
+ if (setuid(*user_) == -1) {
write_pipe_.Write(
static_cast<uint32_t>(aos::starter::LastStopReason::SET_USR_ERR));
PLOG(FATAL) << "Could not set user for " << name_ << " to " << *user_;
@@ -476,6 +476,10 @@
}
void Starter::Run() {
+#ifdef AOS_ARCHITECTURE_arm_frc
+ PCHECK(setuid(0) == 0) << "Failed to change user to root";
+#endif
+
for (auto &application : applications_) {
application.second.Start();
}