Skip to content

fixperms.sh has wrong syntax for chown #64

@Zugschlus

Description

@Zugschlus

Support guidelines

I've found a bug and checked that ...

  • ... the documentation does not mention anything about my problem
  • ... there are no open or closed issues that are related to my problem

Description

Hi,

# cat /etc/cont-init.d/02-fix-perms.sh 
#!/usr/bin/with-contenv sh

echo "Fixing perms..."
mkdir -p /data/db \
  /data/journal \
  /var/run/rrdcached
chown rrdcached. \
  /data/db \
  /data/journal
chown -R rrdcached. \
  /var/run/rrdcached

Thise chown calls fail since rrdcached. is deprecated syntax:

/data # ls -al /data/rrd
total 8
drwxr-xr-x    2 root     root          4096 Feb  7 15:24 .
drwxr-xr-x    1 root     root          4096 Feb  7 15:26 ..
/data # chown rrdcached. /data/rrd
chown: unknown user rrdcached.
/data # chown rrdcached /data/rrd
/data # ls -al /data/rrd
total 8
drwxr-xr-x    2 rrdcached root          4096 Feb  7 15:24 .
drwxr-xr-x    1 root     root          4096 Feb  7 15:26 ..

Depending on what you want, you should either chown to rrdcached or rrdcached:rrdcached

Expected behaviour

I'd expexct my rrdcached to be able to create directories in its rrd directory. It can't do that if the directory is still owned by root.

Actual behaviour

The chown fails an nothing gets created.

Steps to reproduce

docker run --rm -it --volume testvolume20260207:/data/rrd/ --name rrdcached-test crazymax/rrdcached sh
see owner of /data/rrd

Docker info

Client: Docker Engine - Community
 Version:    29.1.3
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.30.1
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v5.0.0
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 11
  Running: 11
  Paused: 0
  Stopped: 0
 Images: 11
 Server Version: 29.1.3
 Storage Driver: overlayfs
  driver-type: io.containerd.snapshotter.v1
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 CDI spec directories:
  /etc/cdi
  /var/run/cdi
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 1c4457e00facac03ce1d75f7b6777a7a851e5c41
 runc version: v1.3.4-0-gd6d73eb8
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.12.57+deb13-amd64
 Operating System: Debian GNU/Linux 13 (trixie)
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 3.792GiB
 Name: dck001
 ID: 33cffbab-be83-4c01-aecd-76e644362fa3
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  ::1/128
  127.0.0.0/8
 Live Restore Enabled: false
 Firewall Backend: iptables

Docker Compose config

n/a, can be reproduced with plain docker.

Logs

$ docker run --rm -it --volume testvolume20260207:/data/rrd/ --name rrdcached-test crazymax/rrdcached  sh
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-fix-logs.sh: executing... 
[cont-init.d] 00-fix-logs.sh: exited 0.
[cont-init.d] 01-fix-uidgid.sh: executing... 
[cont-init.d] 01-fix-uidgid.sh: exited 0.
[cont-init.d] 02-fix-perms.sh: executing... 
Fixing perms...
chown: unknown user rrdcached.
chown: unknown user rrdcached.
[cont-init.d] 02-fix-perms.sh: exited 1.
[cont-init.d] 04-svc-main.sh: executing... 
[cont-init.d] 04-svc-main.sh: exited 0.
[cont-init.d] ~-socklog: executing... 
[cont-init.d] ~-socklog: exited 0.
[cont-init.d] done.
[services.d] starting services
starting up
setgid(1000) succeeded
setuid(1000) succeeded
checking for journal files
JOURNALING DISABLED: Error while trying to create /data/journal/rrd.journal.1770477969.480643 : Permission denied
JOURNALING DISABLED: All values will be flushed at shutdown
journal processing complete
listening for connections[services.d] done.

/data # daemon.info: Feb  7 15:26:09 rrdcached[430]: starting up
daemon.info: Feb  7 15:26:09 rrdcached[430]: setgid(1000) succeeded
daemon.info: Feb  7 15:26:09 rrdcached[430]: setuid(1000) succeeded
daemon.info: Feb  7 15:26:09 rrdcached[430]: checking for journal files
daemon.crit: Feb  7 15:26:09 rrdcached[430]: JOURNALING DISABLED: Error while trying to create /data/journal/rrd.journal.1770477969.480643 : Permission denied
daemon.crit: Feb  7 15:26:09 rrdcached[430]: JOURNALING DISABLED: All values will be flushed at shutdown
daemon.info: Feb  7 15:26:09 rrdcached[430]: journal processing complete
daemon.info: Feb  7 15:26:09 rrdcached[430]: listening for connections

/data # ls -al /data/rrd
total 8
drwxr-xr-x    2 root     root          4096 Feb  7 15:24 .
drwxr-xr-x    1 root     root          4096 Feb  7 15:26 ..
/data # chown rrdcached. /data/rrd
chown: unknown user rrdcached.
/data # chown rrdcached /data/rrd
/data # ls -al /data/rrd
total 8
drwxr-xr-x    2 rrdcached root          4096 Feb  7 15:24 .
drwxr-xr-x    1 root     root          4096 Feb  7 15:26 ..
/data # cat /etc/cont-init.d/02-fix-perms.sh 
#!/usr/bin/with-contenv sh

echo "Fixing perms..."
mkdir -p /data/db \
  /data/journal \
  /var/run/rrdcached
chown rrdcached. \
  /data/db \
  /data/journal
chown -R rrdcached. \
  /var/run/rrdcached
/data # 
/data # 
[cmd] sh exited 0
caught SIGTERM
signal_receiver: Signal 18 was received from process 428.

[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
s6-svwait: fatal: supervisor died
[s6-finish] sending all processes the TERM signal.
signal_receiver: Signal 1 was received from process 899.

caught SIGTERM
signal_receiver: Signal 18 was received from process 428.

signal_receiver: Signal 18 was received from process 899.

starting shutdown
clean shutdown; all RRDs flushed
removing journals
goodbye
[s6-finish] sending all processes the KILL signal and exiting.
mtadmin@dck001:~/librenms$ docker volume rm testvolume20260207

Additional info

I can do a PR if you want to. Maybe all calls to chown in the image should be checked.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions