Function SHELL Not Registered

Home » Asterisk Users » Function SHELL Not Registered
Asterisk Users 8 Comments

Hi all,

I am getting the following error when starting asterisk:
pbx_functions.c: Function SHELL not registered

Some of my conf files use a SHELL command, which used to work with an older version of asterisk, but now with version 13.9.1 I see this warning in the error log. How can I register the SHELL function? From what I can find in the wiki’s, it should just be available?

Best regards,

Michael Jepson

8 thoughts on - Function SHELL Not Registered

  • Did you include func_shell in your Asterisk build?

    Fortunately, it’s no biggie to build a missing module, because the “make”
    command explicitly keeps track of everything it has already done and does not need to do again. Just cd into the folder with your Asterisk source, run
    `make menuselect` and select “func_shell” (under dialplan functions). Then run `make` and finally `make install`.

  • I have rebuilt a new version, making sure func_shell was selected, but I am still getting this error.

    —–Original Message—

  • Even weirder, when I check in asterisk, using “core show functions”, I can see the function SHELL right there. From what I can find, the call is made from a conf. file, as grep shows:

    globals.conf: G_server=${SHELL(hostname)}

    Is this even correct? The config files are from a much older version of asterisk, which I am trying to update.

    —–Original Message—

  • QWRkaW5nIGxpdmVfZGFuZ2Vyb3VzbHkgZGlkIHRoZSB0cmljay4gVGhhbmtzISBCdXQgaG93IGRh bmdlcm91cyBpcyBBc3RlcmlzayBsaXZpbmcgbm93ID8NCg0KRnJvbTogYXN0ZXJpc2stdXNlcnMt Ym91bmNlc0BsaXN0cy5kaWdpdW0uY29tIFttYWlsdG86YXN0ZXJpc2stdXNlcnMtYm91bmNlc0Bs aXN0cy5kaWdpdW0uY29tXSBPbiBCZWhhbGYgT2YgSm9obiBLaW5pc3Rvbg0KU2VudDogZGluc2Rh ZyA1IGp1bGkgMjAxNiAxNzo0MQ0KVG86IEFzdGVyaXNrIFVzZXJzIE1haWxpbmcgTGlzdCAtIE5v bi1Db21tZXJjaWFsIERpc2N1c3Npb24gPGFzdGVyaXNrLXVzZXJzQGxpc3RzLmRpZ2l1bS5jb20+
    DQpTdWJqZWN0OiBSZTogW2FzdGVyaXNrLXVzZXJzXSBGdW5jdGlvbiBTSEVMTCBub3QgcmVnaXN0
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KTmV3IHRvIEFzdGVyaXNrPyBKb2luIHVzIGZvciBhIGxpdmUgaW50
    cm9kdWN0b3J5IHdlYmluYXIgZXZlcnkgVGh1cnM6DQogICAgICAgICAgICAgICBodHRwOi8vd3d3
    LmFzdGVyaXNrLm9yZy9oZWxsbw0KDQphc3Rlcmlzay11c2VycyBtYWlsaW5nIGxpc3QNClRvIFVO
    U1VCU0NSSUJFIG9yIHVwZGF0ZSBvcHRpb25zIHZpc2l0Og0KICAgaHR0cDovL2xpc3RzLmRpZ2l1
    bS5jb20vbWFpbG1hbi9saXN0aW5mby9hc3Rlcmlzay11c2Vycw0KDQoNCg0KLS0NCkEgaHVtYW4g YmVpbmcgc2hvdWxkIGJlIGFibGUgdG8gY2hhbmdlIGEgZGlhcGVyLCBwbGFuIGFuIGludmFzaW9u LCBidXRjaGVyIGEgaG9nLCBjb25uIGEgc2hpcCwgZGVzaWduIGEgYnVpbGRpbmcsIHdyaXRlIGEg c29ubmV0LCBiYWxhbmNlIGFjY291bnRzLCBidWlsZCBhIHdhbGwsIHNldCBhIGJvbmUsIGNvbWZv cnQgdGhlIGR5aW5nLCB0YWtlIG9yZGVycywgZ2l2ZSBvcmRlcnMsIGNvb3BlcmF0ZSwgYWN0IGFs b25lLCBzb2x2ZSBlcXVhdGlvbnMsIGFuYWx5emUgYSBuZXcgcHJvYmxlbSwgcGl0Y2ggbWFudXJl LCBwcm9ncmFtIGEgY29tcHV0ZXIsIGNvb2sgYSB0YXN0eSBtZWFsLCBmaWdodCBlZmZpY2llbnRs eSwgZGllIGdhbGxhbnRseS4gU3BlY2lhbGl6YXRpb24gaXMgZm9yIGluc2VjdHMuDQotLS1IZWlu bGVpbg0K

  • From README-SERIOUSLY.bestpractices.txt:

    ==========================Avoid Privilege Escalations
    ==========================
    External control protocols, such as Manager, often have the ability to get and set channel variables; which allows the execution of dialplan functions.

    Dialplan functions within Asterisk are incredibly powerful, which is wonderful for building applications using Asterisk. But during the read or write execution, certain diaplan functions do much more. For example, reading the SHELL() function can execute arbitrary commands on the system Asterisk is running on. Writing to the FILE() function can change any file that Asterisk has write access to.

    When these functions are executed from an external protocol, that execution could result in a privilege escalation. Asterisk can inhibit the execution of these functions, if live_dangerously in the [options] section of asterisk.conf is set to no.

    In Asterisk 12 and later, live_dangerously defaults to no.

    When setting ‘live_dangerously’ to yes, you are taking responsibility for preventing permission escalation for those dialplan functions that can alter the underlying system. In addition to running Asterisk as a non-root user – which is always a good idea – your external applications should be sanitizing data passed through to said dialplan functions, and should implement their own stringent access control.

    Matt

  • I must admit, still using an ancient Asterisk version, I didn’t know about live_dangerously. But it sort of makes sense.

    It is somewhat dangerous to have a function that can execute arbitrary system commands, especially as root. Just how dangerous depends on what commands can end up being executed. For instance, it probably would -not- be a good idea to include something like

    exten => 666,1,NoOp(${SHELL(/sbin/init 0)})

    in a dialplan on a production server …..

    Just be careful what commands you execute and what parameters you feed to them. You might even want to use a wrapper script around anything that could misbehave if given a wrong parameter (especially if the paramters depend on anything user-settable); do a quick sanity-check in the script itself, and only execute the “real” command if everything is within the range you expect.

    And don’t think that blocking SHELL() makes your Asterisk server magically safe. You can still run dangerous system commands from within an AGI script.