Correct group permission bits with -acl off and -extract file that has ACL

master
Thomas Schmitt 14 years ago
parent c854275d51
commit f5e6a8147b
  1. 2
      xorriso/xorriso_timestamp.h
  2. 158
      xorriso/xorrisoburn.c

@ -1 +1 @@
#define Xorriso_timestamP "2009.02.04.200653"
#define Xorriso_timestamP "2009.02.07.090104"

@ -2023,13 +2023,14 @@ int Xorriso_transfer_properties(struct XorrisO *xorriso, struct stat *stbuf,
if(ret < 0) {
Xorriso_process_msg_queues(xorriso,0);
Xorriso_report_iso_error(xorriso, "", ret,
"Error when obtaining local ACL and xattr", 0,
"FAILURE", 1);
"Error when setting ACL and xattr to image node",
0, "FAILURE", 1);
ret= 0; goto ex;
}
ret= 1;
}
ex:;
Xorriso_process_msg_queues(xorriso,0);
iso_local_get_attrs(disk_path, &num_attrs, &names, &value_lengths,
&values, 1 << 15); /* free memory */
return(ret);
@ -2866,13 +2867,8 @@ int Xorriso_restore_properties(struct XorrisO *xorriso, char *disk_path,
struct utimbuf utime_buffer;
char sfe[5*SfileadrL];
struct stat stbuf;
#ifdef NIX
char *access_text= NULL, *default_text= NULL;
#else
size_t num_attrs= 0, *value_lengths= NULL;
char **names= NULL, **values= NULL;
#endif
ret= lstat(disk_path, &stbuf);
if(ret==-1) {
@ -2885,65 +2881,11 @@ int Xorriso_restore_properties(struct XorrisO *xorriso, char *disk_path,
uid= stbuf.st_uid;
is_dir= S_ISDIR(stbuf.st_mode);
mode= iso_node_get_permissions(node);
if(is_dir && (flag&2)) {
ret= Xorriso_fake_stbuf(xorriso, "", &stbuf, &node, 1);
if(ret<=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);
{ret= -1; goto ex;}
}
mode|= S_IRUSR|S_IWUSR|S_IXUSR;
}
ret= chmod(disk_path, mode);
if(ret==-1) {
sprintf(xorriso->info_text,
"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);
{ret= 0; goto ex;}
}
#ifdef Xorriso_with_aaiP
#ifdef NIX
if(xorriso->do_aaip & 2) {
ret= iso_node_get_acl_text(node, &access_text, &default_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;}
}
/* >>> change to iso_node_set_attrs */;
if(access_text != NULL) {
ret= iso_local_set_acl_text(disk_path, access_text, 0);
if(ret == -1) {
cannot_change_acl:;
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;}
}
}
if(default_text != NULL) {
ret= iso_local_set_acl_text(disk_path, default_text, 1);
if(ret == -1)
goto cannot_change_acl;
}
}
#else /* NIX */
if(xorriso->do_aaip & 10) {
ret= iso_node_get_attrs(node, &num_attrs, &names, &value_lengths, &values,
(!!(xorriso->do_aaip & 2)) | (!(xorriso->do_aaip & 8)) << 2);
@ -2966,11 +2908,39 @@ cannot_change_acl:;
}
Xorriso_process_msg_queues(xorriso,0);
}
#endif /* ! NIX */
if(!(xorriso->do_aaip & 2))
mode= iso_node_get_perms_wo_acl(node);
#endif /* Xorriso_with_aaiP */
if(is_dir && (flag&2)) {
/* >>> ??? need to stack ACL ? */
/* >>> ??? eventually obtain stbuf wo ACL */
ret= Xorriso_fake_stbuf(xorriso, "", &stbuf, &node, 1);
if(ret<=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);
{ret= -1; goto ex;}
}
mode|= S_IRUSR|S_IWUSR|S_IXUSR;
}
ret= chmod(disk_path, mode);
if(ret==-1) {
sprintf(xorriso->info_text,
"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);
{ret= 0; goto ex;}
}
if(flag&1)
{ret= 1; goto ex;}
@ -2990,11 +2960,7 @@ cannot_change_acl:;
}
ret= 1;
ex:;
#ifdef NIX
iso_node_get_acl_text(node, &access_text, &default_text, 1 << 15);
#else
iso_node_get_attrs(node, &num_attrs, &names, &value_lengths, &values,1 << 15);
#endif
return(ret);
}
@ -9046,7 +9012,7 @@ ex:;
/*
@param flag
>>> bit1= check for existence of non-ACL xattr,
bit1= check for existence of non-ACL xattr,
return 0 or 1
*/
int Xorriso_getfattr(struct XorrisO *xorriso, void *in_node, char *path,
@ -9118,3 +9084,57 @@ ex:;
&values, 1 << 15); /* free memory */
return(ret);
}
/* @param node Opaque handle to IsoNode which is to be manipulated
instead of path if it is not NULL.
@param path is used as address if node is NULL.
@param num_attrs Number of attributes
@param names Array of pointers to 0 terminated name strings
@param value_lengths Array of byte lengths for each attribute payload
@param values Array of pointers to the attribute payload bytes
@param flag bit0= Do not maintain eventual existing ACL of the node
bit1= Do not clear the existing attribute list
bit2= Delete the attributes with the given names
@return >0 success , <=0 failure
*/
int Xorriso_setfattr(struct XorrisO *xorriso, void *in_node, char *path,
size_t num_attrs, char **names,
size_t *value_lengths, char **values, int flag)
{
int ret;
IsoNode *node;
node= (IsoNode *) in_node;
if(node == NULL) {
ret= Xorriso_get_node_by_path(xorriso, path, NULL, &node, 0);
if(ret<=0)
goto ex;
}
#ifdef Xorriso_with_aaiP
ret= iso_node_set_attrs(node, num_attrs, names, value_lengths, values,
flag & (1 | 2 | 4));
#else
ret= 0;
#endif
Xorriso_process_msg_queues(xorriso,0);
if(ret <= 0) {
Xorriso_report_iso_error(xorriso, "", ret,
"Error when setting ACL and xattr to image node",
0, "FAILURE", 1);
if(path != NULL && path[0] != 0) {
strcpy(xorriso->info_text, "Error with setting xattr of ");
Text_shellsafe(path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
}
ret= 0; goto ex;
}
xorriso->volset_change_pending= 1;
ret= 1;
ex:;
Xorriso_process_msg_queues(xorriso,0);
return(ret);
}

Loading…
Cancel
Save