Add "find_new_uid" script. This script automates the process of finding a new UID to use by examing all currently-in-use UIDs. BUG=None TEST=Manually ran script and verified that output was correct. Change-Id: If09aff0b4f3c01a30d8de949a3caa35600ece63f Reviewed-on: https://chromium-review.googlesource.com/1600372 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Miriam Zimmerman <mutexlox@chromium.org> Reviewed-by: LaMont Jones <lamontjones@chromium.org>
diff --git a/profiles/base/accounts/README.md b/profiles/base/accounts/README.md index a592cd5..efd623d 100644 --- a/profiles/base/accounts/README.md +++ b/profiles/base/accounts/README.md
@@ -52,7 +52,8 @@ CrOS system daemon UIDs (and associated GIDs) range from 200-299 and from 20100-29999. If you're creating a new user, pick the first UID in the range 20100-29999 that is not currently used, and create both a user -and a group with this ID. +and a group with this ID. To find the next available UID, invoke +`./find_new_uid.sh`. FUSE-based filesystem daemons have UID/GIDs that range from 300-399. If you're adding a daemon that will be talking to `cros-disks` and
diff --git a/profiles/base/accounts/find_new_uid.sh b/profiles/base/accounts/find_new_uid.sh new file mode 100755 index 0000000..8fd0f0a --- /dev/null +++ b/profiles/base/accounts/find_new_uid.sh
@@ -0,0 +1,9 @@ +#!/bin/bash +set -euo pipefail + +files="$(dirname $0)/user/*" +echo -n "Your new UID is: " +awk --field-separator : ' + BEGIN { max = 20099 } + /^uid:/ { if ($2 <= 29999 && $2 > max) max = $2 } + END { print max + 1}' $files