Monday, 27 May 2013

Command added to visudo still is failing on permissions?

Command added to visudo still is failing on permissions?

My sudo file has two commands in it right now that are allowed to run without logging in as root.
It looks like this:
user ALL=(root) NOPASSWD: /home/user/prog1.py
user ALL=(root) NOPASSWD: /home/user/prog2.py
The prog1.py file runs fine without password needed. The prog2.py file fails on permissions denied?
The first program is only accessing a file to read that is root protected. The second program is creating a symlink and removing a root-protected file:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
from random import choice
from subprocess import Popen


def back_drop_change():
    link = "/usr/share/slim/themes/default/background.jpg"
    os.remove(link) # this is the line that returns permission denied
    image_selection = list()
    for di, _, fi in os.walk("/home/user/pictures/apod"):
        for f in fi:
            image_selection.append(di + "/" + f)
    bck_img = choice(image_selection)
    Popen(["ln", "-s", bck_img, link])

if __name__ == "__main__":
    back_drop_change()
I try adding /usr/bin/rm /usr/share/slim/themes/default/background.jpg to the visudo file but, it still fails?

No comments:

Post a Comment