diff --git a/htdocs/js/pages/admin/Plugins.js b/htdocs/js/pages/admin/Plugins.js index 848eb5b..22e9589 100644 --- a/htdocs/js/pages/admin/Plugins.js +++ b/htdocs/js/pages/admin/Plugins.js @@ -572,7 +572,9 @@ Class.add( Page.Admin, {
Run as User (UID):
-
+
+
Run as Group (GID):
+
@@ -581,8 +583,8 @@ Class.add( Page.Admin, { `); html += get_form_table_caption( - `Optionally enter a working directory path, and/or a custom UID for the Plugin.
- The UID may be either numerical or a string ('root', 'wheel', etc.).
+ `Optionally enter a working directory path, and/or a custom UID/GID for the Plugin.
+ The UID/GID may be either numerical or strings ('root', 'wheel', etc.).
` ); html += get_form_table_spacer(); @@ -911,8 +913,10 @@ Class.add( Page.Admin, { plugin.cwd = trim( $('#fe_ep_cwd').val() ); plugin.uid = trim( $('#fe_ep_uid').val() ); + plugin.gid = trim( $('#fe_ep_gid').val() ); if (plugin.uid.match(/^\d+$/)) plugin.uid = parseInt( plugin.uid ); + if (plugin.gid.match(/^\d+$/)) plugin.gid = parseInt( plugin.gid ); return plugin; } diff --git a/lib/job.js b/lib/job.js index be78de2..3dc71fb 100644 --- a/lib/job.js +++ b/lib/job.js @@ -653,9 +653,27 @@ module.exports = Class.create({ return; } + + if (job.gid) { + var grp_info = Tools.getgrnam(job.gid, true); + if (grp_info) { + child_opts.gid = grp_info.gid; + } + else { + // group not found + job.pid = 0; + job.code = 1; + job.description = "Plugin Error: Group does not exist: " + job.gid; + this.logError("child", job.description); + this.activeJobs[job.id] = job; + this.finishLocalJob(job); + return; + } + } + child_opts.uid = parseInt(child_opts.uid); child_opts.gid = parseInt(child_opts.gid); - } + } // if unix // add plugin params as env vars if (job.params) {