'os level': value => $os_level;
'preferred master': value => $preferred_master;
}
-
- file {'/sbin/check_samba_user':
- # script checks to see if a samba account exists for a given user
- owner => root,
- group => root,
- mode => '0755',
- content => template("${module_name}/check_samba_user"),
- }
-
- file {'/sbin/add_samba_user':
- # script creates a new samba account for a given user and password
- owner => root,
- group => root,
- mode => '0755',
- content => template("${module_name}/add_samba_user"),
- }
}
$password,
$user_name = $name,
) {
+ require ::samba::server::install
+
exec { "add smb account for ${user_name}":
- command => "/sbin/add_samba_user '${user_name}' '${password}'" ,
- unless => "/sbin/check_samba_user '${user_name}'" ,
+ command => "/bin/echo -e '${password}\\n${password}\\n' | /usr/bin/pdbedit --password-from-stdin -a '${user_name}'",
+ unless => "/usr/bin/pdbedit '${user_name}'",
require => [ User[$user_name] ],
- notify => Class['samba::server::service']
+ notify => Class['samba::server::service'] #TODO: Is this really required??
}
}
it { should contain_samba__server__option('printing') }
it { should contain_samba__server__option('printcap name') }
it { should contain_samba__server__option('disable spoolss') }
-
- it { should contain_file('/sbin/check_samba_user').with_owner('root') }
- it { should contain_file('/sbin/add_samba_user').with_owner('root') }
end
--- /dev/null
+require 'spec_helper'
+
+describe 'samba::server::user', :type => :define do
+ let(:title) { 'test_user' }
+ let(:params) {{ :password => 'secret' }}
+
+ it { is_expected.to contain_samba__server__user('test_user') }
+ it { is_expected.to contain_exec('add smb account for test_user').with(
+ :command => '/bin/echo -e \'secret\nsecret\n\' | /usr/bin/pdbedit --password-from-stdin -a \'test_user\'',
+ :unless => '/usr/bin/pdbedit \'test_user\'',
+ :require => 'User[test_user]',
+ :notify => 'Class[Samba::Server::Service]'
+ ) }
+end
+++ /dev/null
-#!/bin/bash
-
-# This script adds a samba account for a given user and password
-# call as:
-# > add_samba_user "USERNAME" "PASSWORD"
-
-/bin/echo -e "$2\n$2\n" | sudo /usr/bin/pdbedit -a "$1" -t 1>/dev/null
-results=$?
-
-if [ $results = 0 ]; then
- echo "added samba account for '$1'"
-else
- echo "could not add samba account for '$1'"
-fi
-
-exit $results
+++ /dev/null
-#!/bin/bash
-
-# This script checks to see if a given user account exists on samba
-# if so, it returns 0
-# otherwise it returns 1
-
-sudo /usr/bin/pdbedit -L | egrep -q "^$1:"
-exists=$?
-
-if [ $exists = 0 ]; then
- echo "'$1' is a samba user"
-else
- echo "no samba account matching '$1'"
-fi
-
-exit $exists