Koozali.org formerly Contribs.org

Special ibay and samba config how?

Special ibay and samba config how?
« on: April 23, 2013, 03:00:12 PM »
Sorry, but i am stuck. For a special application, that is not "well-behaving", i need some special ibay/samba parameters. It is:
Code: [Select]
acl compatibility = win2k
level2 oplocks = no
dos filemode = yes

[data]
create mode = 0777
force create mode = 0777
force group = anwalt
directory mode = 0777
guest ok = no
valid users = @anwalt root
locking = no

How can i change these values for this ibay only? I read the developer-howto and several topics in this forum, but did not get the clue. As far as i read, we can shut off oplocks per ibay via database entry. But what about the rest? Where do i have to put or copy/paste/change the template-fragments for /etc/e-smith/templates-custom/etc/smb.conf or where else do we have to put the fragments to change just 1 single ibay?

Sorry, but i do not fully understand the concept, which has changed some time ago. If you advise me a little, i would make a small howto out of it. Thanks for any help.
Alexander Ziemann, Berlin - DE

Offline Stefano

  • *
  • 10,805
  • Skype account: maghissimo
    • Smeserver italian community
Re: Special ibay and samba config how?
« Reply #1 on: April 23, 2013, 03:31:22 PM »
take a look ad the samba audit feature..

more info in /etc/e-smith/templates/etc/smb.conf/ibays/10smbaudit

generally speaking, global flags are set via /etc/e-smith/templates/etc/smb.conf/ fragments, and single ibay properties via /etc/e-smith/templates/etc/smb.conf/ibays/ ones

HTH
Consulente di Smeserver.it -  Soluzioni e supporto su Sme server in Italia

Re: Special ibay and samba config how?
« Reply #2 on: April 26, 2013, 09:28:57 AM »
This is a little hard for me, because i don't know php.   :?

Do i have to use or create a db property like given in the audit example? And where do i put the code, that has to show up in the single ibay (=share) section of smb.conf?

Thanks for the clear statement, where to look and edit.
Alexander Ziemann, Berlin - DE

Offline Stefano

  • *
  • 10,805
  • Skype account: maghissimo
    • Smeserver italian community
Re: Special ibay and samba config how?
« Reply #3 on: April 26, 2013, 11:31:07 AM »
This is a little hard for me, because i don't know php.   :?

it's perl BTW :-)

Quote
Do i have to use or create a db property like given in the audit example? And where do i put the code, that has to show up in the single ibay (=share) section of smb.conf?

Oplocks can be already set with
Code: [Select]
config setprop smb OpLocks enabled (general)
db accounts setprop ibayname OpLocks enabled (per ibay)
signal-event ibay-modify Primary

for
Code: [Select]
acl compatibility = win2k
dos filemode = yes

just log in as root via ssh, then
Code: [Select]
mkdir /etc/e-smith/templates-custom/etc/smb.conf
nano 11zmyvariables

add
Code: [Select]
acl compatibility = win2k
dos filemode = yes


then exit and save with Ctrl+X

for the guest directive, read here:
http://forums.contribs.org/index.php/topic,44889.msg216789.html#msg216789

now the "hardest" part..

1) create a custom-template dir for smb.conf
Code: [Select]
mkdir -p /etc/e-smith/templates-custom/etc/smb.conf/ibays
cd /etc/e-smith/templates-custom/etc/smb.conf/ibays

2) create the custom fragment
Code: [Select]
nano 30permissions

fill it with
Code: [Select]
{
    # the original part
    my %perms = (
            'wr-admin-rd-group' => '0640',
            'wr-group-rd-group' => '0660',
            'wr-group-rd-everyone' => '0664',
        );

        # the new part

        $OUT .= "inherit permissions = yes\n";


        if ( ($ibay->prop('CustPerms') || '0000') eq '0000') {
        my $fmode = $perms{$ibay->prop('UserAccess')} || '0000';
        $OUT .= "create mode = $fmode\n";
    } else {
        my $cperms = $ibay->prop('CustPerms');
        $OUT .= "create mode = $cperms\n";
                $OUT .= "force create mode = $cperms\n";
                $OUT .= "directory mode = $cperms\n";
                $OUT .= "locking = no\n";
                if ( ($ibay->prop('ForceGroup') || '') ne '') {
                        my $fgroup = $ibay->prop('ForceGroup');
                        $OUT .= "force group = $fgroup\n";
                }
                my @userlist = split /[:]/, $ibay->prop('ValidUsers') || '';
                if (@userlist ne '') {
                        my $vusers= join (' ',@userlist);
                        $OUT .= "valid users = $vusers\n;"
                }
    }

}

save and exit with Ctrl-X

now
Code: [Select]
db accounts setprop ibayname CustPerms 0777
db accounts setprop ibayname ForceGroup yourgroup
db accounts setprop ibayname ValidUsers user1:user2:user3
signal-event ibay-modify ibayname

should work, not tested

NOTE
if you don't set CustPerms db value, no valid group/users will be considered

HTH

Consulente di Smeserver.it -  Soluzioni e supporto su Sme server in Italia

Re: Special ibay and samba config how?
« Reply #4 on: April 27, 2013, 06:51:00 PM »
Thanks, Stefano,

i owe you one, even if i don't know php/perl/whatsoever  :smile:

It worked as expected and every variable/output was placed where it should be. I had to make 1 addition, because i had to place "force user = someuser" also in the ibay-part. So i tried to imitate your perl-magic and added one line (the last one):

Code: [Select]
if ( ($ibay->prop('ForceGroup') || '') ne '') {
                        my $fgroup = $ibay->prop('ForceGroup');
                        $OUT .= "force group = $fgroup\n";
                        $OUT .= "force user = office\n";

Not the correct way, but works. At least i understood a bit about perl-magic now and am able to add some variables, if condition applies.

This is really helpful for a perl-dummy like i am because i really had to modify that ibay. What a pity this is so complicated. There should be a window in server-manager panel, where you can add these strange parameters for ibays if needed. Nas4Free has this kind of "extra-window" for each share.

Thanks again. Should i try to make a small howto out of this or is this not supposed to be helpful?
Alexander Ziemann, Berlin - DE

Offline Stefano

  • *
  • 10,805
  • Skype account: maghissimo
    • Smeserver italian community
Re: Special ibay and samba config how?
« Reply #5 on: April 27, 2013, 07:04:25 PM »
first consideration: you are hardcoding a value.. to add "force user" directive, just "copy" the ForceGroup lines.. jus use a different variable name and remember to add the value into db

something like
Code: [Select]
db accounts setprop ibayname ForceUser myuser

then: if you need something, just make a donation to the project or hire someone and pay him..
I know there are many "alternatives" out there, but if you choose SME, you have to know it, understand how it works and do things in "the SME way" :-)

IMHO you don't need to do any kind of howto, but please file a bug (more precisely a NFR), post there the fragment and report here the reference, thank you

finally: SME is a collaborative project and need help to be improved.. if you have time/money to invest in the project, you are welcome :-)
Consulente di Smeserver.it -  Soluzioni e supporto su Sme server in Italia