The below patch is designed to keep install(1) from overwriting symbolic links. The motivation is if cups is installed some programs still expect lpr to be in /usr/bin thus when I install cups I backlink the /usr/local/bin versions of lp* to /usr/bin. When a build/installworld is done these links are overwritten and the sym links have to be performed again. This patch prevents the overwrite. This is my very first patch (of any kind [not just for FreeBSD]) so can people please tell me what I did right and what I did wrong in making it. Also tell me what improvements (if any) can be made to the patched code. --- src/usr.bin/xinstall/xinstall.c.orig 2007-11-01 18:46:45.000000000 -0400 +++ src/usr.bin/xinstall/xinstall.c 2007-11-01 19:44:43.000000000 -0400 _at__at_ -268,7 +268,7 _at__at_ void install(const char *from_name, const char *to_name, u_long fset, u_int flags) { - struct stat from_sb, temp_sb, to_sb; + struct stat from_sb, temp_sb, to_sb, to_lsb; struct timeval tvb[2]; int devnull, files_match, from_fd, serrno, target; int tempcopy, temp_fd, to_fd; _at__at_ -299,6 +299,13 _at__at_ } target = stat(to_name, &to_sb) == 0; + target = lstat(to_name, &to_lsb) == 0; + + if(S_ISLNK(to_lsb.st_mode)) { + printf("%s is a symbolic link not modified\n",to_name); + errno = EFTYPE; + return; + } /* Only install to regular files. */ if (target && !S_ISREG(to_sb.st_mode)) {Received on Fri Nov 02 2007 - 03:24:05 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:20 UTC