Skip to content

BUG: rm: refusing to remove '.' or '..' directory: skipping '/run/scalpel/. #1

@kai-tub

Description

@kai-tub

Hey, thank you very much for providing a way to customize configuration files that require some sops-managed passwords!
This is exactly what I've been looking for! ❤️
Though, I am having some issues and am relatively new to NixOS so sorry for not being able to provide a minimal example.

  1. When I execute the container there is no issue
  2. But when I call it via my flake configuration, I get the following issues:
rm: refusing to remove '.' or '..' directory: skipping '/run/scalpel/.`
rm: refusing to remove '.' or '..' directory: skipping '/run/scalpel/..`
Activation script snippet 'scalpelCreateStore' failed (1)

Looking at the code, the issue seems to come from

config = mkIf (cfg.trafos != { }) {
system.activationScripts.scalpelCreateStore = {
text = ''
echo "[scalpel] Ensuring existance of ${cfg.secretsDir}"
mkdir -p ${cfg.secretsDir}
grep -q "${cfg.secretsDir} ramfs" /proc/mounts || mount -t ramfs none "${cfg.secretsDir}" -o nodev,nosuid,mode=0751
echo "[scalpel] Clearing old secrets from ${cfg.secretsDir}"
rm -rf ${cfg.secretsDir}/{*,.*}
'';
deps = [ "specialfs" ];
};

Where the shell is safeguarding recursively deleting . and ..

I've cloned this repository and changed it to:

system.activationScripts.scalpelCreateStore = { 
       text = '' 
         echo "[scalpel] Ensuring existance of ${cfg.secretsDir}" 
         mkdir -p ${cfg.secretsDir} 
         grep -q "${cfg.secretsDir} ramfs" /proc/mounts || mount -t ramfs none "${cfg.secretsDir}" -o nodev,nosuid,mode=0751 
  
         echo "[scalpel] Clearing old secrets from ${cfg.secretsDir}" 
         find . -name . -o -prune -exec rm -rf -- {} +
       ''; 
       deps = [ "specialfs" ]; 
     }; 

With inspiration from: https://unix.stackexchange.com/a/77313

Which allowed me to run the flake without any issues. :)
I would be happy to open a PR if you think this change would fix it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions