summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-09-16 20:48:58 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-09-16 20:48:58 +0200
commit1486c0164b6ba2e20ce4513010c11c3a638f4b50 (patch)
treef508e27c52f2284b01bd41bf3d2fbf0bdc3a34e4
parentunrar fix (diff)
downloadpyload-1486c0164b6ba2e20ce4513010c11c3a638f4b50.tar.xz
permission settings
-rw-r--r--module/ConfigParser.py2
-rw-r--r--module/config/default.conf8
-rw-r--r--module/plugins/Plugin.py12
-rwxr-xr-xpyLoadCore.py18
4 files changed, 37 insertions, 3 deletions
diff --git a/module/ConfigParser.py b/module/ConfigParser.py
index 568d22db9..7e1af042e 100644
--- a/module/ConfigParser.py
+++ b/module/ConfigParser.py
@@ -246,6 +246,8 @@ class ConfigParser:
return int(value)
elif typ == "bool":
return True if value.lower() in ("1","true", "on", "an","yes") else False
+ elif typ == "str":
+ return str(value)
else:
return value
diff --git a/module/config/default.conf b/module/config/default.conf
index f9c4ecc3b..eaa27f596 100644
--- a/module/config/default.conf
+++ b/module/config/default.conf
@@ -31,6 +31,14 @@ general - "General":
bool folder_per_package : "Create folder for each package" = True
bool skip_existing : "Skip already existing files" = False
ip download_interface : "Outgoing IP address for downloads" = None
+permission - "Permissions":
+ bool change_user : "Change user of running process" = False
+ str user : "Username" = "user"
+ str folder : "Folder Permission mode" = 0755
+ bool change_file : "Change file mode of downloads" = False
+ str file : "Filemode for Downloads" = 0644
+ bool change_group : "Change group of running process" = False
+ str group : "Groupname" = users
reconnect - "Reconnect":
bool activated : "Use Reconnect" = False
str method : "Method" = None
diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py
index 449a032a7..77e4e8183 100644
--- a/module/plugins/Plugin.py
+++ b/module/plugins/Plugin.py
@@ -30,6 +30,7 @@ from os.path import exists
from os import remove
from os import makedirs
+from os import chmod
from mimetypes import guess_type
@@ -257,12 +258,17 @@ class Plugin(object):
location = join(download_folder.encode(sys.getfilesystemencoding(), "replace"), self.pyfile.package().folder.replace(":", "").encode(sys.getfilesystemencoding(), "replace")) # remove : for win compability
- if not exists(location):
- makedirs(location)
+ if not exists(location):
+ makedirs(location, int(self.core.config["permission"]["folder"],8))
- newname = self.req.download(url, self.pyfile.name.encode(sys.getfilesystemencoding(), "replace"), location, get, post, ref, cookies)
+ name = self.pyfile.name.encode(sys.getfilesystemencoding(), "replace")
+ newname = self.req.download(url, name, location, get, post, ref, cookies)
self.pyfile.size = self.req.dl_size
if newname:
+ name = newname
self.pyfile.name = newname
+
+ if self.core.config["permission"]["change_file"]:
+ chmod(join(location, name), int(self.core.config["permission"]["file"],8))
diff --git a/pyLoadCore.py b/pyLoadCore.py
index 353737bce..12fcb3cff 100755
--- a/pyLoadCore.py
+++ b/pyLoadCore.py
@@ -192,6 +192,24 @@ class Core(object):
self.debug = self.doDebug or self.config['general']['debug_mode']
+ if self.config["permission"]["change_user"]:
+ if os.name != "nt":
+ try:
+ from pwd import getpwnam
+ user = getpwnam(self.config["permission"]["user"])
+ os.setuid(user[2])
+ except Exception, e:
+ print _("Failed changing user: %s") % e
+
+ if self.config["permission"]["change_group"]:
+ if os.name != "nt":
+ try:
+ from grp import getgrnam
+ group = getgrnam(self.config["permission"]["group"])
+ os.setgid(group[2])
+ except Exception, e:
+ print _("Failed changing group: %s") % e
+
self.check_file(self.config['log']['log_folder'], _("folder for logs"), True)
if self.debug: