aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPapoteur <papoteur@mageia.org>2023-06-30 11:28:07 +0200
committerPapoteur <papoteur@mageia.org>2023-06-30 11:28:07 +0200
commit23cd3e7048252777e6bb38288b66c14c2ec718db (patch)
tree8be4424b6c21b3603ee5c8846a1098cea378a3c1
parentd9ed76e1088e8af27bdea226a9f562e91209283a (diff)
downloadisodumper-23cd3e7048252777e6bb38288b66c14c2ec718db.tar
isodumper-23cd3e7048252777e6bb38288b66c14c2ec718db.tar.gz
isodumper-23cd3e7048252777e6bb38288b66c14c2ec718db.tar.bz2
isodumper-23cd3e7048252777e6bb38288b66c14c2ec718db.tar.xz
isodumper-23cd3e7048252777e6bb38288b66c14c2ec718db.zip
Give user ownership to the backup image.
-rwxr-xr-xbackend/magiback21
-rwxr-xr-xbackend/raw_write.py5
-rwxr-xr-xlib/isodumper.py3
3 files changed, 27 insertions, 2 deletions
diff --git a/backend/magiback b/backend/magiback
index c65b3a3..526e98a 100755
--- a/backend/magiback
+++ b/backend/magiback
@@ -38,6 +38,12 @@ class Isodumper(raw_write.Dumper):
<arg type='s' name='label' direction='in'/>
<arg type='s' name='key' direction='in'/>
</method>
+ <method name='set_backup_mode'>
+ <arg type='x' name='uid' direction='in'/>
+ <arg type='x' name='gid' direction='in'/>
+ </method>
+ <method name='unset_backup_mode'>
+ </method>
<method name='end'>
<arg type='b' name='success' direction='out'/>
<arg type='s' name='message' direction='out'/>
@@ -69,11 +75,14 @@ class Isodumper(raw_write.Dumper):
self.signature_checked = False
self.writing_perm = False
self.writing_target = ""
+ self.backup_mode = False
+ self.uid = 0
+ self.gid = 0
def do_write(self, source, target, size, dbus_context):
self.finished.clear()
if check_permission('org.mageia.Magiback.Isodumper.write', dbus_context):
- self.thread = threading.Thread(target=self._do_write, args=(source, target, size, ))
+ self.thread = threading.Thread(target=self._do_write, args=(source, target, size, self.backup_mode, self.uid, self.uid))
self.thread.start()
logging.debug("Writing thread started")
self.writing_perm = True
@@ -124,6 +133,16 @@ class Isodumper(raw_write.Dumper):
self.thread = threading.Thread(target=self._check_write, args=(target, source,))
self.thread.start()
+ def set_backup_mode(self, uid, gid):
+ self.backup_mode = True
+ self.uid = uid
+ self.gid = gid
+
+ def unset_backup_mode(self):
+ self.backup_mode = False
+ self.uid = 0
+ self.gid = 0
+
def run(self):
self.loop.run()
diff --git a/backend/raw_write.py b/backend/raw_write.py
index a29b604..fe0fda9 100755
--- a/backend/raw_write.py
+++ b/backend/raw_write.py
@@ -39,7 +39,7 @@ from subprocess import Popen, PIPE
class Dumper(object):
- def _do_write(self,source,target, b):
+ def _do_write(self,source,target, b, backup_mode, uid, gid):
# Writing step
#Dump mode
self.returncode=0
@@ -107,6 +107,9 @@ class Dumper(object):
self.return_message = message
self.finished.set()
return
+ if backup_mode:
+ # Restore user as owner
+ os.chown(target, uid, gid)
try:
ofc.close()
except:
diff --git a/lib/isodumper.py b/lib/isodumper.py
index 85487a0..aef0f93 100755
--- a/lib/isodumper.py
+++ b/lib/isodumper.py
@@ -483,7 +483,10 @@ class IsoDumper(basedialog.BaseDialog):
self.logger(message)
logging.info(message)
# Writing step
+ # set flag and provide uid, gid of current user to set the owner of the backup file at end
+ self.iface.set_backup_mode(os.getuid(), os.getgid())
self.iface.do_write(source, dest, self.deviceSize)
+ self.iface.unset_backup_mode()
while not self.iface.done:
progress = self.iface.progress
self.progress.setValue(progress)