Bug 249951 - installworld results bad symbolic links to libraries and non-root users get link error like -lgcc_s
Summary: installworld results bad symbolic links to libraries and non-root users get l...
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 11.3-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-09-28 05:26 UTC by ota
Modified: 2020-09-29 02:25 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ota 2020-09-28 05:26:24 UTC
After running installworld, non-root users cannot properly read symbolic links from /usr/lib and causing link error like not finding -lgcc_s library.

Root user can link a program without a problem while all others fails to link.

I have / and /usr separate mount points.


After each installworld, I need to run the following to adjust symbolic links:

cd /usr/lib
ls -l *.so | nawk '$NF ~ /..\/..\/lib/{cmd="ln -sf " substr($NF, 6) " " $(NF-2);system(cmd)}'


These are the commands to expose errors and comparison between a root user and non-root user.

% is command as my own user account.
$ is the root user.


% uname -a
FreeBSD XXX 12.2-BETA2 FreeBSD 12.2-BETA2 #348 r365986M: Sat Sep 19 14:36:23 EDT 2020     hiro@XXX:/usr/obj/usr/src/i386.i386/sys/ZFS  i386

% cd /tmp
% cat main.c 
int main()
{
    return 0;
}
% cc main.c 
ld: error: unable to find library -lgcc_s
ld: error: unable to find library -lgcc_s
cc: error: linker command failed with exit code 1 (use -v to see invocation)
% c++ main.c 
c++: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
ld: error: cannot open /usr/lib/libcxxrt.so: Permission denied
ld: error: unable to find library -lgcc_s
ld: error: unable to find library -lgcc_s
c++: error: linker command failed with exit code 1 (use -v to see invocation)
% ls -lsd /usr/lib/libcxxrt.so 
0 lrwxr-xr-x  1 root  wheel  23 Sep 21 23:27 /usr/lib/libcxxrt.so -> ../../lib/libcxxrt.so.1
% ls -lsd /lib/libcxxrt.so.1
90 -r--r--r--  1 root  wheel  90644 Sep 21 23:27 /lib/libcxxrt.so.1
% mount
/dev/ada0s4a on / (ufs, local, soft-updates)
devfs on /dev (devfs, local, multilabel)
/dev/ada0s4d on /usr (ufs, local, noatime, soft-updates)
/dev/ada0s4e on /usr/local (ufs, local, noatime, soft-updates)


$ cc main.c
$ ./a.out
$

I had run the re-link program from comment above.

% ls -lsd /usr/lib/libcxxrt.so /lib/libcxxrt.so.1
90 -r--r--r--  1 root  wheel  90644 Sep 21 23:27 /lib/libcxxrt.so.1
 0 lrwxr-xr-x  1 root  wheel     23 Sep 21 23:27 /usr/lib/libcxxrt.so -> ../../lib/libcxxrt.so.1
% ls -lsd /usr/lib/libcxxrt.so /lib/libcxxrt.so.1
90 -r--r--r--  1 root  wheel  90644 Sep 21 23:27 /lib/libcxxrt.so.1
 0 lrwxr-xr-x  1 root  wheel     18 Sep 22 22:58 /usr/lib/libcxxrt.so -> /lib/libcxxrt.so.1

% cc main.c 
% ./a.out 
%