Koozali.org: home of the SME Server

Auto/Immediate restart of smb service

Offline Danie

  • 2
  • +0/-0
Auto/Immediate restart of smb service
« on: April 24, 2008, 06:11:36 PM »
Hi All,

I'm new to SME and linux and general but I need help please. Correct me if I'm wrong but it seems that when you remove a user's access rights from a group that has access on an Ibay that it takes some time before the blocking of access to that Ibay occurs - i'm assuming that the samba service restarts automatically after some time? What I need is to be able to have a link in the server manager e.g. "restart samba service" that I can click that simply issues the console command "service smb restart".

I've been battling the whole day using the SME developer guide and I've managed to create a script... i think...maybe not even (I'm not even sure what to use i.e. sh or bash etc. I'm really new to linux) and I've also managed to get a link into the server manager from reading the dev guide but it does not work.  :-(

The script is in /etc/e-smith/web/functions and I then created symbolic link to it in /etc/e-smith/web/panels/manager/cgi-bin

The script is called restart-samba and merely says: service smb restart (but I didnt know quite how to create it being #!/bin/sh or #!/bin/bash etc. etc.) It works when run from command line.

After doing this I did chown root:admin restart-samba and then chmod 4750 restart-samba

Then I issued the command: /etc/e-smith/events/actions/navigation-conf

The link to it pops up in server manager but the error I receive when clicking it is: Internal Server Error, the server encountered and internal error or misconfiguration and was unable to complete your request.

The nature of our business requires me to be able to cut off a user's access to sensitive info immediately which is why I really need this. Can anyone please help me, I'm sure this must be way more compllicated than what I thought.

Best regards
Danie

Online Stefano

  • *
  • 10,894
  • +3/-0
Re: Auto/Immediate restart of smb service
« Reply #1 on: April 24, 2008, 06:54:46 PM »
hi..

just a question: have you tried to log off windoze's user and then log-on? maybe a problem of caching client-side..

HTH

Ciao
Stefano

Offline imcintyre

  • *
  • 609
  • +0/-0
Re: Auto/Immediate restart of smb service
« Reply #2 on: April 24, 2008, 07:06:31 PM »
Perhaps this is what you are looking for instead of writing your own script

http://wiki.contribs.org/Service_Control

Offline pfloor

  • *****
  • 889
  • +1/-0
Re: Auto/Immediate restart of smb service
« Reply #3 on: April 24, 2008, 07:21:01 PM »
Danie,

You need to explore how SME works and look under the /etc/e-smith/events directory.  There is already a smb restart built in when you add, delete or modify groups but I think you may have hit a possible bug here.

Currently when you add, delete or modify a group SME sends a "sighup" to smbd.  This doesn't seem sufficient to restart Samba and remove the user from the group permissions.  I have experimented and found that if you issue a restart instead of sighup then the user is immediately removed from the group and access is issued/revoked immediately.

Here is a simple fix but I must CAUTION you that there may be specific reasons as to why the current command is sighup so this should be discussed on the devinfo list or taken to the bug tracker.


ln -sf restart /etc/e-smith/events/group-modify/services2adjust/smbd

If you find problems then you can revert the setting with:

ln -sf sighup /etc/e-smith/events/group-modify/services2adjust/smbd

CAUTION: I tested this and it seems to work but this is an UNTESTED change so if this is a production server you may consider testing on a test server first.
In life, you must either "Push, Pull or Get out of the way!"

Offline pfloor

  • *****
  • 889
  • +1/-0
Re: Auto/Immediate restart of smb service
« Reply #4 on: April 24, 2008, 07:40:03 PM »
Here is a simple fix but I must CAUTION you that there may be specific reasons as to why the current command is sighup so this should be discussed on the devinfo list or taken to the bug tracker.

I have raised this question on the bug tracker, please follow up there:

http://bugs.contribs.org/show_bug.cgi?id=4265
In life, you must either "Push, Pull or Get out of the way!"

Offline pfloor

  • *****
  • 889
  • +1/-0
Re: Auto/Immediate restart of smb service
« Reply #5 on: April 25, 2008, 02:40:40 AM »
Quote
Here is a simple fix but I must CAUTION you that there may be specific reasons as to why the current command is sighup so this should be discussed on the devinfo list or taken to the bug tracker.

And the conclusion is DON'T use "restart".  It can (and most likely will) cause you problems, namely file corruption.  Restart kills all samba connections and if anyone is accessing a file or database through the local network when you initiate the restart it will be like pulling the network cable...Not a good thing!

P.S. Danie, your script will do the same thing and I caution you not to use it.  Unfortunately, this is just the way Samba works :-(
In life, you must either "Push, Pull or Get out of the way!"

Offline thomasch

  • *
  • 232
  • +0/-0
Re: Auto/Immediate restart of smb service
« Reply #6 on: April 25, 2008, 04:31:53 AM »

i'm assuming that the samba service restarts automatically after some time?


Danie,

I don't think so. If samba service restarts automatically then we will lose data while network writing to smb mounts.

I'm sorry can't help you more than this but I think this is a bad assumption and dangerous as you can lose data when smb service down in the middle while another user writing to any ibays.

thomas

Offline thomasch

  • *
  • 232
  • +0/-0
Re: Auto/Immediate restart of smb service
« Reply #7 on: April 25, 2008, 04:37:00 AM »

And this looks like a bug to me:


........... when you remove a user's access rights from a group that has access on an Ibay that it takes some time before the blocking of access to that Ibay occurs...
 

Post a bug in bug tracker please.

thomas

Offline pfloor

  • *****
  • 889
  • +1/-0
Re: Auto/Immediate restart of smb service
« Reply #8 on: April 25, 2008, 05:59:47 AM »
Danie,
I don't think so. If samba service restarts automatically then we will lose data while network writing to smb mounts.

You are correct that Samba doesn't restart but it does continually look for configuration changes and reloads itself when it detects one.

IOW, if you edit the smb.conf file samba WILL reload the configuration file(s) automatically without any further action.  How long it waits to reload depends on many factors and I have discovered the range to be from several seconds to many minutes.

And this looks like a bug to me:

Post a bug in bug tracker please.

thomas

Thomas, if you followed this entire thread you would see a bug has already been opened: http://bugs.contribs.org/show_bug.cgi?id=4265

The bug has been now closed as there is nothing that can be done about the delay in Samba reloading, it's just the way Samba works.
In life, you must either "Push, Pull or Get out of the way!"

Offline Danie

  • 2
  • +0/-0
Re: Auto/Immediate restart of smb service
« Reply #9 on: April 25, 2008, 11:56:08 AM »
Thank you all so much for your replies, I really appreciate the feedback as well as your effort to even open up a bug for it.

After considering your informative replies it actually makes sense that the restart command isnt issued to samba flat out as it will disconnect open filesharing / edits etc - the priority thus being put on data integrity by samba which I think would be most people's preference and keeps it all robust.

It will still make things more difficult sad to say.

As said before I'm new to linux but my mind is just going here and I'm thinking...

Would it not be possible to "grab" the state of any opened / in use files, restart the server thus enforcing the security needed and then restoring the state of the files into the service / for continued use? This would by the very nature of it be very complicated and perhaps I don't realise the implications of what this would mean to the OS.

Best regards and thanks again!
Danie