Restoring ACLs with -extract and others

This commit is contained in:
Thomas Schmitt 2009-01-18 21:40:42 +00:00
parent 7a7aef6f9c
commit 1f37d81537
4 changed files with 78 additions and 16 deletions

View File

@ -13002,7 +13002,7 @@ int Xorriso_option_getfacl(struct XorrisO *xorriso,
/* >>> set up findjob and run it */;
} else {
ret= Xorriso_getfacl(xorriso, optv[i], 0);
ret= Xorriso_getfacl(xorriso, optv[i], NULL, 0);
}
if(ret>0 && !xorriso->request_to_abort)
continue; /* regular bottom of loop */

View File

@ -1 +1 @@
#define Xorriso_timestamP "2009.01.17.181500"
#define Xorriso_timestamP "2009.01.18.213952"

View File

@ -63,6 +63,10 @@
#endif /* Xorriso_standalonE */
#ifdef Libisofs_with_aaiP
#define Xorriso_with_aaiP yes
#endif /* Libisofs_with_aaiP */
/* Some private in advance declarations */
int Xorriso_pacifier_loop(struct XorrisO *xorriso, struct burn_drive *drive,
int flag);
@ -2840,7 +2844,7 @@ int Xorriso_restore_properties(struct XorrisO *xorriso, char *disk_path,
uid_t uid;
gid_t gid;
struct utimbuf utime_buffer;
char sfe[5*SfileadrL];
char sfe[5*SfileadrL], *text= NULL;
struct stat stbuf;
ret= lstat(disk_path, &stbuf);
@ -2849,7 +2853,7 @@ int Xorriso_restore_properties(struct XorrisO *xorriso, char *disk_path,
"Cannot obtain properties of disk file %s",
Text_shellsafe(disk_path, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
return(0);
{ret= 0; goto ex;}
}
uid= stbuf.st_uid;
@ -2858,14 +2862,14 @@ int Xorriso_restore_properties(struct XorrisO *xorriso, char *disk_path,
if(is_dir && (flag&2)) {
ret= Xorriso_fake_stbuf(xorriso, "", &stbuf, &node, 1);
if(ret<=0)
return(0);
{ret= 0; goto ex;}
ret= Permstack_push(&(xorriso->perm_stack), disk_path, &stbuf, 0);
if(ret<=0) {
Xorriso_msgs_submit(xorriso, 0, disk_path, 0, "ERRFILE", 0);
strcpy(xorriso->info_text,
"Cannot memorize permissions for disk directory");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
return(-1);
{ret= -1; goto ex;}
}
mode|= S_IRUSR|S_IWUSR|S_IXUSR;
}
@ -2875,10 +2879,33 @@ int Xorriso_restore_properties(struct XorrisO *xorriso, char *disk_path,
"Cannot change access permissions of disk file %s",
Text_shellsafe(disk_path, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
return(0);
{ret= 0; goto ex;}
}
#ifdef Xorriso_with_aaiP
ret= iso_node_get_acl_text(node, &text, 16);
if(ret < 0) {
strcpy(xorriso->info_text, "Error with obtaining ACL for ");
Text_shellsafe(disk_path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
{ret= 0; goto ex;}
}
if(text != NULL) {
ret= iso_local_set_acl_text(disk_path, text, 0);
if(ret == -1) {
sprintf(xorriso->info_text,
"Cannot change ACL of disk file %s",
Text_shellsafe(disk_path, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
{ret= 0; goto ex;}
}
}
#endif
if(flag&1)
return(1);
{ret= 1; goto ex;}
gid= iso_node_get_gid(node);
if(!(S_ISDIR(stbuf.st_mode) && (flag&2)))
@ -2892,9 +2919,13 @@ int Xorriso_restore_properties(struct XorrisO *xorriso, char *disk_path,
"Cannot change atime, mtime of disk file %s",
Text_shellsafe(disk_path, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
return(0);
{ret= 0; goto ex;}
}
return(1);
ret= 1;
ex:;
if(text != NULL)
free(text);
return(ret);
}
@ -8724,7 +8755,16 @@ ok:;
}
int Xorriso_getfacl(struct XorrisO *xorriso, char *path, int flag)
/* @param acl_text if acl_text is not NULL, then *acl_text will be set to the
ACL text (without comments) of the file object. In this
case it finally has to be freed by the caller.
@param flag bit0= do not report to result but only retrieve ACL text
@return 2 ok, no ACL available, eventual *acl_text will be NULL
1 ok, ACL available, eventual *acl_text stems from malloc()
<=0 error
*/
int Xorriso_getfacl(struct XorrisO *xorriso, char *path, char **acl_text,
int flag)
{
int ret;
IsoNode *node;
@ -8737,18 +8777,29 @@ int Xorriso_getfacl(struct XorrisO *xorriso, char *path, int flag)
ret= Xorriso_get_node_by_path(xorriso, path, NULL, &node, 0);
if(ret<=0)
goto ex;
ret = iso_node_get_acl_text(node, &text, 0);
#ifdef Xorriso_with_aaiP
ret= iso_node_get_acl_text(node, &text, 0);
#else
ret= 0;
#endif
if(ret < 0) {
strcpy(xorriso->info_text, "Error with obtaining ACL of ");
Text_shellsafe(path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
ret= 0; goto ex;
}
if(ret == 0) {
if(flag & 1) {
ret= 1 + (ret == 0);
goto ex;
}
if(ret == 0 || ret == 2) {
strcpy(xorriso->info_text, "No ACL associated with ");
Text_shellsafe(path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
ret= 2; goto ex;
if(ret == 0)
{ret= 2; goto ex;}
}
strcpy(xorriso->result_line, "# file: ");
@ -8783,7 +8834,9 @@ int Xorriso_getfacl(struct XorrisO *xorriso, char *path, int flag)
ret= 1;
ex:;
if(text != NULL)
if(acl_text != NULL)
*acl_text= text;
else if(text != NULL)
free(text);
return(ret);
}

View File

@ -382,7 +382,16 @@ int Xorriso_auto_driveadr(struct XorrisO *xorriso, char *adr, char *result,
int flag);
int Xorriso_getfacl(struct XorrisO *xorriso, char *path, int flag);
/* @param acl_text if acl_text is not NULL, then *acl_text will be set to the
ACL text (without comments) of the file object. In this
case it finally has to be freed by the caller.
@param flag bit0= do not report to result but only retrieve ACL text
@return 2 ok, no ACL available, eventual *acl_text will be NULL
1 ok, ACL available, eventual *acl_text stems from malloc()
<=0 error
*/
int Xorriso_getfacl(struct XorrisO *xorriso, char *path, char **acl_text,
int flag);
/* A pseudo file type for El-Torito bootsectors as in man 2 stat :