FreePBX CLI Console hangs

Hallo…

I have installed the Asterisk CLI Console over the FreePBX Modul Admin.

But now i cant get it running again. When i enter a command i become this message:

Unable to init groups for ‘asterisk’

The Webserver is Apache2 with php5. It runs with

User asterisk
Group asterisk

In the apache configuration.

When I comment the group line, than i become:

Unable to setgid to 108!

The guid 108 is from the asterisk group in the system.

I think, this message comes from asterisk, but why? Starts the PHP script asterisk with -r ?

Any Ideas?

EDIT: Ok… i installed now php4 packages… but the error are the same:
Now i found this page with the source-code and looked for the error output… bing…

I see that asterisk try to set procress group to rungroup (or something)
But rungroup is set by rungroup = ast_config_AST_RUN_GROUP; Or by command line.

But in my asterisk.conf rungroup was not definied. I set it to asterisk and try again… bang! Next error: “Unable to drop unneeded groups”

I have no idea, what i can do… HELP :roll:

Thnanks,
Thomas

ok… after reading the source code from asterisk.c i found this:

[code:1]

if (getenv(“ASTERISK_ALREADY_NONROOT”))
is_child_of_nonroot=1;

<-- and than a few lines further down, the code who fail -->

    if (!is_child_of_nonroot && rungroup) {
            struct group *gr;
            gr = getgrnam(rungroup);
            if (!gr) {
                    ast_log(LOG_WARNING, "No such group '%s'!\n", rungroup);
                    exit(1);
            }
            if (setgid(gr->gr_gid)) {
                    ast_log(LOG_WARNING, "Unable to setgid to %d (%s)\n", (int)gr->gr_gid, rungroup);
                    exit(1);
            }
            if (setgroups(0, NULL)) {
                    ast_log(LOG_WARNING, "Unable to drop unneeded groups\n");
                    exit(1);
            }
            if (option_verbose)
                    ast_verbose("Running as group '%s'\n", rungroup);
    }

[/code:1]

Now, i added the follow under putenv("SCRIPT_FILENAME… in the /var/www/html/admin/modules/asterisk-cli/page.cli.php

[code:1]
putenv(“ASTERISK_ALREADY_NONROOT=yes”);
[/code:1]

Now the script runs…

EDIT: I cant create a Ticket in the Trac-System… so i hope, that some devs read it && create a Ticket for it.

Please also set TERM to linux-m that the color indecator is not set. I use the Debian Unstable Asterisk Package, that added the follow patch

[code:1]
diff -urNad asterisk-1.2.15~dfsg~/term.c asterisk-1.2.15~dfsg/term.c
— asterisk-1.2.15~dfsg~/term.c 2005-11-29 20:24:39.000000000 +0200
+++ asterisk-1.2.15~dfsg/term.c 2007-02-13 16:04:31.000000000 +0200
@@ -79,8 +79,8 @@
int termfd = -1, parseokay = 0, i;

    if (!term)
  •           return 0;
    
  •   if (!option_console || option_nocolor || !option_nofork)
    
  •           term="xterm";
    
  •   if (option_nocolor)
              return 0;
    
      for (i=0 ;; i++) {
    

[/code:1]
And with it i become a Colorterm output in the Asterisk CLI Module from freepbx.

Thanks,
Thomas

Ok… now i have hanged the execute code in /var/www/html/admin/modules/asterisk-cli/page.cli.php

[code:1]
/*
$ph = popen(stripslashes(“asterisk -rx “$fixedcmd””), “r” );
while ($line = fgets($ph))
echo htmlspecialchars($line);
pclose($ph);
*/

    $descriptorspec = array(
        0 => array("pipe", "r"),  // stdin is a pipe that the child will read from
        1 => array("pipe", "w"),  // stdout is a pipe that the child will write to
        2 => array("file", "/tmp/error-output.txt", "a") // stderr is a file to write to
    );

    $cwd = '/tmp';
    $env = array('TERM' => 'vt100','PATH','/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin','SCRIPT_FILENAME',strtok(stripslashes($txtCommand), " "));
    $process = proc_open("strace /usr/sbin/asterisk -rx \"$fixedcmd\"", $descriptorspec, $pipes, $cwd, $env);
    echo stream_get_contents($pipes[1]);
    echo proc_close($process);

[/code:1]

And now i have in /tmp/error-output.txt a trace from what is get…

[code:1]
execve("/usr/sbin/asterisk", ["/usr/sbin/asterisk", “-rx”, “help”], [/* 4 vars /]) = 0
uname({sys=“Linux”, node=“proxy”, …}) = 0
brk(0) = 0x811f000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f4c000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f4b000
open("/etc/ld.so.cache", O_RDONLY) = 12
fstat64(12, {st_mode=S_IFREG|0644, st_size=21319, …}) = 0
mmap2(NULL, 21319, PROT_READ, MAP_PRIVATE, 12, 0) = 0xb7f45000
close(12) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/tls/i686/cmov/libdl.so.2", O_RDONLY) = 12
read(12, “\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\20\f\0”…, 512) = 512
fstat64(12, {st_mode=S_IFREG|0644, st_size=9592, …}) = 0
mmap2(NULL, 12404, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 12, 0) = 0xb7f41000
mmap2(0xb7f43000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 12, 0x1) = 0xb7f43000
close(12) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/tls/i686/cmov/libpthread.so.0", O_RDONLY) = 12
read(12, “\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\240H\0”…, 512) = 512
fstat64(12, {st_mode=S_IFREG|0755, st_size=89370, …}) = 0
mmap2(NULL, 70104, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 12, 0) = 0xb7f2f000
mmap2(0xb7f3d000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 12, 0xe) = 0xb7f3d000
mmap2(0xb7f3f000, 4568, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7f3f000
close(12) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/libncurses.so.5", O_RDONLY) = 12
read(12, “\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\200\345”…, 512) = 512
fstat64(12, {st_mode=S_IFREG|0644, st_size=263040, …}) = 0
mmap2(NULL, 264196, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 12, 0) = 0xb7eee000
mmap2(0xb7f26000, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 12, 0x38) = 0xb7f26000
mmap2(0xb7f2e000, 2052, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7f2e000
close(12) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/tls/i686/cmov/libm.so.6", O_RDONLY) = 12
read(12, “\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0`3\0\000”…, 512) = 512
fstat64(12, {st_mode=S_IFREG|0644, st_size=145136, …}) = 0
mmap2(NULL, 147584, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 12, 0) = 0xb7ec9000
mmap2(0xb7eec000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 12, 0x22) = 0xb7eec000
close(12) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/tls/i686/cmov/libresolv.so.2", O_RDONLY) = 12
read(12, “\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\200$\0”…, 512) = 512
fstat64(12, {st_mode=S_IFREG|0644, st_size=67364, …}) = 0
mmap2(NULL, 75976, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 12, 0) = 0xb7eb6000
mmap2(0xb7ec5000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 12, 0xf) = 0xb7ec5000
mmap2(0xb7ec7000, 6344, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7ec7000
close(12) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/usr/lib/i686/cmov/libssl.so.0.9.8", O_RDONLY) = 12
read(12, “\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0P\255\0”…, 512) = 512
fstat64(12, {st_mode=S_IFREG|0644, st_size=252640, …}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7eb5000
mmap2(NULL, 255604, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 12, 0) = 0xb7e76000
mmap2(0xb7eb1000, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 12, 0x3a) = 0xb7eb1000
close(12) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/tls/i686/cmov/libc.so.6", O_RDONLY) = 12
read(12, “\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\240O\1”…, 512) = 512
fstat64(12, {st_mode=S_IFREG|0644, st_size=1241392, …}) = 0
mmap2(NULL, 1247388, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 12, 0) = 0xb7d45000
mmap2(0xb7e6c000, 28672, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 12, 0x127) = 0xb7e6c000
mmap2(0xb7e73000, 10396, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7e73000
close(12) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/usr/lib/i686/cmov/libcrypto.so.0.9.8", O_RDONLY) = 12
read(12, “\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\300Y\3”…, 512) = 512
fstat64(12, {st_mode=S_IFREG|0644, st_size=1270520, …}) = 0
mmap2(NULL, 1282904, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 12, 0) = 0xb7c0b000
mmap2(0xb7d2d000, 81920, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 12, 0x122) = 0xb7d2d000
mmap2(0xb7d41000, 13144, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7d41000
close(12) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/usr/lib/libz.so.1", O_RDONLY) = 12
read(12, “\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\340\26”…, 512) = 512
fstat64(12, {st_mode=S_IFREG|0644, st_size=78500, …}) = 0
mmap2(NULL, 81456, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 12, 0) = 0xb7bf7000
mmap2(0xb7c0a000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 12, 0x12) = 0xb7c0a000
close(12) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7bf6000
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7bf5000
mprotect(0xb7e6c000, 20480, PROT_READ) = 0
set_thread_area({entry_number:-1 -> 6, base_addr:0xb7bf56c0, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0
munmap(0xb7f45000, 21319) = 0
set_tid_address(0xb7bf5708) = 5362
rt_sigaction(SIGRTMIN, {0xb7f334c0, [], SA_SIGINFO}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0xb7f33420, [], SA_RESTART|SA_SIGINFO}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
getrlimit(RLIMIT_STACK, {rlim_cur=8192
1024, rlim_max=RLIM_INFINITY}) = 0
uname({sys=“Linux”, node=“proxy”, …}) = 0
brk(0) = 0x811f000
brk(0x8140000) = 0x8140000
uname({sys=“Linux”, node=“proxy”, …}) = 0
stat64("/etc/asterisk/asterisk.conf", {st_mode=S_IFREG|0660, st_size=2730, …}) = 0
open("/etc/asterisk/asterisk.conf", O_RDONLY) = 12
fstat64(12, {st_mode=S_IFREG|0660, st_size=2730, …}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f4a000
read(12, “[directories]\n; Make sure these “…, 4096) = 2730
read(12, “”, 4096) = 0
close(12) = 0
munmap(0xb7f4a000, 4096) = 0
sched_setscheduler(0, SCHED_OTHER, { 0 }) = 0
socket(PF_FILE, SOCK_STREAM, 0) = 12
fcntl64(12, F_GETFL) = 0x2 (flags O_RDWR)
fcntl64(12, F_SETFL, O_RDWR|O_NONBLOCK) = 0
connect(12, {sa_family=AF_FILE, path=”/var/run/nscd/socket”}, 110) = -1 ENOENT (No such file or directory)
close(12) = 0
socket(PF_FILE, SOCK_STREAM, 0) = 12
fcntl64(12, F_GETFL) = 0x2 (flags O_RDWR)
fcntl64(12, F_SETFL, O_RDWR|O_NONBLOCK) = 0
connect(12, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
close(12) = 0
open("/etc/nsswitch.conf", O_RDONLY) = 12
fstat64(12, {st_mode=S_IFREG|0644, st_size=475, …}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f4a000
read(12, “# /etc/nsswitch.conf\n#\n# Example”…, 4096) = 475
read(12, “”, 4096) = 0
close(12) = 0
munmap(0xb7f4a000, 4096) = 0
open("/etc/ld.so.cache", O_RDONLY) = 12
fstat64(12, {st_mode=S_IFREG|0644, st_size=21319, …}) = 0
mmap2(NULL, 21319, PROT_READ, MAP_PRIVATE, 12, 0) = 0xb7f45000
close(12) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/tls/i686/cmov/libnss_compat.so.2", O_RDONLY) = 12
read(12, “\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\20\21\0”…, 512) = 512
fstat64(12, {st_mode=S_IFREG|0644, st_size=30428, …}) = 0
mmap2(NULL, 33392, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 12, 0) = 0xb7bec000
mmap2(0xb7bf3000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 12, 0x6) = 0xb7bf3000
close(12) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/tls/i686/cmov/libnsl.so.1", O_RDONLY) = 12
read(12, “\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0p5\0\000”…, 512) = 512
fstat64(12, {st_mode=S_IFREG|0644, st_size=76548, …}) = 0
mmap2(NULL, 87808, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 12, 0) = 0xb7bd6000
mmap2(0xb7be8000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 12, 0x11) = 0xb7be8000
mmap2(0xb7bea000, 5888, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7bea000
close(12) = 0
munmap(0xb7f45000, 21319) = 0
open("/etc/ld.so.cache", O_RDONLY) = 12
fstat64(12, {st_mode=S_IFREG|0644, st_size=21319, …}) = 0
mmap2(NULL, 21319, PROT_READ, MAP_PRIVATE, 12, 0) = 0xb7f45000
close(12) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/tls/i686/cmov/libnss_nis.so.2", O_RDONLY) = 12
read(12, “\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\[email protected]\34\0\000”…, 512) = 512
fstat64(12, {st_mode=S_IFREG|0644, st_size=34320, …}) = 0
mmap2(NULL, 37420, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 12, 0) = 0xb7bcc000
mmap2(0xb7bd4000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 12, 0x7) = 0xb7bd4000
close(12) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/tls/i686/cmov/libnss_files.so.2", O_RDONLY) = 12
read(12, “\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\200\33”…, 512) = 512
fstat64(12, {st_mode=S_IFREG|0644, st_size=38372, …}) = 0
mmap2(NULL, 41620, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 12, 0) = 0xb7bc1000
mmap2(0xb7bca000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 12, 0x8) = 0xb7bca000
close(12) = 0
munmap(0xb7f45000, 21319) = 0
open("/etc/group", O_RDONLY) = 12
fcntl64(12, F_GETFD) = 0
fcntl64(12, F_SETFD, FD_CLOEXEC) = 0
_llseek(12, 0, [0], SEEK_CUR) = 0
fstat64(12, {st_mode=S_IFREG|0644, st_size=682, …}) = 0
mmap2(NULL, 682, PROT_READ, MAP_SHARED, 12, 0) = 0xb7f4a000
_llseek(12, 682, [682], SEEK_SET) = 0
munmap(0xb7f4a000, 682) = 0
close(12) = 0
setgid32(108) = 0
setgroups32(0, []) = -1 EPERM (Operation not permitted)
fstat64(1, {st_mode=S_IFIFO|0600, st_size=0, …}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f4a000
write(1, “Unable to drop unneeded groups\n”, 31) = 31
munmap(0xb7f4a000, 4096) = 0
exit_group(1) = ?
Process 5362 detached
[/code:1]

Any Ideas… ?