CESNET / libnetconf

C NETCONF library
Other
113 stars 83 forks source link

Issue/Warning in NETOPEER-SERVER initialization #235

Closed virajmistry closed 7 years ago

virajmistry commented 7 years ago

Hi ,

I have successfully cross compiled netopeer-server and libnetconf. When i start netopeer-server in root mode on my board then for port number less than 1024 it gives permission denied error though i am root but for >1024 port it is able to start server. But i have also create a new simple server application and ported on my custom board and using this i am able to bind 0-1024 port number without any root permission.

While checking netopeer-server server.c file i came to know that before nc_init function it is allowing to bind port number <1024 without any error but after nc_init function initialized successfully then it gives same error of root permission.

**_printf("Port:836:<%d><%s><%s>\n",__LINE__,__FILE__,__func__);
temp_sock(836);

/* initialize library including internal datastores and maybee something more */
if (nc_init(NC_INIT_ALL | NC_INIT_MULTILAYER) < 0) {
    nc_verb_error("Library initialization failed.");
    return EXIT_FAILURE;
}

server_start = 1;
printf("Port:837:<%d><%s><%s>\n",__LINE__,__FILE__,__func__);
temp_sock(837);_**

Port 836 can bind without any error and port 837 give error of permission denied.

Also netopeer-server log when started as netopeer-server -v 3 is different on host machine and on native machine. The difference is I/O warning : failed to load external entity "/usr/share/libnetconf/rnglib//relaxng-lib.rng" /var/lib/libnetconf//ietf-netconf-acm-config.rng:2: element include: Relax-NG parser error : xmlRelaxNG: could not load /usr/share/libnetconf/rnglib//relaxng-lib.rng /var/lib/libnetconf//ietf-netconf-acm-config.rng:2: element include: Relax-NG parser error : Failed to load include /usr/share/libnetconf/rnglib//relaxng-lib.rng I guess above error/warning may not which is restrict <1024 port number but still please let me know its resolution.

Also how nc_init of libnetconf function can change permission ?

Awaiting for reply.

Regards, Viraj

michalvasko commented 7 years ago

Hi Viraj, this is indeed strange, but it likely will be something platform-specific so I am unable to help you. The error you see should not be related, but if you want validation to work, you need to plate those files in the proper place. They get installed with libnetconf, so something is not working properly there as well.

Regards, Michal

virajmistry commented 7 years ago

Hi Michal,

Thanks for reply. Yes you are right but what excalty nc_init function is doing? Because before that no error but after this function permission error comes. And for validation file i will check it and let u know.

Thanks Viraj

michalvasko commented 7 years ago

Hi Viraj, the problem is that I have no idea what is the problem on your particular platform, you need to find out for yourself. Look into internal.c into nc_init() and try to guess what is the problem. You can try temporarily commenting out various parts of libnetconf initialization and that way find the exact cause of the issue.

Regards, Michal

virajmistry commented 7 years ago

Hi Michal,

Yes actually i am doing same thing. I am looking into nc_init function.

Thanks Viraj

alfredomantilla commented 7 years ago

Hi, had the same issue when crosscompiling with yocto.

Try to add this to a libssh_*.bbappend:

EXTRA_OECMAKE = " \ -DWITH_GCRYPT=0 \ -DWITH_PCAP=0 \ -DWITH_SFTP=1 \ -DWITH_ZLIB=0 \ -DLIB_SUFFIX=${@d.getVar('baselib', True).replace('lib', '')} \ " To compile libssh only with openssl, this fixed it for me and now netopeer-server can bind to ports lower than 1024