cuckoosandbox / cuckoo

Cuckoo Sandbox is an automated dynamic malware analysis system
http://www.cuckoosandbox.org
Other
5.54k stars 1.71k forks source link

Cannot start UWSGI - Unit not found #1746

Closed Phenomanan closed 7 years ago

Phenomanan commented 7 years ago

Hi,

I am having trouble starting cuckoo-api via UWSGI the way it is done in the documentation. Specifically, the line: "sudo service uwsgi start cuckoo-api" returns: Redirecting to /bin/systemctl start cuckoo-api uwsgi.service Failed to start cuckoo-api.service: Unit not found.

I should note that my host is RHEL 7, and have installed cuckoo in a python virtualenv. I have looked at a ton of Google results and other forum posts, but couldn't find the solution to this exact issue.

My .ini files are as follows: ----- /etc/uwsgi.ini ----- virtualenv=/opt/cuckoo-2.0.3/sandbox_env/ uid = uwsgi gid = uwsgi emperor = /etc/uwsgi.d stats = /run/uwsgi/stats.sock chmod-socket = 660 emperor-tyrant = true cap = setgid,setuid enable-threads = true

----- /etc/uwsgi.d/cuckoo-api.ini ----- plugins = python virtualenv = /opt/cuckoo-2.0.3/sandbox_env

pythonpath = /opt/cuckoo-2.0.3/sandbox_env/lib/python2.7/site-packages/

chdir=/opt/cuckoo-2.0.3/sandbox_env/lib/python2.7/site-packages/cuckoo/

module = cuckoo-api callable = app uid = cuckoo gid = cuckoo env = CUCKOO_APP=api env = CUCKOO_CWD=/home/cuckoo/.cuckoo

----- After running "sudo service uwsgi start cuckoo-api" ----- $ systemctl status uwsgi.service: ● uwsgi.service - uWSGI Emperor Service Loaded: loaded (/usr/lib/systemd/system/uwsgi.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2017-08-01 10:34:05 EDT; 5min ago Process: 504 ExecStartPre=/bin/chown uwsgi:uwsgi /run/uwsgi (code=exited, status=0/SUCCESS) Process: 487 ExecStartPre=/bin/mkdir -p /run/uwsgi (code=exited, status=0/SUCCESS) Main PID: 509 (uwsgi) Status: "The Emperor is governing 0 vassals" CGroup: /system.slice/uwsgi.service ├─509 /usr/sbin/uwsgi --ini /etc/uwsgi.ini └─520 /usr/sbin/uwsgi --ini /etc/uwsgi.ini

Aug 01 10:39:03 ip-10-0-0-5.us-east-2.compute.internal uwsgi[509]: detected max file descriptor number: 1024 Aug 01 10:39:03 ip-10-0-0-5.us-east-2.compute.internal uwsgi[509]: lock engine: pthread robust mutexes Aug 01 10:39:03 ip-10-0-0-5.us-east-2.compute.internal uwsgi[509]: thunder lock: disabled (you can enable it with --thunder-lock) Aug 01 10:39:03 ip-10-0-0-5.us-east-2.compute.internal uwsgi[509]: Python version: 2.7.5 (default, Aug 2 2016, 04:20:16) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] Aug 01 10:39:03 ip-10-0-0-5.us-east-2.compute.internal uwsgi[509]: Set PythonHome to /opt/cuckoo-2.0.3/sandbox_env Aug 01 10:39:03 ip-10-0-0-5.us-east-2.compute.internal uwsgi[509]: Python threads support is disabled. You can enable it with --enable-threads Aug 01 10:39:03 ip-10-0-0-5.us-east-2.compute.internal uwsgi[509]: Python main interpreter initialized at 0x1134630 Aug 01 10:39:03 ip-10-0-0-5.us-east-2.compute.internal uwsgi[509]: The -s/--socket option is missing and stdin is not a socket. Aug 01 10:39:03 ip-10-0-0-5.us-east-2.compute.internal uwsgi[509]: Tue Aug 1 10:39:03 2017 - [emperor] curse the uwsgi instance cuckoo-api.ini (pid: 2142) Aug 01 10:39:06 ip-10-0-0-5.us-east-2.compute.internal uwsgi[509]: Tue Aug 1 10:39:06 2017 - [emperor] removed uwsgi instance cuckoo-api.ini

Thanks in advance for the help, and please let me know what else I should provide - this is my first forum post. Also let me know if there is somewhere else I should be posting this.

jbremer commented 7 years ago

This doesn't really look like the output of cuckoo api --uwsgi, including, e.g., the module = ... field which is completely different. Please try our proposed solution before editing it to your personal preference.

Phenomanan commented 7 years ago

Ah, I thought I commented out the changes, but I guess I forgot about module.

---- Original cuckoo-api.ini ---- plugins = python virtualenv = /opt/cuckoo-2.0.3/sandbox_env module = cuckoo.apps.api callable = app uid = cuckoo gid = cuckoo env = CUCKOO_APP=api env = CUCKOO_CWD=/home/cuckoo/.cuckoo

This one didn't work either though... in fact uWSGI wouldn't even start up without adding a systemd .service file to start/stop it (something I didn't have to do on Ubuntu). I think the way uWSGI is set up in RHEL 7 is just very different from Ubuntu. When I tried installing cuckoo on an Ubuntu unit, it was a much smoother process. The uWSGI/nginx part took minutes, where it has taken days on RHEL to no avail. Do you know of any resources/documentation I can look at to get cuckoo-api and cuckoo-web working with uWSGI/nginx on RHEL?

doomedraven commented 7 years ago

Is why ubuntu is suggested as the host

Phenomanan commented 7 years ago

I mean technically cuckoo itself works fine on Redhat - it's really just the uWSGI/nginx configuration that is turning out to be a headache. Surely someone has attempted this configuration on RHEL/centOS though?

jbremer commented 7 years ago

No idea. Furthermore the Cuckoo Rooter doesn't work on RHEL either (most likely). Other than that I suppose RHEL could be used for Cuckoo deployments, but as @doomedraven mentioned we do suggest a Ubuntu host - especially since our docs did help you there. Did you resolve this issue in the meanwhile or? Will not keep this issue open forever :-)

Phenomanan commented 7 years ago

Well I resolved the issue by moving on the Ubuntu as suggested :P. I had just wanted to try getting it to work on RHEL as well, but doesn't seem like that's possible without a host of issues. So I'll close this one, thanks 👍.