1

I've setup a local repo with reprepro, accessible via a local web server. Thus every file and dir in its file sub-tree owns to www-data:www-data. The problem is that every time I add a new package I need to use sudo, that makes all the permissions of the files involved to change, and every time I have to fix this by hand.

Any clue how can I avoid this? Maybe using a sticky bit?

Thanks in advance.

Daniele
  • 448
  • I'm unclear why sudo is changing your file permissions. Can you provide an example? In any case, acl is often an option if you want to "force" permissions. See for example https://unix.stackexchange.com/a/115632/4671. If you give more details, I may be able to offer a more detailed response. – Faheem Mitha Sep 09 '17 at 12:00
  • Because acting as root changes the permission from www-data to root with its umask, and it brokes the whole mechanism. – Daniele Sep 09 '17 at 13:30

1 Answers1

3

You can tell sudo you want to run commands as www-data instead of root:

sudo -u www-data ...

That way the ownership of your repository won’t change.

Stephen Kitt
  • 434,908
  • It works, I tried before with: su www-data -c 'reprepro etc... but it returned this error: This account is currently not available – Daniele Sep 09 '17 at 13:32