Secret: handle empty stdin read, explicit dir perms
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QKxGW1raAWaqeU8WdHsMsp
This commit is contained in:
@@ -30,7 +30,7 @@ set)
|
||||
read -rs -p "API key for $provider: " key
|
||||
echo
|
||||
else
|
||||
IFS= read -r key
|
||||
IFS= read -r key || true
|
||||
fi
|
||||
if [[ -z $key ]]; then
|
||||
echo "Empty key refused" >&2
|
||||
@@ -43,7 +43,8 @@ set)
|
||||
printf '%s\n' "$key" | pass insert -m -f "omarchycn/ai/$provider" > /dev/null
|
||||
echo "Stored in pass (omarchycn/ai/$provider)"
|
||||
else
|
||||
mkdir -p -m 700 "$FILE_DIR"
|
||||
mkdir -p "$FILE_DIR"
|
||||
chmod 700 "$FILE_DIR"
|
||||
(umask 177 && printf '%s' "$key" > "$FILE_PATH")
|
||||
echo "Stored in $FILE_PATH (0600 file fallback — 安装 libsecret 或 pass 可获得更安全的存储)"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user