struct stat st;
int rc = 0;
int xx;
-
+ int selinux = is_selinux_enabled() && (matchpathcon_init(NULL) != -1);
+
switch (_olddbapi) {
case 4:
/* Fall through */
goto cont;
/*
- * Restore uid/gid/mode/mtime if possible.
+ * Restore uid/gid/mode/mtime/security context if possible.
*/
if (stat(dest, &st) < 0)
if (stat(src, &st) < 0)
stamp.modtime = st.st_mtime;
xx = utime(dest, &stamp);
}
+
+ if (selinux) {
+ security_context_t scon = NULL;
+ if (matchpathcon(dest, &st, &scon) != -1) {
+ (void) setfilecon(dest, scon);
+ freecon(scon);
+ }
+ }
+
cont:
free(src);
free(dest);
rc = rpmdbRemoveDatabase(prefix, newdbpath, _newdbapi);
#endif
+ if (selinux) {
+ (void) matchpathcon_fini();
+ }
return rc;
}