Skip to content

Commit 8070ff9

Browse files
committed
fix(install): set correct ownership and permissions for user config files
When installer runs with sudo, config directory and file were created with root ownership, making them inaccessible to the user. Now: - Config directory set to 700 (owner-only access) - Config file set to 600 (owner read/write only) - Ownership transferred to $SUDO_USER when running with sudo
1 parent 1118f99 commit 8070ff9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

install.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,12 @@ install_config_files() {
187187
local config_dir="$HOME/.config/llm-env"
188188
local config_file="$config_dir/config.conf"
189189

190-
# Create config directory
190+
# Create config directory with proper permissions
191191
if ! mkdir -p "$config_dir"; then
192192
print_error "Failed to create config directory: $config_dir"
193193
return 1
194194
fi
195+
chmod 700 "$config_dir"
195196

196197
# Check if config already exists
197198
if [[ -f "$config_file" ]]; then
@@ -247,6 +248,14 @@ description=DeepSeek, excellent coding and reasoning models
247248
enabled=false
248249
EOF
249250
then
251+
# Set appropriate permissions (readable/writable by owner only for security)
252+
chmod 600 "$config_file"
253+
254+
# Fix ownership if running with sudo
255+
if [[ -n "${SUDO_USER:-}" ]] && [[ "${SUDO_USER:-}" != "root" ]]; then
256+
chown "$SUDO_USER" "$config_dir" "$config_file" 2>/dev/null || true
257+
fi
258+
250259
print_success "Created default configuration: $config_file"
251260
else
252261
print_error "Failed to create configuration file"

0 commit comments

Comments
 (0)