install by default follows symlinks meaning if a symlink is replaced by
a file then the file targetted by the symlink is changed not the file
if the symlink was a dead symlink, then install fails
Differential D4191
Install should not follow the symlinks bapt on Nov 17 2015, 11:02 AM. Authored by Tags None Referenced Files
Details install by default follows symlinks meaning if a symlink is replaced by if the symlink was a dead symlink, then install fails
Diff Detail
Event TimelineComment Actions This approach is ok when replacing a normal symlink, but fails on a dead symlink returning "too many links" Comment Actions Better approach: Do not follow symlinks when checking if a target exists Comment Actions Hmm, my experience has been that install *does not* follow symlinks. I've relied on this at work in a very big way. Is your finding only for -l s? Comment Actions Before my patch try and now see the result you will see install does follow the symlinks Comment Actions Hmm, it only "follows" for an error, it does not follow for the installation though. root@bdrewery-fe3c5db-1:~/ > ln -sf /nonexistent/foo bar Yes I would expect the first case to not hit an error. Comment Actions Right sorry I miss explain the second case ln -sf I_do_not_exists bar bar is still a symlink and I_do_not_exists has been created :) Comment Actions It seems this implements Bryan's last suggestion of always overwriting a target symlink and never following it, correct? I stopped looking after my few comments below. Figuring out the best solution to handle this edge case is needed though.
Comment Actions
FYI I was speaking only of my first call to install. I didn't try bapt's second example or look at it.
Comment Actions Base on your comments I think this approach is even simpler and does what this Comment Actions I think this is ok. I'd like to hear from Brooks if possible, but we can't wait forever. I feel like the digest bits should be simpler somehow so it is less convoluted. Comment Actions I think either bapt or jhb's change is ok with regard to digestresult. Everything about digest computation is terrible because it's over optimized to try and avoid reading the file twice. The prior initialization of digestresult for the !dostrip case occurs either in the "If we don't strip, we can compare first." block or in the following "if (!files_match)" block. The sane thing to do would be to compute the digest IFF it's requested just before the call to metadata_log. If it wouldn't break everything I'd also love to kill the strip code. In the CheriBSD tree I no longer use install -s and strip as part of the build. |