Bad -c option



  • Hi everybody,

    I have very simple command fails on pfSense 2.3.4. This command can be successfully executed on FreeBSD 10.3.
    My shell is "sh".

    su -m testuser -c 'sh -c "df -h"'

    it gets:

    Bad -c option

    error.

    where testuser is any user.

    Can you please provide correct version of command or the reason of the above error?

    Thanks



  • 
    [2.3.4-RELEASE][root@pfsense]/root: su -m admin -c 'sh -c "df -h"'
    Filesystem     Size    Used   Avail Capacity  Mounted on
    /dev/da0s1a     50G    2.4G     44G     5%    /
    devfs          1.0K    1.0K      0B   100%    /dev
    /dev/md0       3.4M    148K    3.0M     5%    /var/run
    devfs          1.0K    1.0K      0B   100%    /var/dhcpd/dev
    [2.3.4-RELEASE][root@pfsense]/root: 
    
    

    seems to work for me



  • Thanks for your reply,

    Yes, if you run command directly in related pfsense terminal (physical or virtual) it works.

    But if you access pfSense using ssh and run the same command you'll get "Bad -c option" error.

    su -m admin -c 'sh -c "df -h"'

    Bad -c option

    This is the problem, and I guess you run commands directly to your pfSense machine. If so, can you please give a try with ssh?

    Thanks,



  • That was from SSH session….



  • Interesting, I can reproduce error everytime.

    Steps to reproduce:

    Setup : pfSense-CE-2.3.4-RELEASE-amd64.iso (fresh install), I used KVM.
    Just after installation and without any updates applied, I run previous command from SSH and KVM instance GUI.

    In SSH session, this error message can be seen every time I run command.

    I've updated to 2.3.4_1 and 2.4.0 problem is still there in both versions.

    Thanks,



  • try a different ssh client ? maybe some escape characters get fucked somehow ?



  • I've tried with putty, gnome-terminal (on ubuntu 16.04), and MacOS terminal (all in different physical machines).

    They all gave same error.



  • The problem is you have to be root for it to work.  If you login as admin, you get the error.



  • Yes, it DOES work with root.

    Thank you so much. But, If admin is also a kind of (and actually is) root user (it has 0 id) why couldn't admin able to run this command?

    Thanks,


  • Rebel Alliance Developer Netgate

    @hayati:

    Yes, it DOES work with root.

    Thank you so much. But, If admin is also a kind of (and actually is) root user (it has 0 id) why couldn't admin able to run this command?

    Thanks,

    The "admin" account shell is locked into the menu, it can't run commands like that (nor can it do scp)



  • That makes sense.

    Thanks all!


Log in to reply