New option -getfacl

This commit is contained in:
Thomas Schmitt 2009-01-17 18:15:22 +00:00
parent c4ced566b1
commit 72743ca23b
5 changed files with 123 additions and 1 deletions

View File

@ -12981,6 +12981,49 @@ int Xorriso_option_fs(struct XorrisO *xorriso, char *size, int flag)
}
/* Option -getfacl */
/* @param flag >>> ??? bit0=recursive (-getfacl_r)
*/
int Xorriso_option_getfacl(struct XorrisO *xorriso,
int argc, char **argv, int *idx, int flag)
{
int i, ret, was_failure= 0, end_idx, fret;
int optc= 0;
char **optv= NULL;
struct FindjoB *job= NULL;
ret= Xorriso_opt_args(xorriso, "-getfacl", argc, argv, *idx, &end_idx, &optc,
&optv, 0);
if(ret<=0)
goto ex;
for(i= 0; i<optc; i++) {
if(flag&1) {
/* >>> set up findjob and run it */;
} else {
ret= Xorriso_getfacl(xorriso, optv[i], 0);
}
if(ret>0 && !xorriso->request_to_abort)
continue; /* regular bottom of loop */
was_failure= 1;
fret= Xorriso_eval_problem_status(xorriso, ret, 1|2);
if(fret>=0)
continue;
ret= 0; goto ex;
}
ret= 1;
ex:;
(*idx)= end_idx;
Xorriso_opt_args(xorriso, "-getfacl", argc, argv, *idx, &end_idx,
&optc, &optv, 256);
Findjob_destroy(&job, 0);
if(ret<=0)
return(ret);
return(!was_failure);
}
/* Option -gid */
int Xorriso_option_gid(struct XorrisO *xorriso, char *gid, int flag)
{
@ -13284,6 +13327,7 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" -lsdx pattern [***] like -lsx but listing directories as single items.",
" -lslx pattern [***] like -lsx but also telling some file attributes.",
" -lsdlx pattern [***] like -lsdx but also telling some file attributes.",
" -getfacl pattern [***] list eventual ACLs of the given files.",
"",
" -du pattern [***] recursively lists sizes of files or directories in the",
" ISO image which match one of the shell parser patterns.",
@ -15569,6 +15613,7 @@ int Xorriso_count_args(struct XorrisO *xorriso, int argc, char **argv,
"compare_l","cpr","cpri","cp_rax","cp_rx","cpax","cpx",
"du","dui","dus","dusi","dux","dusx","extract_l",
"file_size_limit","find","findi","findx",
"getfacl","getfacli",
"ls","lsi","lsl","lsli","lsd","lsdi","lsdl","lsdli",
"lsx","lslx","lsdx","lsdlx","map_l","mv","mvi","mkdir","mkdiri",
"not_paths","rm","rmi","rm_r","rm_ri","rmdir","rmdiri","update_l",
@ -15913,6 +15958,9 @@ next_command:;
(*idx)++;
ret= Xorriso_option_fs(xorriso, arg1, 0);
} else if(strcmp(cmd,"getfacl")==0 || strcmp(cmd,"getfacli")==0) {
ret= Xorriso_option_getfacl(xorriso, argc, argv, idx, 0);
} else if(strcmp(cmd,"gid")==0) {
(*idx)++;
ret= Xorriso_option_gid(xorriso,arg1,0);

View File

@ -461,6 +461,10 @@ int Xorriso_option_find(struct XorrisO *xorriso, int argc, char **argv,
/* Option -fs */
int Xorriso_option_fs(struct XorrisO *xorriso, char *size, int flag);
/* Option -getfacl */
int Xorriso_option_getfacl(struct XorrisO *xorriso,
int argc, char **argv, int *idx, int flag);
/* Option -gid */
int Xorriso_option_gid(struct XorrisO *xorriso, char *gid, int flag);

View File

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

View File

@ -21,6 +21,8 @@
#include <fcntl.h>
#include <utime.h>
#include <wait.h>
#include <pwd.h>
#include <grp.h>
/* for -charset */
#include <iconv.h>
@ -8721,3 +8723,68 @@ ok:;
return(1);
}
int Xorriso_getfacl(struct XorrisO *xorriso, char *path, int flag)
{
int ret;
IsoNode *node;
char *text= NULL, *cpt, *npt;
uid_t uid;
gid_t gid;
struct passwd *pwd;
struct group *grp;
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);
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) {
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;
}
strcpy(xorriso->result_line, "# file: ");
Text_shellsafe(path, xorriso->result_line, 1);
strcat(xorriso->result_line, "\n");
Xorriso_result(xorriso, 0);
uid= iso_node_get_uid(node);
pwd= getpwuid(uid);
if(pwd == NULL)
sprintf(xorriso->result_line, "# owner: %.f\n", (double) uid);
else
sprintf(xorriso->result_line, "# owner: %s\n", pwd->pw_name);
Xorriso_result(xorriso, 0);
gid= iso_node_get_gid(node);
grp= getgrgid(gid);
if(grp == NULL)
sprintf(xorriso->result_line, "# group: %.f\n", (double) gid);
else
sprintf(xorriso->result_line, "# group: %s\n", grp->gr_name);
Xorriso_result(xorriso, 0);
for(npt= cpt= text; npt != NULL; cpt= npt + 1) {
npt= strchr(cpt, '\n');
if(npt != NULL)
*npt= 0;
Sfile_str(xorriso->result_line, cpt, 0);
strcat(xorriso->result_line, "\n");
Xorriso_result(xorriso, 0);
}
ret= 1;
ex:;
if(text != NULL)
free(text);
return(ret);
}

View File

@ -382,6 +382,9 @@ int Xorriso_auto_driveadr(struct XorrisO *xorriso, char *adr, char *result,
int flag);
int Xorriso_getfacl(struct XorrisO *xorriso, char *path, int flag);
/* A pseudo file type for El-Torito bootsectors as in man 2 stat :
For now take the highest possible value.
*/