Hi,
This is a rather complex question, so stay with me for a while. I'll sketch the situation as accurate as possible, but if you need more info, give me a call.
I'm running FPC and Lazarus on FreeBSD
OS: FreeBSD 13.1
FPC: 3.2.2
Lazarus: 2.2.2
FPC and Lazarus are Installed using the pkg system
I started with Lazarus 2.2.0 and FPC 3.2.2. Upgraded after a while. The described issue below didn't became visible unit I upgraded to Lazarus 2.2.4. But it's not related to 2.2.4 or even 2.2.6 - I can now also reproduce this on 2.2.2.
Short version:
Sending UDP messages as root user to a server works. Using the same program using a non-privileged user doesn't, i.e. executable is built, but does not work properly,
Send error[22]: Invalid arguments
is reported.
Using Python create a server handling UDP messages:
import socket
scksrv = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
scksrv.bind(('127.0.0.1', 23223))
scksrv.recvfrom(100)
Logon to FreeBSD as root user and install the additional package lNet.
Create a application with a Form. On the form drop the LUDPComponent.
Write the following program:
procedure TForm1.Button1Click(Sender: TObject);
begin
LUDPComponent1.Host := '127.0.0.1';
LUDPComponent1.Port := 23223;
if LUDPComponent1.Connect(LUDPComponent1.Host, LUDPComponent1.Port) then
LUDPComponent1.SendMessage('Hello', Format('%s:%d', [LUDPComponent1.Host, LUDPComponent1.Port]))
else
ShowMessage('Connection failed');
end;
procedure TForm1.LUDPComponent1Error(const msg: string; aSocket: TLSocket);
begin
ShowMessage(msg);
end;
Run the application. You'll notice that the message arrives at the server, so no problem.
On the same machine logon a a non-privileged user:
Launch Lazarus, Provide the location of the FPC RTL and start the IDE. You'll notice that the lNet package is
not installed. So install the lNet package and rebuild the IDE.
At start-up the IDE now complains that the Fppkg configuration is incorrect. the option is given to change it manually or write. I've selected to write the proposed configuration. The fppkg configuration complains that :
File: /usr/home/ig/.config/fppkg.cfg
Error: there is a problem with the Fppkg configuration. (Fppkg reports that the RTL is not installed.)
You could try to restore the configuration files automatically, or adapt the configuration file manually.
Write the same Python server program and create the same Lazarus application.
Run the Python server and the application. The result is: Send error [22]: Invalid argument.
At first I thought this was a bug, in either lNet or Lazarus, but I fear the Fppkg configuration together with the Lazarus configuration is wrong. The Fppkg issue never arose of the root user, so I'm a little bit puzzled.
I've analyzed the configuration files for root and non-privileged user, and they differ largely.
- Where does this difference come from?
- Why is there a difference between the root user and the non-privileged user?
- Are there different templates used?
- If so why and what needs adapting?