mirror of
https://github.com/samba-team/samba.git
synced 2025-03-27 22:50:26 +03:00
gpo: Apply Group Policy Message of the day
Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
This commit is contained in:
parent
e8757e0d36
commit
a4f598fde8
@ -3084,6 +3084,9 @@ Example: 192.9.200.1 192.168.2.61</string>
|
||||
<string id="POL_F19C445A_AFD5_51B6_B87A_E42499C3C5D8_Help">This is the interval in s till tombstone records are deleted from the WINS database. Defaults to 1 day.</string>
|
||||
<string id="POL_8CF1FEA3_BD3E_53C0_9F73_34050187A91E">wreplsrv:verify_interval</string>
|
||||
<string id="POL_8CF1FEA3_BD3E_53C0_9F73_34050187A91E_Help">This is the interval in s till we verify active replica records with the owning WINS server. Unfortunately not implemented yet. Defaults to 24 days.</string>
|
||||
<string id="CAT_9DEF582D_447A_47E9_A1F5_363558D03FA9">Messages</string>
|
||||
<string id="POL_38DA04F0_3FD6_4425_8924_1CEEA685FD07">Message of the day</string>
|
||||
<string id="POL_38DA04F0_3FD6_4425_8924_1CEEA685FD07_Help"> The contents of /etc/motd are displayed after a successful login but just before it executes the login shell.</string>
|
||||
</stringTable>
|
||||
<presentationTable>
|
||||
<presentation id="POL_9320E11F_AC80_4A7D_A5C8_1C0F3F727061">
|
||||
@ -4591,6 +4594,11 @@ Example: 192.9.200.1 192.168.2.61</string>
|
||||
<defaultValue>2073600</defaultValue>
|
||||
</textBox>
|
||||
</presentation>
|
||||
<presentation id="POL_38DA04F0_3FD6_4425_8924_1CEEA685FD07">
|
||||
<textBox refId="TXT_609C208A_3B4D_48F1_8A15_C0DF08EAD4D6">
|
||||
<label>Message of the day</label>
|
||||
</textBox>
|
||||
</presentation>
|
||||
</presentationTable>
|
||||
</resources>
|
||||
</policyDefinitionResources>
|
||||
|
@ -14,6 +14,9 @@
|
||||
<category name="CAT_2B6D622C_5721_4C23_A2D6_5C70D6E059BA" displayName="$(string.CAT_2B6D622C_5721_4C23_A2D6_5C70D6E059BA)">
|
||||
<parentCategory ref="CAT_7D8D7DC8_5A9D_4BE1_8227_F09CDD5AFFC6" />
|
||||
</category>
|
||||
<category name="CAT_9DEF582D_447A_47E9_A1F5_363558D03FA9" displayName="$(string.CAT_9DEF582D_447A_47E9_A1F5_363558D03FA9)">
|
||||
<parentCategory ref="CAT_7D8D7DC8_5A9D_4BE1_8227_F09CDD5AFFC6" />
|
||||
</category>
|
||||
<category displayName="$(string.CAT_10827749_64ED_5052_87F7_E81AD421856A)" name="CAT_10827749_64ED_5052_87F7_E81AD421856A">
|
||||
<parentCategory ref="CAT_3338C1DD_8A00_4273_8547_158D8B8C19E9"/>
|
||||
</category>
|
||||
@ -2511,5 +2514,12 @@
|
||||
<text id="TXT_F35F7924_DBD3_5F6F_B247_7F4893C63844" key="Software\Policies\Samba\smb_conf\wreplsrv:verify_interval" valueName="wreplsrv:verify_interval"/>
|
||||
</elements>
|
||||
</policy>
|
||||
<policy name="POL_38DA04F0_3FD6_4425_8924_1CEEA685FD07" class="Machine" displayName="$(string.POL_38DA04F0_3FD6_4425_8924_1CEEA685FD07)" explainText="$(string.POL_38DA04F0_3FD6_4425_8924_1CEEA685FD07_Help)" presentation="$(presentation.POL_38DA04F0_3FD6_4425_8924_1CEEA685FD07)" key="Software\Policies\Samba\Unix Settings\Messages">
|
||||
<parentCategory ref="CAT_9DEF582D_447A_47E9_A1F5_363558D03FA9" />
|
||||
<supportedOn ref="windows:SUPPORTED_WindowsVista" />
|
||||
<elements>
|
||||
<text id="TXT_609C208A_3B4D_48F1_8A15_C0DF08EAD4D6" key="Software\Policies\Samba\Unix Settings\Messages" valueName="motd" />
|
||||
</elements>
|
||||
</policy>
|
||||
</policies>
|
||||
</policyDefinitions>
|
||||
|
@ -14,9 +14,51 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
from samba.gpclass import gp_pol_ext
|
||||
|
||||
class gp_msgs_ext(gp_pol_ext):
|
||||
def __str__(self):
|
||||
return 'Unix Settings/Messages'
|
||||
|
||||
def process_group_policy(self, deleted_gpo_list, changed_gpo_list,
|
||||
cdir='/etc'):
|
||||
pass
|
||||
for guid, settings in deleted_gpo_list:
|
||||
self.gp_db.set_guid(guid)
|
||||
if str(self) in settings:
|
||||
for attribute, msg in settings[str(self)].items():
|
||||
if attribute == 'motd':
|
||||
mfile = os.path.join(cdir, 'motd')
|
||||
else:
|
||||
continue
|
||||
with open(mfile, 'w') as w:
|
||||
if msg:
|
||||
w.write(msg)
|
||||
else:
|
||||
w.truncate()
|
||||
self.gp_db.delete(str(self), attribute)
|
||||
self.gp_db.commit()
|
||||
|
||||
for gpo in changed_gpo_list:
|
||||
if gpo.file_sys_path:
|
||||
section_name = 'Software\\Policies\\Samba\\Unix Settings\\Messages'
|
||||
self.gp_db.set_guid(gpo.name)
|
||||
pol_file = 'MACHINE/Registry.pol'
|
||||
path = os.path.join(gpo.file_sys_path, pol_file)
|
||||
pol_conf = self.parse(path)
|
||||
if not pol_conf:
|
||||
continue
|
||||
for e in pol_conf.entries:
|
||||
if e.keyname == section_name and e.data.strip():
|
||||
if e.valuename == 'motd':
|
||||
mfile = os.path.join(cdir, 'motd')
|
||||
else:
|
||||
continue
|
||||
if os.path.exists(mfile):
|
||||
old_val = open(mfile, 'r').read()
|
||||
else:
|
||||
old_val = ''
|
||||
with open(mfile, 'w') as w:
|
||||
w.write(e.data)
|
||||
self.gp_db.store(str(self), e.valuename, old_val)
|
||||
self.gp_db.commit()
|
||||
|
@ -396,4 +396,3 @@
|
||||
^samba.tests.ntlmdisabled.python\(ktest\).python2.ntlmdisabled.NtlmDisabledTests.test_samr_change_password\(ktest\)
|
||||
^samba.tests.ntlmdisabled.python\(ad_dc_no_ntlm\).python3.ntlmdisabled.NtlmDisabledTests.test_ntlm_connection\(ad_dc_no_ntlm\)
|
||||
^samba.tests.ntlmdisabled.python\(ad_dc_no_ntlm\).python2.ntlmdisabled.NtlmDisabledTests.test_ntlm_connection\(ad_dc_no_ntlm\)
|
||||
^samba.tests.gpo.samba.tests.gpo.GPOTests.test_gp_motd
|
||||
|
@ -35,6 +35,7 @@ from samba.gp_ext_loader import get_gp_client_side_extensions
|
||||
from samba.gp_scripts_ext import gp_scripts_ext
|
||||
from samba.gp_sudoers_ext import gp_sudoers_ext
|
||||
from samba.gp_smb_conf_ext import gp_smb_conf_ext
|
||||
from samba.gp_msgs_ext import gp_msgs_ext
|
||||
import logging
|
||||
|
||||
if __name__ == "__main__":
|
||||
@ -89,6 +90,7 @@ if __name__ == "__main__":
|
||||
gp_extensions.append(gp_scripts_ext)
|
||||
gp_extensions.append(gp_sudoers_ext)
|
||||
gp_extensions.append(gp_smb_conf_ext)
|
||||
gp_extensions.append(gp_msgs_ext)
|
||||
gp_extensions.extend(machine_exts)
|
||||
elif opts.target == 'User':
|
||||
gp_extensions.extend(user_exts)
|
||||
|
Loading…
x
Reference in New Issue
Block a user