1

I'm working on a GUI for managing the contents of a specific network folder. The files are created/deleted and moved by a script.

I have a json index file that has information about the files in this folder.

Is there a way to give all users write permission to these files, but only if they use my script?

I'm not worried about security, just don't want people to edit files without the index file being updated.

Brad Fallon
  • 134
  • 1
  • 6
  • Possible alternative: use a python program that [watches for file changes](http://stackoverflow.com/a/4690739/5827215) and update the index when the user makes a change. Then they can use the "save file" feature on editor programs etc. without having to go through an extra interface. – Tadhg McDonald-Jensen Aug 17 '16 at 21:38

2 Answers2

2

You can specify this type of thing using visudo.

From: http://www.atrixnet.com/allow-an-unprivileged-user-to-run-a-certain-command-with-sudo/

First, you’ll need to use the visudo utility…

    sudo visudo

This command safely opens up the /etc/sudoers file for you in your default editor. Let’s say you want to allow a user named “joe” to run a given command. You just need to add a line like this below (customize for your needs)

    joe ALL=(ALL) NOPASSWD: /full/path/to/command

Now what if you want to restrict joe to only use that command within a given set of parameters or with only certain arguments? Well, just toss them in there too! Check this out:

    joe ALL=(ALL) NOPASSWD: /full/path/to/command ARG1 ARG2
willpnw
  • 689
  • 4
  • 23
1

You're program needs the SUID bit set https://en.wikipedia.org/wiki/Setuid. I'm not sure if this can be done with a python script.

HoldOffHunger
  • 10,963
  • 6
  • 53
  • 100
Martijn de Munnik
  • 826
  • 10
  • 23