Re: [Freeipa-devel] [PATCH] 388 Remove RUV from LDIF files before using them in ipa-restore

2015-01-20 Thread Jan Cholasta

Dne 13.1.2015 v 17:58 Jan Cholasta napsal(a):

Dne 13.1.2015 v 17:44 Petr Vobornik napsal(a):

On 01/12/2015 05:46 PM, Jan Cholasta wrote:

Hi,

the attached patch fixes https://fedorahosted.org/freeipa/ticket/4822.

Honza



works for me, ACK


Thanks, pushed to:
master: 05e6adecb51b93e9b9d2326df4eabee90c3dfe72
ipa-4-1: eb7917026d418a6d6a1e7a24a19097065df10497



Posting additional patch 394 which fixes a SELinux issue.

--
Jan Cholasta
From 6f88548e2302c1f99d0756afa351ce79b7e4ed67 Mon Sep 17 00:00:00 2001
From: Jan Cholasta jchol...@redhat.com
Date: Tue, 20 Jan 2015 11:22:29 +
Subject: [PATCH] Put LDIF files to their original location in ipa-restore

This prevents SELinux failures during online data restore.

https://fedorahosted.org/freeipa/ticket/4822
---
 ipaserver/install/ipa_restore.py | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/ipaserver/install/ipa_restore.py b/ipaserver/install/ipa_restore.py
index be48716..562a793 100644
--- a/ipaserver/install/ipa_restore.py
+++ b/ipaserver/install/ipa_restore.py
@@ -504,10 +504,17 @@ class Restore(admintool.AdminTool):
 cn = time.strftime('import_%Y_%m_%d_%H_%M_%S')
 dn = DN(('cn', cn), ('cn', 'import'), ('cn', 'tasks'), ('cn', 'config'))
 
+ldifdir = paths.SLAPD_INSTANCE_LDIF_DIR_TEMPLATE % instance
 ldifname = '%s-%s.ldif' % (instance, backend)
+ldiffile = os.path.join(ldifdir, ldifname)
 srcldiffile = os.path.join(self.dir, ldifname)
-ldiffile = '%s.noruv' % srcldiffile
 
+if not os.path.exists(ldifdir):
+pent = pwd.getpwnam(DS_USER)
+os.mkdir(ldifdir, 0770)
+os.chown(ldifdir, pent.pw_uid, pent.pw_gid)
+
+ipautil.backup_file(ldiffile)
 with open(ldiffile, 'wb') as out_file:
 ldif_writer = ldif.LDIFWriter(out_file)
 with open(srcldiffile, 'rb') as in_file:
-- 
2.1.0

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Re: [Freeipa-devel] [PATCH] 388 Remove RUV from LDIF files before using them in ipa-restore

2015-01-20 Thread Martin Kosek
On 01/20/2015 12:59 PM, Jan Cholasta wrote:
 Dne 13.1.2015 v 17:58 Jan Cholasta napsal(a):
 Dne 13.1.2015 v 17:44 Petr Vobornik napsal(a):
 On 01/12/2015 05:46 PM, Jan Cholasta wrote:
 Hi,

 the attached patch fixes https://fedorahosted.org/freeipa/ticket/4822.

 Honza


 works for me, ACK

 Thanks, pushed to:
 master: 05e6adecb51b93e9b9d2326df4eabee90c3dfe72
 ipa-4-1: eb7917026d418a6d6a1e7a24a19097065df10497

 
 Posting additional patch 394 which fixes a SELinux issue.

Works fine, thanks.

ACK. Pushed to:
master: 4994cd1d8dde69d94130894ca86aa8a11fb590bf
ipa-4-1: 85599416ae4a0cc83b8e0669e686740dd2a10ea2

Martin

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH] 388 Remove RUV from LDIF files before using them in ipa-restore

2015-01-13 Thread Petr Vobornik

On 01/12/2015 05:46 PM, Jan Cholasta wrote:

Hi,

the attached patch fixes https://fedorahosted.org/freeipa/ticket/4822.

Honza



works for me, ACK
--
Petr Vobornik

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH] 388 Remove RUV from LDIF files before using them in ipa-restore

2015-01-13 Thread Jan Cholasta

Dne 13.1.2015 v 17:44 Petr Vobornik napsal(a):

On 01/12/2015 05:46 PM, Jan Cholasta wrote:

Hi,

the attached patch fixes https://fedorahosted.org/freeipa/ticket/4822.

Honza



works for me, ACK


Thanks, pushed to:
master: 05e6adecb51b93e9b9d2326df4eabee90c3dfe72
ipa-4-1: eb7917026d418a6d6a1e7a24a19097065df10497

--
Jan Cholasta

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


[Freeipa-devel] [PATCH] 388 Remove RUV from LDIF files before using them in ipa-restore

2015-01-12 Thread Jan Cholasta

Hi,

the attached patch fixes https://fedorahosted.org/freeipa/ticket/4822.

Honza

--
Jan Cholasta
From 38223d7d7df123af672a303aa989fb8259e84384 Mon Sep 17 00:00:00 2001
From: Jan Cholasta jchol...@redhat.com
Date: Mon, 12 Jan 2015 15:37:33 +
Subject: [PATCH] Remove RUV from LDIF files before using them in ipa-restore

https://fedorahosted.org/freeipa/ticket/4822
---
 ipaserver/install/ipa_restore.py | 36 +++-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/ipaserver/install/ipa_restore.py b/ipaserver/install/ipa_restore.py
index 0977039..a6dbeec 100644
--- a/ipaserver/install/ipa_restore.py
+++ b/ipaserver/install/ipa_restore.py
@@ -24,6 +24,7 @@ import tempfile
 import time
 import pwd
 from ConfigParser import SafeConfigParser
+import ldif
 
 from ipalib import api, errors
 from ipapython import version, ipautil, certdb, dogtag
@@ -94,6 +95,32 @@ def decrypt_file(tmpdir, filename, keyring):
 return dest
 
 
+class RemoveRUVParser(ldif.LDIFParser):
+def __init__(self, input_file, writer, logger):
+ldif.LDIFParser.__init__(self, input_file)
+self.writer = writer
+self.log = logger
+
+def handle(self, dn, entry):
+objectclass = None
+nsuniqueid = None
+
+for name, value in entry.iteritems():
+name = name.lower()
+if name == 'objectclass':
+objectclass = [x.lower() for x in value]
+elif name == 'nsuniqueid':
+nsuniqueid = [x.lower() for x in value]
+
+if (objectclass and nsuniqueid and
+'nstombstone' in objectclass and
+'---' in nsuniqueid):
+self.log.debug(Removing RUV entry %s, dn)
+return
+
+self.writer.unparse(dn, entry)
+
+
 class Restore(admintool.AdminTool):
 command_name = 'ipa-restore'
 log_file_name = paths.IPARESTORE_LOG
@@ -449,7 +476,14 @@ class Restore(admintool.AdminTool):
 dn = DN(('cn', cn), ('cn', 'import'), ('cn', 'tasks'), ('cn', 'config'))
 
 ldifname = '%s-%s.ldif' % (instance, backend)
-ldiffile = os.path.join(self.dir, ldifname)
+srcldiffile = os.path.join(self.dir, ldifname)
+ldiffile = '%s.noruv' % srcldiffile
+
+with open(ldiffile, 'wb') as out_file:
+ldif_writer = ldif.LDIFWriter(out_file)
+with open(srcldiffile, 'rb') as in_file:
+ldif_parser = RemoveRUVParser(in_file, ldif_writer, self.log)
+ldif_parser.parse()
 
 if online:
 conn = self.get_connection()
-- 
2.1.0

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel