Teaser : nethserver-shellinabox


(Stéphane de Labrusse) #1

still in development, a tip, when you learnt something, never stop, it is so hard to restart :stuck_out_tongue:

I have a minor issue I need time to understand…why a teaser, now I cannot go back :smile:


Command line from web UI (Server Manager)
(Artem Fedai) #2

Hi @stephdl , dokuwiki and fail2ban could be backported from SME?


#3

Whoah!
For me, it’s a killing feature.

No need anymore to juggle with the browser and webssh on the ipad :grinning:


(JamesMillar) #4

Pretty cool! Can’t wait to see it.


(Stéphane de Labrusse) #5

If you have vim, mock, some vm, nothing is impossible.


(Stéphane de Labrusse) #6

@davidep @giacomo I have an issue with the sysvinit script of shellinabox, it does a hang when I do the event nethserver-shellinabox-update

the sysvinitscript : https://gist.github.com/stephdl/a0bfdfa522753774a14c

my event nethserver-shellinabox-update

# ls -la -R /etc/e-smith/events/nethserver-shellinabox-update/
/etc/e-smith/events/nethserver-shellinabox-update/:
total 16
drwxr-xr-x.  4 root root 4096 Oct 18 15:26 .
drwxr-xr-x. 56 root root 4096 Oct 18 13:27 ..
lrwxrwxrwx.  1 root root   39 Oct 18 15:26 S00initialize-default-databases -> ../actions/initialize-default-databases
drwxr-xr-x.  2 root root 4096 Oct 18 15:26 services2adjust
drwxr-xr-x.  3 root root 4096 Oct 18 13:27 templates2expand

/etc/e-smith/events/nethserver-shellinabox-update/services2adjust:
total 8
drwxr-xr-x. 2 root root 4096 Oct 18 15:26 .
drwxr-xr-x. 4 root root 4096 Oct 18 15:26 ..
lrwxrwxrwx. 1 root root    6 Oct 18 15:26 httpd -> reload
lrwxrwxrwx. 1 root root    7 Oct 18 15:26 shellinaboxd -> restart

/etc/e-smith/events/nethserver-shellinabox-update/templates2expand:
total 12
drwxr-xr-x. 3 root root 4096 Oct 18 13:27 .
drwxr-xr-x. 4 root root 4096 Oct 18 15:26 ..
drwxr-xr-x. 4 root root 4096 Oct 18 13:27 etc

/etc/e-smith/events/nethserver-shellinabox-update/templates2expand/etc:
total 16
drwxr-xr-x. 4 root root 4096 Oct 18 13:27 .
drwxr-xr-x. 3 root root 4096 Oct 18 13:27 ..
drwxr-xr-x. 3 root root 4096 Oct 18 13:27 httpd
drwxr-xr-x. 2 root root 4096 Oct 18 15:26 sysconfig

/etc/e-smith/events/nethserver-shellinabox-update/templates2expand/etc/httpd:
total 12
drwxr-xr-x. 3 root root 4096 Oct 18 13:27 .
drwxr-xr-x. 4 root root 4096 Oct 18 13:27 ..
drwxr-xr-x. 2 root root 4096 Oct 18 15:26 conf.d

/etc/e-smith/events/nethserver-shellinabox-update/templates2expand/etc/httpd/conf.d:
total 8
drwxr-xr-x. 2 root root 4096 Oct 18 15:26 .
drwxr-xr-x. 3 root root 4096 Oct 18 13:27 ..
-rw-r--r--. 1 root root    0 Oct 18 13:27 shellinabox.conf

/etc/e-smith/events/nethserver-shellinabox-update/templates2expand/etc/sysconfig:
total 8
drwxr-xr-x. 2 root root 4096 Oct 18 15:26 .
drwxr-xr-x. 4 root root 4096 Oct 18 13:27 ..
-rw-r--r--. 1 root root    0 Oct 18 13:27 shellinaboxd

the createlinks

#!/usr/bin/perl -w

use esmith::Build::CreateLinks qw(:all);

my $event = 'nethserver-shellinabox-update';

# templates to expand
foreach my $event (qw ( nethserver-shellinabox-update nethserver-shellinabox-save)) {
    templates2events("/etc/sysconfig/shellinaboxd", $event);
    templates2events('/etc/httpd/conf.d/shellinabox.conf', $event);
}

# services to launch on event
foreach my $event (qw ( nethserver-shellinabox-update nethserver-shellinabox-save)) {
event_services($event,
    'httpd' => 'reload',
    'shellinaboxd' => 'restart');
}

# actions to do
my $event = 'nethserver-shellinabox-update';
event_actions($event, 
             'initialize-default-databases' => '00');

my $event = 'nethserver-shellinabox-save';
event_actions($event,
'runlevel-adjust' => '99',
'firewall-adjust' => '70');

exit

/var/log/messages

Oct 18 15:26:44 nethserver-dev esmith::event[3756]: Event: nethserver-shellinabox-update 
Oct 18 15:26:44 nethserver-dev esmith::event[3756]: Migrating existing database accounts
Oct 18 15:26:44 nethserver-dev esmith::event[3756]: Migrating existing database configuration
Oct 18 15:26:44 nethserver-dev esmith::event[3756]: Migrating existing database networks
Oct 18 15:26:44 nethserver-dev esmith::event[3756]: Migrating existing database routes
Oct 18 15:26:44 nethserver-dev esmith::event[3756]: Migrating existing database hosts
Oct 18 15:26:44 nethserver-dev esmith::event[3756]: Action: /etc/e-smith/events/nethserver-shellinabox-update/S00initialize-default-databases SUCCESS [0.13208]
Oct 18 15:26:44 nethserver-dev esmith::event[3756]: expanding /etc/sysconfig/shellinaboxd
Oct 18 15:26:44 nethserver-dev esmith::event[3756]: expanding /etc/httpd/conf.d/shellinabox.conf
Oct 18 15:26:44 nethserver-dev esmith::event[3756]: Action: /etc/e-smith/events/actions/generic_template_expand SUCCESS [0.116091]
Oct 18 15:26:44 nethserver-dev esmith::event[3756]: [INFO] service shellinaboxd restart
Oct 18 15:26:44 nethserver-dev esmith::event[3756]: Stopping shellinaboxd: [  OK  ]#015
Oct 18 15:26:44 nethserver-dev esmith::event[3756]: Starting shellinaboxd: [  OK  ]#015
Oct 18 15:26:44 nethserver-dev esmith::event[3756]: [INFO] shellinaboxd restart
Oct 18 15:26:44 nethserver-dev esmith::event[3756]: [INFO] service httpd reload
Oct 18 15:26:44 nethserver-dev esmith::event[3756]: Reloading httpd: 
Oct 18 15:26:44 nethserver-dev esmith::event[3756]: [INFO] httpd reload
(END) 

the event hangs, until I do a ctrl+C

I have had a similar issue with transmission, I tricked the problem by using an action which was here to restart the service and do the adjust-services, but this time I would understand why instead of turn around the ‘bug’

When I remove the shellinaboxd link to restart, then the event doesn’t hang anymore

Where I can look please ?


(Giacomo Sanchietti) #7

This kind of problem is often caused by the daemon itself which doesn’t correctly close all file descriptors.
I suggest you try using an upstart job.

Create a template-metadata /etc/e-smith/templates.metadata/etc/init/shellinabox.conf with something like this:

TEMPLATE_PATH='upstart-job'
OUTPUT_FILENAME='/etc/init/shellinabox.conf'
MORE_DATA={ name => 'shellinaboxd', description => 'Shellinabox daemon', author => 'Your name ', daemon_bin => '/usr/sbin/shellinaboxd', daemon_args => '', respawn => 1, 'expect' => 'fork', stop_on => 'stopping network', start_on => 'started network' }

See /etc/e-smith/templates.metadata/etc/init/httpd-admin.conf for an example.


(Alessio Fattorini) #8

Go ahead @stephdl I love it! Give us something meaty to tackle


(Stéphane de Labrusse) #9

Upstart doesn’t like shellinaboxd :frowning:

Oct 19 17:04:55 nethserver-dev esmith::event[4905]: Event: nethserver-shellinabox-update 
Oct 19 17:04:55 nethserver-dev esmith::event[4905]: Migrating existing database accounts
Oct 19 17:04:55 nethserver-dev esmith::event[4905]: Migrating existing database configuration
Oct 19 17:04:56 nethserver-dev esmith::event[4905]: Migrating existing database networks
Oct 19 17:04:56 nethserver-dev esmith::event[4905]: Migrating existing database routes
Oct 19 17:04:56 nethserver-dev esmith::event[4905]: Migrating existing database portforward
Oct 19 17:04:56 nethserver-dev esmith::event[4905]: Migrating existing database fwservices
Oct 19 17:04:56 nethserver-dev esmith::event[4905]: Migrating existing database hosts
Oct 19 17:04:56 nethserver-dev esmith::event[4905]: Migrating existing database fwrules
Oct 19 17:04:56 nethserver-dev esmith::event[4905]: Migrating existing database tc
Oct 19 17:04:56 nethserver-dev esmith::event[4905]: Action: /etc/e-smith/events/nethserver-shellinabox-update/S00initialize-default-databases SUCCESS [0.129099]
Oct 19 17:04:56 nethserver-dev esmith::event[4905]: expanding /etc/sysconfig/shellinaboxd
Oct 19 17:04:56 nethserver-dev esmith::event[4905]: expanding /etc/init/shellinaboxd.conf
Oct 19 17:04:56 nethserver-dev esmith::event[4905]: expanding /etc/httpd/conf.d/shellinabox.conf
Oct 19 17:04:56 nethserver-dev esmith::event[4905]: Action: /etc/e-smith/events/actions/generic_template_expand SUCCESS [0.132511]
Oct 19 17:04:56 nethserver-dev esmith::event[4905]: shellinaboxd start/running, process 4914
Oct 19 17:04:56 nethserver-dev esmith::event[4905]: [INFO] shellinaboxd has been started
Oct 19 17:04:56 nethserver-dev esmith::event[4905]: 
Oct 19 17:04:56 nethserver-dev esmith::event[4905]: [INFO] service httpd reload
Oct 19 17:04:56 nethserver-dev init: shellinaboxd main process ended, respawning
Oct 19 17:04:56 nethserver-dev kernel: __ratelimit: 1 callbacks suppressed
Oct 19 17:04:56 nethserver-dev kernel: shellinaboxd[4913]: segfault at 2 ip 00007fda6dca7e2c sp 00007fff600b7d50 error 4 in libc-2.12.so[7fda6dc60000+18a000]
Oct 19 17:04:56 nethserver-dev esmith::event[4905]: Reloading httpd: 
Oct 19 17:04:56 nethserver-dev esmith::event[4905]: [INFO] httpd reload
Oct 19 17:04:56 nethserver-dev esmith::event[4905]: Action: /etc/e-smith/events/actions/adjust-services SUCCESS [0.358138]
Oct 19 17:04:56 nethserver-dev esmith::event[4905]: Event: nethserver-shellinabox-update SUCCESS
Oct 19 17:04:56 nethserver-dev kernel: shellinaboxd[4938]: segfault at 2 ip 00007f12e485fe2c sp 00007ffe0207b170 error 4 in libc-2.12.so[7f12e4818000+18a000]
Oct 19 17:04:56 nethserver-dev init: shellinaboxd main process ended, respawning
Oct 19 17:04:56 nethserver-dev kernel: shellinaboxd[4951]: segfault at 2 ip 00007f7ecf0d7e2c sp 00007ffcfff73830 error 4 in libc-2.12.so[7f7ecf090000+18a000]
Oct 19 17:04:56 nethserver-dev init: shellinaboxd main process ended, respawning
Oct 19 17:04:57 nethserver-dev kernel: shellinaboxd[4956]: segfault at 2 ip 00007fa10eb4fe2c sp 00007ffff2a240f0 error 4 in libc-2.12.so[7fa10eb08000+18a000]
Oct 19 17:04:57 nethserver-dev init: shellinaboxd main process ended, respawning
Oct 19 17:04:57 nethserver-dev kernel: shellinaboxd[4961]: segfault at 2 ip 00007f79d4b4fe2c sp 00007fffefb79790 error 4 in libc-2.12.so[7f79d4b08000+18a000]
Oct 19 17:04:57 nethserver-dev init: shellinaboxd main process ended, respawning
Oct 19 17:04:57 nethserver-dev kernel: shellinaboxd[4966]: segfault at 2 ip 00007fd36b97fe2c sp 00007ffdaedee600 error 4 in libc-2.12.so[7fd36b938000+18a000]
Oct 19 17:04:57 nethserver-dev init: shellinaboxd main process ended, respawning
Oct 19 17:04:57 nethserver-dev kernel: shellinaboxd[4971]: segfault at 2 ip 00007f0f46dcfe2c sp 00007ffec1d1ca40 error 4 in libc-2.12.so[7f0f46d88000+18a000]
Oct 19 17:04:57 nethserver-dev init: shellinaboxd main process ended, respawning
Oct 19 17:04:57 nethserver-dev kernel: shellinaboxd[4976]: segfault at 2 ip 00007f0185d87e2c sp 00007ffcb8983340 error 4 in libc-2.12.so[7f0185d40000+18a000]
Oct 19 17:04:57 nethserver-dev init: shellinaboxd main process ended, respawning
Oct 19 17:04:58 nethserver-dev kernel: shellinaboxd[4981]: segfault at 2 ip 00007f6ee3a77e2c sp 00007ffc2bcc4580 error 4 in libc-2.12.so[7f6ee3a30000+18a000]
Oct 19 17:04:58 nethserver-dev init: shellinaboxd main process ended, respawning
Oct 19 17:04:58 nethserver-dev kernel: shellinaboxd[4986]: segfault at 2 ip 00007f008cd0fe2c sp 00007fff2377dd10 error 4 in libc-2.12.so[7f008ccc8000+18a000]
Oct 19 17:04:58 nethserver-dev init: shellinaboxd main process ended, respawning
Oct 19 17:04:58 nethserver-dev init: shellinaboxd respawning too fast, stopped

The template.metadata

# cat /etc/e-smith/templates.metadata/etc/init/shellinaboxd.conf 
TEMPLATE_PATH='upstart-job'
OUTPUT_FILENAME='/etc/init/shellinaboxd.conf'
MORE_DATA={ name => 'shellinaboxd', description => 'Shellinabox daemon', author => 'Stephane de Labrusse <stephdl@de-labrusse.fr>', daemon_bin => '/usr/sbin/shellinaboxd', daemon_args => '', respawn => 1, 'expect' => 'fork', stop_on => 'stopping network', start_on => 'started network' }

(Painkiller) #10

this would be great!


(Stéphane de Labrusse) #11

the event stops to hang when I redirect the daemon (in the sysvinit script) to /dev/null…argh

-    daemon $prog -u $USER -g $GROUP --cert=${CERTDIR} --port=${PORT} --background=$pid $OPTS

+   daemon $prog -u $USER -g $GROUP --cert=${CERTDIR} --port=${PORT} --background=$pid $OPTS >/dev/null 2>&1

(Giacomo Sanchietti) #12

I smell a bad written daemon :stuck_out_tongue:


(Alessio Fattorini) #13

Discussion is continuing here