bstansell / conserver

Logged, multi-user access to device consoles
https://www.conserver.com/
BSD 3-Clause "New" or "Revised" License
129 stars 38 forks source link

Issue with replstring and tasks #73

Open glance- opened 2 years ago

glance- commented 2 years ago

I have some templates setting up ipmi consoles with ipmitool.

task 1 {
    description "Power on a machine via ipmi";
    cmd "ipmitool -I lanplus -H % R chassis power on";
    subst %=hs,R=rs;
    confirm no;
}

task 2 {
    description "Power off a machine via ipmi";
    cmd "ipmitool -I lanplus -H % R chassis power off";
    subst %=hs,R=rs;
    confirm yes;
}

task 0 {
    description "Reset a machine via ipmi";
    cmd "ipmitool -I lanplus -H % R chassis power reset";
    subst %=hs,R=rs;
    confirm yes;
}

task q {
    description "View chassis power status";
    cmd "ipmitool -I lanplus -H % R chassis power status";
    subst %=hs,R=rs;
    confirm no;
}

default ipmi-sol {
    exec "ipmitool -I lanplus -H % R sol deactivate || true ; exec ipmitool -I lanplus -H % R sol activate usesolkeepalive";
    break 4;
    type exec;
    # % is substituted by the hostname
    # r is substituded by credentails arguments
    execsubst %=hs,R=rs;
    # add power tasks
    tasklist 1,2,0,q;
    motd "Plain serial port connected through ipmitool
break = ^e c l0";
}

default ipmi-sol-ADMIN {
    include ipmi-sol;
    replstring "-U ADMIN -P ADMIN";
}

default ipmi-sol-ADMIN-no-usesolkeepalive {
    include ipmi-sol-ADMIN;
    exec  "ipmitool -I lanplus -H % R sol deactivate || true ; exec ipmitool -I lanplus -H % R sol activate";
}

console X.intern {
    master Y.intern;
    include ipmi-sol-ADMIN-no-usesolkeepalive;
    host X-ipmi.intern;
}

The config is more complex than that but the issue can be reproduced with only that.

After some time, when running the console and trying to run a task I just get:

[task `q' started]
Password: Error: Unable to establish IPMI v2 / RMCP+ session
[task terminated: exit(1)]

After applying some strace to the relevant conserver process i see:

# strace -s 4096 -e execve -fp 3913
strace: Process 3913 attached
strace: Process 8460 attached
[pid  8460] execve("/bin/sh", ["/bin/sh", "-ce", "ipmitool -I lanplus -H X-ipmi.intern * chassis power off"], 0x7fff379fe210 /* 9 vars */) = 0
strace: Process 8461 attached
[pid  8461] execve("/usr/bin/ipmitool", ["ipmitool", "-I", "lanplus", "-H", "X-ipmi.intern", "bin", "boot", "dev", (truncated away the rest of directories in / ), "chassis", "power", "off"], 0x558911105868 /* 10 vars */) = 0
[pid  8461] +++ exited with 1 +++
[pid  8460] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=8461, si_uid=114, si_status=1, si_utime=0, si_stime=0} ---
[pid  8460] +++ exited with 1 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=8460, si_uid=114, si_status=1, si_utime=0, si_stime=0} ---
^Cstrace: Process 3913 detached

Somewhere in memory my replstring got replaced by a "*"