Skip to content

Commit

Permalink
sync to 0.9.45 (gid feature)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeTWC1984 committed Mar 30, 2024
1 parent fc6cb77 commit 07d8ab9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
10 changes: 7 additions & 3 deletions htdocs/js/pages/admin/Plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,9 @@ Class.add( Page.Admin, {
<div class="plugin_params_content"><input type="text" id="fe_ep_cwd" size="50" value="${escape_text_field_value(plugin.cwd)}" placeholder="" spellcheck="false"/></div>
<div class="plugin_params_label">Run as User (UID):</div>
<div class="plugin_params_content"><input type="text" id="fe_ep_uid" size="20" value="${escape_text_field_value(plugin.uid)}" placeholder="" spellcheck="false"/></div>
<div class="plugin_params_content"><input type="text" id="fe_ep_uid" size="20" value="${escape_text_field_value(plugin.uid)}" placeholder="" spellcheck="false"/></div>
<div class="plugin_params_label">Run as Group (GID):</div>
<div class="plugin_params_content"><input type="text" id="fe_ep_gid" size="20" value="${escape_text_field_value(plugin.gid)}" placeholder="" spellcheck="false"/></div>
<input name="DummyUsername" type="text" style="display:none;">
<input name="DummyPassword" type="password" style="display:none;"></input>
Expand All @@ -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.<br>
The UID may be either numerical or a string ('root', 'wheel', etc.).<br>
`Optionally enter a working directory path, and/or a custom UID/GID for the Plugin.<br>
The UID/GID may be either numerical or strings ('root', 'wheel', etc.).<br>
`
);
html += get_form_table_spacer();
Expand Down Expand Up @@ -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;
}
Expand Down
20 changes: 19 additions & 1 deletion lib/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 07d8ab9

Please sign in to comment.