Skip to content

Commit

Permalink
Print user IDs instead of usernames in config sanity checks
Browse files Browse the repository at this point in the history
  • Loading branch information
dezeroku authored and anatol committed Feb 18, 2024
1 parent 41cd5ae commit 8f985fd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ Alternatively, you can use docker-compose:
version: "3.8"
services:
pacoloco:
# if a specific user id is provided, you have to make sure
# the mounted directories have the same user id owner on host
# user: 1000:1000
container_name: pacoloco
# to pull the image from github's registry:
image: ghcr.io/anatol/pacoloco
Expand Down
14 changes: 3 additions & 11 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"log"
"os/user"
"os"
"time"

"github.com/gorhill/cronexpr"
Expand Down Expand Up @@ -73,11 +73,7 @@ func parseConfig(raw []byte) *Config {
}
// validate Mirrorlist config
if repo.Mirrorlist != "" && unix.Access(repo.Mirrorlist, unix.R_OK) != nil {
u, err := user.Current()
if err != nil {
log.Fatal(err)
}
log.Fatalf("mirrorlist file %v for repo %v does not exist or isn't readable for user %v", repo.Mirrorlist, name, u.Username)
log.Fatalf("mirrorlist file %v for repo %v does not exist or isn't readable for userid %v", repo.Mirrorlist, name, os.Getuid())
}
}

Expand All @@ -86,11 +82,7 @@ func parseConfig(raw []byte) *Config {
}

if unix.Access(result.CacheDir, unix.R_OK|unix.W_OK) != nil {
u, err := user.Current()
if err != nil {
log.Fatal(err)
}
log.Fatalf("directory %v does not exist or isn't writable for user %v", result.CacheDir, u.Username)
log.Fatalf("directory %v does not exist or isn't writable for userid %v", result.CacheDir, os.Getuid())
}
// validate Prefetch config

Expand Down

0 comments on commit 8f985fd

Please sign in to comment.