From fc03217d917dfa3e3c4d7208d282f236451084aa Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Wed, 15 Mar 2023 20:49:32 +0100 Subject: [PATCH] Emitting SORRY event for dangling symbolic links if -follow is set to "link" --- xorriso/disk_ops.c | 18 ++++++++++++++++-- xorriso/iso_manip.c | 5 +++-- xorriso/xorriso_timestamp.h | 2 +- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/xorriso/disk_ops.c b/xorriso/disk_ops.c index ba5bb994..f9fed8d1 100644 --- a/xorriso/disk_ops.c +++ b/xorriso/disk_ops.c @@ -1,7 +1,7 @@ /* xorriso - creates, loads, manipulates and burns ISO 9660 filesystem images. - Copyright 2007-2022 Thomas Schmitt, + Copyright 2007-2023 Thomas Schmitt, Provided under GPL version 2 or later. @@ -300,11 +300,14 @@ unrecognizable:; /* @param flag bit0= for Xorriso_msgs_submit: use pager bit1= do not issue warnings + bit2= warn about dangling link + bit3= report sorry if dangling link */ int Xorriso_hop_link(struct XorrisO *xorriso, char *link_path, struct LinkiteM **link_stack, struct stat *stbuf, int flag) { int ret; + char *severity; struct LinkiteM *litm; if(*link_stack != NULL) { @@ -318,8 +321,19 @@ int Xorriso_hop_link(struct XorrisO *xorriso, char *link_path, } } ret= stat(link_path, stbuf); - if(ret==-1) + if(ret == -1) { + if(flag & (4 | 8)) { + if(flag & 8) + severity= "SORRY"; + else + severity= "WARNING"; + sprintf(xorriso->info_text, "Non-existing link target with : "); + Text_shellsafe(link_path, xorriso->info_text, 1); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, severity, + flag & 1); + } return(0); + } ret= Linkitem_find(*link_stack, stbuf->st_dev, stbuf->st_ino, &litm, 0); if(ret>0) { sprintf(xorriso->info_text, "Detected symbolic link loop around : "); diff --git a/xorriso/iso_manip.c b/xorriso/iso_manip.c index 4a62b998..ede9942e 100644 --- a/xorriso/iso_manip.c +++ b/xorriso/iso_manip.c @@ -1,7 +1,7 @@ /* xorriso - creates, loads, manipulates and burns ISO 9660 filesystem images. - Copyright 2007-2022 Thomas Schmitt, + Copyright 2007-2023 Thomas Schmitt, Provided under GPL version 2 or later. @@ -490,7 +490,7 @@ cannot_lstat:; source_is_link= S_ISLNK(stbuf.st_mode); if(xorriso->do_follow_links && source_is_link) { /* Xorriso_hop_link checks for wide link loops */ - ret= Xorriso_hop_link(xorriso, srcpt, &own_link_stack, &hstbuf, 0); + ret= Xorriso_hop_link(xorriso, srcpt, &own_link_stack, &hstbuf, 8); if(ret<0) goto was_problem; if(ret==1) { @@ -502,6 +502,7 @@ cannot_lstat:; if(lstat(srcpt, &stbuf)==-1) goto cannot_lstat; } else { + Xorriso_msgs_submit(xorriso, 0, srcpt, 0, "ERRFILE", 0); if(Xorriso_eval_problem_status(xorriso, 0, 1|2)<0) {ret= 0; goto was_problem;} ret= Xorriso_resolve_link(xorriso, srcpt, link_target, 1); diff --git a/xorriso/xorriso_timestamp.h b/xorriso/xorriso_timestamp.h index 4d6658a1..689d6328 100644 --- a/xorriso/xorriso_timestamp.h +++ b/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2023.02.28.150706" +#define Xorriso_timestamP "2023.03.15.194905"