Bug 42241 - Can't start/stop/restart Samba4 Service via UMC
Can't start/stop/restart Samba4 Service via UMC
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UMC - System services
UCS 4.4
Other Linux
: P5 normal (vote)
: UCS 4.4-1-errata
Assigned To: Florian Best
Arvid Requate
:
: 49215 (view as bug list)
Depends on:
Blocks: 50098
  Show dependency treegraph
 
Reported: 2016-09-02 16:48 CEST by Hendrik Peter
Modified: 2019-09-03 10:19 CEST (History)
9 users (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 5: Major Usability: Impairs usability in key scenarios
Who will be affected by this bug?: 3: Will affect average number of installed domains
How will those affected feel about the bug?: 2: A Pain – users won’t like this once they notice it
User Pain: 0.171
Enterprise Customer affected?: Yes
School Customer affected?: Yes
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number: 2019040121000345, 2019042421000865, 2019033121000201, 2019050321000143, 2019060321000589
Bug group (optional):
Max CVSS v3 score:
best: Patch_Available+


Attachments
patch (git:fbest/42241-fix-samba-service-detection) (2.94 KB, patch)
2019-05-13 14:48 CEST, Florian Best
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Hendrik Peter univentionstaff 2016-09-02 16:48:31 CEST
System Services shows a Service called 'Samba4' which can't be stopped, started or restarted via the Management Console.

'Samba4' displays the Status of the samba/smbd/samba-ad-dc Service but can't manage it.

----------------------
Popup when trying to start/stop/restart:
Internal module error: An error occured during command processing.

Server error message:

Restarting the following services failed: samba4

----------------------
The Log-File
/var/log/univention/management-console-module-services.log

only shows the following, when trying to restart via the Restart-Button:
02.09.16 16:23:28.531  MODULE      ( ERROR   ) : ['services/restart']

No other messages are shown, when trying to Start/Stop the app.

----------------------
Note:
The following Apps where installed:
Active Directory-compatible Domain Controller
(DHCP server
SiouxApp Business Suite
SiouxApp DokuWiki)
Comment 1 Florian Best univentionstaff 2016-09-09 15:35:12 CEST
Did this happen with UCS 4.1 or UCS 4.2?

The error handling will be solved via Bug #36562.
Comment 2 Hendrik Peter univentionstaff 2016-09-09 16:12:50 CEST
4.1, sorry.
Comment 3 Michael Salm 2017-05-11 08:43:55 CEST
UCS 4.1 is missing the symlink "/etc/init.d/samba4". In UCS 3.3 it existed, linking to "/etc/init.d/samba-ad-dc".

As workaround create the symlink yourself and voila - UMC can start/stop/restart the samba4 service again.
Comment 4 Florian Best univentionstaff 2017-06-28 14:52:57 CEST
There is a Customer ID set so I set the flag "Enterprise Customer affected".
Comment 5 Michael Salm 2017-07-13 08:39:21 CEST
UCS 4.2 still has this problem - samba4 cannot be managed from System Services.

Since 4.2 uses systemd the workaround for earlier UCS versions does not work anymore.

I helped myself by adding a symlink "/run/systemd/generator.late/samba4.service" showing to "/run/systemd/generator.late/samba-ad-dc.service".
Comment 6 Stefan Gohmann univentionstaff 2019-01-03 07:19:29 CET
This issue has been filled against UCS 4.1. The maintenance with bug and security fixes for UCS 4.1 has ended on 5st of April 2018.

Customers still on UCS 4.1 are encouraged to update to UCS 4.3. Please contact
your partner or Univention for any questions.

If this issue still occurs in newer UCS versions, please use "Clone this bug" or simply reopen the issue. In this case please provide detailed information on how this issue is affecting you.
Comment 7 Michele 2019-03-12 17:56:39 CET
I need to reopen this bug because after upgrade to UCS 4.4 I have exactly the same problem.
Comment 8 Florian Best univentionstaff 2019-03-13 11:39:21 CET
I can confirm this:
UMC displays a service named samba4 which is always displayed as stopped. Clicking on start causes the error message:
"""
Starting the service samba4 failed:
Unit samba4.service could not be found.
"""

The process list shows a samba process:
root     16042  0.2  1.4 612100 43544 ?        Ss   16:16   0:00 samba: root process
root     16061  0.0  0.9 612100 27892 ?        S    16:16   0:00  \_ samba: task[s3fs_parent]
root     16063  0.0  0.7 612104 22408 ?        S    16:16   0:00  |   \_ samba: tfork waiter process
root     16062  0.0  1.2 616352 38544 ?        S    16:16   0:00  \_ samba: task[dcesrv]
root     16064  0.0  0.9 614712 28980 ?        S    16:16   0:00  \_ samba: task[wreplsrv]
root     16066  0.1  1.1 612100 34152 ?        S    16:16   0:00  \_ samba: task[ldapsrv]
root     18711  0.6  1.2 616968 39224 ?        S    16:19   0:00  |   \_ samba: conn[ldap] c[unix:] s[unix:/var/lib/samba/private/ldap_priv/ldapi] server_id[18711]
root     16067  0.0  0.9 612100 30828 ?        S    16:16   0:00  \_ samba: task[cldapd]
root     16068  0.0  1.3 616352 40124 ?        S    16:16   0:00  \_ samba: task[kdc]
root     16069  0.0  1.0 612100 32596 ?        S    16:16   0:00  \_ samba: task[dreplsrv]
root     16070  0.0  0.9 612100 27828 ?        S    16:16   0:00  \_ samba: task[winbindd_parent]
root     16073  0.0  0.7 612104 23844 ?        S    16:16   0:00  |   \_ samba: tfork waiter process
root     16071  0.0  1.0 612100 31196 ?        S    16:16   0:00  \_ samba: task[ntp_signd]
root     16072  0.0  1.2 612100 38672 ?        S    16:16   0:00  \_ samba: task[kccsrv]
root     16074  0.0  1.0 612100 31780 ?        S    16:16   0:00  \_ samba: task[dnsupdate]

# ls -l /proc/16042/exe 
lrwxrwxrwx 1 root root 0 Mär 11 16:17 /proc/16042/exe -> /usr/sbin/samba

# cat /etc/univention/service.info/services/univention-samba4.cfg
[samba4]
description[de]=Stellt Dienste für Windows Systeme zur Verfügung
description[en]=Provides Services for Windows
icon=service/samba
programs=/usr/sbin/samba
start_type=samba4/autostart
systemd=samba-ad-dc.service

Is the systemd entry wrong?
Comment 9 Erik Damrose univentionstaff 2019-04-02 12:41:29 CEST
*** Bug 49215 has been marked as a duplicate of this bug. ***
Comment 10 Christian Völker univentionstaff 2019-04-02 15:20:36 CEST
Happened for a customer.
Comment 11 Florian Best univentionstaff 2019-05-13 14:48:24 CEST
Created attachment 10024 [details]
patch (git:fbest/42241-fix-samba-service-detection)

Attached is a patch for:
1. the detection of running service which rewrite their process arguments /proc/$pid/cmdline as samba does. Detect via len(args) == 1 and symlink(/proc/$pid/exe) == args[0])

2. use of the correct systemd service definition from the service configuration file:
/etc/univention/service.info/services/univention-samba4.cfg defines the service "samba4" with systemd=samba-ad-dc.service.
but the UMC code called "service samba4 restart" instead of "service samba-ad-dc.service restart".

This affects also (the probably broken services):
[uvmm/novnc]
systemd=univention-novnc.service

and

[openbsd-inetd]
systemd=inetd.service
Comment 12 Florian Best univentionstaff 2019-05-21 20:53:34 CEST
postfix is also broken:
service definiton: /usr/lib/postfix/master
running program: /usr/lib/postfix/sbin/master -w

postgres is also broken:
service definition: /usr/lib/postgresql/9.4/bin/postgres
running programm: /usr/lib/postgresql/9.6/bin/postgres -D /var/lib/postgresql/9.6/main -c config_file=/etc/postgresql/9.6/main/postgresql.conf
Comment 13 Florian Best univentionstaff 2019-06-03 14:56:44 CEST
Since Bug #49176 only the second file in the patch is necessary. The status of Samba should now already be detected correctly but start/stop/restarting is not possible.

<http://errata.software-univention.de/ucs/4.4/119.html>
Comment 14 Christian Völker univentionstaff 2019-06-04 09:33:04 CEST
Sorry, I do not get it. 

What is fixed now with e119?
Just the service display in UMC?
Or the possibility to start/stop/restart at least samba4 (samba-ad-dc) through UMC?

Happened for another customer, attaching ticket.
Comment 15 Florian Best univentionstaff 2019-06-04 10:05:27 CEST
(In reply to Christian Völker from comment #14)
> Sorry, I do not get it. 
> 
> What is fixed now with e119?
> Just the service display in UMC?
Yes, only that the state is detected correctly.

> Or the possibility to start/stop/restart at least samba4 (samba-ad-dc)
> through UMC?
No, this is still not possible. Therefore there is the second file in the patch file of attachment 10024 [details].
Comment 16 Florian Best univentionstaff 2019-07-30 16:01:07 CEST
Fixed the generic issue in the services module:
Use the "systemd" definition of the service instead of the section name when restart/start/stop services.

And fixed univention-postgresql by splitting it into two service files for each postgresql version.
postgresql-9.6 was never displayed until now. It has the new UCR variable postgresql9.6/autostart.
postgresql-9.4 has been fixed and uses the old UCR variable, which it used before, postgresql8/autostart.

Also fixed the binary path for univention-mail-postfix, so that the service is visible again in UMC.

univention-postgresql (11.0.1-2)
c6eca30b9b0d | Bug #42241: fix univention service definition

univention-mail-postfix.yaml
d754c171455c | Bug #42241: fix service definition of postfix

univention-mail-postfix (13.0.1-2)
d754c171455c | Bug #42241: fix service definition of postfix

univention-postgresql.yaml
c6eca30b9b0d | Bug #42241: fix univention service definition

univention-management-console-module-services (8.0.1-2)
25cb35f5c7c5 | Bug #42241: fix start/restart/stop of services with different systemd name than the service definition name

univention-management-console-module-services (8.0.1-3)
220039464cba | Bug #42241: enhancement: service $foo.service does not work, only systemctl restart $foo.service works. Strip .service therefore.

univention-management-console-module-services.yaml
25cb35f5c7c5 | Bug #42241: fix start/restart/stop of services with different systemd name than the service definition name
Comment 17 Florian Best univentionstaff 2019-08-02 18:06:26 CEST
(In reply to Florian Best from comment #16)
> Fixed the generic issue in the services module:
> Use the "systemd" definition of the service instead of the section name when
> restart/start/stop services.
Unfortionately this must not be done for Samba 4 because of Bug #44237 and especially Bug #47634, as the samba service defintion defined only to restart samba-ad-dc.

Because of this, I moved the start/stop/restart handling into service_info.py and introduced a "init_script=samba" in the samba service definition.
If init_script is used, it uses /etc/init.d/$init_script $action to restart/… the service.

univention-samba4 (8.0.0-26)
3d0ced99417e | Bug #42241: fix service definition of samba

univention-management-console-module-services (8.0.1-4)
9de6f183ac1f | Bug #42241: move start/stop/restart logic into service_info.py

univention-config-registry (14.0.0-11)
df4b966c50b5 | Bug #42241: move start/stop/restart logic into service_info.py
Comment 18 Arvid Requate univentionstaff 2019-08-07 14:38:23 CEST
Verified:
* Code review
* Package update
* Functional test
* Advisories
Comment 20 Philipp Hahn univentionstaff 2019-08-14 11:07:55 CEST
Those changes were never documented and caused a regression, when univention-install-service-info is invoked.

[4.4-1] 7352ba9512 Bug #42241 ucr: Silence u-install-service-info warning
 .../doc/univention-install-service-info.1                | 10 +++++++++-
 .../python/univention/service_info.py                    |  2 +-
 doc/developer-reference/ucr/ucr.xml                      | 16 +++++++++++++++-
 3 files changed, 25 insertions(+), 3 deletions(-)