Setting chattr "C" and "i" at their proper times during restoring to disk
This commit is contained in:
@@ -42,6 +42,7 @@
|
||||
|
||||
#include "xorriso.h"
|
||||
#include "xorriso_private.h"
|
||||
#include "xorrisoburn.h"
|
||||
|
||||
|
||||
/* ---------------------------- SplitparT ------------------------- */
|
||||
@@ -939,10 +940,16 @@ int Linkitem_get_link_count(struct LinkiteM *item, int flag)
|
||||
struct PermiteM {
|
||||
char *disk_path;
|
||||
struct stat stbuf;
|
||||
int immutable; /* bit0= set chattr immutable bit
|
||||
bit1= only set immutable bit
|
||||
*/
|
||||
struct PermiteM *next;
|
||||
};
|
||||
|
||||
|
||||
/* @param flag bit0= Linux chattr immutable bit is set
|
||||
bit1= when popping only set immutable bit
|
||||
*/
|
||||
int Permstack_push(struct PermiteM **o, char *disk_path, struct stat *stbuf,
|
||||
int flag)
|
||||
{
|
||||
@@ -953,6 +960,7 @@ int Permstack_push(struct PermiteM **o, char *disk_path, struct stat *stbuf,
|
||||
return(-1);
|
||||
m->disk_path= NULL;
|
||||
memcpy(&(m->stbuf), stbuf, sizeof(struct stat));
|
||||
m->immutable= flag & 3;
|
||||
m->next= *o;
|
||||
|
||||
m->disk_path= strdup(disk_path);
|
||||
@@ -971,6 +979,7 @@ failed:;
|
||||
|
||||
/* @param flag bit0= minimal transfer: access permissions only
|
||||
bit1= do not set timestamps
|
||||
bit2= do not set chattr flag i "immutable"
|
||||
*/
|
||||
int Permstack_pop(struct PermiteM **o, struct PermiteM *stopper,
|
||||
struct XorrisO *xorriso, int flag)
|
||||
@@ -992,18 +1001,21 @@ int Permstack_pop(struct PermiteM **o, struct PermiteM *stopper,
|
||||
}
|
||||
|
||||
for(m= *o; m!=stopper; m= m_next) {
|
||||
ret= chmod(m->disk_path, m->stbuf.st_mode);
|
||||
if(ret==-1) {
|
||||
if(xorriso!=NULL) {
|
||||
sprintf(xorriso->info_text,
|
||||
"Cannot change access permissions of disk directory: chmod %o ",
|
||||
(unsigned int) (m->stbuf.st_mode & 07777));
|
||||
Text_shellsafe(m->disk_path, xorriso->info_text, 1);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",
|
||||
0);
|
||||
if(!(m->immutable & 2)) {
|
||||
ret= chmod(m->disk_path, m->stbuf.st_mode);
|
||||
if(ret==-1) {
|
||||
if(xorriso!=NULL) {
|
||||
sprintf(xorriso->info_text,
|
||||
"Cannot change access permissions of disk directory: chmod %o ",
|
||||
(unsigned int) (m->stbuf.st_mode & 07777));
|
||||
Text_shellsafe(m->disk_path, xorriso->info_text, 1);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",
|
||||
0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!(flag&1)) {
|
||||
|
||||
if(!((flag & 1) || (m->immutable & 2))) {
|
||||
ret= chown(m->disk_path, m->stbuf.st_uid, m->stbuf.st_gid);
|
||||
/* don't complain if it fails */
|
||||
if(!(flag&2)) {
|
||||
@@ -1019,6 +1031,10 @@ int Permstack_pop(struct PermiteM **o, struct PermiteM *stopper,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if((m->immutable & 1) && !(flag & 4))
|
||||
Xorriso_set_local_chattr_i(xorriso, m->disk_path, 0);
|
||||
|
||||
m_next= m->next;
|
||||
free(m->disk_path);
|
||||
free((char *) m);
|
||||
|
Reference in New Issue
Block a user