-
Notifications
You must be signed in to change notification settings - Fork 1
clear logs, shell history, ssh keys and networks #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Caution Review failedThe pull request is closed. """ WalkthroughA default Changes
Assessment against linked issues
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (3)
rootfiles/etc/wpa_supplicant/wpa_supplicant.conf (2)
1-9
: Verify group membership for control interface.Using
ctrl_interface_group=wheel
assumes thewheel
group exists on the target system and has the necessary rights to manage wpa_supplicant sockets. On many Linux distributions, interfaces are assigned tonetdev
or a custom group. Ensure that:
- The
wheel
group is present on your target OS.- Users needing Wi-Fi access are members of
wheel
, or switch this tonetdev
(or appropriate group).
11-11
: Provide example network block.The placeholder
# Add here your networks.
could confuse users unfamiliar withwpa_supplicant.conf
syntax. Consider including a commented sample stanza:# network={ # ssid="YourSSID" # psk="YourPSK" # }
This will make onboarding and customization easier.
tools/finalize-nakamochi.sh (1)
299-300
: Handle missing files and directory safety.
rm "$USD_MOUNT_POINT"/root/.bash_history
will error if the file is already gone; userm -f
to suppress the error.echo > "$USD_MOUNT_POINT"/root/.ssh/authorized_keys
assumesroot/.ssh
exists. If the directory is missing, this will fail. Either:
- Ensure the directory exists (
mkdir -p …/.ssh
), or- Guard with an
if [[ -d …/.ssh ]]; then …; fi
.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
rootfiles/etc/wpa_supplicant/wpa_supplicant.conf
(1 hunks)tools/finalize-nakamochi.sh
(1 hunks)
for d in "$USD_MOUNT_POINT"/var/log/socklog/*; do echo > "$d/current"; done | ||
rm "$USD_MOUNT_POINT"/root/.bash_history | ||
echo > "$USD_MOUNT_POINT"/root/.ssh/authorized_keys | ||
cp "$(dirname "$0")"/../rootfiles/etc/wpa_supplicant/wpa_supplicant.conf "$USD_MOUNT_POINT"/etc/wpa_supplicant/wpa_supplicant.conf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Avoid brittle relative paths for config copy.
Relying on $(dirname "$0")/../rootfiles/...
couples the script’s runtime location to the source tree layout. Consider:
- Adding a CLI flag or environment variable for the
rootfiles
base path. - Verifying the source file exists before
cp
, and exiting on failure. - Using
install -m 600
(orcp --preserve=mode
) to set correct permissions on the deployed wpa_supplicant.conf.
🤖 Prompt for AI Agents
In tools/finalize-nakamochi.sh at line 301, the script uses a brittle relative
path to copy wpa_supplicant.conf, which depends on the script's runtime
location. Refactor by introducing a CLI flag or environment variable to specify
the rootfiles base path, check if the source file exists before copying and exit
with an error if not, and replace the cp command with install -m 600 or cp
--preserve=mode to ensure the copied file has correct permissions.
rm -f "$USD_MOUNT_POINT"/var/log/* 2> /dev/null | ||
for d in "$USD_MOUNT_POINT"/var/log/socklog/*; do echo > "$d/current"; done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Use recursive and safe log cleanup.
The command
rm -f "$USD_MOUNT_POINT"/var/log/*
only removes top-level files and leaves directories intact. For a complete wipe of log contents, consider:
- rm -f "$USD_MOUNT_POINT"/var/log/*
+ # Enable nullglob to avoid literal “*” when no files exist
+ shopt -s nullglob
+ # Delete all files under var/log recursively
+ find "$USD_MOUNT_POINT/var/log" -type f -delete
+ # (Optional) remove empty directories
+ find "$USD_MOUNT_POINT/var/log" -type d -empty -delete
This ensures all files in subdirectories are also removed and guards against globbing errors.
🤖 Prompt for AI Agents
In tools/finalize-nakamochi.sh around lines 297 to 298, the rm command only
deletes top-level files in the log directory and does not remove files inside
subdirectories. Replace the rm command with a recursive and safe deletion
method, such as using rm -rf on the log directory contents or find with -delete,
to ensure all files including those in subdirectories are removed without
causing globbing errors.
Resolves #18.
Summary by CodeRabbit