Skip to content

Commit

Permalink
fix: log crejsonldap stderr, do NOT parse it as JSON (GLPI UP1#168946)
Browse files Browse the repository at this point in the history
  • Loading branch information
prigaux committed Nov 25, 2024
1 parent 90e32c1 commit a0bf166
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion server/crejsonldap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const call = (v: v, opts: options) => {
}

// exported for tests purpose
export const callRaw = { fn: (param: string) => utils.popen(param, 'createCompte', []) };
export const callRaw = { fn: (param: string) => utils.popen(param, 'createCompte', [], { log_stderr: true }) };

export const throw_if_err = (resp: resp) => {
const err = resp.err && resp.err[0];
Expand Down
4 changes: 2 additions & 2 deletions server/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export const wait = (milliseconds: number) => (

import { spawn } from 'child_process';

export function popen(inText: string, cmd: string, params: string[]): Promise<string> {
export function popen(inText: string, cmd: string, params: string[], opts?: { log_stderr?: true }): Promise<string> {
let p = spawn(cmd, params);
p.stdin.write(inText);
p.stdin.end();
Expand All @@ -169,7 +169,7 @@ export function popen(inText: string, cmd: string, params: string[]): Promise<st
let get_ouput = (data: any) => { output += data; };

p.stdout.on('data', get_ouput);
p.stderr.on('data', get_ouput);
p.stderr.on('data', opts?.log_stderr ? data => console.error(`${cmd} stderr : ${data}`) : get_ouput);
p.on('error', event => {
reject(event);
});
Expand Down

0 comments on commit a0bf166

Please sign in to comment.