Created attachment 994997 [details]
Sample code to be run as non-root
glfs_init() hangs on pthread_cond_wait() when user is non-root
Steps to Reproduce:
$ gcc try.c -I /usr/local/include/glusterfs/ -lgfapi -O0 -ggdb
Program received signal SIGINT, Interrupt.
0x00007ffff68d7ca0 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
Missing separate debuginfos, use: debuginfo-install glibc-2.18-16.fc20.x86_64 keyutils-libs-1.5.9-1.fc20.x86_64 krb5-libs-1.11.5-11.fc20.x86_64 libcom_err-1.42.8-3.fc20.x86_64 libselinux-2.2.1-6.fc20.x86_64 openssl-libs-1.0.1e-41.fc20.x86_64 pcre-8.33-8.fc20.x86_64 sssd-client-1.11.7-2.fc20.x86_64 xz-libs-5.1.2-12alpha.fc20.x86_64 zlib-1.2.8-3.fc20.x86_64
#0 0x00007ffff68d7ca0 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1 0x00007ffff7bc6cc2 in glfs_lock (fs=0x630b80) at glfs-internal.h:214
#2 0x00007ffff7bc7fb6 in glfs_init_wait (fs=0x630b80) at glfs.c:703
#3 0x00007ffff7bc82a7 in pub_glfs_init (fs=0x630b80) at glfs.c:809
#4 0x00000000004009d3 in main (argc=1, argv=0x7fffffffdee8) at try.c:20
Should error out gracefully
The issue does not occur when the server.allow-insecure and rpc-allow-insecure options are set. Without these options, the gfapi application will not be allowed to connect from ports > 1024. Only root can bind() to ports < 1024, running a gfapi application as non-root uses ports > 1024.
Possibly http://review.gluster.org/7405 contains a way to catch the error and report the problem back to the application.
Yes Niels, that's true. I wouldn't expect a hang though. Ideally, glfs_init() should return -1 with errno set to EPERM (or something)
(In reply to Prashanth Pai from comment #2)
> Yes Niels, that's true. I wouldn't expect a hang though. Ideally,
> glfs_init() should return -1 with errno set to EPERM (or something)
Yes, most definitely!
Tried glfsxmp.c as a non-user, and things are working fine with glusterfs-6.x